public class JmsSpoutTest {
@Test
public void testFailure() throws JMSException, Exception{
JmsSpout spout = new JmsSpout();
JmsProvider mockProvider = new MockJmsProvider();
MockSpoutOutputCollector mockCollector = new MockSpoutOutputCollector();
SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector);
spout.setJmsProvider(new MockJmsProvider());
spout.setJmsTupleProducer(new MockTupleProducer());
spout.setJmsAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
spout.setRecoveryPeriod(10); // Rapid recovery for testing.
spout.open(new HashMap<String,String>(), null, collector);
Message msg = this.sendMessage(mockProvider.connectionFactory(), mockProvider.destination());
Thread.sleep(100);
spout.nextTuple(); // Pretend to be storm.
Assert.assertTrue(mockCollector.emitted);
mockCollector.reset();