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));
}
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));
}
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());
}
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());
}
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()));
}
Aggregations