use of backtype.storm.spout.SpoutOutputCollector in project kafka-spout by HolmesNL.
the class KafkaSpoutConstructorTest method testOpenWithDefaultConstructor.
/**
* Using the default constructor, a topic name must be in the storm config
*/
@Test
public void testOpenWithDefaultConstructor() {
KafkaSpout spout = spy(new KafkaSpout());
TopologyContext topology = mock(TopologyContext.class);
SpoutOutputCollector collector = mock(SpoutOutputCollector.class);
Map<String, Object> config = new HashMap<String, Object>();
config.put(ConfigUtils.CONFIG_TOPIC, "topic");
doNothing().when(spout).createConsumer(config);
spout.open(config, topology, collector);
assertEquals("Wrong Topic Name", spout._topic, "topic");
}
use of backtype.storm.spout.SpoutOutputCollector in project pulsar by yahoo.
the class PulsarSpoutTest method testNoSharedConsumer.
@Test
public void testNoSharedConsumer() throws Exception {
PersistentTopicStats topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
pulsarSpoutConf.setSharedConsumerEnabled(false);
PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector();
SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
when(context.getThisTaskId()).thenReturn(1);
otherSpout.open(Maps.newHashMap(), context, collector);
topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 2);
otherSpout.close();
topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
}
Aggregations