Search in sources :

Example 1 with ActionContext

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

the class AddressCommandTest method testCreateAddressAlreadyExistsShowsError.

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

Example 2 with ActionContext

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

the class AddressCommandTest method testDeleteAddressDoesNotExistsShowsError.

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

Example 3 with ActionContext

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

the class AddressCommandTest method testDeleteAddress.

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

Example 4 with ActionContext

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

the class AddressCommandTest method testShowAddressBindings.

@Test
public void testShowAddressBindings() throws Exception {
    // Create bindings
    SimpleString address = new SimpleString("address");
    server.addAddressInfo(new AddressInfo(address, RoutingType.MULTICAST));
    server.createQueue(address, RoutingType.MULTICAST, new SimpleString("queue1"), null, true, false);
    server.createQueue(address, RoutingType.MULTICAST, new SimpleString("queue2"), null, true, false);
    server.createQueue(address, RoutingType.MULTICAST, 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());
}
Also used : PrintStream(java.io.PrintStream) ShowAddress(org.apache.activemq.artemis.cli.commands.address.ShowAddress) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) 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 5 with ActionContext

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

the class AddressCommandTest method testFailUpdateAddressDoesNotExist.

@Test
public void testFailUpdateAddressDoesNotExist() throws Exception {
    final String addressName = "address";
    final UpdateAddress updateAddress = new UpdateAddress();
    updateAddress.setName(addressName);
    updateAddress.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
    checkExecutionFailure(updateAddress, "Address Does Not Exist");
}
Also used : PrintStream(java.io.PrintStream) UpdateAddress(org.apache.activemq.artemis.cli.commands.address.UpdateAddress) 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