use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class BasicActiveMqConsumerTest method createDurableSubsAdapter.
private Adapter createDurableSubsAdapter(String adapterName, EmbeddedActiveMq activeMqBroker) throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(adapterName);
Channel c = new Channel();
JmsConnection conn = activeMqBroker.getJmsConnection(createVendorImpl());
conn.setClientId(MY_CLIENT_ID);
c.setConsumeConnection(conn);
StandardWorkflow swf = new StandardWorkflow();
PasConsumer pasConsumer = new PasConsumer().withTopic(new GuidGenerator().safeUUID());
pasConsumer.setSubscriptionId(MY_SUBSCRIPTION_ID);
swf.setConsumer(pasConsumer);
c.getWorkflowList().add(swf);
ChannelList cl = new ChannelList();
cl.addChannel(c);
adapter.setChannelList(cl);
return adapter;
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testQueue_ProduceWhenConsumerStopped.
@Test
public void testQueue_ProduceWhenConsumerStopped() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandardWorkflow workflow = new StandardWorkflow();
MockMessageProducer producer = new MockMessageProducer();
workflow.setConsumer(consumer);
workflow.setProducer(producer);
Channel channel = createChannel(activeMqBroker.getJmsConnection(createVendorImpl()), workflow);
try {
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue((getName())));
channel.requestStart();
workflow.requestStop();
start(standaloneProducer);
AdaptrisMessage msg = createMessage(null);
standaloneProducer.produce(msg);
Thread.sleep(250);
assertEquals(0, producer.messageCount());
stop(standaloneProducer);
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class ActiveJmsConnectionErrorHandlerTest method createWorkflow.
private Workflow createWorkflow(EmbeddedActiveMq mq, String destName) throws Exception {
StandardWorkflow wf = new StandardWorkflow();
PasConsumer consumer = new PasConsumer().withTopic(destName);
wf.setProducer(new MockMessageProducer());
wf.setConsumer(consumer);
return wf;
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class JavaxValidationCheckerTest method createAdapterConfig.
private Adapter createAdapterConfig(boolean validates, boolean channels) throws Exception {
Adapter adapter = new Adapter();
if (validates) {
// have a unique-id
adapter.setUniqueId("MyAdapter");
AddTimestampMetadataService ts = new AddTimestampMetadataService();
ts.setUniqueId("valid-add-timestamp-service");
PayloadHashingService ph = new PayloadHashingService();
ph.setUniqueId("valid-payload-hasher");
ph.setMetadataKey("payloadHash");
ph.setHashAlgorithm("SHA-256");
adapter.getSharedComponents().addService(ts);
adapter.getSharedComponents().addService(ph);
} else {
// no adapter unique-id
// explicitly set add timestamp to have an empty key, thankfully
// no checks on the setter...
AddTimestampMetadataService ts = new AddTimestampMetadataService();
ts.setUniqueId("invalid-add-timestamp-service");
ts.setMetadataKey("");
// don't specify the hash algo or the metadata-key
PayloadHashingService ph = new PayloadHashingService();
ph.setUniqueId("invalid-payload-hasher");
adapter.getSharedComponents().addService(ts);
adapter.getSharedComponents().addService(ph);
}
if (channels) {
Channel c = new Channel();
c.setUniqueId("channel");
StandardWorkflow w = new StandardWorkflow();
w.setUniqueId("workflow");
if (!validates) {
PayloadHashingService ph = new PayloadHashingService();
ph.setUniqueId("invalid-payload-hasher-2");
w.getServiceCollection().add(ph);
}
c.getWorkflowList().add(w);
adapter.getChannelList().add(c);
}
return adapter;
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddAndBindSharedConnection_AddChannel_StartChannel.
@Test
public void testMBean_AddAndBindSharedConnection_AddChannel_StartChannel() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
Channel newChannel = createChannel(getName(), 1);
StandardWorkflow wf = (StandardWorkflow) newChannel.getWorkflowList().getWorkflows().get(0);
MockServiceWithConnection service = new MockServiceWithConnection(new SharedConnection(getName()));
wf.getServiceCollection().add(service);
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
adapterManager.requestStart();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName())));
ObjectName channelObj = amp.addChannel(m.marshal(newChannel));
ChannelManagerMBean cmb = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertEquals(ClosedState.getInstance(), cmb.getComponentState());
// This should start, referencing the shared connection in JNDI.
cmb.requestStart();
} finally {
adapterManager.requestClose();
}
}
Aggregations