Package org.apache.qpid.test.utils

Examples of org.apache.qpid.test.utils.JMXTestUtils


     * by monitoring message count while sending new messages to the topic and then
     * consuming them.
     */
    public void testSelectorDurability() throws Exception
    {
        JMXTestUtils jmxUtils = null;
        try
        {
            jmxUtils = new JMXTestUtils(this, "guest", "guest");
            jmxUtils.open();
        }
        catch (Exception e)
        {
            fail("Unable to establish JMX connection, test cannot proceed");
        }

        try
        {
            ManagedQueue dursubQueue = jmxUtils.getManagedQueue("clientid" + ":" + SELECTOR_SUB_NAME);
            assertEquals("DurableSubscription backing queue should have 1 message on it initially",
                          new Integer(1), dursubQueue.getMessageCount());

            // Create a connection and start it
            TopicConnection connection = (TopicConnection) getConnection();
            connection.start();

            // Send messages which don't match and do match the selector, checking message count
            TopicSession pubSession = connection.createTopicSession(true, Session.SESSION_TRANSACTED);
            Topic topic = pubSession.createTopic(SELECTOR_TOPIC_NAME);
            TopicPublisher publisher = pubSession.createPublisher(topic);

            publishMessages(pubSession, publisher, topic, DeliveryMode.PERSISTENT, 1*1024, 1, "false");
            pubSession.commit();
            assertEquals("DurableSubscription backing queue should still have 1 message on it",
                         Integer.valueOf(1), dursubQueue.getMessageCount());

            publishMessages(pubSession, publisher, topic, DeliveryMode.PERSISTENT, 1*1024, 1, "true");
            pubSession.commit();
            assertEquals("DurableSubscription backing queue should now have 2 messages on it",
                         Integer.valueOf(2), dursubQueue.getMessageCount());

            TopicSubscriber durSub = pubSession.createDurableSubscriber(topic, SELECTOR_SUB_NAME,"testprop='true'", false);
            Message m = durSub.receive(2000);
            assertNotNull("Failed to receive an expected message", m);
            m = durSub.receive(2000);
            assertNotNull("Failed to receive an expected message", m);
            pubSession.commit();

            pubSession.close();
        }
        finally
        {
            jmxUtils.close();
        }
    }
View Full Code Here


     * Test that the DurableSubscription without selector was successfully
     * transfered to the new store, and functions as expected with continued use.
     */
    public void testDurableSubscriptionWithoutSelector() throws Exception
    {
        JMXTestUtils jmxUtils = null;
        try
        {
            jmxUtils = new JMXTestUtils(this, "guest", "guest");
            jmxUtils.open();
        }
        catch (Exception e)
        {
            fail("Unable to establish JMX connection, test cannot proceed");
        }

        try
        {
            ManagedQueue dursubQueue = jmxUtils.getManagedQueue("clientid" + ":" + SUB_NAME);
            assertEquals("DurableSubscription backing queue should have 1 message on it initially",
                          new Integer(1), dursubQueue.getMessageCount());

            // Create a connection and start it
            TopicConnection connection = (TopicConnection) getConnection();
            connection.start();

            // Send new message matching the topic, checking message count
            TopicSession session = connection.createTopicSession(true, Session.SESSION_TRANSACTED);
            Topic topic = session.createTopic(TOPIC_NAME);
            TopicPublisher publisher = session.createPublisher(topic);

            publishMessages(session, publisher, topic, DeliveryMode.PERSISTENT, 1*1024, 1, "indifferent");
            session.commit();
            assertEquals("DurableSubscription backing queue should now have 2 messages on it",
                        Integer.valueOf(2), dursubQueue.getMessageCount());

            TopicSubscriber durSub = session.createDurableSubscriber(topic, SUB_NAME);
            Message m = durSub.receive(2000);
            assertNotNull("Failed to receive an expected message", m);
            m = durSub.receive(2000);
            assertNotNull("Failed to receive an expected message", m);

            session.commit();
            session.close();
        }
        finally
        {
            jmxUtils.close();
        }
    }
