use of com.adaptris.core.http.MetadataContentTypeProvider in project interlok by adaptris.
the class StandardHttpProducerTest method testRequest_ObjectMetadataResponseHeaders.
@Test
public void testRequest_ObjectMetadataResponseHeaders() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
Channel c = HttpHelper.createAndStartChannel(mock);
StandardHttpProducer stdHttp = new StandardHttpProducer().withURL(HttpHelper.createURL(c));
stdHttp.setContentTypeProvider(new MetadataContentTypeProvider(HttpHelper.CONTENT_TYPE));
stdHttp.setResponseHeaderHandler(new ResponseHeadersAsObjectMetadata());
StandaloneRequestor producer = new StandaloneRequestor(stdHttp);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
msg.addMetadata(HttpHelper.CONTENT_TYPE, "text/complicated");
assertFalse(msg.headersContainsKey("Server"));
try {
c.requestStart();
start(producer);
producer.doService(msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(c);
stop(producer);
}
assertFalse(msg.headersContainsKey("Server"));
assertTrue(msg.getObjectHeaders().containsKey("Server"));
}
use of com.adaptris.core.http.MetadataContentTypeProvider in project interlok by adaptris.
the class StandardResponseProducerTest method createRequestor.
protected static StandaloneRequestor createRequestor(int port) {
StandardHttpProducer producer = new StandardHttpProducer().withURL(createURL(port));
producer.setContentTypeProvider(new MetadataContentTypeProvider(CONTENT_TYPE));
producer.setResponseHeaderHandler(new ResponseHeadersAsMetadata());
return new StandaloneRequestor(producer);
}
use of com.adaptris.core.http.MetadataContentTypeProvider in project interlok by adaptris.
the class StandardResponseProducerTest method testResponse_MetadataContentType.
@Test
public void testResponse_MetadataContentType() throws Exception {
StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
responder.setContentTypeProvider(new MetadataContentTypeProvider("MyContentType"));
AddMetadataService addMetadata = new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement("MyContentType", "text/xml") }));
HttpConnection httpConnection = createConnection();
Channel c = createChannel(httpConnection, createWorkflow(createConsumer(URL_TO_POST_TO), new MockMessageProducer(), new ServiceList(new Service[] { addMetadata, new StandaloneProducer(responder) })));
StandaloneRequestor requestor = createRequestor(httpConnection.getPort());
AdaptrisMessage msg = createMessage();
try {
c.requestStart();
start(requestor);
requestor.doService(msg);
assertEquals(TEXT, msg.getContent());
assertTrue(msg.containsKey("Content-Type"));
assertTrue(msg.getMetadataValue("Content-Type").startsWith("text/xml"));
} finally {
c.requestClose();
stop(requestor);
PortManager.release(httpConnection.getPort());
}
}
use of com.adaptris.core.http.MetadataContentTypeProvider in project interlok by adaptris.
the class StandardResponseProducerTest method testResponse_MetadataContentType_MissingMetadata.
@Test
public void testResponse_MetadataContentType_MissingMetadata() throws Exception {
StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
responder.setContentTypeProvider(new MetadataContentTypeProvider("MyContentType"));
HttpConnection httpConnection = createConnection();
Channel c = createChannel(httpConnection, createWorkflow(createConsumer(URL_TO_POST_TO), new MockMessageProducer(), new ServiceList(new Service[] { new StandaloneProducer(responder) })));
StandaloneRequestor requestor = createRequestor(httpConnection.getPort());
AdaptrisMessage msg = createMessage();
try {
c.requestStart();
start(requestor);
requestor.doService(msg);
assertEquals(TEXT, msg.getContent());
} finally {
c.requestClose();
stop(requestor);
PortManager.release(httpConnection.getPort());
}
}
use of com.adaptris.core.http.MetadataContentTypeProvider in project interlok by adaptris.
the class EmbeddedHttpConsumerTest method createProducer.
protected StandardHttpProducer createProducer() {
StandardHttpProducer p = new StandardHttpProducer();
p.setContentTypeProvider(new MetadataContentTypeProvider("content.type"));
p.setUrl("dummy_url");
p.setIgnoreServerResponseCode(true);
p.registerConnection(new NullConnection());
return p;
}
Aggregations