[1/2] activemq-artemis git commit: ARTEMIS-1107 - fix and Test AddressControl.sendMessage()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[1/2] activemq-artemis git commit: ARTEMIS-1107 - fix and Test AddressControl.sendMessage()

martyntaylor
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 0032a5df9 -> 62096f975


ARTEMIS-1107 - fix and Test AddressControl.sendMessage()

https://issues.apache.org/jira/browse/ARTEMIS-1107


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

Branch: refs/heads/master
Commit: fb3de112e4f661f53d896f5e0cbee5ad61ef924a
Parents: 0032a5d
Author: Andy Taylor <[hidden email]>
Authored: Tue Apr 11 08:29:43 2017 +0100
Committer: Andy Taylor <[hidden email]>
Committed: Tue Apr 11 08:29:43 2017 +0100

----------------------------------------------------------------------
 .../management/impl/AddressControlImpl.java     |  7 ++++-
 .../tests/integration/amqp/ProtonTest.java      | 31 +++++++++++++++++++-
 .../management/AddressControlTest.java          |  2 --
 3 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fb3de112/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
index a321165..f0a3a77 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.AddressControl;
@@ -300,7 +301,11 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
          message.setDurable(durable);
          message.setTimestamp(System.currentTimeMillis());
          if (body != null) {
-            message.getBodyBuffer().writeBytes(Base64.decode(body));
+            if (type == Message.TEXT_TYPE) {
+               message.getBodyBuffer().writeNullableSimpleString(new SimpleString(body));
+            } else {
+               message.getBodyBuffer().writeBytes(Base64.decode(body));
+            }
          }
          message.setAddress(addressInfo.getName());
          postOffice.route(message, true);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fb3de112/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
index f443338..938e7ae 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java
@@ -262,7 +262,7 @@ public class ProtonTest extends ProtonTestBase {
 
       AddressControl addressControl = ManagementControlHelper.createAddressControl(address, mBeanServer);
       Assert.assertEquals(1, addressControl.getQueueNames().length);
-      addressControl.sendMessage(null, org.apache.activemq.artemis.api.core.Message.BYTES_TYPE, Base64.encodeBytes("test".getBytes()), false, null, null);
+      addressControl.sendMessage(null, org.apache.activemq.artemis.api.core.Message.BYTES_TYPE, Base64.encodeBytes("test".getBytes()), false, userName, password);
 
       Assert.assertEquals(1, addressControl.getMessageCount());
 
@@ -286,6 +286,35 @@ public class ProtonTest extends ProtonTestBase {
    }
 
    @Test
+   public void testAddressControlSendMessageWithText() throws Exception {
+      SimpleString address = RandomUtil.randomSimpleString();
+      server.createQueue(address, RoutingType.ANYCAST, address, null, true, false);
+
+      AddressControl addressControl = ManagementControlHelper.createAddressControl(address, mBeanServer);
+      Assert.assertEquals(1, addressControl.getQueueNames().length);
+      addressControl.sendMessage(null, org.apache.activemq.artemis.api.core.Message.TEXT_TYPE, "test", false, userName, password);
+
+      Assert.assertEquals(1, addressControl.getMessageCount());
+
+      Connection connection = createConnection("myClientId");
+      try {
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         javax.jms.Queue queue = session.createQueue(address.toString());
+         MessageConsumer consumer = session.createConsumer(queue);
+         Message message = consumer.receive(500);
+         assertNotNull(message);
+         String text = ((TextMessage) message).getText();
+         assertEquals("test", text);
+         session.close();
+         connection.close();
+      } finally {
+         if (connection != null) {
+            connection.close();
+         }
+      }
+   }
+
+   @Test
    public void testDurableSubscriptionUnsubscribe() throws Exception {
       Connection connection = createConnection("myClientId");
       try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fb3de112/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java
index 85f6eca..08781fe 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java
@@ -23,7 +23,6 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.RoutingType;
@@ -36,7 +35,6 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.api.core.management.AddressControl;
 import org.apache.activemq.artemis.api.core.management.RoleInfo;
-import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.security.CheckType;
 import org.apache.activemq.artemis.core.security.Role;

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[2/2] activemq-artemis git commit: This closes #1193

martyntaylor
This closes #1193


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

Branch: refs/heads/master
Commit: 62096f975e3d2cd4c24799c2075cc9e07250fa74
Parents: 0032a5d fb3de11
Author: Martyn Taylor <[hidden email]>
Authored: Tue Apr 11 10:43:54 2017 +0100
Committer: Martyn Taylor <[hidden email]>
Committed: Tue Apr 11 10:43:54 2017 +0100

----------------------------------------------------------------------
 .../management/impl/AddressControlImpl.java     |  7 ++++-
 .../tests/integration/amqp/ProtonTest.java      | 31 +++++++++++++++++++-
 .../management/AddressControlTest.java          |  2 --
 3 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


Loading...