use of org.apache.camel.Processor in project camel by apache.
the class JettyRecipientListCxfIssueTest method testJettyRecipientListCxf.
@Test
public void testJettyRecipientListCxf() throws Exception {
final String request = context().getTypeConverter().convertTo(String.class, new File("src/test/resources/greetMe.xml"));
assertNotNull(request);
// send a message to jetty
Exchange out = template.request("jetty:http://0.0.0.0:{{RecipientListCxfTest.port3}}/myapp", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader("operationName", "greetMe");
exchange.getIn().setBody(request);
}
});
assertNotNull(out);
assertTrue("Should have out", out.hasOut());
String body = out.getOut().getBody(String.class);
log.info("Reply from jetty call:\n{}", body);
// we get the last reply as response
assertNotNull(body);
assertTrue("Should have Bye Camel", body.contains("Bye Camel"));
}
use of org.apache.camel.Processor in project camel by apache.
the class HttpRouteContentLengthTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
port1 = AvailablePortFinder.getNextAvailable(8000);
port2 = AvailablePortFinder.getNextAvailable(9000);
// use jetty as server as it supports sending response as chunked encoding
from("jetty:http://localhost:" + port1 + "/test").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String contentLength = exchange.getIn().getHeader(Exchange.CONTENT_LENGTH, String.class);
String request = exchange.getIn().getBody(String.class);
exchange.getOut().setBody(request + ": " + contentLength);
}
}).transform().simple("Bye ${body}");
// set up a netty http proxy
from("jetty:http://localhost:" + port2 + "/test").to(getHttpEndpointScheme() + port1 + "/test?bridgeEndpoint=true&throwExceptionOnFailure=false");
}
};
}
use of org.apache.camel.Processor in project camel by apache.
the class HttpRouteContentLengthTest method invokeService.
private void invokeService(int port) {
Exchange out = template.request("http://localhost:" + port + "/test", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("Camel request.");
}
});
assertNotNull(out);
assertEquals("Bye Camel request.: 14", out.getOut().getBody(String.class));
}
use of org.apache.camel.Processor in project camel by apache.
the class JettyHttpFileCacheTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("jetty:http://localhost:8201/clipboard/download?chunked=true&matchOnUriPrefix=true").to("http://localhost:9101?bridgeEndpoint=true");
from("jetty:http://localhost:9101?chunked=true&matchOnUriPrefix=true").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody(TEST_STRING);
}
});
}
};
}
use of org.apache.camel.Processor in project camel by apache.
the class JettyHttpTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from(targetConsumerUri).process(new Processor() {
public void process(Exchange exchange) throws Exception {
String path = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
exchange.getOut().setBody("Hi! " + path);
}
});
from(sourceUri).to(targetProducerUri);
from("direct:root").to(sourceProducerUri).to("mock:result");
from("direct:relative").to(sourceProducerUri + "/relative").to("mock:result");
}
};
}
Aggregations