Search in sources :

Example 76 with DefaultMessageFactory

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

the class FileDataOutputParameterTest method testDestination.

@Test
public void testDestination() throws Exception {
    AdaptrisMessage m = new DefaultMessageFactory().newMessage();
    FileDataOutputParameter p = new FileDataOutputParameter();
    try {
        p.url(m);
        fail();
    } catch (IllegalArgumentException e) {
    // ok
    }
    p.setUrl("file:////tmp/abc");
    assertEquals("file:////tmp/abc", p.url(m));
    try {
        p.setUrl(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertEquals("file:////tmp/abc", p.url(m));
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 77 with DefaultMessageFactory

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

the class FileInputStreamDataInputParameterTest method testDestination.

@Test
public void testDestination() throws Exception {
    AdaptrisMessage m = new DefaultMessageFactory().newMessage();
    FileInputStreamDataInputParameter p = new FileInputStreamDataInputParameter();
    try {
        p.url(m);
        fail();
    } catch (IllegalArgumentException e) {
    // ok
    }
    p.setUrl("file:////tmp/abc");
    assertEquals("file:////tmp/abc", p.url(m));
    try {
        p.setUrl(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertEquals("file:////tmp/abc", p.url(m));
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 78 with DefaultMessageFactory

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

the class BranchingHttpRequestServiceTest method testService_DefaultServiceId.

@Test
public void testService_DefaultServiceId() throws Exception {
    MockMessageProducer mock = new MockMessageProducer();
    Channel c = HttpHelper.createAndStartChannel(mock);
    BranchingHttpRequestService service = new BranchingHttpRequestService().withDefaultServiceId("DefaultServiceId").withUrl(HttpHelper.createProduceDestination(c)).withContentType("text/complicated");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
    try {
        c.requestStart();
        execute(service, msg);
        waitForMessages(mock, 1);
    } finally {
        HttpHelper.stopChannelAndRelease(c);
    }
    assertEquals(1, mock.messageCount());
    assertEquals("DefaultServiceId", msg.getNextServiceId());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Channel(com.adaptris.core.Channel) Test(org.junit.Test)

Example 79 with DefaultMessageFactory

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

the class BranchingHttpRequestServiceTest method testService_ExactMatch_WithError.

@Test
public void testService_ExactMatch_WithError() throws Exception {
    MockMessageProducer mock = new MockMessageProducer();
    Channel c = HttpHelper.createAndStartChannel(mock, "This is the reply body", HttpStatus.INTERNAL_ERROR_500);
    BranchingHttpRequestService service = new BranchingHttpRequestService(HttpHelper.createProduceDestination(c)).withDefaultServiceId("DefaultServiceId").withStatusMatches(new ExactMatch(500, "500 Server Error"), new ExactMatch(200, "200 OK")).withContentType("text/complicated");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
    try {
        c.requestStart();
        execute(service, msg);
        waitForMessages(mock, 1);
        assertEquals("This is the reply body", msg.getContent());
    } finally {
        HttpHelper.stopChannelAndRelease(c);
    }
    assertEquals(1, mock.messageCount());
    assertEquals("500 Server Error", msg.getNextServiceId());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ExactMatch(com.adaptris.core.http.client.ExactMatch) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Channel(com.adaptris.core.Channel) Test(org.junit.Test)

Example 80 with DefaultMessageFactory

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

the class HttpRequestServiceTest method testService_MetadataRequestHeaders.

@Test
public void testService_MetadataRequestHeaders() throws Exception {
    MockMessageProducer mock = new MockMessageProducer();
    Channel c = HttpHelper.createAndStartChannel(mock);
    HttpRequestService service = new HttpRequestService().withUrl(HttpHelper.createProduceDestination(c)).withRequestHeaderProvider(new MetadataRequestHeaders(new RegexMetadataFilter()));
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
    msg.addMetadata(getName(), getName());
    try {
        c.requestStart();
        execute(service, msg);
        waitForMessages(mock, 1);
    } finally {
        HttpHelper.stopChannelAndRelease(c);
    }
    assertEquals(1, mock.messageCount());
    AdaptrisMessage m2 = mock.getMessages().get(0);
    assertTrue(m2.headersContainsKey(getName()));
    assertEquals(getName(), m2.getMetadataValue(getName()));
}
Also used : RegexMetadataFilter(com.adaptris.core.metadata.RegexMetadataFilter) DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) Test(org.junit.Test) HttpConsumerTest(com.adaptris.core.http.jetty.HttpConsumerTest)

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