Package org.codehaus.activemq.broker

Examples of org.codehaus.activemq.broker.BrokerClientStub


    protected BrokerClient client;
    protected Object semaphore = new Object();

    public void testSendingMessagesToVariousDestinations() throws Exception {

        BrokerClientStub queueA = new BrokerClientStub(semaphore);
        BrokerClientStub queueB = new BrokerClientStub(semaphore);
        BrokerClientStub queueC = new BrokerClientStub(semaphore);
        BrokerClientStub queueD = new BrokerClientStub(semaphore);

        addSubscription("FOO.BAR", null, queueA, isTopic());
        addSubscription("FOO.*", null, queueB, isTopic());
        addSubscription("BAR.*", "priority = 123", queueC, isTopic());
        addSubscription("BAR.*", "x = 'ABC'", queueD, isTopic());

        ActiveMQMessage message = dispatchMessage(broker, "FOO.BAR");
        queueA.waitForMessageToArrive();
        if (isTopic()) {
            assertEquals("queueA", true, queueA.flushMessages().contains(message));
            assertEquals("queueB", true, queueB.flushMessages().contains(message));
        }
        else {
            boolean atA = queueA.flushMessages().contains(message);
            boolean atB = queueB.flushMessages().contains(message);
            assertTrue("Sent to queueA or queueB. a: " + atA + " b: " + atB, (atA && !atB) || (!atA && atB));
        }
        assertEquals("queueC", false, queueC.flushMessages().contains(message));

        message = dispatchMessage(broker, "FOO.XYZ");
        queueB.waitForMessageToArrive();
        assertEquals("queueA", false, queueA.flushMessages().contains(message));
        assertEquals("queueC", false, queueC.flushMessages().contains(message));
        assertEquals("queueD", false, queueD.flushMessages().contains(message));
        assertEquals("queueB", true, queueB.flushMessages().contains(message));

        message = createMessage("BAR.XYZ");
        message.setIntProperty("priority", 123);
        broker.sendMessage(client, message);
        queueC.waitForMessageToArrive();

        assertEquals("queueA", false, queueA.flushMessages().contains(message));
        assertEquals("queueB", false, queueB.flushMessages().contains(message));
        assertEquals("queueC", true, queueC.flushMessages().contains(message));
        assertEquals("queueD", false, queueD.flushMessages().contains(message));

        message = createMessage("BAR.XYZ");
        message.setStringProperty("x", "ABC");
        broker.sendMessage(client, message);
        queueD.waitForMessageToArrive();

        assertEquals("queueA", false, queueA.flushMessages().contains(message));
        assertEquals("queueB", false, queueB.flushMessages().contains(message));
        assertEquals("queueC", false, queueC.flushMessages().contains(message));
        assertEquals("queueD", true, queueD.flushMessages().contains(message));
    }
View Full Code Here


    protected BrokerClient client;
    protected Object semaphore = new Object();

    public void testSendingMessagesToVariousDestinations() throws Exception {

        BrokerClientStub queueA = new BrokerClientStub(semaphore);
        BrokerClientStub queueB = new BrokerClientStub(semaphore);
        BrokerClientStub queueC = new BrokerClientStub(semaphore);
        BrokerClientStub queueD = new BrokerClientStub(semaphore);

        addSubscription("FOO.BAR", null, queueA, isTopic());
        addSubscription("FOO.*", null, queueB, isTopic());
        addSubscription("BAR.*", "priority = 123", queueC, isTopic());
        addSubscription("BAR.*", "x = 'ABC'", queueD, isTopic());

        ActiveMQMessage message = dispatchMessage(broker, "FOO.BAR");
        queueA.waitForMessageToArrive();
        if (isTopic()) {
            assertEquals("queueA", true, queueA.flushMessages().contains(message));
            assertEquals("queueB", true, queueB.flushMessages().contains(message));
        }
        else {
            boolean atA = queueA.flushMessages().contains(message);
            boolean atB = queueB.flushMessages().contains(message);
            assertTrue("Sent to queueA or queueB. a: " + atA + " b: " + atB, (atA && !atB) || (!atA && atB));
        }
        assertEquals("queueC", false, queueC.flushMessages().contains(message));

        message = dispatchMessage(broker, "FOO.XYZ");
        queueB.waitForMessageToArrive();
        assertEquals("queueA", false, queueA.flushMessages().contains(message));
        assertEquals("queueC", false, queueC.flushMessages().contains(message));
        assertEquals("queueD", false, queueD.flushMessages().contains(message));
        assertEquals("queueB", true, queueB.flushMessages().contains(message));

        message = createMessage("BAR.XYZ");
        message.setIntProperty("priority", 123);
        broker.sendMessage(client, message);
        queueC.waitForMessageToArrive();

        assertEquals("queueA", false, queueA.flushMessages().contains(message));
        assertEquals("queueB", false, queueB.flushMessages().contains(message));
        assertEquals("queueC", true, queueC.flushMessages().contains(message));
        assertEquals("queueD", false, queueD.flushMessages().contains(message));

        message = createMessage("BAR.XYZ");
        message.setStringProperty("x", "ABC");
        broker.sendMessage(client, message);
        queueD.waitForMessageToArrive();

        assertEquals("queueA", false, queueA.flushMessages().contains(message));
        assertEquals("queueB", false, queueB.flushMessages().contains(message));
        assertEquals("queueC", false, queueC.flushMessages().contains(message));
        assertEquals("queueD", true, queueD.flushMessages().contains(message));
    }
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.broker.BrokerClientStub

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.