You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2011/04/25 04:55:51 UTC

svn commit: r1096400 - in /camel/trunk/tests/camel-itest-osgi/src/test: java/org/apache/camel/itest/osgi/ java/org/apache/camel/itest/osgi/util/ java/org/apache/camel/itest/osgi/util/jsse/ resources/org/apache/camel/itest/osgi/util/ resources/org/apach...

Author: ningjiang
Date: Mon Apr 25 02:55:51 2011
New Revision: 1096400

URL: http://svn.apache.org/viewvc?rev=1096400&view=rev
Log:
CAMEL-3750 applied patch for osgi integration test

Added:
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml   (with props)
    camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/localhost.ks   (with props)
Modified:
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java

Modified: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java?rev=1096400&r1=1096399&r2=1096400&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java Mon Apr 25 02:55:51 2011
@@ -27,6 +27,7 @@ public abstract class OSGiIntegrationSpr
     
     @Override
     protected CamelContext createCamelContext() throws Exception {
+        setThreadContextClassLoader();
         applicationContext = createApplicationContext();        
         assertNotNull("Should have created a valid spring context", applicationContext);
         applicationContext.setBundleContext(bundleContext);

Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java?rev=1096400&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java Mon Apr 25 02:55:51 2011
@@ -0,0 +1,92 @@
+/**
+ * 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.itest.osgi.util.jsse;
+
+import java.io.File;
+import java.net.URL;
+import java.security.KeyStore;
+
+import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
+
+@RunWith(JUnit4TestRunner.class)
+public class JsseUtilTest extends OSGiIntegrationSpringTestSupport {
+    
+    @Test
+    public void testSslContextParameters() throws Exception {
+        
+        SSLContextParameters scp = this.applicationContext.getBean(SSLContextParameters.class);
+        
+        assertEquals("TLS", scp.getSecureSocketProtocol());
+        
+        assertNotNull(scp.getKeyManagers());
+        assertEquals("changeit", scp.getKeyManagers().getKeyPassword());
+        assertNull(scp.getKeyManagers().getProvider());
+        assertNotNull(scp.getKeyManagers().getKeyStore());
+        assertNull(scp.getKeyManagers().getKeyStore().getType());
+        
+        assertNotNull(scp.getTrustManagers());
+        assertNull(scp.getTrustManagers().getProvider());
+        assertNotNull(scp.getTrustManagers().getKeyStore());
+        assertNull(scp.getTrustManagers().getKeyStore().getType());
+        
+        assertNull(scp.getSecureRandom());
+        
+        assertNull(scp.getClientParameters());
+        
+        assertNull(scp.getServerParameters());
+        
+        // Test that the instantiation will work when running in OSGi and using
+        // class path resources.
+        scp.createSSLContext();
+    }
+    
+    @Test
+    public void testKeyStoreParametersResourceLoading() throws Exception {
+        
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setPassword("changeit");
+        ksp.setResource("org/apache/camel/itest/osgi/util/jsse/localhost.ks");
+        
+        
+        KeyStore ks = ksp.createKeyStore();
+        assertNotNull(ks.getCertificate("server"));
+        
+        
+        URL resourceUrl = this.getClass().getResource("/org/apache/camel/itest/osgi/util/jsse/localhost.ks");
+        ksp.setResource(resourceUrl.toExternalForm());
+        ks = ksp.createKeyStore();
+        assertNotNull(ks.getCertificate("server"));
+        
+        
+        File file = new File("../test-classes/org/apache/camel/itest/osgi/util/jsse/localhost.ks");
+        ksp.setResource(file.getAbsolutePath());
+        ks = ksp.createKeyStore();
+        assertNotNull(ks.getCertificate("server"));
+    }
+
+    @Override
+    protected OsgiBundleXmlApplicationContext createApplicationContext() {
+        return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml"});
+    }
+
+}

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml?rev=1096400&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml Mon Apr 25 02:55:51 2011
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+       
+  <camel:camelContext/>
+       
+  <camel:sslContextParameters
+      id="id"
+      sessionTimeout="1"
+      secureSocketProtocol="TLS">
+    
+    <camel:keyManagers
+        keyPassword="changeit">
+      <camel:keyStore
+          resource="org/apache/camel/itest/osgi/util/jsse/localhost.ks"
+          password="changeit"/>
+    </camel:keyManagers>
+    
+    <camel:trustManagers>
+      <camel:keyStore
+          resource="org/apache/camel/itest/osgi/util/jsse/localhost.ks"
+          password="changeit"/>
+    </camel:trustManagers>
+
+  </camel:sslContextParameters>
+  
+</beans>

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/JsseUtilTest-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/localhost.ks
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/localhost.ks?rev=1096400&view=auto
==============================================================================
Binary file - no diff available.

Propchange: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/util/jsse/localhost.ks
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream