camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dval...@apache.org
Subject svn commit: r1295633 - in /camel/trunk/components: camel-mail/src/main/java/org/apache/camel/component/mail/ camel-mina2/src/main/java/org/apache/camel/component/mina2/ camel-mina2/src/test/java/org/apache/camel/component/mina2/ camel-mina2/src/test/re...
Date Thu, 01 Mar 2012 15:50:20 GMT
Author: dvaleri
Date: Thu Mar  1 15:50:19 2012
New Revision: 1295633

URL: http://svn.apache.org/viewvc?rev=1295633&view=rev
Log:
[CAMEL-5037] Added support for JSSE Confoguration Utility to Mina 2 component.

Added:
    camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslConextParametersUdpTest.java
  (with props)
    camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersTcpTest.java
  (with props)
    camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersVmTest.java
  (with props)
    camel/trunk/components/camel-mina2/src/test/resources/jsse/
    camel/trunk/components/camel-mina2/src/test/resources/jsse/localhost.ks
Modified:
    camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
    camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java
    camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
    camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java
    camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java
    camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java

Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java?rev=1295633&r1=1295632&r2=1295633&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
(original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
Thu Mar  1 15:50:19 2012
@@ -22,8 +22,10 @@ import java.util.Map;
 import java.util.Properties;
 import javax.mail.Message;
 import javax.mail.Session;
+import javax.net.ssl.SSLContext;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.jsse.SSLContextParameters;
 
 /**
  * Represents the configuration data for communicating over email
@@ -59,6 +61,7 @@ public class MailConfiguration implement
     private boolean useInlineAttachments;
     private boolean ignoreUnsupportedCharset;
     private boolean disconnect;
+    private SSLContextParameters sslContextParameters;
 
     public MailConfiguration() {
     }
@@ -170,6 +173,15 @@ public class MailConfiguration implement
             properties.put("javax.net.debug", "all");
         }
 
+        if (sslContextParameters != null && isSecureProtocol()) {
+            SSLContext sslContext;
+            try {
+                sslContext = sslContextParameters.createSSLContext();
+            } catch (Exception e) {
+                throw new RuntimeCamelException("Error initializing SSLContext.", e);
+            }
+            properties.put("mail." + protocol + ".socketFactory", sslContext.getSocketFactory());
+        }
         if (dummyTrustManager && isSecureProtocol()) {
             // set the custom SSL properties
             properties.put("mail." + protocol + ".socketFactory.class", "org.apache.camel.component.mail.security.DummySSLSocketFactory");
@@ -453,4 +465,12 @@ public class MailConfiguration implement
     public void setDisconnect(boolean disconnect) {
         this.disconnect = disconnect;
     }
+    
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 }

Modified: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java?rev=1295633&r1=1295632&r2=1295633&view=diff
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java
(original)
+++ camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java
Thu Mar  1 15:50:19 2012
@@ -21,6 +21,7 @@ import java.util.List;
 
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.jsse.SSLContextParameters;
 import org.apache.mina.core.filterchain.IoFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 
@@ -48,6 +49,8 @@ public class Mina2Configuration implemen
     private boolean disconnect;
     private boolean disconnectOnNoReply = true;
     private LoggingLevel noReplyLogLevel = LoggingLevel.WARN;
+    private SSLContextParameters sslContextParameters;
+    private boolean autoStartTls = true;
 
     /**
      * Returns a copy of this configuration
@@ -226,4 +229,20 @@ public class Mina2Configuration implemen
     public void setNoReplyLogLevel(LoggingLevel noReplyLogLevel) {
         this.noReplyLogLevel = noReplyLogLevel;
     }
+
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
+
+    public boolean isAutoStartTls() {
+        return autoStartTls;
+    }
+
+    public void setAutoStartTls(boolean autoStartTls) {
+        this.autoStartTls = autoStartTls;
+    }
 }

Modified: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java?rev=1295633&r1=1295632&r2=1295633&view=diff
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
(original)
+++ camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
Thu Mar  1 15:50:19 2012
@@ -40,6 +40,7 @@ import org.apache.mina.filter.codec.seri
 import org.apache.mina.filter.codec.textline.LineDelimiter;
 import org.apache.mina.filter.executor.ExecutorFilter;
 import org.apache.mina.filter.logging.LoggingFilter;
+import org.apache.mina.filter.ssl.SslFilter;
 import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
 import org.apache.mina.transport.socket.nio.NioProcessor;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
@@ -60,7 +61,7 @@ public class Mina2Consumer extends Defau
     private IoAcceptor acceptor;
     private Mina2Configuration configuration;
 
-    public Mina2Consumer(final Mina2Endpoint endpoint, Processor processor) {
+    public Mina2Consumer(final Mina2Endpoint endpoint, Processor processor) throws Exception
{
         super(endpoint, processor);
         this.configuration = endpoint.getConfiguration();
         //
@@ -111,9 +112,13 @@ public class Mina2Consumer extends Defau
             acceptor.getFilterChain().addLast("logger", new LoggingFilter());
         }
         appendIoFiltersToChain(filters, acceptor.getFilterChain());
+        if (configuration.getSslContextParameters() != null) {
+            LOG.warn("Using vm protocol"
+                     + ", but an SSLContextParameters instance was provided.  SSLContextParameters
is only supported on the TCP protocol.");
+        }
     }
 
-    protected void createSocketEndpoint(String uri, Mina2Configuration configuration) {
+    protected void createSocketEndpoint(String uri, Mina2Configuration configuration) throws
Exception {
         LOG.debug("createSocketEndpoint");
         boolean minaLogger = configuration.isMinaLogger();
         List<IoFilter> filters = configuration.getFilters();
@@ -133,6 +138,11 @@ public class Mina2Consumer extends Defau
             acceptor.getFilterChain().addLast("logger", new LoggingFilter());
         }
         appendIoFiltersToChain(filters, acceptor.getFilterChain());
+        if (configuration.getSslContextParameters() != null) {
+            SslFilter filter = new SslFilter(configuration.getSslContextParameters().createSSLContext(),
configuration.isAutoStartTls());
+            filter.setUseClientMode(true);
+            acceptor.getFilterChain().addFirst("sslFilter", filter);
+        }
     }
 
     protected void configureCodecFactory(String type, IoService service, Mina2Configuration
configuration) {
@@ -186,6 +196,10 @@ public class Mina2Consumer extends Defau
             acceptor.getFilterChain().addLast("logger", new LoggingFilter());
         }
         appendIoFiltersToChain(filters, acceptor.getFilterChain());
+        if (configuration.getSslContextParameters() != null) {
+            LOG.warn("Using datagram protocol, " + configuration.getProtocol()
+                     + ", but an SSLContextParameters instance was provided.  SSLContextParameters
is only supported on the TCP protocol.");
+        }
     }
 
     /**

Modified: camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java?rev=1295633&r1=1295632&r2=1295633&view=diff
==============================================================================
--- camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java
(original)
+++ camel/trunk/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java
Thu Mar  1 15:50:19 2012
@@ -47,6 +47,7 @@ import org.apache.mina.filter.codec.seri
 import org.apache.mina.filter.codec.textline.LineDelimiter;
 import org.apache.mina.filter.executor.ExecutorFilter;
 import org.apache.mina.filter.logging.LoggingFilter;
+import org.apache.mina.filter.ssl.SslFilter;
 import org.apache.mina.transport.socket.nio.NioDatagramConnector;
 import org.apache.mina.transport.socket.nio.NioProcessor;
 import org.apache.mina.transport.socket.nio.NioSocketConnector;
@@ -74,7 +75,7 @@ public class Mina2Producer extends Defau
     private Mina2Configuration configuration;
     private IoSessionConfig connectorConfig;
 
-    public Mina2Producer(Mina2Endpoint endpoint) {
+    public Mina2Producer(Mina2Endpoint endpoint) throws Exception {
         super(endpoint);
         configuration = endpoint.getConfiguration();
         this.lazySessionCreation = configuration.isLazySessionCreation();
@@ -259,6 +260,10 @@ public class Mina2Producer extends Defau
             connector.getFilterChain().addLast("logger", new LoggingFilter());
         }
         appendIoFiltersToChain(filters, connector.getFilterChain());
+        if (configuration.getSslContextParameters() != null) {
+            LOG.warn("Using vm protocol"
+                     + ", but an SSLContextParameters instance was provided.  SSLContextParameters
is only supported on the TCP protocol.");
+        }
         configureCodecFactory("Mina2Producer", connector);
 
         // set sync or async mode after endpoint is created
@@ -269,7 +274,7 @@ public class Mina2Producer extends Defau
         }
     }
 
-    protected void createSocketEndpoint(String uri) {
+    protected void createSocketEndpoint(String uri) throws Exception {
         LOG.debug("createSocketEndpoint");
         boolean minaLogger = configuration.isMinaLogger();
         long timeout = configuration.getTimeout();
@@ -288,6 +293,9 @@ public class Mina2Producer extends Defau
             connector.getFilterChain().addLast("logger", new LoggingFilter());
         }
         appendIoFiltersToChain(filters, connector.getFilterChain());
+        if (configuration.getSslContextParameters() != null) {
+            connector.getFilterChain().addFirst("sslFilter", new SslFilter(configuration.getSslContextParameters().createSSLContext(),
configuration.isAutoStartTls()));
+        }
         configureCodecFactory("Mina2Producer", connector);
         // set connect timeout to mina in seconds
         connector.setConnectTimeoutMillis(timeout);
@@ -354,6 +362,10 @@ public class Mina2Producer extends Defau
             connector.getFilterChain().addLast("logger", new LoggingFilter());
         }
         appendIoFiltersToChain(filters, connector.getFilterChain());
+        if (configuration.getSslContextParameters() != null) {
+            LOG.warn("Using datagram protocol, " + configuration.getProtocol()
+                     + ", but an SSLContextParameters instance was provided.  SSLContextParameters
is only supported on the TCP protocol.");
+        }
         configureDataGramCodecFactory("Mina2Producer", connector, configuration);
         // set connect timeout to mina in seconds
         connector.setConnectTimeoutMillis(timeout);

Modified: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java?rev=1295633&r1=1295632&r2=1295633&view=diff
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java
(original)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/BaseMina2Test.java
Thu Mar  1 15:50:19 2012
@@ -16,11 +16,20 @@
  */
 package org.apache.camel.component.mina2;
 
+import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.jsse.ClientAuthentication;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.camel.util.jsse.SSLContextServerParameters;
+import org.apache.camel.util.jsse.TrustManagersParameters;
 import org.junit.BeforeClass;
 
 public class BaseMina2Test extends CamelTestSupport {
+    
+    protected static final String KEY_STORE_PASSWORD = "changeit";
 
     private static volatile int port;
 
@@ -36,4 +45,44 @@ public class BaseMina2Test extends Camel
     protected int getPort() {
         return port;
     }
+    
+    protected boolean isUseSslContext() {
+        return false;
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry reg = super.createRegistry();
+        
+        if (isUseSslContext()) {
+            addSslContextParametersToRegistry(reg);
+        }
+        return reg;
+    }
+    
+    protected void addSslContextParametersToRegistry(JndiRegistry registry) {
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
+        ksp.setPassword(KEY_STORE_PASSWORD);
+
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setKeyPassword(KEY_STORE_PASSWORD);
+        kmp.setKeyStore(ksp);
+
+        TrustManagersParameters tmp = new TrustManagersParameters();
+        tmp.setKeyStore(ksp);
+
+        // NOTE: Needed since the client uses a loose trust configuration when no ssl context
+        // is provided.  We turn on client-auth to ensure that the tests onlt pass when
+        // the client is configured explicitly.
+        SSLContextServerParameters scsp = new SSLContextServerParameters();
+        scsp.setClientAuthentication(ClientAuthentication.REQUIRE.name());
+        
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        sslContextParameters.setKeyManagers(kmp);
+        sslContextParameters.setTrustManagers(tmp);
+        sslContextParameters.setServerParameters(scsp);
+
+        registry.bind("sslContextParameters", sslContextParameters);
+    }
 }

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslConextParametersUdpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslConextParametersUdpTest.java?rev=1295633&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslConextParametersUdpTest.java
(added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslConextParametersUdpTest.java
Thu Mar  1 15:50:19 2012
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mina2;
+
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class Mina2SslConextParametersUdpTest extends BaseMina2Test {
+
+    protected int messageCount = 3;
+
+    public Mina2SslConextParametersUdpTest() {
+    }
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+        endpoint.expectedBodiesReceived("Hello Message: 0", "Hello Message: 1", "Hello Message:
2");
+
+        sendUdpMessages();
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected void sendUdpMessages() throws Exception {
+        DatagramSocket socket = new DatagramSocket();
+        try {
+            InetAddress address = InetAddress.getByName("127.0.0.1");
+            for (int i = 0; i < messageCount; i++) {
+                String text = "Hello Message: " + Integer.toString(i);
+                byte[] data = text.getBytes();
+
+                //DatagramPacket packet = new DatagramPacket(data, data.length, address,
getPort());
+                DatagramPacket packet = new DatagramPacket(data, data.length, address, 10111);
+                socket.send(packet);
+            }
+            Thread.sleep(2000);
+        } finally {
+            socket.close();
+        }
+    }
+    
+    @Override
+    protected boolean isUseSslContext() {
+        return true;
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            public void configure() {
+                from("mina2:udp://127.0.0.1:10111?sync=false&minaLogger=true&sslContextParameters=#sslContextParameters").to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslConextParametersUdpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersTcpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersTcpTest.java?rev=1295633&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersTcpTest.java
(added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersTcpTest.java
Thu Mar  1 15:50:19 2012
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mina2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class Mina2SslContextParametersTcpTest extends BaseMina2Test {
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+        Object body = "Hello there!";
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBodyAndHeader(String.format("mina2:tcp://localhost:%1$s?sync=false&minaLogger=true&sslContextParameters=#sslContextParameters",
getPort()), body, "cheese",
+                                   123);
+
+        assertMockEndpointsSatisfied();
+    }
+    
+    @Override
+    protected boolean isUseSslContext() {
+        return true;
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            public void configure() {
+                from(String.format("mina2:tcp://localhost:%1$s?sync=false&minaLogger=true&sslContextParameters=#sslContextParameters",
getPort())).to("log:before?showAll=true")
+                        .to("mock:result").to("log:after?showAll=true");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersTcpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersVmTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersVmTest.java?rev=1295633&view=auto
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersVmTest.java
(added)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersVmTest.java
Thu Mar  1 15:50:19 2012
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mina2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class Mina2SslContextParametersVmTest extends BaseMina2Test {
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:result");
+        Object body = "Hello there!";
+        endpoint.expectedBodiesReceived(body);
+
+        template.sendBodyAndHeader(String.format("mina2:vm://localhost:%1$s?sync=false&minaLogger=true&sslContextParameters=#sslContextParameters",
getPort()), body, "cheese", 123);
+
+        assertMockEndpointsSatisfied();
+    }
+    
+    @Override
+    protected boolean isUseSslContext() {
+        return true;
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            public void configure() {
+                from(String.format("mina2:vm://localhost:%1$s?sync=false&minaLogger=true&sslContextParameters=#sslContextParameters",
getPort())).to("log:before?showAll=true").to("mock:result")
+                        .to("log:after?showAll=true");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2SslContextParametersVmTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java?rev=1295633&r1=1295632&r2=1295633&view=diff
==============================================================================
--- camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java
(original)
+++ camel/trunk/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2UdpNoCamelTest.java
Thu Mar  1 15:50:19 2012
@@ -41,7 +41,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 /**
  *

Added: camel/trunk/components/camel-mina2/src/test/resources/jsse/localhost.ks
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mina2/src/test/resources/jsse/localhost.ks?rev=1295633&view=auto
==============================================================================
Files camel/trunk/components/camel-mina2/src/test/resources/jsse/localhost.ks (added) and
camel/trunk/components/camel-mina2/src/test/resources/jsse/localhost.ks Thu Mar  1 15:50:19
2012 differ



Mime
View raw message