Package org.activemq.jndi

Source Code of org.activemq.jndi.ActiveMQInitialContextFactoryTest

/**
*
* Copyright 2004 Protique Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/
package org.activemq.jndi;

import org.activemq.message.ActiveMQQueue;
import org.activemq.message.ActiveMQTopic;

import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;

/**
* @version $Revision: 1.1.1.1 $
*/
public class ActiveMQInitialContextFactoryTest extends JNDITestSupport {

    public void testConnectionFactoriesArePresent() throws NamingException {
        String lookupName = getConnectionFactoryLookupName();
        assertConnectionFactoryPresent(lookupName);
    }

    public void testDestinationsArePresent() throws NamingException {
        Object destinations = context.lookup("destinations");

        assertTrue("Should have created a destinations context but got: " + destinations, destinations instanceof Context);

        Context destContext = (Context) destinations;
        NamingEnumeration iter = destContext.listBindings("");
        while (iter.hasMore()) {
            Binding binding = (Binding) iter.next();
            System.out.println("Found key: " + binding.getName());
            assertBinding(binding);
        }
    }

    public void testDynamicallyGrowing() throws Exception {
        Object answer = context.lookup("dynamicQueues/FOO.BAR");
        assertTrue("Should have found a queue but found: " + answer, answer instanceof ActiveMQQueue);

        ActiveMQQueue queue = (ActiveMQQueue) answer;
        assertEquals("queue name", "FOO.BAR", queue.getPhysicalName());

         answer = context.lookup("dynamicTopics/A.B.C");
        assertTrue("Should have found a topic but found: " + answer, answer instanceof ActiveMQTopic);

        ActiveMQTopic topic = (ActiveMQTopic) answer;
        assertEquals("topic name", "A.B.C", topic.getPhysicalName());

    }


    protected String getConnectionFactoryLookupName() {
        return "ConnectionFactory";
    }
}
TOP

Related Classes of org.activemq.jndi.ActiveMQInitialContextFactoryTest

TOP
Copyright © 2018 www.massapi.com. 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.