Search in sources :

Example 26 with StandardJndiImplementation

use of com.adaptris.core.jms.jndi.StandardJndiImplementation in project interlok by adaptris.

the class JndiImplementationCase method testInitialiseWithTopicConnectionFactoryNotFound.

@Test
public void testInitialiseWithTopicConnectionFactoryNotFound() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    PasProducer producer = new PasProducer().withTopic(queueName);
    StandardJndiImplementation jv = createVendorImplementation();
    JmsConnection c = activeMqBroker.getJndiPasConnection(jv, false, queueName, topicName);
    c.setConnectionAttempts(1);
    c.setConnectionRetryInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS.name()));
    jv.setJndiName("testInitialiseWithTopicConnectionFactoryNotFound");
    StandaloneProducer standaloneProducer = new StandaloneProducer(c, producer);
    try {
        LifecycleHelper.init(standaloneProducer);
        fail("Should Fail to lookup 'testInitialiseWithTopicConnectionFactoryNotFound'");
    } catch (Exception e) {
    // expected
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 27 with StandardJndiImplementation

use of com.adaptris.core.jms.jndi.StandardJndiImplementation in project interlok by adaptris.

the class JndiImplementationCase method testInitialiseWithQueueConnectionFactoryNotFound.

@Test
public void testInitialiseWithQueueConnectionFactoryNotFound() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    PasProducer producer = new PasProducer().withTopic((topicName));
    StandardJndiImplementation jv = createVendorImplementation();
    JmsConnection c = activeMqBroker.getJndiPtpConnection(jv, false, queueName, topicName);
    c.setConnectionAttempts(1);
    c.setConnectionRetryInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS));
    jv.setJndiName("testInitialiseWithQueueConnectionFactoryNotFound");
    StandaloneProducer standaloneProducer = new StandaloneProducer(c, producer);
    try {
        LifecycleHelper.init(standaloneProducer);
        fail("Should Fail to lookup 'testInitialiseWithQueueConnectionFactoryNotFound'");
    } catch (Exception e) {
    // expected
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 28 with StandardJndiImplementation

use of com.adaptris.core.jms.jndi.StandardJndiImplementation in project interlok by adaptris.

the class JndiImplementationCase method testInitialiseWithEncryptedPassword_withEnableEncodedPasswords.

@Test
public void testInitialiseWithEncryptedPassword_withEnableEncodedPasswords() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    RequiresCredentialsBroker broker = new RequiresCredentialsBroker();
    PasProducer producer = new PasProducer().withTopic(queueName);
    StandardJndiImplementation jv = createVendorImplementation();
    JmsConnection c = broker.getJndiPasConnection(jv, false, queueName, topicName);
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("UserName", RequiresCredentialsBroker.DEFAULT_USERNAME));
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("Password", Password.encode(RequiresCredentialsBroker.DEFAULT_PASSWORD, Password.PORTABLE_PASSWORD)));
    jv.setEncodedPasswordKeys("Password");
    jv.setEnableEncodedPasswords(true);
    StandaloneProducer standaloneProducer = new StandaloneProducer(c, producer);
    try {
        broker.start();
        LifecycleHelper.init(standaloneProducer);
    } finally {
        LifecycleHelper.close(standaloneProducer);
        broker.destroy();
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) RequiresCredentialsBroker(com.adaptris.core.jms.activemq.RequiresCredentialsBroker) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)28 Test (org.junit.Test)20 StandaloneProducer (com.adaptris.core.StandaloneProducer)16 JmsConnection (com.adaptris.core.jms.JmsConnection)14 PasProducer (com.adaptris.core.jms.PasProducer)11 KeyValuePair (com.adaptris.util.KeyValuePair)11 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)7 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)7 PtpProducer (com.adaptris.core.jms.PtpProducer)6 TimeInterval (com.adaptris.util.TimeInterval)6 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)5 PasConsumer (com.adaptris.core.jms.PasConsumer)4 PtpConsumer (com.adaptris.core.jms.PtpConsumer)3 RequiresCredentialsBroker (com.adaptris.core.jms.activemq.RequiresCredentialsBroker)3 MockChannel (com.adaptris.core.stubs.MockChannel)3 ProduceException (com.adaptris.core.ProduceException)2 FailoverJmsConnection (com.adaptris.core.jms.FailoverJmsConnection)2 SimpleFactoryConfiguration (com.adaptris.core.jms.jndi.SimpleFactoryConfiguration)2 ActiveJmsConnectionErrorHandler (com.adaptris.core.jms.ActiveJmsConnectionErrorHandler)1 JmsConnectionErrorHandler (com.adaptris.core.jms.JmsConnectionErrorHandler)1