use of org.apache.qpid.disttest.message.Command in project qpid-broker-j by apache.
the class ControllerJmsDelegate method start.
public void start() {
try {
createControllerQueue();
final MessageConsumer consumer = _controllerQueueListenerSession.createConsumer(_controllerQueue);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(final Message message) {
try {
String jmsMessageID = message.getJMSMessageID();
LOGGER.debug("Received message ID {}", jmsMessageID);
final Command command = JmsMessageAdaptor.messageToCommand(message);
LOGGER.debug("Converted message ID {} into command {}", jmsMessageID, command);
processCommandWithFirstSupportingListener(command);
LOGGER.debug("Finished processing command for message ID", jmsMessageID);
} catch (Exception t) {
LOGGER.error("Can't handle JMS message", t);
}
}
});
} catch (final JMSException e) {
throw new DistributedTestException(e);
}
}
use of org.apache.qpid.disttest.message.Command in project qpid-broker-j by apache.
the class ClientConfig method createCommands.
public List<CommandForClient> createCommands() {
List<CommandForClient> commandsForClient = new ArrayList<CommandForClient>();
for (MessageProviderConfig messageProvider : _messageProviders) {
Command command = messageProvider.createCommand();
commandsForClient.add(new CommandForClient(_name, command));
}
for (ConnectionConfig connection : _connections) {
List<Command> commands = connection.createCommands();
for (Command command : commands) {
commandsForClient.add(new CommandForClient(_name, command));
}
}
return commandsForClient;
}
use of org.apache.qpid.disttest.message.Command in project qpid-broker-j by apache.
the class ControllerTest method setUp.
@Before
public void setUp() throws Exception {
_respondingJmsDelegate = mock(ControllerJmsDelegate.class);
final Map<String, String> controllerOptions = new HashMap<>();
controllerOptions.put(ControllerRunner.REGISTRATION_TIMEOUT, String.valueOf(REGISTRATION_TIMEOUT));
controllerOptions.put(ControllerRunner.COMMAND_RESPONSE_TIMEOUT, String.valueOf(COMMAND_RESPONSE_TIMEOUT));
_controller = new Controller(_respondingJmsDelegate, controllerOptions);
_clientRegistry = mock(ClientRegistry.class);
Config configWithOneClient = createMockConfig(1);
_controller.setConfig(configWithOneClient);
_controller.setClientRegistry(_clientRegistry);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
final String clientName = (String) invocation.getArguments()[0];
final Command command = (Command) invocation.getArguments()[1];
_controller.processStopClientResponse(new Response(clientName, command.getType()));
return null;
}
}).when(_respondingJmsDelegate).sendCommandToClient(anyString(), isA(Command.class));
}
use of org.apache.qpid.disttest.message.Command in project qpid-broker-j by apache.
the class ConnectionConfigTest method createConnectionConfigWithChildCommands.
private ConnectionConfig createConnectionConfigWithChildCommands() {
SessionConfig sessionConfig = mock(SessionConfig.class);
NoOpCommand cmd1 = mock(NoOpCommand.class);
NoOpCommand cmd2 = mock(NoOpCommand.class);
List<Command> commands = Arrays.asList((Command) cmd1, (Command) cmd2);
when(sessionConfig.createCommands(CONNECTION_NAME)).thenReturn(commands);
return new ConnectionConfig(CONNECTION_NAME, CONNECTION_FACTORY_NAME, sessionConfig);
}
use of org.apache.qpid.disttest.message.Command in project qpid-broker-j by apache.
the class ConnectionConfigTest method testCreateCommandsForConnectionAndChildren.
@Test
public void testCreateCommandsForConnectionAndChildren() {
ConnectionConfig connectionConfig = createConnectionConfigWithChildCommands();
List<Command> commands = connectionConfig.createCommands();
assertEquals((long) 3, (long) commands.size());
assertCommandEquals(commands, 0, CreateConnectionCommand.class);
assertCommandEquals(commands, 1, NoOpCommand.class);
assertCommandEquals(commands, 2, NoOpCommand.class);
CreateConnectionCommand createConnectionCommand = getCommand(commands, 0);
assertEquals(CONNECTION_NAME, createConnectionCommand.getConnectionName());
assertEquals(CONNECTION_FACTORY_NAME, createConnectionCommand.getConnectionFactoryName());
}
Aggregations