Package org.fcrepo.client.messaging

Examples of org.fcrepo.client.messaging.JmsMessagingClient


    public void testMessagingClientTopic() throws Exception {

        String clientId = "0";
        MessagingClient messagingClient =
                new JmsMessagingClient(clientId, this, properties, false);

        messagingClient.start();
        sendMessage(TOPIC_NAME);
        checkMessage(clientId, TOPIC);
        messagingClient.stop(true);
    }
View Full Code Here


    public void testMessagingClientDurableTopic() throws Exception {

        String clientId = "1";
        MessagingClient messagingClient =
                new JmsMessagingClient(clientId, this, properties, true);

        // Establish that the client can start and receive messages
        messagingClient.start();
        sendMessage(TOPIC_NAME);
        checkMessage(clientId, TOPIC);
        messagingClient.stop(false);

        // Check to see if messages are received in a durable fashion
        sendMessage(TOPIC_NAME);
        messagingClient.start();
        checkMessage(clientId, TOPIC);
        messagingClient.stop(true);

        // Make sure durable subscriptions were closed
        sendMessage(TOPIC_NAME);
        messagingClient.start();
        checkNoMessages();
        messagingClient.stop(true);
    }
View Full Code Here

        String clientId = "2";
        String topicName = "additionalTopic";
        String topic = "org.fcrepo.test.additional";
        properties.setProperty("topic." + topicName, topic);
        MessagingClient messagingClient =
                new JmsMessagingClient(clientId, this, properties, true);

        messagingClient.start();
        sendMessage(TOPIC_NAME);
        checkMessage(clientId, TOPIC);
        sendMessage(topicName);
        checkMessage(clientId, topic);
        messagingClient.stop(true);
    }
View Full Code Here

    public void testMessagingClientQueue() throws Exception {

        String clientId = "3";
        MessagingClient messagingClient =
                new JmsMessagingClient(clientId, this, properties, false);

        messagingClient.start();
        sendMessage(QUEUE_NAME);
        checkMessage(clientId, QUEUE);
        messagingClient.stop(true);
    }
View Full Code Here

    }

    public void testInvalidProperties() throws Exception {
        // Null properties
        try {
            new JmsMessagingClient("4", this, null, false);
            fail("Creating a Messagingient with null properties " +
                 "should throw an exception");
        } catch(MessagingException me) {
            assertTrue(me.getMessage().contains("Connection properties may not be null"));
        }

        // Missing all properties
        properties = new Properties();

        try {
            new JmsMessagingClient("5", this, properties, false);
            fail("Creating a Messaging Client with no properties " +
                 "should throw an exception");
        } catch(MessagingException me) {
            assertTrue(me.getMessage().contains("Propery values"));
            assertTrue(me.getMessage().contains("must be provided"));
        }

        // Missing connection factory property
        properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                               "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        properties.setProperty(Context.PROVIDER_URL,
                               "vm://localhost?broker.useShutdownHook=false&broker.persistent=false");

        try {
            new JmsMessagingClient("6", this, properties, false);
            fail("Creating a Messaging Client with no connection factory " +
                 "property should throw an exception");
        } catch(MessagingException me) {
            assertTrue(me.getMessage().contains("Propery values"));
            assertTrue(me.getMessage().contains("must be provided"));
        }

        // Missing provider url property
        properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                               "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        properties.setProperty(JMSManager.CONNECTION_FACTORY_NAME,
                               "ConnectionFactory");

        try {
            new JmsMessagingClient("7", this, properties, false);
            fail("Creating a Messaging Client with no provider url " +
                 "property should throw an exception");
        } catch(MessagingException me) {
            assertTrue(me.getMessage().contains("Propery values"));
            assertTrue(me.getMessage().contains("must be provided"));
        }

        // Missing initial context factory property
        properties = new Properties();
        properties.setProperty(Context.PROVIDER_URL,
                               "vm://localhost?broker.useShutdownHook=false&broker.persistent=false");
        properties.setProperty(JMSManager.CONNECTION_FACTORY_NAME,
                               "ConnectionFactory");

        try {
            new JmsMessagingClient("8", this, properties, false);
            fail("Creating a Messaging Client with no initial context factory " +
                 "property should throw an exception");
        } catch(MessagingException me) {
            assertTrue(me.getMessage().contains("Propery values"));
            assertTrue(me.getMessage().contains("must be provided"));
View Full Code Here

        String clientId = "9";
        // Selector to include test message
        String messageSelector = propertyName + " LIKE 'test%'";
        MessagingClient messagingClient =
                new JmsMessagingClient(clientId, this, properties,
                                       messageSelector, false);
        messagingClient.start();
        sendMessage(TOPIC_NAME);
        checkMessage(clientId, TOPIC);
        messagingClient.stop(true);

        clientId = "10";
        // Selector to omit test message
        messageSelector = propertyName + " LIKE 'testing%'";
        messagingClient =
                new JmsMessagingClient(clientId, this, properties,
                                       messageSelector, false);
        messagingClient.start();
        sendMessage(TOPIC_NAME);
        checkNoMessages();
        messagingClient.stop(true);
    }
View Full Code Here

        messagingClient.stop(true);
    }

    public void testAsynchronousStart() throws Exception {
        String clientId = "11";
        JmsMessagingClient messagingClient =
                new JmsMessagingClient(clientId, this, properties, false);

        messagingClient.start(false);
        long startTime = System.currentTimeMillis();
        long maxWaitTime = 60000;
        while(!messagingClient.isConnected()) {
            // Don't wait forever
            if(System.currentTimeMillis() - startTime > maxWaitTime) {
                fail("Messaging client did not connect in " +
                     maxWaitTime/1000 + " seconds.");
            }
        }
        sendMessage(TOPIC_NAME);
        checkMessage(clientId, TOPIC);
        messagingClient.stop(true);
    }
View Full Code Here

TOP

Related Classes of org.fcrepo.client.messaging.JmsMessagingClient

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.