You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/12/19 03:39:26 UTC
[1/2] activemq-artemis git commit: ARTEMIS-1341 fixed getBody
Repository: activemq-artemis
Updated Branches:
refs/heads/master d67c65b8a -> d1c9bc0f2
ARTEMIS-1341 fixed getBody
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/58cd0209
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/58cd0209
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/58cd0209
Branch: refs/heads/master
Commit: 58cd02090d1db57e642bb62be10910e330a28e51
Parents: d67c65b
Author: Stanislav Knot <sk...@redhat.com>
Authored: Tue Dec 12 14:49:31 2017 +0100
Committer: Clebert Suconic <cl...@apache.org>
Committed: Mon Dec 18 22:39:19 2017 -0500
----------------------------------------------------------------------
.../artemis/jms/client/ActiveMQMessage.java | 2 ++
.../integration/jms/jms2client/BodyTest.java | 27 +++++++++++++-------
.../tests/message/BodyIsAssignableFromTest.java | 2 +-
3 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd0209/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
index 9dca137..896a8ed 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
@@ -742,6 +742,8 @@ public class ActiveMQMessage implements javax.jms.Message {
public <T> T getBody(Class<T> c) throws JMSException {
if (isBodyAssignableTo(c)) {
return getBodyInternal(c);
+ } else if (hasNoBody()) {
+ return null;
}
// XXX HORNETQ-1209 Do we need translations here?
throw new MessageFormatException("Body not assignable to " + c);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd0209/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java
index 826a4c6..3409ee0 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/jms2client/BodyTest.java
@@ -20,12 +20,12 @@ import javax.jms.BytesMessage;
import javax.jms.Connection;
import javax.jms.Message;
import javax.jms.MessageConsumer;
-import javax.jms.MessageFormatException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.tests.util.JMSTestBase;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -48,7 +48,6 @@ public class BodyTest extends JMSTestBase {
try (
Connection conn = cf.createConnection();
) {
-
Session sess = conn.createSession();
MessageProducer producer = sess.createProducer(queue);
@@ -56,17 +55,27 @@ public class BodyTest extends JMSTestBase {
conn.start();
BytesMessage bytesMessage = sess.createBytesMessage();
- producer.send(bytesMessage);
+ BytesMessage bytesMessage2 = sess.createBytesMessage();
+ bytesMessage2.writeInt(42);
+ bytesMessage2.reset();
+ producer.send(bytesMessage);
Message msg = cons.receiveNoWait();
+
+ producer.send(bytesMessage2);
+ Message msg2 = cons.receiveNoWait();
+
assertNotNull(msg);
+ assertNotNull(msg2);
- try {
- msg.getBody(String.class);
- fail("Exception expected");
- } catch (MessageFormatException e) {
- }
- }
+ // message body is empty. getBody parameter may be set to any type
+ Assert.assertNull(msg.getBody(java.lang.Object.class));
+ Assert.assertNull(msg.getBody(byte[].class));
+ Assert.assertNull(msg.getBody(String.class));
+ // message body is not empty. getBody parameter must be set to byte[].class (or java.lang.Object.class)
+ Assert.assertNotNull(msg2.getBody(byte[].class));
+ Assert.assertNotNull(msg2.getBody(java.lang.Object.class));
+ }
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd0209/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java
index 47e43de..b791ce2 100644
--- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java
+++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/BodyIsAssignableFromTest.java
@@ -94,7 +94,7 @@ public class BodyIsAssignableFromTest extends MessageBodyTestCase {
} else {
try {
Object foo = msg.getBody(c);
- Assert.fail("expected a " + MessageFormatException.class);
+ Assert.assertNull("body should be null", foo);
} catch (MessageFormatException e) {
// expected
}
[2/2] activemq-artemis git commit: This closes #1697
Posted by cl...@apache.org.
This closes #1697
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/d1c9bc0f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/d1c9bc0f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/d1c9bc0f
Branch: refs/heads/master
Commit: d1c9bc0f2dfc02d4d6b4a25ecb03a6b5577aad9d
Parents: d67c65b 58cd020
Author: Clebert Suconic <cl...@apache.org>
Authored: Mon Dec 18 22:39:20 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Mon Dec 18 22:39:20 2017 -0500
----------------------------------------------------------------------
.../artemis/jms/client/ActiveMQMessage.java | 2 ++
.../integration/jms/jms2client/BodyTest.java | 27 +++++++++++++-------
.../tests/message/BodyIsAssignableFromTest.java | 2 +-
3 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------