Package org.apache.qpid.disttest.message

Examples of org.apache.qpid.disttest.message.Command


            @Override
            public void onMessage(Message message)
            {
                try
                {
                    Command command = JmsMessageAdaptor.messageToCommand(message);
                    LOGGER.debug("Test client received " + command);
                    commandList.add(command);
                    producer.send(JmsMessageAdaptor.commandToMessage(_session, new Response(CLIENT1, command.getType())));
                }
                catch(Exception e)
                {
                    listenerException.set(e);
                }
            }
        });

        _controller.runAllTests();
        assertCommandType(CommandType.CREATE_CONNECTION, commandList);
        assertCommandType(CommandType.START_TEST, commandList);
        assertCommandType(CommandType.TEAR_DOWN_TEST, commandList);

        _controller.stopAllRegisteredClients();
        assertCommandType(CommandType.STOP_CLIENT, commandList);
        assertNull("Unexpected exception occured", listenerException.get());
        Command command = commandList.poll(1l, TimeUnit.SECONDS);
        assertNull("Unexpected command is received", command);
    }
View Full Code Here


        assertNull("Unexpected command is received", command);
    }

    private void assertCommandType(CommandType expectedType, BlockingQueue<Command> commandList) throws InterruptedException
    {
        Command command = commandList.poll(1l, TimeUnit.SECONDS);
        assertNotNull("Command of type " + expectedType + " is not received", command);
        assertEquals("Unexpected command type", expectedType, command.getType());
    }
View Full Code Here

    private void sendRegistration(final String clientId) throws JMSException
    {
        final MessageProducer registrationProducer = _session.createProducer(_controllerQueue);

        final Command command = new RegisterClientCommand(clientId, _clientQueue.getQueueName());
        final Message registrationMessage = JmsMessageAdaptor.commandToMessage(_session, command);
        registrationProducer.send(registrationMessage);
        LOGGER.debug("sent registrationMessage: " + registrationMessage);
    }
View Full Code Here

        }
    }

    public void sendRegistrationMessage()
    {
        Command command;
        try
        {
            command = new RegisterClientCommand(_clientName, _instructionQueue.getQueueName());
        }
        catch (final JMSException e)
View Full Code Here

{
    public static <C extends Command> void assertCommandForClient(final List<CommandForClient> commandsForClients, final int index, final String expectedRegisteredClientName, final Class<C> expectedCommandClass)
    {
        final CommandForClient commandForClient = commandsForClients.get(index);
        assertEquals(expectedRegisteredClientName, commandForClient.getClientName());
        final Command command = commandForClient.getCommand();
        assertTrue("Command " + index + " is of class " + command.getClass() + " but expecting " + expectedCommandClass,
                expectedCommandClass.isAssignableFrom(command.getClass()));
    }
View Full Code Here

        {
            @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));
    }
View Full Code Here

        return (T) JmsMessageAdaptor.messageToCommand(message);
    }

    public void addNextResponse(Map<CommandType, Command> responses) throws JMSException
    {
        Command nextResponse = getNext();
        responses.put(nextResponse.getType(), nextResponse);
    }
View Full Code Here

                    try
                    {
                        String jmsMessageID = message.getJMSMessageID();
                        LOGGER.debug("Received message " + jmsMessageID);

                        final Command command = JmsMessageAdaptor.messageToCommand(message);
                        LOGGER.debug("Converted message " + jmsMessageID + " into command: " + command);

                        processCommandWithFirstSupportingListener(command);
                        LOGGER.debug("Finished processing command for message " + jmsMessageID);
                    }
View Full Code Here

        for (CommandForClient commandForClient : commandsForAllClients)
        {
            String configuredClientName = commandForClient.getClientName();
            String registeredClientName = _participatingClients.getRegisteredNameFromConfiguredName(configuredClientName);

            Command command = commandForClient.getCommand();

            LOGGER.debug("Sending command : {} ", command);

            sendCommandInternal(registeredClientName, command);
        }
View Full Code Here

    public void testProcessInstructionVisitsCommandAndResponds() throws Exception
    {
        // has to be declared to be of supertype Command otherwise Mockito verify()
        // refers to wrong method
        final Command command = new StopClientCommand();
        _client.processInstruction(command);

        verify(_visitor).visit(command);
        verify(_delegate).sendResponseMessage(isA(Response.class));
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.disttest.message.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.