use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class HttpRequestServiceTest method testRequest_GetMethod_NonZeroBytes.
@Test
public void testRequest_GetMethod_NonZeroBytes() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
HttpConnection jc = HttpHelper.createConnection();
JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new PayloadFromTemplateService().withTemplate(TEXT), new StandaloneProducer(new StandardResponseProducer(HttpStatus.OK_200)) })));
HttpRequestService service = new HttpRequestService(HttpHelper.createProduceDestination(c)).withMethod("GET");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("Hello World");
try {
start(c);
execute(service, msg);
waitForMessages(mock, 1);
} finally {
stop(c);
}
assertEquals(1, mock.messageCount());
AdaptrisMessage m2 = mock.getMessages().get(0);
assertEquals("GET", m2.getMetadataValue(CoreConstants.HTTP_METHOD));
assertEquals(TEXT, msg.getContent());
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class MetadataRequestMethodProviderTest method testDefaultMethod.
@Test
public void testDefaultMethod() {
MetadataRequestMethodProvider prov = new MetadataRequestMethodProvider("httpMethod");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
assertEquals(RequestMethod.POST, prov.getMethod(msg));
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class MetadataRequestMethodProviderTest method testGetMethod_WithMetadata.
@Test
public void testGetMethod_WithMetadata() {
MetadataRequestMethodProvider prov = new MetadataRequestMethodProvider("httpMethod");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
msg.addMetadata("httpMethod", "GET");
assertEquals(RequestMethod.GET, prov.getMethod(msg));
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class MetadataStatusProviderTest method testGetStatus_MissingMetadata_WithText.
@Test
public void testGetStatus_MissingMetadata_WithText() {
MetadataStatusProvider prov = new MetadataStatusProvider("httpStatus", "httpStatusText");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
msg.addMetadata("httpStatusText", "Really Not OK");
assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, prov.getStatus(msg).getCode());
assertNotSame("Internal Server Error", prov.getStatus(msg).getText());
assertEquals("Really Not OK", prov.getStatus(msg).getText());
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class MetadataStatusProviderTest method testGetStatus_WithMetadata.
@Test
public void testGetStatus_WithMetadata() {
MetadataStatusProvider prov = new MetadataStatusProvider("httpStatus");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
msg.addMetadata("httpStatus", "200");
assertEquals(HttpURLConnection.HTTP_OK, prov.getStatus(msg).getCode());
assertEquals("OK", prov.getStatus(msg).getText());
}
Aggregations