use of com.adaptris.core.http.jetty.StandardResponseProducer in project interlok by adaptris.
the class HttpRequestServiceTest method testRequest_GetMethod_ZeroBytes.
@Test
public void testRequest_GetMethod_ZeroBytes() 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();
try {
start(c);
execute(service, msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(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.http.jetty.StandardResponseProducer in project interlok by adaptris.
the class HttpHelper method createAndStartChannel.
public static Channel createAndStartChannel(MockMessageProducer mock, String replyPayload, HttpStatusProvider.HttpStatus status) throws Exception {
JettyMessageConsumer mc = createConsumer(URL_TO_POST_TO);
mc.setHeaderHandler(new MetadataHeaderHandler());
HttpConnection jc = createConnection();
Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new PayloadFromTemplateService().withTemplate(replyPayload), new StandaloneProducer(new StandardResponseProducer(status)) })));
start(c);
return c;
}
use of com.adaptris.core.http.jetty.StandardResponseProducer 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.http.jetty.StandardResponseProducer in project interlok by adaptris.
the class HttpHelper method createAndStartChannel.
public static Channel createAndStartChannel(MockMessageProducer mock, HttpStatusProvider.HttpStatus status) throws Exception {
JettyMessageConsumer mc = createConsumer(URL_TO_POST_TO);
mc.setHeaderHandler(new MetadataHeaderHandler());
HttpConnection jc = createConnection();
Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new StandaloneProducer(new StandardResponseProducer(status)) })));
start(c);
return c;
}
use of com.adaptris.core.http.jetty.StandardResponseProducer in project interlok by adaptris.
the class HttpRequestServiceTest method testRequest_EmptyReply.
@Test
public void testRequest_EmptyReply() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
HttpConnection jc = HttpHelper.createConnection();
JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
responder.setSendPayload(false);
Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new StandaloneProducer(responder) })));
HttpRequestService service = new HttpRequestService(HttpHelper.createProduceDestination(c)).withMethod("POST");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
try {
start(c);
execute(service, msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(c);
}
assertEquals(1, mock.messageCount());
AdaptrisMessage m2 = mock.getMessages().get(0);
assertEquals("POST", m2.getMetadataValue(CoreConstants.HTTP_METHOD));
assertEquals(0, msg.getSize());
}
Aggregations