use of com.adaptris.core.Channel in project interlok by adaptris.
the class WorkflowRetryAndFailTest method testFailedInitialise_ExceedsMax.
@Override
@Test
public void testFailedInitialise_ExceedsMax() throws Exception {
WorkflowList wfl = new WorkflowList();
WorkflowRetryAndFail strategy = new WorkflowRetryAndFail(2, new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
FailInit workflow = new FailInit(3);
wfl.add(workflow);
wfl.setLifecycleStrategy(strategy);
Channel c = createChannel(wfl);
try {
c.requestInit();
} catch (CoreException expected) {
}
// That's right 1 + 2 retries.
assertEquals(3, workflow.getAttempts());
assertEquals(ClosedState.getInstance(), workflow.retrieveComponentState());
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class ConfigurationCheckRunnerTest method createAdapterConfig.
private String createAdapterConfig(AdaptrisConnection sharedComponent, AdaptrisConnection consumeConnection, AdaptrisConnection produceConnection) throws Exception {
Adapter adapter = new Adapter();
if (sharedComponent != null) {
adapter.getSharedComponents().addConnection(sharedComponent);
}
Channel channel = new Channel();
if (consumeConnection != null) {
channel.setConsumeConnection(consumeConnection);
}
if (produceConnection != null) {
channel.setProduceConnection(produceConnection);
}
adapter.getChannelList().add(channel);
return DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
}
use of com.adaptris.core.Channel 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.Channel 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();
}
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddChannel.
@Test
public void testMBean_AddChannel() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel newChannel = createChannel(getName() + "_1");
ObjectName adapterObj = adapterManager.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
ObjectName channelObj = adapterManagerProxy.addChannel(DefaultMarshaller.getDefaultMarshaller().marshal(newChannel));
assertNotNull(channelObj);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertEquals(ClosedState.getInstance(), channelManagerProxy.getComponentState());
Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(adapterManagerProxy.getConfiguration());
assertEquals(1, marshalledAdapter.getChannelList().size());
} finally {
}
}
Aggregations