Search in sources :

Example 21 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class JndiContextFactoryTest method testJndiLookupFromMultiple.

@Test
public void testJndiLookupFromMultiple() throws Exception {
    // Pump the JNDI context with some connection objects
    NullConnection connection1 = new NullConnection();
    connection1.setUniqueId("connection1");
    JmsConnection connection2 = new JmsConnection();
    connection2.setUniqueId("connection2");
    JmsConnection connection3 = new JmsConnection();
    connection3.setUniqueId("connection3");
    FtpConnection connection4 = new FtpConnection();
    connection4.setUniqueId("connection4");
    HttpConnection connection5 = new HttpConnection();
    connection5.setUniqueId("connection5");
    ArrayList<AdaptrisConnection> connectionList = new ArrayList<AdaptrisConnection>();
    connectionList.add(connection1);
    connectionList.add(connection2);
    connectionList.add(connection3);
    connectionList.add(connection4);
    connectionList.add(connection5);
    AdaptrisConnectionImp connectionObject = null;
    InitialContext ctx = new InitialContext(env);
    try {
        JndiHelper.bind(connectionList);
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection1");
        assertTrue(connectionObject instanceof NullConnection);
        assertEquals("connection1", connectionObject.getUniqueId());
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection2");
        assertTrue(connectionObject instanceof JmsConnection);
        assertEquals("connection2", connectionObject.getUniqueId());
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection3");
        assertTrue(connectionObject instanceof JmsConnection);
        assertEquals("connection3", connectionObject.getUniqueId());
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection4");
        assertTrue(connectionObject instanceof FtpConnection);
        assertEquals("connection4", connectionObject.getUniqueId());
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection5");
        assertTrue(connectionObject instanceof HttpConnection);
        assertEquals("connection5", connectionObject.getUniqueId());
    } finally {
        JndiHelper.unbindQuietly(ctx, connectionList, false);
    }
}
Also used : HttpConnection(com.adaptris.core.http.jetty.HttpConnection) FtpConnection(com.adaptris.core.ftp.FtpConnection) ArrayList(java.util.ArrayList) JmsConnection(com.adaptris.core.jms.JmsConnection) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 22 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class RequestReplyWorkflowTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    Channel c = new Channel();
    try {
        c.setConsumeConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616")));
        c.setProduceConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:2506")));
        RequestReplyWorkflow workflow = new RequestReplyWorkflow();
        workflow.getServiceCollection().addService(new Base64DecodeService());
        workflow.setConsumer(new PtpConsumer().withQueue("inputQueue"));
        workflow.setProducer(new PtpProducer().withQueue("outputQueue"));
        workflow.setReplyProducer(new PtpProducer().withQueue("TODO"));
        workflow.getReplyServiceCollection().addService(new Base64EncodeService());
        c.getWorkflowList().add(workflow);
        c.setUniqueId(UUID.randomUUID().toString());
        workflow.setUniqueId(UUID.randomUUID().toString());
    } catch (CoreException e) {
        throw new RuntimeException(e);
    }
    return c;
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) Base64EncodeService(com.adaptris.core.services.Base64EncodeService) BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) MockChannel(com.adaptris.core.stubs.MockChannel) Base64DecodeService(com.adaptris.core.services.Base64DecodeService) JmsConnection(com.adaptris.core.jms.JmsConnection) PtpProducer(com.adaptris.core.jms.PtpProducer)

Example 23 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class JndiContextFactoryTest method testLoadWithNonUniqueObjectIds.

@Test
public void testLoadWithNonUniqueObjectIds() throws Exception {
    NullConnection connection1 = new NullConnection();
    connection1.setUniqueId("connection1");
    JmsConnection connection2 = new JmsConnection();
    connection2.setUniqueId("connection1");
    JmsConnection connection3 = new JmsConnection();
    connection3.setUniqueId("connection1");
    ArrayList<AdaptrisConnection> connectionList = new ArrayList<AdaptrisConnection>();
    connectionList.add(connection1);
    connectionList.add(connection2);
    connectionList.add(connection3);
    InitialContext ctx = new InitialContext(env);
    try {
        JndiHelper.bind(connectionList);
        fail();
    } catch (CoreException expected) {
    } finally {
        JndiHelper.unbindQuietly(ctx, connectionList, false);
    }
}
Also used : ArrayList(java.util.ArrayList) JmsConnection(com.adaptris.core.jms.JmsConnection) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 24 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class AdapterTest method createRetryingAdapter.

