use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class NettySSLClasspathTest method testSSLInOutWithNettyConsumer.
@Test
public void testSSLInOutWithNettyConsumer() throws Exception {
// ibm jdks dont have sun security algorithms
if (isJavaVendor("ibm")) {
return;
}
context.addRoutes(new RouteBuilder() {
public void configure() {
from("netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreResource=classpath:keystore.jks&trustStoreResource=classpath:keystore.jks").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.");
}
});
}
});
context.start();
String response = template.requestBody("netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreResource=classpath:keystore.jks&trustStoreResource=classpath:keystore.jks", "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
}
use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class NettySSLContextParametersTest method testSSLInOutWithNettyConsumer.
@Test
public void testSSLInOutWithNettyConsumer() throws Exception {
// ibm jdks dont have sun security algorithms
if (isJavaVendor("ibm")) {
return;
}
context.addRoutes(new RouteBuilder() {
public void configure() {
from("netty:tcp://localhost:{{port}}?sync=true&ssl=true&sslContextParameters=#sslContextParameters").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.");
}
});
}
});
context.start();
String response = template.requestBody("netty:tcp://localhost:{{port}}?sync=true&ssl=true&sslContextParameters=#sslContextParameters", "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
}
use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class NettySSLPassphaseBeanTest method testPassphaseBean.
@Test
public void testPassphaseBean() throws Exception {
// ibm jdks dont have sun security algorithms
if (isJavaVendor("ibm")) {
return;
}
context.addRoutes(new RouteBuilder() {
public void configure() {
from("netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=#myBean&keyStoreResource=classpath:keystore.jks&trustStoreResource=classpath:keystore.jks").process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.");
}
});
}
});
context.start();
String response = template.requestBody("netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=#myBean&keyStoreResource=classpath:keystore.jks&trustStoreResource=classpath:keystore.jks", "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
}
use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class NettyTextlineInOutSynchronousTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("log:before").process(new Processor() {
public void process(Exchange exchange) throws Exception {
beforeThreadName = Thread.currentThread().getName();
}
}).to("netty:tcp://localhost:{{port}}?textline=true&sync=true&synchronous=true").process(new Processor() {
public void process(Exchange exchange) throws Exception {
afterThreadName = Thread.currentThread().getName();
}
}).to("log:after").to("mock:result");
from("netty:tcp://localhost:{{port}}?textline=true&sync=true&synchronous=true").validate(body().isInstanceOf(String.class)).transform(body().regexReplaceAll("Hello", "Bye"));
}
};
}
use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class NettyReuseChannelTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("netty4:tcp://localhost:{{port}}?textline=true&sync=true&reuseChannel=true&disconnect=true").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Channel channel = exchange.getProperty(NettyConstants.NETTY_CHANNEL, Channel.class);
channels.add(channel);
assertTrue("Should be active", channel.isActive());
}
}).to("mock:a").to("netty4:tcp://localhost:{{port}}?textline=true&sync=true&reuseChannel=true&disconnect=true").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Channel channel = exchange.getProperty(NettyConstants.NETTY_CHANNEL, Channel.class);
channels.add(channel);
assertTrue("Should be active", channel.isActive());
}
}).to("mock:b");
from("netty4:tcp://localhost:{{port}}?textline=true&sync=true").transform(body().prepend("Hello ")).to("mock:result");
}
};
}
Aggregations