use of com.adaptris.core.Channel in project interlok by adaptris.
the class HttpRequestServiceTest method testRequest_ObjectMetadataResponseHeaders.
@Test
public void testRequest_ObjectMetadataResponseHeaders() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
Channel c = HttpHelper.createAndStartChannel(mock);
HttpRequestService service = new HttpRequestService(HttpHelper.createProduceDestination(c)).withContentType("%message{" + HttpHelper.CONTENT_TYPE + "}").withResponseHeaderHandler(new ResponseHeadersAsObjectMetadata());
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
msg.addMetadata(HttpHelper.CONTENT_TYPE, "text/complicated");
assertFalse(msg.headersContainsKey("Server"));
try {
c.requestStart();
execute(service, msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(c);
}
assertFalse(msg.headersContainsKey("Server"));
assertTrue(msg.getObjectHeaders().containsKey("Server"));
}
use of com.adaptris.core.Channel 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.Channel in project interlok by adaptris.
the class MetadataRequestHeadersTest method testAddHeaders.
@Test
public void testAddHeaders() throws Exception {
Channel c = null;
HttpURLConnection urlC = null;
try {
c = HttpHelper.createAndStartChannel();
URL url = new URL(HttpHelper.createProduceDestination(c));
urlC = (HttpURLConnection) url.openConnection();
MetadataRequestHeaders headers = new MetadataRequestHeaders();
headers.setFilter(new RegexMetadataFilter());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("");
String name = testName.getMethodName();
msg.addMetadata(name, name);
urlC = headers.addHeaders(msg, urlC);
assertTrue(contains(urlC, name, name));
} finally {
HttpHelper.stopChannelAndRelease(c);
}
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class MetadataRequestHeadersTest method testAddHeaders_Flatten.
@Test
public void testAddHeaders_Flatten() throws Exception {
Channel c = null;
HttpURLConnection urlC = null;
try {
c = HttpHelper.createAndStartChannel();
URL url = new URL(HttpHelper.createProduceDestination(c));
urlC = (HttpURLConnection) url.openConnection();
MetadataRequestHeaders headers = new MetadataRequestHeaders();
headers.setUnfold(true);
headers.setFilter(new RegexMetadataFilter());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("");
String name = testName.getMethodName();
msg.addMetadata(name, name + "\r\n " + name);
urlC = headers.addHeaders(msg, urlC);
assertTrue(contains(urlC, name, name + " " + name));
} finally {
HttpHelper.stopChannelAndRelease(c);
}
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class JettyNoBacklogInterceptorTest method retrieveObjectForSampleConfig.
@Override
protected Channel retrieveObjectForSampleConfig() {
Channel c = new Channel();
PoolingWorkflow wf = new PoolingWorkflow();
wf.addInterceptor(new JettyPoolingWorkflowInterceptor());
wf.addInterceptor(new JettyNoBacklogInterceptor());
c.setUniqueId(UUID.randomUUID().toString());
wf.setUniqueId(UUID.randomUUID().toString());
c.getWorkflowList().add(wf);
return c;
}
Aggregations