Search in sources :

Example 36 with RouteBuilder

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);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 37 with RouteBuilder

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);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 38 with RouteBuilder

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);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 39 with RouteBuilder

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"));
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 40 with RouteBuilder

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");
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Channel(io.netty.channel.Channel)

Aggregations

RouteBuilder (org.apache.camel.builder.RouteBuilder)1759 Exchange (org.apache.camel.Exchange)628 Processor (org.apache.camel.Processor)545 Test (org.junit.Test)476 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)341 CamelExecutionException (org.apache.camel.CamelExecutionException)135 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)119 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)104 File (java.io.File)68 CamelContext (org.apache.camel.CamelContext)64 IOException (java.io.IOException)61 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)42 HashMap (java.util.HashMap)35 Path (org.apache.hadoop.fs.Path)34 CountDownLatch (java.util.concurrent.CountDownLatch)32 Configuration (org.apache.hadoop.conf.Configuration)32 Endpoint (org.apache.camel.Endpoint)30 ArrayFile (org.apache.hadoop.io.ArrayFile)30 SequenceFile (org.apache.hadoop.io.SequenceFile)30 RuntimeCamelException (org.apache.camel.RuntimeCamelException)26