View Full Code Here

     * detected and set as being exclusive during the upgrade process, and that the
     * regular queue was not.
     */
    public void testQueueExclusivity() throws Exception
    {
        JMXTestUtils jmxUtils = null;
        try
        {
            jmxUtils = new JMXTestUtils(this, "guest", "guest");
            jmxUtils.open();
        }
        catch (Exception e)
        {
            fail("Unable to establish JMX connection, test cannot proceed");
        }

        try
        {
            ManagedQueue queue = jmxUtils.getManagedQueue(QUEUE_NAME);
            assertFalse("Queue should not have been marked as Exclusive during upgrade", queue.isExclusive());

            ManagedQueue dursubQueue = jmxUtils.getManagedQueue("clientid" + ":" + SUB_NAME);
            assertTrue("DurableSubscription backing queue should have been marked as Exclusive during upgrade", dursubQueue.isExclusive());
        }
        finally
        {
            jmxUtils.close();
        }
    }
View Full Code Here

     * DLQs are NOT enabled at the virtualhost level, we are testing recovery of the arguments
     * that turned it on for this specific queue.
     */
    public void testRecoveryOfQueueWithDLQ() throws Exception
    {
        JMXTestUtils jmxUtils = null;
        try
        {
            jmxUtils = new JMXTestUtils(this, "guest", "guest");
            jmxUtils.open();
        }
        catch (Exception e)
        {
            fail("Unable to establish JMX connection, test cannot proceed");
        }

        try
        {
            //verify the DLE exchange exists, has the expected type, and a single binding for the DLQ
            ManagedExchange exchange = jmxUtils.getManagedExchange(QUEUE_WITH_DLQ_NAME + "_DLE");
            assertEquals("Wrong exchange type", "fanout", exchange.getExchangeType());
            TabularDataSupport bindings = (TabularDataSupport) exchange.bindings();
            assertEquals(1, bindings.size());
            for(Object o : bindings.values())
            {
                CompositeData binding = (CompositeData) o;

                String bindingKey = (String) binding.get(ManagedExchange.BINDING_KEY);
                String[] queueNames = (String[]) binding.get(ManagedExchange.QUEUE_NAMES);

                //Because its a fanout exchange, we just return a single '*' key with all bound queues
                assertEquals("unexpected binding key", "*", bindingKey);
                assertEquals("unexpected number of queues bound", 1, queueNames.length);
                assertEquals("unexpected queue name", QUEUE_WITH_DLQ_NAME + "_DLQ", queueNames[0]);
            }

            //verify the queue exists, has the expected alternate exchange and max delivery count
            ManagedQueue queue = jmxUtils.getManagedQueue(QUEUE_WITH_DLQ_NAME);
            assertEquals("Queue does not have the expected AlternateExchange", QUEUE_WITH_DLQ_NAME + "_DLE", queue.getAlternateExchange());
            assertEquals("Unexpected maximum delivery count", Integer.valueOf(2), queue.getMaximumDeliveryCount());

            ManagedQueue dlQqueue = jmxUtils.getManagedQueue(QUEUE_WITH_DLQ_NAME + "_DLQ");
            assertNull("Queue should not have an AlternateExchange", dlQqueue.getAlternateExchange());
            assertEquals("Unexpected maximum delivery count", Integer.valueOf(0), dlQqueue.getMaximumDeliveryCount());

            String dlqDlqObjectNameString = jmxUtils.getQueueObjectNameString("test", QUEUE_WITH_DLQ_NAME + "_DLQ" + "_DLQ");
            assertFalse("a DLQ should not exist for the DLQ itself", jmxUtils.doesManagedObjectExist(dlqDlqObjectNameString));
        }
        finally
        {
            jmxUtils.close();
        }
    }
