@Test public void validateSuccessfulConsumeAndTransferToSuccess() throws Exception { JmsTemplate jmsTemplate = CommonTest.buildJmsTemplateForDestination("cooQueue", false); JMSPublisher sender = new JMSPublisher(jmsTemplate, mock(ComponentLog.class)); sender.publish("Hey dude!".getBytes()); TestRunner runner = TestRunners.newTestRunner(new ConsumeJMS()); JMSConnectionFactoryProviderDefinition cs = mock(JMSConnectionFactoryProviderDefinition.class); when(cs.getIdentifier()).thenReturn("cfProvider"); when(cs.getConnectionFactory()).thenReturn(jmsTemplate.getConnectionFactory()); runner.addControllerService("cfProvider", cs); runner.enableControllerService(cs); runner.setProperty(PublishJMS.CF_SERVICE, "cfProvider"); runner.setProperty(ConsumeJMS.DESTINATION, "cooQueue"); runner.setProperty(ConsumeJMS.DESTINATION_TYPE, ConsumeJMS.QUEUE); runner.run(1, false); // final MockFlowFile successFF = runner.getFlowFilesForRelationship(PublishJMS.REL_SUCCESS).get(0); assertNotNull(successFF); assertEquals("cooQueue", successFF.getAttributes().get(JmsHeaders.DESTINATION)); successFF.assertContentEquals("Hey dude!".getBytes()); ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy(); }
@Before public void setUp() { super.init(); }