Search in sources :

Example 1 with UpdateQueue

use of org.apache.activemq.artemis.cli.commands.queue.UpdateQueue in project activemq-artemis by apache.

the class QueueCommandTest method testUpdateCoreQueue.

@Test
public void testUpdateCoreQueue() throws Exception {
    final String queueName = "updateQueue";
    final SimpleString queueNameString = new SimpleString(queueName);
    final String addressName = "address";
    final SimpleString addressSimpleString = new SimpleString(addressName);
    final int oldMaxConsumers = -1;
    final RoutingType oldRoutingType = RoutingType.MULTICAST;
    final boolean oldPurgeOnNoConsumers = false;
    final AddressInfo addressInfo = new AddressInfo(addressSimpleString, EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST));
    server.addAddressInfo(addressInfo);
    server.createQueue(addressSimpleString, oldRoutingType, queueNameString, null, true, false, oldMaxConsumers, oldPurgeOnNoConsumers, false);
    final int newMaxConsumers = 1;
    final RoutingType newRoutingType = RoutingType.ANYCAST;
    final boolean newPurgeOnNoConsumers = true;
    final UpdateQueue updateQueue = new UpdateQueue();
    updateQueue.setName(queueName);
    updateQueue.setPurgeOnNoConsumers(newPurgeOnNoConsumers);
    updateQueue.setAnycast(true);
    updateQueue.setMulticast(false);
    updateQueue.setMaxConsumers(newMaxConsumers);
    updateQueue.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionPassed(updateQueue);
    final QueueQueryResult queueQueryResult = server.queueQuery(queueNameString);
    assertEquals("maxConsumers", newMaxConsumers, queueQueryResult.getMaxConsumers());
    assertEquals("routingType", newRoutingType, queueQueryResult.getRoutingType());
    assertTrue("purgeOnNoConsumers", newPurgeOnNoConsumers == queueQueryResult.isPurgeOnNoConsumers());
}
Also used : PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueQueryResult(org.apache.activemq.artemis.core.server.QueueQueryResult) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) UpdateQueue(org.apache.activemq.artemis.cli.commands.queue.UpdateQueue) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 2 with UpdateQueue

use of org.apache.activemq.artemis.cli.commands.queue.UpdateQueue in project activemq-artemis by apache.

the class QueueCommandTest method testUpdateCoreQueueCannotChangeRoutingType.

@Test
public void testUpdateCoreQueueCannotChangeRoutingType() throws Exception {
    final String queueName = "updateQueue";
    final SimpleString queueNameString = new SimpleString(queueName);
    final String addressName = "address";
    final SimpleString addressSimpleString = new SimpleString(addressName);
    final int oldMaxConsumers = 10;
    final RoutingType oldRoutingType = RoutingType.MULTICAST;
    final boolean oldPurgeOnNoConsumers = false;
    final Set<RoutingType> supportedRoutingTypes = EnumSet.of(oldRoutingType);
    final AddressInfo addressInfo = new AddressInfo(addressSimpleString, EnumSet.copyOf(supportedRoutingTypes));
    server.addAddressInfo(addressInfo);
    server.createQueue(addressSimpleString, oldRoutingType, queueNameString, null, true, false, oldMaxConsumers, oldPurgeOnNoConsumers, false);
    final RoutingType newRoutingType = RoutingType.ANYCAST;
    final UpdateQueue updateQueue = new UpdateQueue();
    updateQueue.setName(queueName);
    updateQueue.setAnycast(true);
    updateQueue.setMulticast(false);
    updateQueue.setMaxConsumers(-1);
    updateQueue.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionFailure(updateQueue, "AMQ119211");
    final QueueQueryResult queueQueryResult = server.queueQuery(queueNameString);
    assertEquals("maxConsumers", oldMaxConsumers, queueQueryResult.getMaxConsumers());
    assertEquals("routingType", oldRoutingType, queueQueryResult.getRoutingType());
    assertTrue("purgeOnNoConsumers", oldPurgeOnNoConsumers == queueQueryResult.isPurgeOnNoConsumers());
}
Also used : PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueQueryResult(org.apache.activemq.artemis.core.server.QueueQueryResult) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) UpdateQueue(org.apache.activemq.artemis.cli.commands.queue.UpdateQueue) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 3 with UpdateQueue

use of org.apache.activemq.artemis.cli.commands.queue.UpdateQueue in project activemq-artemis by apache.

the class QueueCommandTest method testUpdateCoreQueueCannotLowerMaxConsumers.

@Test
public void testUpdateCoreQueueCannotLowerMaxConsumers() throws Exception {
    final String queueName = "updateQueue";
    final SimpleString queueNameString = new SimpleString(queueName);
    final String addressName = "address";
    final SimpleString addressSimpleString = new SimpleString(addressName);
    final int oldMaxConsumers = 2;
    final RoutingType oldRoutingType = RoutingType.MULTICAST;
    final boolean oldPurgeOnNoConsumers = false;
    final AddressInfo addressInfo = new AddressInfo(addressSimpleString, oldRoutingType);
    server.addAddressInfo(addressInfo);
    server.createQueue(addressSimpleString, oldRoutingType, queueNameString, null, true, false, oldMaxConsumers, oldPurgeOnNoConsumers, false);
    server.locateQueue(queueNameString).addConsumer(new DummyServerConsumer());
    server.locateQueue(queueNameString).addConsumer(new DummyServerConsumer());
    final int newMaxConsumers = 1;
    final UpdateQueue updateQueue = new UpdateQueue();
    updateQueue.setName(queueName);
    updateQueue.setMaxConsumers(newMaxConsumers);
    updateQueue.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionFailure(updateQueue, "AMQ119210");
    final QueueQueryResult queueQueryResult = server.queueQuery(queueNameString);
    assertEquals("maxConsumers", oldMaxConsumers, queueQueryResult.getMaxConsumers());
}
Also used : PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueQueryResult(org.apache.activemq.artemis.core.server.QueueQueryResult) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) UpdateQueue(org.apache.activemq.artemis.cli.commands.queue.UpdateQueue) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 4 with UpdateQueue

use of org.apache.activemq.artemis.cli.commands.queue.UpdateQueue in project activemq-artemis by apache.

the class QueueCommandTest method testUpdateCoreQueueDoesNotExist.

@Test
public void testUpdateCoreQueueDoesNotExist() throws Exception {
    SimpleString queueName = new SimpleString("updateQueue");
    UpdateQueue updateQueue = new UpdateQueue();
    updateQueue.setName(queueName.toString());
    updateQueue.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionFailure(updateQueue, "AMQ119017: Queue " + queueName + " does not exist");
    assertFalse(server.queueQuery(queueName).isExists());
}
Also used : PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) UpdateQueue(org.apache.activemq.artemis.cli.commands.queue.UpdateQueue) Test(org.junit.Test)

Aggregations

PrintStream (java.io.PrintStream)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 ActionContext (org.apache.activemq.artemis.cli.commands.ActionContext)4 UpdateQueue (org.apache.activemq.artemis.cli.commands.queue.UpdateQueue)4 Test (org.junit.Test)4 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)3 QueueQueryResult (org.apache.activemq.artemis.core.server.QueueQueryResult)3 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)3