use of com.adaptris.core.http.client.MetadataRequestMethodProvider in project interlok by adaptris.
the class StandardHttpProducerTest method testProduce_WithMetadataMethod.
@Test
public void testProduce_WithMetadataMethod() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
HttpConnection jc = HttpHelper.createConnection();
JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
ServiceList sl = new ServiceList();
PayloadFromTemplateService pms = new PayloadFromTemplateService().withTemplate(TEXT);
sl.add(pms);
sl.add(new StandaloneProducer(new StandardResponseProducer(HttpStatus.OK_200)));
Channel c = createChannel(jc, createWorkflow(mc, mock, sl));
StandardWorkflow workflow = (StandardWorkflow) c.getWorkflowList().get(0);
StandardHttpProducer stdHttp = new StandardHttpProducer().withURL(HttpHelper.createURL(c));
stdHttp.setMethodProvider(new MetadataRequestMethodProvider("httpMethod"));
StandaloneRequestor producer = new StandaloneRequestor(stdHttp);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
msg.addMetadata("httpMethod", "get");
try {
start(c);
start(producer);
producer.doService(msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(c);
stop(producer);
}
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.client.MetadataRequestMethodProvider 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.http.client.MetadataRequestMethodProvider 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));
}
Aggregations