Search in sources :

Example 1 with CreateQueue

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

the class QueueCommandTest method testCreateCoreQueueShowsErrorWhenAddressDoesNotExists.

@Test
public void testCreateCoreQueueShowsErrorWhenAddressDoesNotExists() throws Exception {
    String queueName = "queue1";
    CreateQueue command = new CreateQueue();
    command.setName(queueName);
    command.setMulticast(true);
    command.setAnycast(false);
    command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionFailure(command, "AMQ119203");
    assertFalse(server.queueQuery(new SimpleString(queueName)).isExists());
}
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) Test(org.junit.Test)

Example 2 with CreateQueue

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

the class QueueCommandTest method testCreateCoreQueueAddressExists.

@Test
public void testCreateCoreQueueAddressExists() throws Exception {
    String queueName = "queue";
    String address = "address";
    CreateQueue command = new CreateQueue();
    command.setName(queueName);
    command.setAutoCreateAddress(false);
    command.setMulticast(true);
    command.setAnycast(false);
    command.setAddress(address);
    server.addOrUpdateAddressInfo(new AddressInfo(new SimpleString(address), RoutingType.MULTICAST));
    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.isPurgeOnNoConsumers());
    assertTrue(server.queueQuery(new SimpleString(queueName)).isExists());
}
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) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 3 with CreateQueue

use of org.apache.activemq.artemis.cli.commands.queue.CreateQueue 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 4 with CreateQueue

use of org.apache.activemq.artemis.cli.commands.queue.CreateQueue 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 5 with CreateQueue

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

the class QueueCommandTest method testDeleteQueueWithConsumersFails.

@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.setMulticast(true);
    command.setAnycast(false);
    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");
}
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)

Aggregations

PrintStream (java.io.PrintStream)9 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)9 ActionContext (org.apache.activemq.artemis.cli.commands.ActionContext)9 CreateQueue (org.apache.activemq.artemis.cli.commands.queue.CreateQueue)9 Test (org.junit.Test)9 DeleteQueue (org.apache.activemq.artemis.cli.commands.queue.DeleteQueue)7 UpdateQueue (org.apache.activemq.artemis.cli.commands.queue.UpdateQueue)3 Queue (org.apache.activemq.artemis.core.server.Queue)3 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)1