1 18 package org.apache.activemq.jndi; 19 20 import org.apache.activemq.command.ActiveMQQueue; 21 import org.apache.activemq.command.ActiveMQTopic; 22 23 24 import javax.naming.*; 25 26 29 public class ActiveMQInitialContextFactoryTest extends JNDITestSupport { 30 31 public void testConnectionFactoriesArePresent() throws NamingException { 32 String lookupName = getConnectionFactoryLookupName(); 33 assertConnectionFactoryPresent(lookupName); 34 } 35 36 public void testDestinationsArePresent() throws NamingException { 37 38 40 InitialContext context = new InitialContext(); 41 42 assertTrue("Created context", context != null); 44 45 Object topicDestination = context.lookup("MyTopic"); 46 47 assertTrue("Should have found a topic but found: " + topicDestination, topicDestination instanceof ActiveMQTopic); 49 50 Object queueDestination = context.lookup("MyQueue"); 51 52 assertTrue("Should have found a queue but found: " + queueDestination,queueDestination instanceof ActiveMQQueue); 54 55 } 56 57 public void testDynamicallyGrowing() throws Exception { 58 Object answer = context.lookup("dynamicQueues/FOO.BAR"); 59 assertTrue("Should have found a queue but found: " + answer, answer instanceof ActiveMQQueue); 60 61 ActiveMQQueue queue = (ActiveMQQueue) answer; 62 assertEquals("queue name", "FOO.BAR", queue.getPhysicalName()); 63 64 answer = context.lookup("dynamicTopics/A.B.C"); 65 assertTrue("Should have found a topic but found: " + answer, answer instanceof ActiveMQTopic); 66 67 ActiveMQTopic topic = (ActiveMQTopic) answer; 68 assertEquals("topic name", "A.B.C", topic.getPhysicalName()); 69 70 } 71 72 73 protected String getConnectionFactoryLookupName() { 74 return "ConnectionFactory"; 75 } 76 } 77 | Popular Tags |