Search in sources :

Example 11 with ActionContext

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

the class QueueCommandTest method testAutoDeleteAddress.

@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.setMulticast(true);
    command.setAnycast(false);
    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));
}
Also used : DeleteQueue(org.apache.activemq.artemis.cli.commands.queue.DeleteQueue) PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CreateQueue(org.apache.activemq.artemis.cli.commands.queue.CreateQueue) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) Test(org.junit.Test)

Example 12 with ActionContext

use of org.apache.activemq.artemis.cli.commands.ActionContext 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 13 with ActionContext

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

the class QueueCommandTest method testCreateCoreQueueWithFilter.

@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.setMulticast(true);
    command.setAnycast(false);
    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());
}
Also used : PrintStream(java.io.PrintStream) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CreateQueue(org.apache.activemq.artemis.cli.commands.queue.CreateQueue) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) UpdateQueue(org.apache.activemq.artemis.cli.commands.queue.UpdateQueue) Queue(org.apache.activemq.artemis.core.server.Queue) DeleteQueue(org.apache.activemq.artemis.cli.commands.queue.DeleteQueue) CreateQueue(org.apache.activemq.artemis.cli.commands.queue.CreateQueue) Test(org.junit.Test)

Example 14 with ActionContext

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

the class AddressCommandTest method testFailUpdateAddressRoutingTypesWhenExistsQueues.

@Test
public void testFailUpdateAddressRoutingTypesWhenExistsQueues() throws Exception {
    final String addressName = "address";
    final SimpleString addressSimpleString = new SimpleString(addressName);
    final AddressInfo addressInfo = new AddressInfo(addressSimpleString, EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST));
    server.addAddressInfo(addressInfo);
    server.createQueue(addressSimpleString, RoutingType.MULTICAST, new SimpleString("queue1"), null, true, false);
    final UpdateAddress updateAddress = new UpdateAddress();
    updateAddress.setName(addressName);
    updateAddress.setAnycast(true);
    updateAddress.setMulticast(false);
    updateAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    final String expectedErrorMessage = MessageFormat.format("Can''t remove routing type {0}, queues exists for address: {1}. Please delete queues before removing this routing type.", RoutingType.MULTICAST, addressName);
    checkExecutionFailure(updateAddress, expectedErrorMessage);
}
Also used : PrintStream(java.io.PrintStream) UpdateAddress(org.apache.activemq.artemis.cli.commands.address.UpdateAddress) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 15 with ActionContext

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

the class AddressCommandTest method testShowAddressDoesNotExist.

@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");
}
Also used : PrintStream(java.io.PrintStream) ShowAddress(org.apache.activemq.artemis.cli.commands.address.ShowAddress) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) Test(org.junit.Test)

Aggregations

ActionContext (org.apache.activemq.artemis.cli.commands.ActionContext)27 Test (org.junit.Test)27 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)26 PrintStream (java.io.PrintStream)25 CreateQueue (org.apache.activemq.artemis.cli.commands.queue.CreateQueue)9 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)9 DeleteQueue (org.apache.activemq.artemis.cli.commands.queue.DeleteQueue)8 UpdateQueue (org.apache.activemq.artemis.cli.commands.queue.UpdateQueue)7 CreateAddress (org.apache.activemq.artemis.cli.commands.address.CreateAddress)4 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)3 DeleteAddress (org.apache.activemq.artemis.cli.commands.address.DeleteAddress)3 ShowAddress (org.apache.activemq.artemis.cli.commands.address.ShowAddress)3 UpdateAddress (org.apache.activemq.artemis.cli.commands.address.UpdateAddress)3 Queue (org.apache.activemq.artemis.core.server.Queue)3 QueueQueryResult (org.apache.activemq.artemis.core.server.QueueQueryResult)3 ParseArgumentsUnexpectedException (io.airlift.airline.ParseArgumentsUnexpectedException)1 File (java.io.File)1 InvalidOptionsError (org.apache.activemq.artemis.cli.commands.InvalidOptionsError)1 AddUser (org.apache.activemq.artemis.cli.commands.user.AddUser)1 ListUser (org.apache.activemq.artemis.cli.commands.user.ListUser)1