use of org.apache.activemq.artemis.cli.commands.ActionContext in project activemq-artemis by apache.
the class AddressCommandTest method testShowAddress.
@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());
}
use of org.apache.activemq.artemis.cli.commands.ActionContext in project activemq-artemis by apache.
the class AddressCommandTest method testUpdateAddressRoutingTypes.
@Test
public void testUpdateAddressRoutingTypes() throws Exception {
final String addressName = "address";
final SimpleString address = new SimpleString(addressName);
server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST));
final UpdateAddress updateAddress = new UpdateAddress();
updateAddress.setName(addressName);
updateAddress.setAnycast(true);
updateAddress.setMulticast(true);
updateAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
checkExecutionPassed(updateAddress);
final AddressInfo addressInfo = server.getAddressInfo(address);
assertNotNull(addressInfo);
assertEquals(EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST), addressInfo.getRoutingTypes());
}
use of org.apache.activemq.artemis.cli.commands.ActionContext 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());
}
use of org.apache.activemq.artemis.cli.commands.ActionContext 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());
}
use of org.apache.activemq.artemis.cli.commands.ActionContext 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());
}
Aggregations