Search in sources :

Example 1 with StandardJndiImplementation

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

the class JmsConnectionErrorHandlerTest method testComparatorWith2IdenticalJNDIConnections.

@Test
public void testComparatorWith2IdenticalJNDIConnections() throws Exception {
    JmsConnectionErrorHandler connectionErrorHandler1 = new JmsConnectionErrorHandler();
    JmsConnectionErrorHandler connectionErrorHandler2 = new JmsConnectionErrorHandler();
    JmsConnection connection1 = new JmsConnection();
    JmsConnection connection2 = new JmsConnection();
    KeyValuePairSet keyValuePairSet = new KeyValuePairSet();
    KeyValuePair keyVPInitial = new KeyValuePair();
    keyVPInitial.setKey("java.naming.factory.initial");
    keyVPInitial.setValue("com.sonicsw.jndi.mfcontext.MFContextFactory");
    KeyValuePair keyVPCred = new KeyValuePair();
    keyVPCred.setKey("java.naming.security.credentials");
    keyVPCred.setValue("Administrator");
    KeyValuePair keyVPDomain = new KeyValuePair();
    keyVPDomain.setKey("com.sonicsw.jndi.mfcontext.domain");
    keyVPDomain.setValue("Domain1");
    KeyValuePair keyVPUrl = new KeyValuePair();
    keyVPUrl.setKey("java.naming.provider.url");
    keyVPUrl.setValue("tcp://localhost:2506");
    KeyValuePair keyVPPrinciple = new KeyValuePair();
    keyVPPrinciple.setKey("java.naming.security.principal");
    keyVPPrinciple.setValue("Administrator");
    keyValuePairSet.add(keyVPInitial);
    keyValuePairSet.add(keyVPCred);
    keyValuePairSet.add(keyVPCred);
    keyValuePairSet.add(keyVPInitial);
    StandardJndiImplementation jndiVendor1 = new StandardJndiImplementation();
    jndiVendor1.setJndiParams(keyValuePairSet);
    StandardJndiImplementation jndiVendor2 = new StandardJndiImplementation();
    jndiVendor2.setJndiParams(keyValuePairSet);
    connection1.setVendorImplementation(jndiVendor1);
    connection2.setVendorImplementation(jndiVendor2);
    connectionErrorHandler1.registerConnection(connection1);
    connectionErrorHandler2.registerConnection(connection2);
    assertFalse(connectionErrorHandler1.allowedInConjunctionWith(connectionErrorHandler2));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 2 with StandardJndiImplementation

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

the class JmsConnectionErrorHandlerTest method testComparatorWith2DifferemtJNDIConnections.

@Test
public void testComparatorWith2DifferemtJNDIConnections() throws Exception {
    JmsConnectionErrorHandler connectionErrorHandler1 = new JmsConnectionErrorHandler();
    JmsConnectionErrorHandler connectionErrorHandler2 = new JmsConnectionErrorHandler();
    JmsConnection connection1 = new JmsConnection();
    JmsConnection connection2 = new JmsConnection();
    KeyValuePairSet keyValuePairSet1 = new KeyValuePairSet();
    KeyValuePair keyVPInitial = new KeyValuePair();
    keyVPInitial.setKey("java.naming.factory.initial");
    keyVPInitial.setValue("com.sonicsw.jndi.mfcontext.MFContextFactory");
    KeyValuePair keyVPCred = new KeyValuePair();
    keyVPCred.setKey("java.naming.security.credentials");
    keyVPCred.setValue("Administrator");
    KeyValuePair keyVPDomain = new KeyValuePair();
    keyVPDomain.setKey("com.sonicsw.jndi.mfcontext.domain");
    keyVPDomain.setValue("Domain1");
    KeyValuePair keyVPUrl = new KeyValuePair();
    keyVPUrl.setKey("java.naming.provider.url");
    keyVPUrl.setValue("tcp://localhost:2506");
    KeyValuePair keyVPPrinciple = new KeyValuePair();
    keyVPPrinciple.setKey("java.naming.security.principal");
    keyVPPrinciple.setValue("Administrator");
    keyValuePairSet1.add(keyVPInitial);
    keyValuePairSet1.add(keyVPCred);
    keyValuePairSet1.add(keyVPCred);
    keyValuePairSet1.add(keyVPInitial);
    KeyValuePairSet keyValuePairSet2 = new KeyValuePairSet(keyValuePairSet1);
    keyValuePairSet2.addKeyValuePair(new KeyValuePair("java.naming.provider.url", "tcp://localhost:2507"));
    StandardJndiImplementation jndiVendor1 = new StandardJndiImplementation();
    jndiVendor1.setJndiParams(keyValuePairSet1);
    StandardJndiImplementation jndiVendor2 = new StandardJndiImplementation();
    jndiVendor2.setJndiParams(keyValuePairSet2);
    connection1.setVendorImplementation(jndiVendor1);
    connection2.setVendorImplementation(jndiVendor2);
    connectionErrorHandler1.registerConnection(connection1);
    connectionErrorHandler2.registerConnection(connection2);
    assertTrue(connectionErrorHandler1.allowedInConjunctionWith(connectionErrorHandler2));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 3 with StandardJndiImplementation

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

the class JmsTransactedWorkflowTest method configure.

static JmsConnection configure(JmsConnection c) {
    StandardJndiImplementation jndi = new StandardJndiImplementation();
    jndi.setJndiName("JNDI_Name_For_Connection_Factory");
    c.setVendorImplementation(jndi);
    return c;
}
Also used : StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation)

Example 4 with StandardJndiImplementation

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

the class DestinationCacheJndiPasProducerTest method testProduceAndConsumeWithCache.

@Test
public void testProduceAndConsumeWithCache() throws Exception {
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPasConnection(recvVendorImp, false, queueName, topicName), new PasConsumer().withTopic(topicName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPasConnection(sendVendorImp, false, queueName, topicName), new PasProducer().withTopic(topicName));
    try {
        start(standaloneConsumer);
        start(standaloneProducer);
        standaloneProducer.doService(createMessage(null));
        standaloneProducer.doService(createMessage(null));
        waitForMessages(jms, 2);
        assertMessages(jms, 2);
    } finally {
        stop(standaloneProducer);
        stop(standaloneConsumer);
    }
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 5 with StandardJndiImplementation

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

the class ActiveJmsConnectionErrorHandlerTest method testConnectionErrorHandlerWhileConnectionIsClosed.

@Test
public void testConnectionErrorHandlerWhileConnectionIsClosed() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    JmsConnection jmsCon = activeMqBroker.getJndiPasConnection(new StandardJndiImplementation(), false, queueName, topicName);
    jmsCon.setConnectionAttempts(null);
    MockChannel channel = createChannel(activeMqBroker, jmsCon, topicName);
    try {
        ActiveJmsConnectionErrorHandler handler = new ActiveJmsConnectionErrorHandler();
        handler.setCheckInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS));
        handler.setAdditionalLogging(Boolean.TRUE);
        channel.getConsumeConnection().setConnectionErrorHandler(handler);
        channel.requestStart();
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        channel.requestClose();
        activeMqBroker.stop();
        activeMqBroker.start();
        assertEquals(ClosedState.getInstance(), channel.retrieveComponentState());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) TimeInterval(com.adaptris.util.TimeInterval) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) JmsConnection(com.adaptris.core.jms.JmsConnection) ActiveJmsConnectionErrorHandler(com.adaptris.core.jms.ActiveJmsConnectionErrorHandler) 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