Search in sources :

Example 6 with JMSConnectionFactoryProviderDefinition

use of org.apache.nifi.jms.cf.JMSConnectionFactoryProviderDefinition in project nifi by apache.

the class PublishJMSIT method validateFailedPublishAndTransferToFailure.

@Test
public void validateFailedPublishAndTransferToFailure() throws Exception {
    ConnectionFactory cf = mock(ConnectionFactory.class);
    PublishJMS pubProc = new PublishJMS();
    TestRunner runner = TestRunners.newTestRunner(pubProc);
    JMSConnectionFactoryProviderDefinition cs = mock(JMSConnectionFactoryProviderDefinition.class);
    when(cs.getIdentifier()).thenReturn("cfProvider");
    when(cs.getConnectionFactory()).thenReturn(cf);
    runner.addControllerService("cfProvider", cs);
    runner.enableControllerService(cs);
    runner.setProperty(PublishJMS.CF_SERVICE, "cfProvider");
    runner.setProperty(PublishJMS.DESTINATION, "validateFailedPublishAndTransferToFailure");
    runner.enqueue("Hello Joe".getBytes());
    runner.run();
    Thread.sleep(200);
    assertTrue(runner.getFlowFilesForRelationship(PublishJMS.REL_SUCCESS).isEmpty());
    assertNotNull(runner.getFlowFilesForRelationship(PublishJMS.REL_FAILURE).get(0));
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ConnectionFactory(javax.jms.ConnectionFactory) TestRunner(org.apache.nifi.util.TestRunner) JMSConnectionFactoryProviderDefinition(org.apache.nifi.jms.cf.JMSConnectionFactoryProviderDefinition) Test(org.junit.Test)

Aggregations

JMSConnectionFactoryProviderDefinition (org.apache.nifi.jms.cf.JMSConnectionFactoryProviderDefinition)6 TestRunner (org.apache.nifi.util.TestRunner)5 Test (org.junit.Test)5 JmsTemplate (org.springframework.jms.core.JmsTemplate)5 HashMap (java.util.HashMap)4 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)4 MockFlowFile (org.apache.nifi.util.MockFlowFile)4 BytesMessage (javax.jms.BytesMessage)3 ConnectionFactory (javax.jms.ConnectionFactory)2 CachingConnectionFactory (org.springframework.jms.connection.CachingConnectionFactory)2 Message (javax.jms.Message)1 TextMessage (javax.jms.TextMessage)1 ComponentLog (org.apache.nifi.logging.ComponentLog)1 UserCredentialsConnectionFactoryAdapter (org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter)1