/**
 * <p>
 * Creates a valid Adapter to use in tests. Uese Mock aka Memory MessageConsumer / Producer.
 * </p>
 *
 * @param uniqueId a uniqure identifier for this <code>Adapter</code>
 */
public static Adapter createRetryingAdapter(String uniqueId) throws Exception {
    Adapter result = null;
    AdaptrisConnection consume = new NullConnection();
    JmsConnection produce = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:5000"));
    produce.setConnectionRetryInterval(new TimeInterval(1L, TimeUnit.SECONDS.name()));
    produce.setConnectionAttempts(20);
    AdaptrisMessageProducer producer1 = new PtpProducer().withQueue("dummyQueue");
    StandardWorkflow workflow1 = new StandardWorkflow();
    workflow1.setProducer(producer1);
    WorkflowList workflows = new WorkflowList();
    workflows.add(workflow1);
    Channel channel = new Channel();
    channel.setUniqueId(uniqueId + "_c1");
    channel.setConsumeConnection(consume);
    channel.setProduceConnection(produce);
    channel.setWorkflowList(workflows);
    ChannelList channels = new ChannelList();
    channels.addChannel(channel);
    result = new Adapter();
    result.setChannelList(channels);
    result.setUniqueId(uniqueId);
    return result;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval) JmsConnection(com.adaptris.core.jms.JmsConnection) PtpProducer(com.adaptris.core.jms.PtpProducer)

Example 25 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class SharedComponentListTest method createAdapter.

private Adapter createAdapter() throws CoreException, PasswordException {
    Adapter adapter = new Adapter();
    adapter.setUniqueId("upbeat_liskov");
    JmsConnection jmsConnection = createPtpConnection("jms-connection");
    adapter.getSharedComponents().addConnection(jmsConnection);
    ServiceList serviceList = new ServiceList();
    serviceList.setUniqueId("shared-service-list");
    serviceList.add(new LogMessageService("log-message-service"));
    adapter.getSharedComponents().addService(serviceList);
    StandardWorkflow wf1 = new StandardWorkflow();
    wf1.setUniqueId("reverent-edison");
    wf1.setConsumer(new FsConsumer().withBaseDirectoryUrl("in-directory"));
    wf1.setProducer(new FsProducer().withBaseDirectoryUrl("out-directory"));
    wf1.getServiceCollection().add(new SharedService("shared-service-list"));
    StandardWorkflow wf = new StandardWorkflow();
    wf.setUniqueId("pedantic_brown");
    wf.setConsumer(new JmsConsumer().withEndpoint("jms:queue:SampleQueue1"));
    wf.setProducer(new NullMessageProducer());
    wf.getServiceCollection().add(new StandaloneProducer(new SharedConnection("jms-connection"), new JmsProducer().withEndpoint("jms:topic:MyTopicName")));
    Channel channel = new Channel();
    channel.setUniqueId("quirky_shannon");
    channel.setConsumeConnection(new SharedConnection("jms-connection"));
    channel.getWorkflowList().add(wf);
    channel.getWorkflowList().add(wf1);
    adapter.getChannelList().add(channel);
    return adapter;
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) LogMessageService(com.adaptris.core.services.LogMessageService) FsProducer(com.adaptris.core.fs.FsProducer) JmsConsumer(com.adaptris.core.jms.JmsConsumer) FsConsumer(com.adaptris.core.fs.FsConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection)

Aggregations

JmsConnection (com.adaptris.core.jms.JmsConnection)47 Test (org.junit.Test)25 StandaloneProducer (com.adaptris.core.StandaloneProducer)17 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)14 TimeInterval (com.adaptris.util.TimeInterval)14 PasProducer (com.adaptris.core.jms.PasProducer)12 MockChannel (com.adaptris.core.stubs.MockChannel)10 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)8 PtpProducer (com.adaptris.core.jms.PtpProducer)8 KeyValuePair (com.adaptris.util.KeyValuePair)6 Adapter (com.adaptris.core.Adapter)5 PtpConsumer (com.adaptris.core.jms.PtpConsumer)5 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)5 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)4 SharedConnection (com.adaptris.core.SharedConnection)4 MessageTypeTranslatorImp (com.adaptris.core.jms.MessageTypeTranslatorImp)4 UrlVendorImplementation (com.adaptris.core.jms.UrlVendorImplementation)4 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)4 Message (javax.jms.Message)4