CreateAddress CLI work

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

Branch: refs/heads/ARTEMIS-780
Commit: e2844e0cce016e1e5af0fa36d42e959e1360cb6c
Parents: fea23a1
Author: jbertram <[email protected]>
Authored: Mon Nov 28 21:45:23 2016 -0600
Committer: jbertram <[email protected]>
Committed: Tue Nov 29 10:56:16 2016 -0600

----------------------------------------------------------------------
 .../artemis/cli/commands/address/CreateAddress.java    | 13 ++++++++-----
 .../management/impl/ActiveMQServerControlImpl.java     |  2 +-
 .../activemq/artemis/core/server/impl/AddressInfo.java |  3 +++
 .../tests/integration/cli/AddressCommandTest.java      |  6 +++++-
 4 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e2844e0c/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java
index ac1a9a9..05df14b 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java
@@ -35,7 +35,7 @@ public class CreateAddress extends AbstractAction {
    String name;
 
    @Option(name = "--routingTypes", description = "The routing types supported 
by this address, options are 'anycast' or 'multicast', enter comma separated 
list, defaults to 'multicast' only")
-   Set<RoutingType> routingTypes = new HashSet<>();
+   String[] routingTypes = new String[] {RoutingType.MULTICAST.toString()};
 
    @Option(name = "--defaultMaxConsumers", description = "Sets the default max 
consumers for any queues created under this address, default = -1 (no limit)")
    int defaultMaxConsumers = -1;
@@ -54,7 +54,7 @@ public class CreateAddress extends AbstractAction {
       performCoreManagement(new ManagementCallback<ClientMessage>() {
          @Override
          public void setUpInvocation(ClientMessage message) throws Exception {
-            ManagementHelper.putOperationInvocation(message, "broker", 
"createAddress", getName(), routingTypes, defaultDeleteOnNoConsumers, 
defaultMaxConsumers);
+            ManagementHelper.putOperationInvocation(message, "broker", 
"createAddress", getName(), routingTypes);
          }
 
          @Override
@@ -78,13 +78,16 @@ public class CreateAddress extends AbstractAction {
       return name;
    }
 
-   public Set<RoutingType> getRoutingTypes() {
+   public String[] getRoutingTypes() {
       return routingTypes;
    }
 
    public void setRoutingTypes(String routingTypes) {
-      for (String s : routingTypes.split(",")) {
-         this.routingTypes.add(RoutingType.valueOf(s.trim()));
+      String[] split = routingTypes.split(",");
+      this.routingTypes = new String[split.length];
+      for (int i = 0; i < split.length; i++) {
+         RoutingType.valueOf(split[i].trim());
+         this.routingTypes[i] = split[i].trim();
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e2844e0c/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
index 9e103f4..1e2ac0d 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
@@ -665,7 +665,7 @@ public class ActiveMQServerControlImpl extends 
AbstractControl implements Active
             filter = new SimpleString(filterStr);
          }
 
-         server.createQueue(SimpleString.toSimpleString(address), 
RoutingType.valueOf(routingType), new SimpleString(name), filter, durable, 
false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
+         server.createQueue(SimpleString.toSimpleString(address), 
RoutingType.valueOf(routingType.toUpperCase()), new SimpleString(name), filter, 
durable, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
       } finally {
          blockOnIO();
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e2844e0c/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java
index 7816cde..d05628c 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java
@@ -119,6 +119,9 @@ public class AddressInfo {
       for (RoutingType routingType : routingTypes) {
          buff.append(routingType.toString() + ",");
       }
+      // delete hanging comma
+      buff.deleteCharAt(buff.length() - 1);
+      buff.append("}");
       buff.append(", autoCreated=" + autoCreated);
       buff.append("]");
       return buff.toString();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e2844e0c/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java
----------------------------------------------------------------------
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java
index c04fc0b..6c373ec 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java
@@ -51,9 +51,13 @@ public class AddressCommandTest extends JMSTestBase {
       String address = "address";
       CreateAddress command = new CreateAddress();
       command.setName(address);
+      command.setRoutingTypes(RoutingType.ANYCAST.toString() + "," + 
RoutingType.MULTICAST.toString());
       command.execute(new ActionContext(System.in, new PrintStream(output), 
new PrintStream(error)));
       checkExecutionPassed(command);
-      assertNotNull(server.getAddressInfo(new SimpleString(address)));
+      AddressInfo addressInfo = server.getAddressInfo(new 
SimpleString(address));
+      assertNotNull(addressInfo);
+      assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST));
+      
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST));
    }
 
    @Test

Reply via email to