/*
* Copyright 2015 the original author or authors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.acme;
import static org.junit.Assert.*;
import static org.springframework.xd.dirt.test.process.SingleNodeProcessingChainSupport.*;
import com.rometools.rome.feed.synd.SyndEntry;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.xd.dirt.server.singlenode.SingleNodeApplication;
import org.springframework.xd.dirt.test.SingleNodeIntegrationTestSupport;
import org.springframework.xd.dirt.test.SingletonModuleRegistry;
import org.springframework.xd.dirt.test.process.SingleNodeProcessingChainConsumer;
import org.springframework.xd.module.ModuleType;
import org.springframework.xd.test.RandomConfigurationSupport;
/**
* @author David Turanski
*/
public class FeedSourceModuleIntegrationTest {
private static SingleNodeApplication application;
private static int RECEIVE_TIMEOUT = 6000;
/**
* Start the single node container, binding random unused ports, etc. to not conflict with any other instances
* running on this host. Configure the ModuleRegistry to include the project module.
*/
@BeforeClass
public static void setUp() {
RandomConfigurationSupport randomConfigSupport = new RandomConfigurationSupport();
application = new SingleNodeApplication().run();
SingleNodeIntegrationTestSupport singleNodeIntegrationTestSupport = new SingleNodeIntegrationTestSupport
(application);
singleNodeIntegrationTestSupport.addModuleRegistry(new SingletonModuleRegistry(ModuleType.source,
"feed"));
}
@Test
public void test() {
String url = "http://feeds.bbci.co.uk/news/rss.xml";
SingleNodeProcessingChainConsumer chain = chainConsumer(application, "feedStream",
String.format("feed --url='%s'", url));
Object payload = chain.receivePayload(RECEIVE_TIMEOUT);
assertTrue(payload instanceof String);
chain.destroy();
}
}