Search in sources :

Example 1 with Response

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();
}
Also used : Response(org.apache.qpid.disttest.message.Response)

Example 2 with Response

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));
}
Also used : HashMap(java.util.HashMap) Config(org.apache.qpid.disttest.controller.config.Config) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Response(org.apache.qpid.disttest.message.Response) StopClientCommand(org.apache.qpid.disttest.message.StopClientCommand) RegisterClientCommand(org.apache.qpid.disttest.message.RegisterClientCommand) Command(org.apache.qpid.disttest.message.Command) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ControllerJmsDelegate(org.apache.qpid.disttest.jms.ControllerJmsDelegate) Before(org.junit.Before)

Example 3 with Response

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());
    }
}
Also used : Response(org.apache.qpid.disttest.message.Response) DistributedTestException(org.apache.qpid.disttest.DistributedTestException) Test(org.junit.Test)

Example 4 with Response

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());
}
Also used : Response(org.apache.qpid.disttest.message.Response) ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) Test(org.junit.Test)

Aggregations

Response (org.apache.qpid.disttest.message.Response)4 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 DistributedTestException (org.apache.qpid.disttest.DistributedTestException)1 Config (org.apache.qpid.disttest.controller.config.Config)1 ControllerJmsDelegate (org.apache.qpid.disttest.jms.ControllerJmsDelegate)1 Command (org.apache.qpid.disttest.message.Command)1 ParticipantResult (org.apache.qpid.disttest.message.ParticipantResult)1 RegisterClientCommand (org.apache.qpid.disttest.message.RegisterClientCommand)1 StopClientCommand (org.apache.qpid.disttest.message.StopClientCommand)1 Before (org.junit.Before)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1