use of com.adaptris.core.http.MetadataContentTypeProvider in project interlok by adaptris.
the class StandardHttpProducerTest method testRequest_MetadataResponseHeaders.
@Test
public void testRequest_MetadataResponseHeaders() 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 ResponseHeadersAsMetadata("", "|"));
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);
}
assertEquals(1, mock.messageCount());
AdaptrisMessage m2 = mock.getMessages().get(0);
assertTrue(m2.headersContainsKey("Content-Type"));
assertEquals("text/complicated", m2.getMetadataValue("Content-Type"));
assertTrue(msg.headersContainsKey("Server"));
}
use of com.adaptris.core.http.MetadataContentTypeProvider in project interlok by adaptris.
the class StandardHttpProducerTest method testRequest_CompositeMetadataResponseHeaders.
@Test
public void testRequest_CompositeMetadataResponseHeaders() 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 CompositeResponseHeaderHandler(new ResponseHeadersAsMetadata(), 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);
}
assertTrue(msg.headersContainsKey("Server"));
assertTrue(msg.getObjectHeaders().containsKey("Server"));
}
use of com.adaptris.core.http.MetadataContentTypeProvider in project interlok by adaptris.
the class StandardHttpProducerTest method testProduceWithContentTypeMetadata.
@Test
public void testProduceWithContentTypeMetadata() 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));
StandaloneProducer producer = new StandaloneProducer(stdHttp);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
msg.addMetadata(HttpHelper.CONTENT_TYPE, "text/complicated");
try {
c.requestStart();
start(producer);
producer.produce(msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(c);
stop(producer);
}
assertEquals(1, mock.messageCount());
AdaptrisMessage m2 = mock.getMessages().get(0);
assertTrue(m2.headersContainsKey("Content-Type"));
assertEquals("text/complicated", m2.getMetadataValue("Content-Type"));
}
Aggregations