Search in sources :

Example 6 with StandardJndiImplementation

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

the class JmsConnectionErrorHandlerTest method testConnectionErrorHandlerWithJndi.

@Test
public void testConnectionErrorHandlerWithJndi() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    MockChannel channel = createChannel(activeMqBroker, activeMqBroker.getJndiPasConnection(new StandardJndiImplementation(), false, queueName, topicName), topicName, new JmsConnectionErrorHandler());
    try {
        channel.requestStart();
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        activeMqBroker.stop();
        Thread.sleep(1000);
        activeMqBroker.start();
        waitForChannelToMatchState(StartedState.getInstance(), channel);
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        assertEquals(2, channel.getStartCount());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) JmsConnectionErrorHandler(com.adaptris.core.jms.JmsConnectionErrorHandler) Test(org.junit.Test)

Example 7 with StandardJndiImplementation

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

the class JndiPasProducerCase method testProduceJndiOnlyObjectNotFound.

@Test
public void testProduceJndiOnlyObjectNotFound() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPasConnection(sendVendorImp, true, queueName, topicName), new PasProducer().withTopic(this.getClass().getSimpleName()));
    try {
        start(standaloneProducer);
        standaloneProducer.produce(createMessage(null));
        fail("Expected ProduceException");
    } catch (ProduceException expected) {
    } finally {
        stop(standaloneProducer);
    }
}
Also used : StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) ProduceException(com.adaptris.core.ProduceException) Test(org.junit.Test)

Example 8 with StandardJndiImplementation

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

the class JndiPtpProducerCase method testProduceJndiOnlyObjectNotFound.

@Test
public void testProduceJndiOnlyObjectNotFound() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((this.getClass().getSimpleName())));
    try {
        start(standaloneProducer);
        standaloneProducer.produce(createMessage(null));
        fail("Expected ProduceException");
    } catch (ProduceException expected) {
    } finally {
        stop(standaloneProducer);
    }
}
Also used : StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) ProduceException(com.adaptris.core.ProduceException) Test(org.junit.Test)

Example 9 with StandardJndiImplementation

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

the class JndiPtpProducerCase method testProduceAndConsumeUsingJndiOnly.

@Test
public void testProduceAndConsumeUsingJndiOnly() throws Exception {
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, true, queueName, topicName), new PtpConsumer().withQueue(queueName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((queueName)));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 10 with StandardJndiImplementation

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

the class JndiPtpProducerCase method testProduceAndConsume_ExtraConfig.

@Test
public void testProduceAndConsume_ExtraConfig() throws Exception {
    SimpleFactoryConfiguration sfc = new SimpleFactoryConfiguration();
    KeyValuePairSet kvps = new KeyValuePairSet();
    kvps.add(new KeyValuePair("ClientID", "testProduceAndConsume_ExtraConfig"));
    kvps.add(new KeyValuePair("UseCompression", "true"));
    sfc.setProperties(kvps);
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    sendVendorImp.setExtraFactoryConfiguration(sfc);
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, false, queueName, topicName), new PtpConsumer().withQueue(queueName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, false, queueName, topicName), new PtpProducer().withQueue((queueName)));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) SimpleFactoryConfiguration(com.adaptris.core.jms.jndi.SimpleFactoryConfiguration) PtpProducer(com.adaptris.core.jms.PtpProducer) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) 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