Search in sources :

Example 1 with XStreamMarshaller

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);
}
Also used : Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) XStreamMarshaller(com.adaptris.core.XStreamMarshaller) Test(org.junit.Test)

Example 2 with XStreamMarshaller

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);
}
Also used : Adapter(com.adaptris.core.Adapter) XStreamMarshaller(com.adaptris.core.XStreamMarshaller) Test(org.junit.Test)

Example 3 with XStreamMarshaller

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);
}
Also used : Channel(com.adaptris.core.Channel) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) XStreamMarshaller(com.adaptris.core.XStreamMarshaller) Test(org.junit.Test)

Example 4 with XStreamMarshaller

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()));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) LogMessageService(com.adaptris.core.services.LogMessageService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) MetadataElement(com.adaptris.core.MetadataElement) XStreamMarshaller(com.adaptris.core.XStreamMarshaller) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 5 with XStreamMarshaller

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());
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) XmlValidationService(com.adaptris.core.transform.XmlValidationService) XStreamMarshaller(com.adaptris.core.XStreamMarshaller) Test(org.junit.Test)

Aggregations

XStreamMarshaller (com.adaptris.core.XStreamMarshaller)10 Test (org.junit.Test)8 Adapter (com.adaptris.core.Adapter)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 Channel (com.adaptris.core.Channel)3 SAXParseException (org.xml.sax.SAXParseException)2 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)1 MetadataElement (com.adaptris.core.MetadataElement)1 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)1 Service (com.adaptris.core.Service)1 ServiceList (com.adaptris.core.ServiceList)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1 Workflow (com.adaptris.core.Workflow)1 JdbcConnection (com.adaptris.core.jdbc.JdbcConnection)1 LogMessageService (com.adaptris.core.services.LogMessageService)1 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)1 XmlValidationService (com.adaptris.core.transform.XmlValidationService)1