use of org.apache.activemq.artemis.jndi.JNDIReferenceFactory in project activemq-artemis by apache.
the class ObjectFactoryTest method testDestination.
@Test(timeout = 1000)
public void testDestination() throws Exception {
// Create sample destination
ActiveMQDestination dest = (ActiveMQDestination) ActiveMQJMSClient.createQueue(RandomUtil.randomString());
// Create reference
Reference ref = JNDIReferenceFactory.createReference(dest.getClass().getName(), dest);
// Get object created based on reference
ActiveMQDestination temp;
JNDIReferenceFactory refFactory = new JNDIReferenceFactory();
temp = (ActiveMQDestination) refFactory.getObjectInstance(ref, null, null, null);
// Check settings
assertEquals(dest.getAddress(), temp.getAddress());
}
use of org.apache.activemq.artemis.jndi.JNDIReferenceFactory in project activemq-artemis by apache.
the class ObjectFactoryTest method testConnectionFactory.
@Test(timeout = 1000)
public void testConnectionFactory() throws Exception {
// Create sample connection factory
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://0");
String clientID = RandomUtil.randomString();
String user = RandomUtil.randomString();
String password = RandomUtil.randomString();
long clientFailureCheckPeriod = RandomUtil.randomPositiveLong();
long connectionTTL = RandomUtil.randomPositiveLong();
long callTimeout = RandomUtil.randomPositiveLong();
int minLargeMessageSize = RandomUtil.randomPositiveInt();
int consumerWindowSize = RandomUtil.randomPositiveInt();
int consumerMaxRate = RandomUtil.randomPositiveInt();
int confirmationWindowSize = RandomUtil.randomPositiveInt();
int producerMaxRate = RandomUtil.randomPositiveInt();
boolean blockOnAcknowledge = RandomUtil.randomBoolean();
boolean blockOnDurableSend = RandomUtil.randomBoolean();
boolean blockOnNonDurableSend = RandomUtil.randomBoolean();
boolean autoGroup = RandomUtil.randomBoolean();
boolean preAcknowledge = RandomUtil.randomBoolean();
String loadBalancingPolicyClassName = RandomUtil.randomString();
boolean useGlobalPools = RandomUtil.randomBoolean();
int scheduledThreadPoolMaxSize = RandomUtil.randomPositiveInt();
int threadPoolMaxSize = RandomUtil.randomPositiveInt();
long retryInterval = RandomUtil.randomPositiveLong();
double retryIntervalMultiplier = RandomUtil.randomDouble();
int reconnectAttempts = RandomUtil.randomPositiveInt();
factory.setClientID(clientID);
factory.setUser(user);
factory.setPassword(password);
factory.setClientFailureCheckPeriod(clientFailureCheckPeriod);
factory.setConnectionTTL(connectionTTL);
factory.setCallTimeout(callTimeout);
factory.setMinLargeMessageSize(minLargeMessageSize);
factory.setConsumerWindowSize(consumerWindowSize);
factory.setConsumerMaxRate(consumerMaxRate);
factory.setConfirmationWindowSize(confirmationWindowSize);
factory.setProducerMaxRate(producerMaxRate);
factory.setBlockOnAcknowledge(blockOnAcknowledge);
factory.setBlockOnDurableSend(blockOnDurableSend);
factory.setBlockOnNonDurableSend(blockOnNonDurableSend);
factory.setAutoGroup(autoGroup);
factory.setPreAcknowledge(preAcknowledge);
factory.setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
factory.setUseGlobalPools(useGlobalPools);
factory.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
factory.setThreadPoolMaxSize(threadPoolMaxSize);
factory.setRetryInterval(retryInterval);
factory.setRetryIntervalMultiplier(retryIntervalMultiplier);
factory.setReconnectAttempts(reconnectAttempts);
// Create reference
Reference ref = JNDIReferenceFactory.createReference(factory.getClass().getName(), factory);
// Get object created based on reference
ActiveMQConnectionFactory temp;
JNDIReferenceFactory refFactory = new JNDIReferenceFactory();
temp = (ActiveMQConnectionFactory) refFactory.getObjectInstance(ref, null, null, null);
// Check settings
Assert.assertEquals(clientID, temp.getClientID());
Assert.assertEquals(user, temp.getUser());
Assert.assertEquals(password, temp.getPassword());
Assert.assertEquals(clientFailureCheckPeriod, temp.getClientFailureCheckPeriod());
Assert.assertEquals(connectionTTL, temp.getConnectionTTL());
Assert.assertEquals(callTimeout, temp.getCallTimeout());
Assert.assertEquals(minLargeMessageSize, temp.getMinLargeMessageSize());
Assert.assertEquals(consumerWindowSize, temp.getConsumerWindowSize());
Assert.assertEquals(consumerMaxRate, temp.getConsumerMaxRate());
Assert.assertEquals(confirmationWindowSize, temp.getConfirmationWindowSize());
Assert.assertEquals(producerMaxRate, temp.getProducerMaxRate());
Assert.assertEquals(blockOnAcknowledge, temp.isBlockOnAcknowledge());
Assert.assertEquals(blockOnDurableSend, temp.isBlockOnDurableSend());
Assert.assertEquals(blockOnNonDurableSend, temp.isBlockOnNonDurableSend());
Assert.assertEquals(autoGroup, temp.isAutoGroup());
Assert.assertEquals(preAcknowledge, temp.isPreAcknowledge());
Assert.assertEquals(loadBalancingPolicyClassName, temp.getConnectionLoadBalancingPolicyClassName());
Assert.assertEquals(useGlobalPools, temp.isUseGlobalPools());
Assert.assertEquals(scheduledThreadPoolMaxSize, temp.getScheduledThreadPoolMaxSize());
Assert.assertEquals(threadPoolMaxSize, temp.getThreadPoolMaxSize());
Assert.assertEquals(retryInterval, temp.getRetryInterval());
Assert.assertEquals(retryIntervalMultiplier, temp.getRetryIntervalMultiplier(), 0.0001);
Assert.assertEquals(reconnectAttempts, temp.getReconnectAttempts());
}
Aggregations