use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testAddChild.
@Test
public void testAddChild() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel c1 = createChannel(getName() + "_1");
Channel c2 = createChannel(getName() + "_2");
ChannelManager child1 = new ChannelManager(c1, adapterManager);
ChannelManager child2 = new ChannelManager(c2, adapterManager);
assertEquals(2, adapterManager.getChildren().size());
try {
adapterManager.addChild(child1);
} catch (IllegalArgumentException expected) {
assertTrue(expected.getMessage().startsWith("duplicate Channel ID"));
}
assertEquals(2, adapterManager.getChildren().size());
try {
adapterManager.addChild(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(2, adapterManager.getChildren().size());
assertEquals(2, adapter.getChannelList().size());
Adapter marshalledAdapter = (Adapter) new XStreamMarshaller().unmarshal(adapterManager.getConfiguration());
assertRoundtripEquality(adapter, marshalledAdapter);
}
use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testGetConfiguration.
@Test
public void testGetConfiguration() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
AdapterManager am1 = new AdapterManager(adapter);
Adapter marshalledAdapter = (Adapter) new XStreamMarshaller().unmarshal(am1.getConfiguration());
assertRoundtripEquality(adapter, marshalledAdapter);
}
use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class WorkflowManagerTest method testGetConfiguration.
@Test
public void testGetConfiguration() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
Workflow workflow = createWorkflow("w1");
WorkflowManager workflowManager = new WorkflowManager(workflow, channelManager);
Workflow marshalledWorkflow = (Workflow) new XStreamMarshaller().unmarshal(workflowManager.getConfiguration());
assertRoundtripEquality(workflow, marshalledWorkflow);
Channel marshalledChannel = (Channel) new XStreamMarshaller().unmarshal(channelManager.getConfiguration());
assertRoundtripEquality(channel, marshalledChannel);
Adapter marshalledAdapter = (Adapter) new XStreamMarshaller().unmarshal(adapterManager.getConfiguration());
assertRoundtripEquality(adapter, marshalledAdapter);
}
use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class DynamicServiceExecutorTest method testDoService_DefaultServiceExtractor_WithMarshaller.
@Test
public void testDoService_DefaultServiceExtractor_WithMarshaller() throws Exception {
AddMetadataService metadataService = new AddMetadataService();
metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
DynamicServiceExecutor dynamicService = createService();
dynamicService.setMarshaller(new XStreamMarshaller());
AdaptrisMessage msg = createMessage(new ServiceList(new Service[] { metadataService }));
execute(dynamicService, msg);
assertEquals(getName(), msg.getMetadataValue(getName()));
}
use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class ExtendedSchemaValidatorTest method testExtendedValidator_Invalid.
@Test
public void testExtendedValidator_Invalid() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_WILL_NOT_VALIDATE);
ExtendedXmlSchemaValidator validator = new ExtendedXmlSchemaValidator().withSchemaViolationHandler(new ViolationsAsMetadata()).withSchema(schemaUrl);
AdaptrisMessage msg = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_INPUT_FILE));
XmlValidationService service = new XmlValidationService(validator);
execute(service, msg);
assertTrue(msg.headersContainsKey(ViolationHandlerImpl.DEFAULT_KEY));
SchemaViolations v = (SchemaViolations) new XStreamMarshaller().unmarshal(msg.getMetadataValue(ViolationHandlerImpl.DEFAULT_KEY));
assertEquals(2, v.getViolations().size());
}
Aggregations