Search in sources :

Example 36 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class ReadMetadataFromFilesystemTest method testService_InputXml.

@Test
public void testService_InputXml() throws Exception {
    String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
    ReadMetadataFromFilesystem service = createService(subDir);
    service.setInputStyle(InputStyle.XML);
    service.setFilenameCreator(new FormattedFilenameCreator());
    File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
    String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
    Properties p = createProperties();
    writeProperties(p, new File(propsFilename), true);
    execute(service, msg);
    assertTrue(msg.headersContainsKey("key5"));
    assertEquals("v5", msg.getMetadataValue("key5"));
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) FormattedFilenameCreator(com.adaptris.core.FormattedFilenameCreator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 37 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class ReadMetadataFromFilesystemTest method testService_Default.

@Test
public void testService_Default() throws Exception {
    String subDir = new GuidGenerator().safeUUID();
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
    ReadMetadataFromFilesystem service = createService(subDir);
    File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
    String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
    Properties p = createProperties();
    writeProperties(p, new File(propsFilename), false);
    execute(service, msg);
    assertTrue(msg.headersContainsKey("key5"));
    assertEquals("v5", msg.getMetadataValue("key5"));
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 38 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class ReadMetadataFromFilesystemTest method testService_DestinationIsFile.

@Test
public void testService_DestinationIsFile() throws Exception {
    String subDir = new GuidGenerator().safeUUID();
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
    File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
    String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
    Properties p = createProperties();
    writeProperties(p, new File(propsFilename), false);
    ReadMetadataFromFilesystem service = createService(subDir + "/" + msg.getUniqueId());
    execute(service, msg);
    assertTrue(msg.headersContainsKey("key5"));
    assertEquals("v5", msg.getMetadataValue("key5"));
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) Properties(java.util.Properties) File(java.io.File) Test(org.junit.Test)

Example 39 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class DecodingServiceTest method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    DecodingService s = new DecodingService();
    assertNull(s.getMessageFactory());
    s = new DecodingService(new MockEncoder());
    assertNull(s.getMessageFactory());
    assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
    s = new DecodingService(new MockEncoder());
    AdaptrisMessageFactory amf = new StubMessageFactory();
    s.setMessageFactory(amf);
    try {
        LifecycleHelper.init(s);
        assertEquals(amf, s.getMessageFactory());
        assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
        assertEquals(amf, s.getEncoder().currentMessageFactory());
    } finally {
        LifecycleHelper.close(s);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessageFactory(com.adaptris.core.AdaptrisMessageFactory) MockEncoder(com.adaptris.core.stubs.MockEncoder) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) Test(org.junit.Test)

Example 40 with DefaultMessageFactory

use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.

the class EncodingServiceTest method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    EncodingService s = new EncodingService();
    assertNull(s.getMessageFactory());
    s = new EncodingService(new MockEncoder());
    assertNull(s.getMessageFactory());
    assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
    s = new EncodingService(new MockEncoder());
    AdaptrisMessageFactory amf = new StubMessageFactory();
    s.setMessageFactory(amf);
    try {
        LifecycleHelper.init(s);
        assertEquals(amf, s.getMessageFactory());
        assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
        assertEquals(amf, s.getEncoder().currentMessageFactory());
    } finally {
        LifecycleHelper.close(s);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessageFactory(com.adaptris.core.AdaptrisMessageFactory) MockEncoder(com.adaptris.core.stubs.MockEncoder) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) Test(org.junit.Test)

Aggregations

DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)170 Test (org.junit.Test)163 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)158 Channel (com.adaptris.core.Channel)37 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)30 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)30 StandaloneProducer (com.adaptris.core.StandaloneProducer)27 ServiceException (com.adaptris.core.ServiceException)26 File (java.io.File)26 ServiceList (com.adaptris.core.ServiceList)18 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)18 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)18 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)18 GuidGenerator (com.adaptris.util.GuidGenerator)18 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)15 ValidationStage (com.adaptris.transform.validate.ValidationStage)15 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)12 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10