nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegz <...@git.apache.org>
Subject [GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Date Tue, 10 Nov 2015 17:00:48 GMT
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/118#discussion_r44432971
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetJMSQueue.java
---
    @@ -24,73 +29,116 @@
     import javax.jms.Session;
     import javax.jms.StreamMessage;
     
    +import org.apache.nifi.processor.Relationship;
     import org.apache.nifi.processors.standard.util.JmsFactory;
     import org.apache.nifi.processors.standard.util.JmsProperties;
     import org.apache.nifi.processors.standard.util.WrappedMessageProducer;
    +import org.apache.nifi.util.MockFlowFile;
    +import org.apache.nifi.util.MockProcessSession;
    +import org.apache.nifi.util.StandardProcessorTestRunner;
     import org.apache.nifi.util.TestRunner;
     import org.apache.nifi.util.TestRunners;
     import org.apache.nifi.web.Revision;
    +import org.junit.Test;
     
     public class TestGetJMSQueue {
     
    -    @org.junit.Ignore
    +    @Test
         public void testSendTextToQueue() throws Exception {
    -        final TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class);
    +        GetJMSQueue getJmsQueue = new GetJMSQueue();
    +        StandardProcessorTestRunner runner = (StandardProcessorTestRunner) TestRunners.newTestRunner(getJmsQueue);
             runner.setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
    -        runner.setProperty(JmsProperties.URL, "tcp://localhost:61616");
    +        runner.setProperty(JmsProperties.URL, "vm://localhost?broker.persistent=false");
             runner.setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
             runner.setProperty(JmsProperties.DESTINATION_NAME, "queue.testing");
             runner.setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
    +
    +        MockProcessSession pSession = (MockProcessSession) runner.getProcessSessionFactory().createSession();
             WrappedMessageProducer wrappedProducer = JmsFactory.createMessageProducer(runner.getProcessContext(),
true);
             final Session jmsSession = wrappedProducer.getSession();
             final MessageProducer producer = wrappedProducer.getProducer();
    -
             final Message message = jmsSession.createTextMessage("Hello World");
     
             producer.send(message);
             jmsSession.commit();
    +
    +        getJmsQueue.onTrigger(runner.getProcessContext(), pSession);
    +
    +        List<MockFlowFile> flowFiles = pSession
    +                .getFlowFilesForRelationship(new Relationship.Builder().name("success").build());
    +
    +        assertTrue(flowFiles.size() == 1);
    +        MockFlowFile successFlowFile = flowFiles.get(0);
    +        String receivedMessage = new String(runner.getContentAsByteArray(successFlowFile));
    +        assertEquals("Hello World", receivedMessage);
    +        assertEquals("queue.testing", successFlowFile.getAttribute("jms.JMSDestination"));
             producer.close();
             jmsSession.close();
         }
     
    -    @org.junit.Ignore
    +    @Test
         public void testSendBytesToQueue() throws Exception {
    -        final TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class);
    +        GetJMSQueue getJmsQueue = new GetJMSQueue();
    +        StandardProcessorTestRunner runner = (StandardProcessorTestRunner) TestRunners.newTestRunner(getJmsQueue);
             runner.setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
    -        runner.setProperty(JmsProperties.URL, "tcp://localhost:61616");
    +        runner.setProperty(JmsProperties.URL, "vm://localhost?broker.persistent=false");
             runner.setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
             runner.setProperty(JmsProperties.DESTINATION_NAME, "queue.testing");
             runner.setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
             WrappedMessageProducer wrappedProducer = JmsFactory.createMessageProducer(runner.getProcessContext(),
true);
             final Session jmsSession = wrappedProducer.getSession();
             final MessageProducer producer = wrappedProducer.getProducer();
    -
    +        MockProcessSession pSession = (MockProcessSession) runner.getProcessSessionFactory().createSession();
             final BytesMessage message = jmsSession.createBytesMessage();
             message.writeBytes("Hello Bytes".getBytes());
     
             producer.send(message);
             jmsSession.commit();
    +
    --- End diff --
    
    Mark, please look at it again, all your concerns were addressed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message