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 2016/12/07 18:18:31 UTC

[28/55] [abbrv] activemq-artemis git commit: CLI WORK

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index 7e219c6..564aabd 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -785,7 +785,7 @@ public interface ActiveMQServerLogger extends BasicLogger {
       format = Message.Format.MESSAGE_FORMAT)
    void noQueueIdDefined(ServerMessage message, ServerMessage messageCopy, SimpleString idsHeaderName);
 
-   @LogMessage(level = Logger.Level.WARN)
+   @LogMessage(level = Logger.Level.TRACE)
    @Message(id = 222111, value = "exception while invoking {0} on {1}",
       format = Message.Format.MESSAGE_FORMAT)
    void managementOperationError(@Cause Exception e, String op, String resourceName);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 7aa802b..ea72bea 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -48,6 +48,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
+import org.apache.activemq.artemis.api.core.ActiveMQDeleteAddressException;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl;
@@ -1476,8 +1477,9 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final boolean durable,
                             final boolean temporary,
                             final Integer maxConsumers,
-                            final Boolean deleteOnNoConsumers) throws Exception {
-      return createQueue(address, queueName, filterString, null, durable, temporary, false, false, false, maxConsumers, deleteOnNoConsumers);
+                            final Boolean deleteOnNoConsumers,
+                            final boolean autoCreateAddress) throws Exception {
+      return createQueue(address, queueName, filterString, null, durable, temporary, false, false, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
    }
 
    @Override
@@ -1498,8 +1500,9 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             boolean durable,
                             boolean temporary,
                             Integer maxConsumers,
-                            Boolean deleteOnNoConsumers) throws Exception {
-      return createQueue(address, queueName, filter, user, durable, temporary, false, false, false, maxConsumers, deleteOnNoConsumers);
+                            Boolean deleteOnNoConsumers,
+                            boolean autoCreateAddress) throws Exception {
+      return createQueue(address, queueName, filter, user, durable, temporary, false, false, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
    }
 
    @Override
@@ -1522,8 +1525,9 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             boolean temporary,
                             boolean autoCreated,
                             Integer maxConsumers,
-                            Boolean deleteOnNoConsumers) throws Exception {
-      return createQueue(address, queueName, filter, user, durable, temporary, false, false, autoCreated, maxConsumers, deleteOnNoConsumers);
+                            Boolean deleteOnNoConsumers,
+                            boolean autoCreateAddress) throws Exception {
+      return createQueue(address, queueName, filter, user, durable, temporary, false, false, autoCreated, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
    }
 
    @Override
@@ -1585,7 +1589,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final boolean durable,
                             final boolean temporary,
                             final boolean autoCreated) throws Exception {
-      return deployQueue(address, queueName, filterString, durable, temporary, autoCreated, null, null);
+      return deployQueue(address, queueName, filterString, durable, temporary, autoCreated, null, null, true);
    }
 
    @Override
@@ -1596,12 +1600,13 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final boolean temporary,
                             final boolean autoCreated,
                             final Integer maxConsumers,
