use of org.apache.camel.component.jetty.JettyHttpComponent in project camel by apache.
the class AhcProduceJavaBodyTest method testNotAllowed.
@Test
public void testNotAllowed() throws Exception {
JettyHttpComponent jetty = context.getComponent("jetty", JettyHttpComponent.class);
jetty.setAllowJavaSerializedObject(false);
AhcComponent ahc = context.getComponent("ahc", AhcComponent.class);
ahc.setAllowJavaSerializedObject(false);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from(getTestServerEndpointUri()).process(new Processor() {
public void process(Exchange exchange) throws Exception {
String body = exchange.getIn().getBody(String.class);
assertNotNull(body);
assertEquals("Hello World", body);
MyCoolBean reply = new MyCoolBean(456, "Camel rocks");
exchange.getOut().setBody(reply);
exchange.getOut().setHeader(Exchange.CONTENT_TYPE, AhcConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
}
});
}
});
context.start();
MyCoolBean cool = new MyCoolBean(123, "Camel");
try {
template.requestBodyAndHeader(getAhcEndpointUri(), cool, Exchange.CONTENT_TYPE, AhcConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, MyCoolBean.class);
fail("Should fail");
} catch (Exception e) {
assertTrue(e.getCause().getMessage().startsWith("Content-type application/x-java-serialized-object is not allowed"));
}
}
use of org.apache.camel.component.jetty.JettyHttpComponent in project camel by apache.
the class JettyHttpsProducerSslContextInUriTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws URISyntaxException {
JettyHttpComponent componentJetty = (JettyHttpComponent) context.getComponent("jetty");
componentJetty.setSslPassword(pwd);
componentJetty.setSslKeyPassword(pwd);
URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
componentJetty.setKeystore(keyStoreUrl.toURI().getPath());
from("jetty:https://localhost:" + port1 + "/test?sslContextParametersRef=sslContextParameters").to("mock:a");
Processor proc = new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody("<b>Hello World</b>");
}
};
from("jetty:https://localhost:" + port1 + "/hello?sslContextParametersRef=sslContextParameters").process(proc);
from("jetty:https://localhost:" + port2 + "/test?sslContextParametersRef=sslContextParameters").to("mock:b");
}
};
}
Aggregations