1 18 package org.apache.activemq.jndi; 19 20 import org.apache.activemq.ActiveMQConnectionFactory; 21 import org.apache.activemq.CombinationTestSupport; 22 import org.apache.activemq.command.ActiveMQDestination; 23 import org.apache.activemq.command.ActiveMQQueue; 24 25 import javax.naming.Reference ; 26 27 public class ObjectFactoryTest extends CombinationTestSupport { 28 public void testConnectionFactory() throws Exception { 29 ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(); 31 factory.setDispatchAsync(true); 32 factory.setBrokerURL("vm://test"); 33 factory.setClientID("test"); 34 factory.setCopyMessageOnSend(false); 35 factory.setDisableTimeStampsByDefault(true); 36 factory.setObjectMessageSerializationDefered(true); 37 factory.setOptimizedMessageDispatch(false); 38 factory.setPassword("pass"); 39 factory.setUseAsyncSend(true); 40 factory.setUseCompression(true); 41 factory.setUseRetroactiveConsumer(true); 42 factory.setUserName("user"); 43 factory.getPrefetchPolicy().setQueuePrefetch(777); 44 factory.getRedeliveryPolicy().setMaximumRedeliveries(15); 45 factory.getRedeliveryPolicy().setBackOffMultiplier((short) 32); 46 47 48 Reference ref = JNDIReferenceFactory.createReference(factory.getClass().getName(), factory); 50 51 ActiveMQConnectionFactory temp; 53 JNDIReferenceFactory refFactory = new JNDIReferenceFactory(); 54 temp = (ActiveMQConnectionFactory)refFactory.getObjectInstance(ref, null, null, null); 55 56 assertEquals(factory.isDispatchAsync(), temp.isDispatchAsync()); 58 assertEquals(factory.getBrokerURL(), temp.getBrokerURL()); 59 assertEquals(factory.getClientID(), temp.getClientID()); 60 assertEquals(factory.isCopyMessageOnSend(), temp.isCopyMessageOnSend()); 61 assertEquals(factory.isDisableTimeStampsByDefault(), temp.isDisableTimeStampsByDefault()); 62 assertEquals(factory.isObjectMessageSerializationDefered(), temp.isObjectMessageSerializationDefered()); 63 assertEquals(factory.isOptimizedMessageDispatch(), temp.isOptimizedMessageDispatch()); 64 assertEquals(factory.getPassword(), temp.getPassword()); 65 assertEquals(factory.isUseAsyncSend(), temp.isUseAsyncSend()); 66 assertEquals(factory.isUseCompression(), temp.isUseCompression()); 67 assertEquals(factory.isUseRetroactiveConsumer(), temp.isUseRetroactiveConsumer()); 68 assertEquals(factory.getUserName(), temp.getUserName()); 69 assertEquals(factory.getPrefetchPolicy().getQueuePrefetch(), temp.getPrefetchPolicy().getQueuePrefetch()); 70 assertEquals(factory.getRedeliveryPolicy().getMaximumRedeliveries(), temp.getRedeliveryPolicy().getMaximumRedeliveries()); 71 assertEquals(factory.getRedeliveryPolicy().getBackOffMultiplier(), temp.getRedeliveryPolicy().getBackOffMultiplier()); 72 } 73 74 public void testDestination() throws Exception { 75 ActiveMQDestination dest = new ActiveMQQueue(); 77 dest.setPhysicalName("TEST.FOO"); 78 79 Reference ref = JNDIReferenceFactory.createReference(dest.getClass().getName(), dest); 81 82 ActiveMQDestination temp; 84 JNDIReferenceFactory refFactory = new JNDIReferenceFactory(); 85 temp = (ActiveMQDestination)refFactory.getObjectInstance(ref, null, null, null); 86 87 assertEquals(dest.getPhysicalName(), temp.getPhysicalName()); 89 } 90 } 91 | Popular Tags |