-                            final Boolean deleteOnNoConsumers) throws Exception {
+                            final Boolean deleteOnNoConsumers,
+                            final boolean autoCreateAddress) throws Exception {
 
       // TODO: fix logging here as this could be for a topic or queue
       ActiveMQServerLogger.LOGGER.deployQueue(queueName);
 
-      return createQueue(address, queueName, filterString, null, durable, temporary, true, false, autoCreated, maxConsumers, deleteOnNoConsumers);
+      return createQueue(address, queueName, filterString, null, durable, temporary, true, false, autoCreated, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
    }
 
    @Override
@@ -1621,7 +1626,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
    public void destroyQueue(final SimpleString queueName,
                             final SecurityAuth session,
                             final boolean checkConsumerCount) throws Exception {
-      destroyQueue(queueName, session, checkConsumerCount, false);
+      destroyQueue(queueName, session, checkConsumerCount, false, true);
    }
 
    @Override
@@ -1629,6 +1634,15 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SecurityAuth session,
                             final boolean checkConsumerCount,
                             final boolean removeConsumers) throws Exception {
+      destroyQueue(queueName, session, checkConsumerCount, removeConsumers, true);
+   }
+
+   @Override
+   public void destroyQueue(final SimpleString queueName,
+                            final SecurityAuth session,
+                            final boolean checkConsumerCount,
+                            final boolean removeConsumers,
+                            final boolean autoDeleteAddress) throws Exception {
       if (postOffice == null) {
          return;
       }
@@ -1662,6 +1676,14 @@ public class ActiveMQServerImpl implements ActiveMQServer {
 
       queue.deleteQueue(removeConsumers);
 
+      if (autoDeleteAddress && postOffice != null) {
+         try {
+            postOffice.removeAddressInfo(address);
+         } catch (ActiveMQDeleteAddressException e) {
+            // Could be thrown if the address has bindings or is not deletable.
+         }
+      }
+
       callPostQueueDeletionCallbacks(address, queueName);
    }
 
@@ -2101,15 +2123,15 @@ public class ActiveMQServerImpl implements ActiveMQServer {
       // Deploy any predefined queues
       deployQueuesFromConfiguration();
 
-      registerPostQueueDeletionCallback(new PostQueueDeletionCallback() {
-         // TODO delete auto-created addresses when queueCount == 0
-         @Override
-         public void callback(SimpleString address, SimpleString queueName) throws Exception {
-            if (getAddressInfo(address).isAutoCreated() && postOffice.getBindingsForAddress(address).getBindings().size() == 0) {
-               removeAddressInfo(address);
-            }
-         }
-      });
+      //      registerPostQueueDeletionCallback(new PostQueueDeletionCallback() {
+      //         // TODO delete auto-created addresses when queueCount == 0
+      //         @Override
+      //         public void callback(SimpleString address, SimpleString queueName) throws Exception {
+      //            if (getAddressInfo(address).isAutoCreated()) {
+      //               removeAddressInfo(address);
+      //            }
+      //         }
+      //      });
 
       // We need to call this here, this gives any dependent server a chance to deploy its own addresses
       // this needs to be done before clustering is fully activated
@@ -2200,7 +2222,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
 
    private void deployQueuesFromListCoreQueueConfiguration(List<CoreQueueConfiguration> queues) throws Exception {
       for (CoreQueueConfiguration config : queues) {
-         deployQueue(SimpleString.toSimpleString(config.getAddress()), SimpleString.toSimpleString(config.getName()), SimpleString.toSimpleString(config.getFilterString()), config.isDurable(), false, false, config.getMaxConsumers(), config.getDeleteOnNoConsumers());
+         deployQueue(SimpleString.toSimpleString(config.getAddress()), SimpleString.toSimpleString(config.getName()), SimpleString.toSimpleString(config.getFilterString()), config.isDurable(), false, false, config.getMaxConsumers(), config.getDeleteOnNoConsumers(), true);
       }
    }
 
@@ -2316,6 +2338,13 @@ public class ActiveMQServerImpl implements ActiveMQServer {
    }
 
    @Override
+   public void createAddressInfo(AddressInfo addressInfo) throws Exception {
+      if (putAddressInfoIfAbsent(addressInfo) != null) {
+         throw ActiveMQMessageBundle.BUNDLE.addressAlreadyExists(addressInfo.getName());
+      }
+   }
+
+   @Override
    public AddressInfo createOrUpdateAddressInfo(AddressInfo addressInfo) throws Exception {
       AddressInfo result = postOffice.addOrUpdateAddressInfo(addressInfo);
 
@@ -2329,12 +2358,14 @@ public class ActiveMQServerImpl implements ActiveMQServer {
 
    @Override
    public void removeAddressInfo(SimpleString address) throws Exception {
-      postOffice.removeAddressInfo(address);
+      if (postOffice.removeAddressInfo(address) == null) {
+         throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(address);
+      };
 
       // TODO: is this the right way to do this?
-//      long txID = storageManager.generateID();
-//      storageManager.deleteAddressBinding(txID, getAddressInfo(address).getID());
-//      storageManager.commitBindings(txID);
+      //      long txID = storageManager.generateID();
+      //      storageManager.deleteAddressBinding(txID, getAddressInfo(address).getID());
+      //      storageManager.commitBindings(txID);
 
    }
 
@@ -2357,17 +2388,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                              final boolean ignoreIfExists,
                              final boolean transientQueue,
                              final boolean autoCreated) throws Exception {
-      return createQueue(addressName,
-                         queueName,
-                         filterString,
-                         user,
-                         durable,
-                         temporary,
-                         ignoreIfExists,
-                         transientQueue,
-                         autoCreated,
-                         null,
-                         null);
+      return createQueue(addressName, queueName, filterString, user, durable, temporary, ignoreIfExists, transientQueue, autoCreated, null, null, true);
    }
 
    @Override
@@ -2381,7 +2402,9 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final boolean transientQueue,
                             final boolean autoCreated,
                             final Integer maxConsumers,
-                            final Boolean deleteOnNoConsumers) throws Exception {
+                            final Boolean deleteOnNoConsumers,
+                            final boolean autoCreateAddress) throws Exception {
+
       final QueueBinding binding = (QueueBinding) postOffice.getBinding(queueName);
       if (binding != null) {
          if (ignoreIfExists) {
@@ -2404,34 +2427,26 @@ public class ActiveMQServerImpl implements ActiveMQServer {
       }
 
       AddressInfo defaultAddressInfo = new AddressInfo(addressName);
-      // FIXME This boils down to a putIfAbsent (avoids race).  This should be reflected in the API.
       AddressInfo info = postOffice.getAddressInfo(addressName);
 
       if (info == null) {
-         info = defaultAddressInfo;
+         if (autoCreateAddress) {
+            info = defaultAddressInfo;
+         } else {
+            throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(addressName);
+         }
       }
 
       final boolean isDeleteOnNoConsumers = deleteOnNoConsumers == null ? info.isDefaultDeleteOnNoConsumers() : deleteOnNoConsumers;
       final int noMaxConsumers = maxConsumers == null ? info.getDefaultMaxQueueConsumers() : maxConsumers;
 
-      final QueueConfig queueConfig = queueConfigBuilder
-         .filter(filter)
-         .pagingManager(pagingManager)
-         .user(user)
-         .durable(durable)
-         .temporary(temporary)
-         .autoCreated(autoCreated)
-         .deleteOnNoConsumers(isDeleteOnNoConsumers)
-         .maxConsumers(noMaxConsumers)
-         .build();
+      final QueueConfig queueConfig = queueConfigBuilder.filter(filter).pagingManager(pagingManager).user(user).durable(durable).temporary(temporary).autoCreated(autoCreated).deleteOnNoConsumers(isDeleteOnNoConsumers).maxConsumers(noMaxConsumers).build();
       final Queue queue = queueFactory.createQueueWith(queueConfig);
 
       boolean addressAlreadyExists = true;
 
       if (postOffice.getAddressInfo(queue.getAddress()) == null) {
-         postOffice.addAddressInfo(new AddressInfo(queue.getAddress())
-                           .setRoutingType(AddressInfo.RoutingType.MULTICAST)
-                           .setDefaultMaxQueueConsumers(maxConsumers == null ? ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers() : maxConsumers));
+         postOffice.addAddressInfo(new AddressInfo(queue.getAddress()).setRoutingType(AddressInfo.RoutingType.MULTICAST).setDefaultMaxQueueConsumers(maxConsumers == null ? ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers() : maxConsumers));
          addressAlreadyExists = false;
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/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 6ad40fa..a92e8d3 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
@@ -31,6 +31,8 @@ public class AddressInfo {
 
    private boolean autoCreated = false;
 
+   private boolean deletable = false;
+
    public AddressInfo(SimpleString name) {
       this.name = name;
    }
@@ -85,7 +87,7 @@ public class AddressInfo {
    @Override
    public String toString() {
       StringBuffer buff = new StringBuffer();
-      buff.append("AddressInfo [name=" + name);
+      buff.append("Address [name=" + name);
       buff.append(", routingType=" + routingType);
       buff.append(", defaultMaxQueueConsumers=" + defaultMaxQueueConsumers);
       buff.append(", defaultDeleteOnNoConsumers=" + defaultDeleteOnNoConsumers);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
index 7c614ae..f6da245 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
@@ -1421,7 +1421,8 @@ public class QueueImpl implements Queue {
    @Override
    public void deleteQueue(boolean removeConsumers) throws Exception {
       synchronized (this) {
-         if (this.queueDestroyed) return;
+         if (this.queueDestroyed)
+            return;
          this.queueDestroyed = true;
       }
 
@@ -1454,7 +1455,6 @@ public class QueueImpl implements Queue {
          tx.rollback();
          throw e;
       }
-
    }
 
    @Override
@@ -1799,7 +1799,7 @@ public class QueueImpl implements Queue {
    }
 
    @Override
-   public synchronized void pause(boolean persist)  {
+   public synchronized void pause(boolean persist) {
       try {
          this.flushDeliveriesInTransit();
          if (persist && isDurable()) {
@@ -1887,6 +1887,7 @@ public class QueueImpl implements Queue {
       return "QueueImpl[name=" + name.toString() + ", postOffice=" + this.postOffice + ", temp=" + this.temporary + "]@" + Integer.toHexString(System.identityHashCode(this));
    }
 
+
    private synchronized void internalAddTail(final MessageReference ref) {
       refAdded(ref);
       messageReferences.addTail(ref, getPriority(ref));
@@ -2960,8 +2961,6 @@ public class QueueImpl implements Queue {
          return false;
       }
 
-
-
       @Override
       public MessageReference next() {
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index b3fc5ac..88ab0c0 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -510,7 +510,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
 
       server.checkQueueCreationLimit(getUsername());
 
-      Queue queue = server.createQueue(address, name, filterString, SimpleString.toSimpleString(getUsername()), durable, temporary, autoCreated, maxConsumers, deleteOnNoConsumers);
+      Queue queue = server.createQueue(address, name, filterString, SimpleString.toSimpleString(getUsername()), durable, temporary, maxConsumers, deleteOnNoConsumers, true);
 
       if (temporary) {
          // Temporary queue in core simply means the queue will be deleted if

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index 242cbc7..4cfa57a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -739,7 +739,6 @@ public class ManagementServiceImpl implements ManagementService {
       }
 
       Object result = method.invoke(resource, params);
-
       return result;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
index b6e4de7..827e1b3 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AddressingTest.java
@@ -229,7 +229,7 @@ public class AddressingTest extends ActiveMQTestBase {
       SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
       // For each address, create 2 Queues with the same address, assert both queues receive message
       boolean deleteOnNoConsumers = true;
-      Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers);
+      Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers, false);
 
       ClientSession session = sessionFactory.createSession();
       session.start();
@@ -246,7 +246,7 @@ public class AddressingTest extends ActiveMQTestBase {
       SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
       // For each address, create 2 Queues with the same address, assert both queues receive message
       boolean deleteOnNoConsumers = false;
-      Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers);
+      Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers, false);
 
       ClientSession session = sessionFactory.createSession();
       session.start();
@@ -263,7 +263,7 @@ public class AddressingTest extends ActiveMQTestBase {
       SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
       // For each address, create 2 Queues with the same address, assert both queues receive message
       boolean deleteOnNoConsumers = false;
-      Queue q1 = server.createQueue(address, queueName, null, true, false, 0, deleteOnNoConsumers);
+      Queue q1 = server.createQueue(address, queueName, null, true, false, 0, deleteOnNoConsumers, false);
 
       Exception expectedException = null;
       String expectedMessage = "Maximum Consumer Limit Reached on Queue";
@@ -290,7 +290,7 @@ public class AddressingTest extends ActiveMQTestBase {
       SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
       // For each address, create 2 Queues with the same address, assert both queues receive message
       boolean deleteOnNoConsumers = false;
-      Queue q1 = server.createQueue(address, queueName, null, true, false, -1, deleteOnNoConsumers);
+      Queue q1 = server.createQueue(address, queueName, null, true, false, -1, deleteOnNoConsumers, false);
 
       ClientSession session = sessionFactory.createSession();
       session.start();
@@ -310,7 +310,7 @@ public class AddressingTest extends ActiveMQTestBase {
       boolean deleteOnNoConsumers = false;
       AddressInfo addressInfo = new AddressInfo(address);
       addressInfo.setDefaultMaxQueueConsumers(0);
-      Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers);
+      Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers, false);
 
       ClientSession session = sessionFactory.createSession();
       session.start();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/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
new file mode 100644
index 0000000..9589f47
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.cli;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.UUID;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.cli.commands.AbstractAction;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.cli.commands.address.CreateAddress;
+import org.apache.activemq.artemis.cli.commands.address.DeleteAddress;
+import org.apache.activemq.artemis.cli.commands.address.ShowAddress;
+import org.apache.activemq.artemis.cli.commands.queue.CreateQueue;
+import org.apache.activemq.artemis.cli.commands.queue.DeleteQueue;
+import org.apache.activemq.artemis.core.config.DivertConfiguration;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.core.server.impl.AddressInfo;
+import org.apache.activemq.artemis.tests.util.JMSTestBase;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AddressCommandTest extends JMSTestBase {
+
+   //the command
+   private ByteArrayOutputStream output;
+   private ByteArrayOutputStream error;
+
+   @Before
+   @Override
+   public void setUp() throws Exception {
+      super.setUp();
+      this.output = new ByteArrayOutputStream(1024);
+      this.error = new ByteArrayOutputStream(1024);
+   }
+
+   @Test
+   public void testCreateAddress() throws Exception {
+      String address = "address";
+      CreateAddress command = new CreateAddress();
+      command.setName(address);
+      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionPassed(command);
+      assertNotNull(server.getAddressInfo(new SimpleString(address)));
+   }
+
+   @Test
+   public void testCreateAddressAlreadyExistsShowsError() throws Exception {
+      String address = "address";
+      CreateAddress command = new CreateAddress();
+      command.setName(address);
+      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionPassed(command);
+      assertNotNull(server.getAddressInfo(new SimpleString(address)));
+
+      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionFailure(command, "Address already exists");
+   }
+
+   @Test
+   public void testDeleteAddress() throws Exception {
+      String address = "address";
+      CreateAddress command = new CreateAddress();
+      command.setName(address);
+      command.execute(new ActionContext());
+      assertNotNull(server.getAddressInfo(new SimpleString(address)));
+
+      DeleteAddress deleteAddress = new DeleteAddress();
+      deleteAddress.setName(address);
+      deleteAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionPassed(deleteAddress);
+      assertNull(server.getAddressInfo(new SimpleString(address)));
+   }
+
+   @Test
+   public void testDeleteAddressDoesNotExistsShowsError() throws Exception {
+      String address = "address";
+      DeleteAddress deleteAddress = new DeleteAddress();
+      deleteAddress.setName(address);
+      deleteAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionFailure(deleteAddress, "Address Does Not Exist");
+   }
+
+   @Test
+   public void testShowAddress() throws Exception {
+      String address = "address";
+      CreateAddress command = new CreateAddress();
+      command.setName(address);
+      command.execute(new ActionContext());
+      assertNotNull(server.getAddressInfo(new SimpleString(address)));
+
+      ShowAddress showAddress = new ShowAddress();
+      showAddress.setName(address);
+      showAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      System.out.println(output.toString());
+   }
+
+   @Test
+   public void testShowAddressDoesNotExist() throws Exception {
+      String address = "address";
+      ShowAddress showAddress = new ShowAddress();
+      showAddress.setName(address);
+      showAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionFailure(showAddress, "Address Does Not Exist");
+   }
+
+   @Test
+   public void testShowAddressBindings() throws Exception {
+
+      // Create bindings
+      SimpleString address = new SimpleString("address");
+      server.createAddressInfo(new AddressInfo(address));
+      server.createQueue(address, new SimpleString("queue1"), null, true, false);
+      server.createQueue(address, new SimpleString("queue2"), null, true, false);
+      server.createQueue(address, new SimpleString("queue3"), null, true, false);
+
+      DivertConfiguration divertConfiguration = new DivertConfiguration();
+      divertConfiguration.setName(address.toString());
+      divertConfiguration.setAddress(address.toString());
+      server.deployDivert(divertConfiguration);
+
+      ShowAddress showAddress = new ShowAddress();
+      showAddress.setName(address.toString());
+      showAddress.setBindings(true);
+      showAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      System.out.println(output.toString());
+   }
+
+   private void checkExecutionPassed(AbstractAction command) throws Exception {
+      String fullMessage = output.toString();
+      System.out.println("output: " + fullMessage);
+      assertTrue(fullMessage, fullMessage.contains("successfully"));
+   }
+
+   private void checkExecutionFailure(AbstractAction command, String message) throws Exception {
+      String fullMessage = error.toString();
+      System.out.println("error: " + fullMessage);
+      assertTrue(fullMessage, fullMessage.contains(message));
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DestinationCommandTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DestinationCommandTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DestinationCommandTest.java
deleted file mode 100644
index a9266ef..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DestinationCommandTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.tests.integration.cli;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.Map;
-
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.cli.commands.ActionContext;
-import org.apache.activemq.artemis.cli.commands.destination.CreateDestination;
-import org.apache.activemq.artemis.cli.commands.destination.DeleteDestination;
-import org.apache.activemq.artemis.cli.commands.destination.DestinationAction;
-import org.apache.activemq.artemis.core.filter.Filter;
-import org.apache.activemq.artemis.core.postoffice.Binding;
-import org.apache.activemq.artemis.tests.util.JMSTestBase;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DestinationCommandTest extends JMSTestBase {
-
-   //the command
-   private ByteArrayOutputStream output;
-   private ByteArrayOutputStream error;
-
-   @Before
-   @Override
-   public void setUp() throws Exception {
-      super.setUp();
-      this.output = new ByteArrayOutputStream(1024);
-      this.error = new ByteArrayOutputStream(1024);
-   }
-
-   @Test
-   public void testCreateJmsQueue() throws Exception {
-      CreateDestination command = new CreateDestination();
-      command.setName("jmsQueue1");
-      command.setBindings("jmsQueue1Binding");
-      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(command);
-   }
-
-   @Test
-   public void testDeleteJmsQueue() throws Exception {
-      CreateDestination command = new CreateDestination();
-      command.setName("jmsQueue1");
-      command.setBindings("jmsQueue1Binding");
-      command.execute(new ActionContext());
-
-      DeleteDestination delete = new DeleteDestination();
-      delete.setName("jmsQueue1");
-      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(delete);
-   }
-
-   @Test
-   public void testDeleteNonExistJmsQueue() throws Exception {
-      DeleteDestination delete = new DeleteDestination();
-      delete.setName("jmsQueue1NotExist");
-      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(delete);
-   }
-
-   @Test
-   public void testCreateJmsQueueWithFilter() throws Exception {
-      CreateDestination command = new CreateDestination();
-      command.setName("jmsQueue2");
-      command.setBindings("jmsQueue2Binding");
-      command.setFilter("color='red'");
-      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(command);
-      assertTrue(checkBindingExists(command, "color='red'"));
-   }
-
-   @Test
-   public void testCreateJmsTopic() throws Exception {
-      CreateDestination command = new CreateDestination();
-      command.setDestType(DestinationAction.JMS_TOPIC);
-      command.setName("jmsTopic1");
-      command.setBindings("jmsTopic1Binding");
-      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(command);
-   }
-
-   @Test
-   public void testDeleteJmsTopic() throws Exception {
-      CreateDestination command = new CreateDestination();
-      command.setDestType(DestinationAction.JMS_TOPIC);
-      command.setName("jmsTopic1");
-      command.setBindings("jmsTopic1Binding");
-      command.execute(new ActionContext());
-
-      DeleteDestination delete = new DeleteDestination();
-      delete.setDestType(DestinationAction.JMS_TOPIC);
-      delete.setName("jmsTopic1");
-      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(delete);
-   }
-
-   @Test
-   public void testDeleteJmsTopicNotExist() throws Exception {
-      DeleteDestination delete = new DeleteDestination();
-      delete.setDestType(DestinationAction.JMS_TOPIC);
-      delete.setName("jmsTopic1NotExist");
-      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(delete);
-   }
-
-   @Test
-   public void testCreateCoreQueue() throws Exception {
-      CreateDestination command = new CreateDestination();
-      command.setDestType(DestinationAction.CORE_QUEUE);
-      command.setName("coreQueue1");
-      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(command);
-   }
-
-   @Test
-   public void testCreateCoreQueueWithFilter() throws Exception {
-      CreateDestination command = new CreateDestination();
-      command.setName("coreQueue2");
-      command.setDestType(DestinationAction.CORE_QUEUE);
-      command.setFilter("color='green'");
-      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(command);
-   }
-
-   @Test
-   public void testDeleteCoreQueue() throws Exception {
-      CreateDestination command = new CreateDestination();
-      command.setName("coreQueue2");
-      command.setDestType(DestinationAction.CORE_QUEUE);
-      command.setFilter("color='green'");
-      command.execute(new ActionContext());
-
-      DeleteDestination delete = new DeleteDestination();
-      delete.setName("coreQueue2");
-      delete.setDestType(DestinationAction.CORE_QUEUE);
-      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(delete);
-   }
-
-   @Test
-   public void testDeleteCoreQueueNotExist() throws Exception {
-      DeleteDestination delete = new DeleteDestination();
-      delete.setName("coreQueue2NotExist");
-      delete.setDestType(DestinationAction.CORE_QUEUE);
-      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
-      checkExecutionResult(delete);
-   }
-
-   private boolean isCreateCommand(DestinationAction command) {
-      return command instanceof CreateDestination;
-   }
-
-   private boolean isJms(DestinationAction command) {
-      String destType = command.getDestType();
-      return !DestinationAction.CORE_QUEUE.equals(destType);
-   }
-
-   private boolean isTopic(DestinationAction command) {
-      String destType = command.getDestType();
-      return DestinationAction.JMS_TOPIC.equals(destType);
-   }
-
-   private void checkExecutionResult(DestinationAction command) throws Exception {
-      if (isCreateCommand(command)) {
-         String fullMessage = output.toString();
-         System.out.println("output: " + fullMessage);
-         assertTrue(fullMessage, fullMessage.contains("successfully"));
-         assertTrue(checkBindingExists(command, null));
-      } else {
-         if (command.getName().equals("jmsQueue1") || command.getName().equals("coreQueue2") || command.getName().equals("jmsTopic1")) {
-            String fullMessage = output.toString();
-            System.out.println("output: " + fullMessage);
-            assertTrue(fullMessage, fullMessage.contains("successfully"));
-            assertFalse(checkBindingExists(command, null));
-         } else {
-            String errorMessage = error.toString();
-            System.out.println("error: " + errorMessage);
-            assertTrue(errorMessage, errorMessage.contains("Failed to"));
-            assertFalse(checkBindingExists(command, null));
-         }
-      }
-   }
-
-   private boolean checkBindingExists(DestinationAction command, String filter) {
-      String bindingKey = command.getName();
-      if (isJms(command)) {
-         if (isTopic(command)) {
-//            bindingKey = bindingKey;
-         } else {
-//            bindingKey = bindingKey;
-         }
-      }
-      Map<SimpleString, Binding> bindings = server.getPostOffice().getAllBindings();
-      System.out.println("bindings: " + bindings);
-      Binding binding = bindings.get(new SimpleString(bindingKey));
-      System.out.println("got binding: " + binding);
-      if (binding == null) {
-         System.out.println("No bindings for " + bindingKey);
-         return false;
-      }
-      if (filter != null) {
-         Filter bindingFilter = binding.getFilter();
-         assertNotNull(bindingFilter);
-         assertEquals(filter, bindingFilter.getFilterString().toString());
-      }
-      return true;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DummyServerConsumer.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DummyServerConsumer.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DummyServerConsumer.java
new file mode 100644
index 0000000..d79b444
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/DummyServerConsumer.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.cli;
+
+import java.util.List;
+
+import org.apache.activemq.artemis.core.filter.Filter;
+import org.apache.activemq.artemis.core.server.HandleStatus;
+import org.apache.activemq.artemis.core.server.MessageReference;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.core.server.ServerConsumer;
+import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
+import org.apache.activemq.artemis.core.transaction.Transaction;
+
+public class DummyServerConsumer implements ServerConsumer {
+
+   @Override
+   public void setlowConsumerDetection(SlowConsumerDetectionListener listener) {
+
+   }
+
+   @Override
+   public SlowConsumerDetectionListener getSlowConsumerDetecion() {
+      return null;
+   }
+
+   @Override
+   public void fireSlowConsumer() {
+
+   }
+
+   @Override
+   public Object getProtocolData() {
+      return null;
+   }
+
+   @Override
+   public void setProtocolData(Object protocolData) {
+
+   }
+
+   @Override
+   public void setProtocolContext(Object protocolContext) {
+
+   }
+
+   @Override
+   public Object getProtocolContext() {
+      return null;
+   }
+
+   @Override
+   public long getID() {
+      return 0;
+   }
+
+   @Override
+   public Object getConnectionID() {
+      return null;
+   }
+
+   @Override
+   public void close(boolean failed) throws Exception {
+
+   }
+
+   @Override
+   public void removeItself() throws Exception {
+
+   }
+
+   @Override
+   public List<MessageReference> cancelRefs(boolean failed,
+                                            boolean lastConsumedAsDelivered,
+                                            Transaction tx) throws Exception {
+      return null;
+   }
+
+   @Override
+   public void setStarted(boolean started) {
+
+   }
+
+   @Override
+   public void receiveCredits(int credits) {
+
+   }
+
+   @Override
+   public Queue getQueue() {
+      return null;
+   }
+
+   @Override
+   public MessageReference removeReferenceByID(long messageID) throws Exception {
+      return null;
+   }
+
+   @Override
+   public void backToDelivering(MessageReference reference) {
+
+   }
+
+   @Override
+   public List<MessageReference> getDeliveringReferencesBasedOnProtocol(boolean remove,
+                                                                        Object protocolDataStart,
+                                                                        Object protocolDataEnd) {
+      return null;
+   }
+
+   @Override
+   public void acknowledge(Transaction tx, long messageID) throws Exception {
+
+   }
+
+   @Override
+   public void individualAcknowledge(Transaction tx, long messageID) throws Exception {
+
+   }
+
+   @Override
+   public void individualCancel(long messageID, boolean failed) throws Exception {
+
+   }
+
+   @Override
+   public void forceDelivery(long sequence) {
+
+   }
+
+   @Override
+   public void setTransferring(boolean transferring) {
+
+   }
+
+   @Override
+   public boolean isBrowseOnly() {
+      return false;
+   }
+
+   @Override
+   public long getCreationTime() {
+      return 0;
+   }
+
+   @Override
+   public String getSessionID() {
+      return null;
+   }
+
+   @Override
+   public void promptDelivery() {
+
+   }
+
+   @Override
+   public HandleStatus handle(MessageReference reference) throws Exception {
+      return null;
+   }
+
+   @Override
+   public void proceedDeliver(MessageReference reference) throws Exception {
+
+   }
+
+   @Override
+   public Filter getFilter() {
+      return null;
+   }
+
+   @Override
+   public List<MessageReference> getDeliveringMessages() {
+      return null;
+   }
+
+   @Override
+   public String debug() {
+      return null;
+   }
+
+   @Override
+   public String toManagementString() {
+      return null;
+   }
+
+   @Override
+   public void disconnect() {
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/QueueCommandTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/QueueCommandTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/QueueCommandTest.java
new file mode 100644
index 0000000..5d7a695
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/QueueCommandTest.java
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.tests.integration.cli;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.UUID;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.cli.commands.queue.CreateQueue;
+import org.apache.activemq.artemis.cli.commands.queue.DeleteQueue;
+import org.apache.activemq.artemis.cli.commands.AbstractAction;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.core.server.impl.AddressInfo;
+import org.apache.activemq.artemis.tests.util.JMSTestBase;
+import org.junit.Before;
+import org.junit.Test;
+
+public class QueueCommandTest extends JMSTestBase {
+
+   //the command
+   private ByteArrayOutputStream output;
+   private ByteArrayOutputStream error;
+
+   @Before
+   @Override
+   public void setUp() throws Exception {
+      super.setUp();
+      this.output = new ByteArrayOutputStream(1024);
+      this.error = new ByteArrayOutputStream(1024);
+   }
+
+   @Test
+   public void testCreateCoreQueueShowsErrorWhenAddressDoesNotExists() throws Exception {
+      String queueName = "queue1";
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName);
+      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionFailure(command, "AMQ119203: Address Does Not Exist:");;
+      assertFalse(server.queueQuery(new SimpleString(queueName)).isExists());
+   }
+
+   @Test
+   public void testCreateCoreQueueAutoCreateAddressDefaultAddress() throws Exception {
+      String queueName = UUID.randomUUID().toString();
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName);
+      command.setAutoCreateAddress(true);
+      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionPassed(command);
+      assertNotNull(server.getAddressInfo(new SimpleString(queueName)));
+
+      Queue queue = server.locateQueue(new SimpleString(queueName));
+      assertEquals(-1, queue.getMaxConsumers());
+      assertEquals(false, queue.isDeleteOnNoConsumers());
+      assertTrue(server.queueQuery(new SimpleString(queueName)).isExists());
+   }
+
+   @Test
+   public void testCreateCoreQueueAddressExists() throws Exception {
+      String queueName = "queue";
+      String address= "address";
+
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName);
+      command.setAutoCreateAddress(false);
+      command.setAddress(address);
+
+      server.createOrUpdateAddressInfo(new AddressInfo(new SimpleString(address)));
+
+      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionPassed(command);
+      assertNotNull(server.getAddressInfo(new SimpleString(address)));
+
+      Queue queue = server.locateQueue(new SimpleString(queueName));
+      assertEquals(-1, queue.getMaxConsumers());
+      assertEquals(false, queue.isDeleteOnNoConsumers());
+      assertTrue(server.queueQuery(new SimpleString(queueName)).isExists());
+   }
+
+   @Test
+   public void testCreateCoreQueueWithFilter() throws Exception {
+      String queueName = "queue2";
+      String filerString = "color='green'";
+
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName);
+      command.setFilter("color='green'");
+      command.setAutoCreateAddress(true);
+      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+
+      checkExecutionPassed(command);
+      Queue queue = server.locateQueue(new SimpleString(queueName));
+      assertNotNull(queue);
+      assertEquals(new SimpleString(filerString), queue.getFilter().getFilterString());
+   }
+
+   @Test
+   public void testCreateQueueAlreadyExists() throws Exception {
+      String queueName = "queue2";
+      String filerString = "color='green'";
+
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName);
+      command.setFilter("color='green'");
+      command.setAutoCreateAddress(true);
+      command.execute(new ActionContext());
+      command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionFailure(command, "AMQ119019: Queue already exists " + queueName);
+   }
+
+   @Test
+   public void testDeleteCoreQueue() throws Exception {
+      SimpleString queueName = new SimpleString("deleteQueue");
+
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName.toString());
+      command.setFilter("color='green'");
+      command.setAutoCreateAddress(true);
+      command.execute(new ActionContext());
+
+      DeleteQueue delete = new DeleteQueue();
+      delete.setName(queueName.toString());
+      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionPassed(delete);
+
+      assertFalse(server.queueQuery(queueName).isExists());
+   }
+
+   @Test
+   public void testDeleteQueueDoesNotExist() throws Exception {
+      SimpleString queueName = new SimpleString("deleteQueue");
+
+      DeleteQueue delete = new DeleteQueue();
+      delete.setName(queueName.toString());
+      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionFailure(delete, "AMQ119017: Queue " + queueName + " does not exist");
+
+      assertFalse(server.queueQuery(queueName).isExists());
+   }
+
+   @Test
+   public void testDeleteQueueWithConsumersFails() throws Exception {
+      SimpleString queueName = new SimpleString("deleteQueue");
+
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName.toString());
+      command.setFilter("color='green'");
+      command.setAutoCreateAddress(true);
+      command.execute(new ActionContext());
+
+      server.locateQueue(queueName).addConsumer(new DummyServerConsumer());
+
+      DeleteQueue delete = new DeleteQueue();
+      delete.setName(queueName.toString());
+      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionFailure(delete, "AMQ119025: Cannot delete queue " + queueName + " on binding deleteQueue");
+   }
+
+   @Test
+   public void testDeleteQueueWithConsumersFailsAndRemoveConsumersTrue() throws Exception {
+      SimpleString queueName = new SimpleString("deleteQueue");
+
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName.toString());
+      command.setFilter("color='green'");
+      command.setAutoCreateAddress(true);
+      command.execute(new ActionContext());
+
+      server.locateQueue(queueName).addConsumer(new DummyServerConsumer());
+
+      DeleteQueue delete = new DeleteQueue();
+      delete.setName(queueName.toString());
+      delete.setRemoveConsumers(true);
+      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+      checkExecutionPassed(command);
+   }
+
+   @Test
+   public void testAutoDeleteAddress() throws Exception {
+      SimpleString queueName = new SimpleString("deleteQueue");
+
+      CreateQueue command = new CreateQueue();
+      command.setName(queueName.toString());
+      command.setFilter("color='green'");
+      command.setAutoCreateAddress(true);
+      command.execute(new ActionContext());
+      assertNotNull(server.getAddressInfo(queueName));
+
+      server.locateQueue(queueName).addConsumer(new DummyServerConsumer());
+
+      DeleteQueue delete = new DeleteQueue();
+      delete.setName(queueName.toString());
+      delete.setRemoveConsumers(true);
+      delete.setAutoDeleteAddress(true);
+      delete.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
+
+      checkExecutionPassed(command);
+      assertNull(server.getAddressInfo(queueName));
+   }
+
+   private void checkExecutionPassed(AbstractAction command) throws Exception {
+      String fullMessage = output.toString();
+      System.out.println("output: " + fullMessage);
+      assertTrue(fullMessage, fullMessage.contains("successfully"));
+   }
+
+   private void checkExecutionFailure(AbstractAction command, String message) throws Exception {
+      String fullMessage = error.toString();
+      System.out.println("error: " + fullMessage);
+      assertTrue(fullMessage, fullMessage.contains(message));
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
index ad36598..2547bb6 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.tests.integration.management;
 
+import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
 import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
 import org.apache.activemq.artemis.api.core.management.Parameter;
 import org.apache.activemq.artemis.api.core.management.ResourceNames;
@@ -104,6 +105,14 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
          }
 
          @Override
+         public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
+                                   @Parameter(name = "routingType", desc = "The routing type for the address either 'MULTICAST' or 'ANYCAST'") String routingType,
+                                   @Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
+                                   @Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception {
+            proxy.invokeOperation("createAddress", name, routingType, defaultDeleteOnNoConsumers, defaultMaxConsumers);
+         }
+
+         @Override
          public void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception {
             proxy.invokeOperation("deleteAddress", name);
          }
@@ -122,6 +131,17 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
          }
 
          @Override
+         public void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
+                                 @Parameter(name = "name", desc = "Name of the queue") String name,
+                                 @Parameter(name = "filter", desc = "Filter of the queue") String filter,
+                                 @Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
+                                 @Parameter(name = "maxConsumers", desc = "The maximum number of consumers allowed on this queue at any one time") int maxConsumers,
+                                 @Parameter(name = "deleteOnNoConsumers", desc = "Delete this queue when the last consumer disconnects") boolean deleteOnNoConsumers,
+                                 @Parameter(name = "autoCreateAddress", desc = "Create an address with default values should a matching address not be found") boolean autoCreateAddress) throws Exception {
+
+         }
+
+         @Override
          public void deployQueue(final String address,
                                  final String name,
                                  final String filter,
@@ -145,6 +165,12 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
          }
 
          @Override
+         public void destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name,
+                                  @Parameter(name = "removeConsumers", desc = "Remove consumers of this queue") boolean removeConsumers,
+                                  boolean autoDeleteAddress) throws Exception {
+         }
+
+         @Override
          public void disableMessageCounters() throws Exception {
             proxy.invokeOperation("disableMessageCounters");
          }
@@ -632,6 +658,16 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
          }
 
          @Override
+         public String getAddressInfo(String address) throws ActiveMQAddressDoesNotExistException {
+            return null;
+         }
+
+         @Override
+         public String[] listBindingsForAddress(String address) throws Exception {
+            return new String[0];
+         }
+
+         @Override
          public void removeAddressSettings(String addressMatch) throws Exception {
             proxy.invokeOperation("removeAddressSettings", addressMatch);
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
index 00d220b..3095cb5 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/imported/MQTTTest.java
@@ -1628,7 +1628,7 @@ public class MQTTTest extends MQTTTestSupport {
          addressInfo.setDefaultMaxQueueConsumers(0);
          getServer().createOrUpdateAddressInfo(addressInfo);
 
-         getServer().createQueue(coreAddress, new SimpleString(clientId + "." + coreAddress), null, false, true, 0, false);
+         getServer().createQueue(coreAddress, new SimpleString(clientId + "." + coreAddress), null, false, true, 0, false, false);
 
          MQTT mqtt = createMQTTConnection();
          mqtt.setClientId(clientId);
@@ -1674,7 +1674,7 @@ public class MQTTTest extends MQTTTestSupport {
       try {
          String clientId = "testMqtt";
          SimpleString coreAddress = new SimpleString("foo.bar");
-         getServer().createQueue(coreAddress, new SimpleString(clientId + "." + coreAddress), null, false, true, -1, true);
+         getServer().createQueue(coreAddress, new SimpleString(clientId + "." + coreAddress), null, false, true, -1, true, false);
 
          Topic[] mqttSubscription = new Topic[]{new Topic("foo/bar", QoS.AT_LEAST_ONCE)};
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/328c0bbc/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java
index 35fe5cc..f2c844e 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakePostOffice.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.tests.unit.core.server.impl.fakes;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -81,6 +82,11 @@ public class FakePostOffice implements PostOffice {
    }
 
    @Override
+   public List<Queue> listQueuesForAddress(SimpleString address) throws Exception {
+      return null;
+   }
+
+   @Override
    public void addBinding(final Binding binding) throws Exception {
 
    }