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);
}
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations