activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-657: ensure management response bodies are encoded into amqp
Date Tue, 30 Aug 2016 21:12:36 GMT
ARTEMIS-657: ensure management response bodies are encoded into amqp


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/8f188ef2
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/8f188ef2
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/8f188ef2

Branch: refs/heads/master
Commit: 8f188ef23615cb71355e3bf64202e623fa198f4d
Parents: 6bb156c
Author: Gordon Sim <gsim@redhat.com>
Authored: Fri Aug 19 17:24:42 2016 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Aug 30 17:12:19 2016 -0400

----------------------------------------------------------------------
 .../message/JMSMappingOutboundTransformer.java  |  7 ++++
 .../tests/integration/proton/ProtonTest.java    | 37 ++++++++++++++++++++
 2 files changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8f188ef2/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java
index a6ccfa9..0129f47 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java
@@ -139,6 +139,13 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer
{
          body = new AmqpValue(((ObjectMessage) msg).getObject());
       }
 
+      if (body == null && msg instanceof org.apache.activemq.artemis.core.protocol.proton.converter.jms.ServerJMSMessage)
{
+         Object s = ((org.apache.activemq.artemis.core.protocol.proton.converter.jms.ServerJMSMessage)
msg).getInnerMessage().getBodyBuffer().readNullableSimpleString();
+         if (s != null) {
+            body = new AmqpValue(s.toString());
+         }
+      }
+
       header.setDurable(msg.getJMSDeliveryMode() == DeliveryMode.PERSISTENT ? true : false);
       header.setPriority(new UnsignedByte((byte) msg.getJMSPriority()));
       if (msg.getJMSType() != null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8f188ef2/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
index aac1599..b197bc6 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/proton/ProtonTest.java
@@ -78,6 +78,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
+import static org.junit.Assume.assumeTrue;
 import org.proton.plug.AMQPClientConnectionContext;
 import org.proton.plug.AMQPClientReceiverContext;
 import org.proton.plug.AMQPClientSenderContext;
@@ -640,6 +641,42 @@ public class ProtonTest extends ActiveMQTestBase {
    }
 
    @Test
+   public void testManagementQueryOverAMQP() throws Throwable {
+      assumeTrue(protocol == 0 || protocol == 3); // Only run this test for AMQP protocol
+
+      AmqpClient client = new AmqpClient(new URI(tcpAmqpConnectionUri), userName, password);
+      AmqpConnection amqpConnection = client.connect();
+      try {
+         String destinationAddress = address + 1;
+         AmqpSession session = amqpConnection.createSession();
+         AmqpSender sender = session.createSender("jms.queue.activemq.management");
+         AmqpReceiver receiver = session.createReceiver(destinationAddress);
+         receiver.flow(10);
+
+         //create request message for getQueueNames query
+         AmqpMessage request = new AmqpMessage();
+         request.setApplicationProperty("_AMQ_ResourceName", "core.server");
+         request.setApplicationProperty("_AMQ_OperationName", "getQueueNames");
+         request.setApplicationProperty("JMSReplyTo", destinationAddress);
+         request.setText("[]");
+
+         sender.send(request);
+         AmqpMessage response = receiver.receive();
+         assertNotNull(response);
+         Object section = response.getWrappedMessage().getBody();
+         assertTrue(section instanceof AmqpValue);
+         Object value = ((AmqpValue) section).getValue();
+         assertTrue(value instanceof String);
+         assertTrue(((String) value).length() > 0);
+         assertTrue(((String) value).contains(destinationAddress));
+         response.accept();
+      }
+      finally {
+         amqpConnection.close();
+      }
+   }
+
+   @Test
    public void testReplyTo() throws Throwable {
       Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       TemporaryQueue queue = session.createTemporaryQueue();


Mime
View raw message