View Full Code Here

    public void setUp() throws Exception
    {
        getBrokerConfiguration().addJmxManagementConfiguration();

        _jmxUtils = new JMXTestUtils(this);

        super.setUp();
        _jmxUtils.open();
        _managedBroker = _jmxUtils.getManagedBroker(VIRTUAL_HOST);
    }
View Full Code Here

        getBrokerConfiguration().addJmxManagementConfiguration();

        // to test exchange selectors the publishing of unroutable messages should be allowed
        getBrokerConfiguration().setBrokerAttribute(Broker.CONNECTION_CLOSE_WHEN_NO_ROUTE, false);

        _jmxUtils = new JMXTestUtils(this);

        super.setUp();

        _jmxUtils.open();
View Full Code Here

    {
        if (isJavaBroker())
        {
            startBrokerAndCreateMonitor(true, false);

            final JMXTestUtils jmxUtils = new JMXTestUtils(this);
            List<String> openResults = null;
            List<String> closeResults = null;
            try
            {
                jmxUtils.open();
                openResults = waitAndFindMatches("MNG-1007");
            }
            finally
            {
                if (jmxUtils != null)
                {
                    jmxUtils.close();
                    closeResults = waitAndFindMatches("MNG-1008");
                }
            }

            assertNotNull("Management Open results null", openResults.size());
View Full Code Here

    public void setUp() throws Exception
    {
        getBrokerConfiguration().addJmxManagementConfiguration();

        _jmxUtils = new JMXTestUtils(this);

        super.setUp();
        _sourceQueueName = getTestQueueName() + "_src";
        _destinationQueueName = getTestQueueName() + "_dest";
View Full Code Here

     * @throws Exception
     */
    public void testMovedToQueue() throws Exception
    {
        // Setup JMXUtils
        JMXTestUtils jmxUtils = new JMXTestUtils(this);
        jmxUtils.setUp();
        // Open the JMX Connection
        jmxUtils.open();
        try
        {

            Queue queue = _session.createQueue(getTestQueueName());

            _session.createConsumer(queue).close();

            sendMessage(_session, queue, 1);

            Topic topic = _session.createTopic(getTestQueueName() + "Topic");

            MessageConsumer consumer = _session.createConsumer(topic);

            // Use Management to move message.

            ManagedQueue managedQueue = jmxUtils.
                    getManagedObject(ManagedQueue.class,
                                     jmxUtils.getQueueObjectName(getConnectionFactory().getVirtualPath().substring(1),
                                                                 getTestQueueName()));

            // Find the first message on the queue
            TabularData data = managedQueue.viewMessages(1L, 2L);

            Iterator values = data.values().iterator();
            assertTrue("No Messages found via JMX", values.hasNext());

            // Get its message ID
            Long msgID = (Long) ((CompositeDataSupport) values.next()).get("AMQ MessageId");

            // Start the connection and consume message that has been moved to the
            // queue
            _connection.start();

            Message message = consumer.receive(1000);

            //Validate we don't have a message on the queue before we start
            assertNull("Message should be null", message);

            // Move it to from the topic to the queue
            managedQueue.moveMessages(msgID, msgID, ((AMQTopic) topic).getQueueName());

            // Retrieve the newly moved message
            message = consumer.receive(1000);

            assertNotNull("Message should not be null", message);

            Destination destination = message.getJMSDestination();

            assertNotNull("JMSDestination should not be null", destination);

            assertEquals("Incorrect Destination type", queue.getClass(), destination.getClass());

        }
        finally
        {
            jmxUtils.close();
        }

    }
View Full Code Here

    private JMXTestUtils _jmxUtils;

    @Override
    public void setUp() throws Exception
    {
        _jmxUtils = new JMXTestUtils(this);
        _jmxUtils.setUp();

        super.setUp();
        _jmxUtils.open();
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.test.utils.JMXTestUtils

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.