Search in sources :

Example 1 with JNDIReferenceFactory

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());
}
Also used : Reference(javax.naming.Reference) JNDIReferenceFactory(org.apache.activemq.artemis.jndi.JNDIReferenceFactory) ActiveMQDestination(org.apache.activemq.artemis.jms.client.ActiveMQDestination) Test(org.junit.Test)

Example 2 with JNDIReferenceFactory

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());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Reference(javax.naming.Reference) JNDIReferenceFactory(org.apache.activemq.artemis.jndi.JNDIReferenceFactory) Test(org.junit.Test)

Aggregations

Reference (javax.naming.Reference)2 JNDIReferenceFactory (org.apache.activemq.artemis.jndi.JNDIReferenceFactory)2 Test (org.junit.Test)2 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)1 ActiveMQDestination (org.apache.activemq.artemis.jms.client.ActiveMQDestination)1