use of com.adaptris.core.Adapter in project interlok by adaptris.
the class FilteredSharedComponentStartTest method testNonBlockingStart_WithException.
@Test
public void testNonBlockingStart_WithException() throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(getName());
TriggeredFailingMockConnection sharedConnection = new TriggeredFailingMockConnection(getName());
try {
adapter.getSharedComponents().addConnection(sharedConnection);
adapter.getSharedComponents().setLifecycleStrategy(new FilteredSharedComponentStart(true));
adapter.requestInit();
// Will return straight away.
assertEquals(InitialisedState.getInstance(), adapter.retrieveComponentState());
assertNotSame(InitialisedState.getInstance(), sharedConnection.retrieveComponentState());
sharedConnection.wakeup = true;
Thread.sleep(1000);
// The connection should never start.
assertEquals(ClosedState.getInstance(), sharedConnection.retrieveComponentState());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.Adapter 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.Adapter in project interlok by adaptris.
the class DeserializationConfigurationCheckerTest method createAdapterConfig.
private String createAdapterConfig() throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId("MyAdapter");
return DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
}
use of com.adaptris.core.Adapter 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.Adapter in project interlok by adaptris.
the class ShutdownHandlerTest method testRun.
@Test
public void testRun() throws Exception {
String adapterName = nameGenerator.safeUUID();
Adapter adapter = new Adapter();
adapter.setUniqueId(adapterName);
BootstrapProperties boot = bootstrapWithAdapter(adapter);
AdapterManagerMBean mgmtBean = boot.getConfigManager().createAdapter();
try {
mgmtBean.requestStart();
ShutdownHandler shutdown = new ShutdownHandler(boot);
shutdown.run();
} finally {
unregisterQuietly(mgmtBean);
}
}
Aggregations