You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by olegz <gi...@git.apache.org> on 2015/11/10 00:36:37 UTC
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
GitHub user olegz opened a pull request:
https://github.com/apache/nifi/pull/118
NIFI-1000 Fixed JmsFactory to properly obtain destiniation name
Re-enabled JMS Tests that were annotated with @Ignore
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/olegz/nifi NIFI-1000
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/nifi/pull/118.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #118
----
commit ef0be5a5d6fbfc8abb55e250fc1ddbc294fda743
Author: Oleg Zhurakousky <ol...@suitcase.io>
Date: 2015-11-09T23:35:31Z
NIFI-1000 Fixed JmsFactory to properly obtain destiniation name
Re-enabled JMS Tests that were annotated with @Ignore
----
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44421395
--- 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);
--- End diff --
Rather than calling onTrigger directly, should use TestRunner.run(). This will handle the ProcessSession and Process Context for you, as well as the appropriate lifecycle methods.
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44422933
--- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml ---
@@ -152,7 +152,8 @@ language governing permissions and limitations under the License. -->
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>activemq-client</artifactId>
+ <artifactId>activemq-all</artifactId>
+ <scope>test</scope>
--- End diff --
I agree we don't need the activemq-all at runtime, but I think we do need the activemq-client at runtime, no? As-is here, we bring it all in for test and none of it at runtime.
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44423704
--- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml ---
@@ -152,7 +152,8 @@ language governing permissions and limitations under the License. -->
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>activemq-client</artifactId>
+ <artifactId>activemq-all</artifactId>
+ <scope>test</scope>
--- End diff --
Basically its like db driver, provided at runtime.
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44421276
--- 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);
--- End diff --
@olegz Why cast this to StandardProcessorTestRunner? The TestRunner interface, I think, should be sufficient.
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44421520
--- 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));
--- End diff --
Would recommend here we just do successFlowFile.assertContentEquals("Hello World")
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44421577
--- 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"));
--- End diff --
Here we can just use successFlowFile.assertAttributeEquals("jms.JMSDestination", "queue.testing");
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/nifi/pull/118
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by olegz <gi...@git.apache.org>.
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44422157
--- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml ---
@@ -152,7 +152,8 @@ language governing permissions and limitations under the License. -->
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>activemq-client</artifactId>
+ <artifactId>activemq-all</artifactId>
+ <scope>test</scope>
--- End diff --
Yeah, activemq-all will bring the client back in. The real issue is that when using embedded broker like I am doing in test you also need other JARs from active mq and they all have to be in sink. So activemq-all will ensure that. Also, we don't need it at runtime, only at testCompile
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44421629
--- 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 --
Same comments as above for the unit test methods.
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by markap14 <gi...@git.apache.org>.
Github user markap14 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44421141
--- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml ---
@@ -152,7 +152,8 @@ language governing permissions and limitations under the License. -->
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>activemq-client</artifactId>
+ <artifactId>activemq-all</artifactId>
+ <scope>test</scope>
--- End diff --
@olegz - this is removing the activemq-client from the runtime classpath. Was that the intent? Is it already brought in elsewhere, or am I missing something?
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44423561
--- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml ---
@@ -152,7 +152,8 @@ language governing permissions and limitations under the License. -->
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>activemq-client</artifactId>
+ <artifactId>activemq-all</artifactId>
+ <scope>test</scope>
--- End diff --
No, we only need javax.jms at runtime. If we do need activeMq at runtime we are in big trouble unless the intention of JmsFactory and all components around it was to work with ActiveMq only.
---
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.
---
[GitHub] nifi pull request: NIFI-1000 Fixed JmsFactory to properly obtain d...
Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:
https://github.com/apache/nifi/pull/118#discussion_r44422260
--- 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);
--- End diff --
Notice that on another test, will fix
---
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.
---