use of org.apache.qpid.disttest.message.Response in project qpid-broker-j by apache.
the class Client method stop.
public void stop() {
_clientJmsDelegate.setConnectionLostListener(null);
_clientJmsDelegate.sendResponseMessage(new Response(_clientJmsDelegate.getClientName(), CommandType.STOP_CLIENT, null));
transitToStopped();
}
use of org.apache.qpid.disttest.message.Response 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.Response in project qpid-broker-j by apache.
the class OrdinaryTestRunnerTest method testClientRespondingWithErrorResponseStopsTest.
@Test
public void testClientRespondingWithErrorResponseStopsTest() {
Response errorResponse = new Response(CLIENT1_REGISTERED_NAME, CommandType.CREATE_CONNECTION, "error occurred");
configureMockToReturnResponseTo(CreateConnectionCommand.class, errorResponse, null);
_testInstance = createTestInstanceWithConnection();
_testRunner = new OrdinaryTestRunner(_participatingClients, _testInstance, _respondingJmsDelegate, COMMAND_RESPONSE_TIMEOUT, TEST_RESULT_TIMEOUT);
try {
_testRunner.run();
fail("Exception not thrown");
} catch (DistributedTestException e) {
assertEquals("One or more clients were unable to successfully process commands. " + "1 command(s) generated an error response.", e.getMessage());
}
}
use of org.apache.qpid.disttest.message.Response in project qpid-broker-j by apache.
the class OrdinaryTestRunnerTest method testSuccessfulTestRunReturnsTestResult.
@Test
public void testSuccessfulTestRunReturnsTestResult() {
ParticipantResult participantResult = new ParticipantResult(PARTICIPANT_NAME);
configureMockToReturnResponseTo(CreateConnectionCommand.class, new Response(CLIENT1_REGISTERED_NAME, CommandType.CREATE_CONNECTION), null);
configureMockToReturnResponseTo(StartTestCommand.class, new Response(CLIENT1_REGISTERED_NAME, CommandType.START_TEST), null);
configureMockToReturnResponseTo(StartDataCollectionCommand.class, new Response(CLIENT1_REGISTERED_NAME, CommandType.START_DATA_COLLECTION), participantResult);
configureMockToReturnResponseTo(TearDownTestCommand.class, new Response(CLIENT1_REGISTERED_NAME, CommandType.TEAR_DOWN_TEST), null);
_testInstance = createTestInstanceWithConnection();
_testRunner = new OrdinaryTestRunner(_participatingClients, _testInstance, _respondingJmsDelegate, COMMAND_RESPONSE_TIMEOUT, TEST_RESULT_TIMEOUT);
TestResult testResult = _testRunner.run();
assertNotNull(testResult);
assertEquals("Unexpected number of participant results", (long) 1, (long) testResult.getParticipantResults().size());
}
Aggregations