cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r468050 [2/2] - in /incubator/cxf/trunk/rt: bindings/http/src/main/java/org/apache/cxf/binding/http/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/ frontend/simple/src/main/java/org/apache/cxf/service/factory/ transports/ht...
Date Thu, 26 Oct 2006 16:03:56 GMT
Copied: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/https/JettySslListenerFactoryTest.java
(from r438444, incubator/cxf/branches/post_apache_integration/rt/transports/http/src/test/java/org/objectweb/celtix/transports/https/JettySslListenerConfigurerTest.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/https/JettySslListenerFactoryTest.java?view=diff&rev=468050&p1=incubator/cxf/branches/post_apache_integration/rt/transports/http/src/test/java/org/objectweb/celtix/transports/https/JettySslListenerConfigurerTest.java&r1=438444&p2=incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/https/JettySslListenerFactoryTest.java&r2=468050
==============================================================================
--- incubator/cxf/branches/post_apache_integration/rt/transports/http/src/test/java/org/objectweb/celtix/transports/https/JettySslListenerConfigurerTest.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/https/JettySslListenerFactoryTest.java
Thu Oct 26 09:03:54 2006
@@ -1,4 +1,23 @@
-package org.objectweb.celtix.transports.https;
+/**
+ * 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.cxf.transport.https;
 
 import java.net.URL;
 import java.util.Properties;
@@ -8,32 +27,21 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.easymock.classextension.EasyMock;
+import org.apache.cxf.configuration.security.SSLServerPolicy;
+
 import org.mortbay.http.SslListener;
-import org.objectweb.celtix.BusException;
-import org.objectweb.celtix.bus.configuration.security.SSLServerPolicy;
-import org.objectweb.celtix.configuration.CompoundName;
-import org.objectweb.celtix.configuration.Configuration;
 
-public class JettySslListenerConfigurerTest extends TestCase {
 
+public class JettySslListenerFactoryTest extends TestCase {
     
-    private static final String DROP_BACK_SRC_DIR = 
-        "../../../../../../../src/test/java/org/objectweb/celtix/transports/https/";
-    private static final CompoundName HTTP_LISTENER_CONFIG_ID = 
-        new CompoundName("celtix", "http-listener.1234");
-
-    private Configuration configuration;
-
+    private SslListener sslListener;
     
-
-
-    public JettySslListenerConfigurerTest(String arg0) {
+    public JettySslListenerFactoryTest(String arg0) {
         super(arg0);
     }
 
     public static Test suite() throws Exception {
-        TestSuite suite = new TestSuite(JettySslListenerConfigurerTest.class);
+        TestSuite suite = new TestSuite(JettySslListenerFactoryTest.class);
         return new TestSetup(suite) {
             protected void tearDown() throws Exception {
                 super.tearDown();
@@ -41,35 +49,29 @@
         };
     }
 
-
     public static void main(String[] args) {
-        junit.textui.TestRunner.run(JettySslListenerConfigurerTest.class);
+        junit.textui.TestRunner.run(JettySslListenerFactoryTest.class);
     }
-
-    public void setUp() throws BusException {
-        configuration = EasyMock.createMock(Configuration.class);
+    
+    public void setUp() throws Exception {
+        sslListener = new SslListener();
     }
 
     public void tearDown() throws Exception {
-        EasyMock.reset(configuration);
         Properties props = System.getProperties();
         props.remove("javax.net.ssl.trustStore");
         props.remove("javax.net.ssl.keyStore");
     }
     
+    /*
     public void testSecurityConfigurer() {
         try {
-            System.setProperty("celtix.security.configurer." + HTTP_LISTENER_CONFIG_ID.toString(),
-                               "org.objectweb.celtix.transports.https.SetAllDataSecurityDataProvider");
             SSLServerPolicy sslServerPolicy = new SSLServerPolicy();
-            TestHandler handler = new TestHandler();
-            JettySslListenerConfigurer jettySslListenerConfigurer = 
-                                createJettySslListenerConfigurer(sslServerPolicy, 
-                                                               "https://dummyurl",
-                                                               handler);
-    
-            jettySslListenerConfigurer.configure();
-            SslListener sslListener = jettySslListenerConfigurer.getSslListener(); 
+            TestLogHandler handler = new TestLogHandler();
+            JettySslListenerFactory factory = createFactory(sslServerPolicy, 
+                                                            "https://dummyurl",
+                                                            handler);    
+            factory.decorate(sslListener);
             assertTrue("Keystore not set properly", 
                        sslListener.getKeystore().contains("resources/defaultkeystore"));
             String trustStr = System.getProperty("javax.net.ssl.trustStore");
@@ -104,30 +106,27 @@
                                                       + "CertValidator"));
             
             System.setProperty("celtix.security.configurer." + HTTP_LISTENER_CONFIG_ID.toString(),
-                "org.objectweb.celtix.bus.transports.https.DoesNotExistSetAllDataSecurityDataProvider");
+                "org.apache.cxf.bus.transports.https.DoesNotExistSetAllDataSecurityDataProvider");
             SSLServerPolicy sslServerPolicy2 = new SSLServerPolicy();
-            TestHandler handler2 = new TestHandler();
-            EasyMock.reset(configuration);
-            configuration = EasyMock.createMock(Configuration.class);
-            JettySslListenerConfigurer jettySslListenerConfigurer2 = 
-                createJettySslListenerConfigurer(sslServerPolicy2, 
-                                            "https://dummyurl",
-                                            handler2);
+            TestLogHandler handler2 = new TestLogHandler();
+            JettySslListenerFactory factory2 = createFactory(sslServerPolicy2, 
+                                                             "https://dummyurl",
+                                                             handler2);
             sslServerPolicy2.setKeyPassword("test");
             sslServerPolicy2.setKeystorePassword("test1");
-            jettySslListenerConfigurer2.configure();
+            factory2.decorate(sslListener);
             
             assertTrue("Keystore not set properly", 
                        handler2.checkLogContainsString("Failure invoking on custom security
configurer "
-                                 + "org.objectweb.celtix.bus.transports.https."
+                                 + "org.apache.cxf.bus.transports.https."
                                  + "DoesNotExistSetAllDataSecurityDataProvider, "));
         } finally {
             System.getProperties().remove("celtix.security.configurer." + HTTP_LISTENER_CONFIG_ID.toString());
         }
     }
+    */
     
-    public void testSetAllData() {
-        
+    public void testSetAllData() {       
         String keyStoreStr = getPath("resources/defaultkeystore");
         SSLServerPolicy sslServerPolicy = new SSLServerPolicy();
         sslServerPolicy.setKeystore(keyStoreStr);
@@ -143,18 +142,14 @@
         sslServerPolicy.setMaxChainLength(new Long(2));
         sslServerPolicy.setCertValidator("Anything");
 
-        
         String trustStoreStr = getPath("resources/defaulttruststore");
         sslServerPolicy.setTrustStore(trustStoreStr);
-        TestHandler handler = new TestHandler();
-        JettySslListenerConfigurer jettySslListenerConfigurer = 
-                            createJettySslListenerConfigurer(sslServerPolicy, 
-                                                           "https://dummyurl",
-                                                           handler);
-
-        jettySslListenerConfigurer.configure();
-        SslListener sslListener = 
-                jettySslListenerConfigurer.getSslListener();
+        TestLogHandler handler = new TestLogHandler();
+        JettySslListenerFactory factory = createFactory(sslServerPolicy, 
+                                                        "https://dummyurl",
+                                                        handler);
+
+        factory.decorate(sslListener);
         
         assertTrue("Keystore not set properly", 
                    sslListener.getKeystore().contains("resources/defaultkeystore"));
@@ -190,8 +185,7 @@
                                                   + "CertValidator"));
     }
     
-    public void testSetAllDataExceptKeystoreAndTrustStore() {
-        
+    public void testSetAllDataExceptKeystoreAndTrustStore() {        
         SSLServerPolicy sslServerPolicy = new SSLServerPolicy();
         sslServerPolicy.setKeystore(null);
         sslServerPolicy.setKeystoreType("JKS");
@@ -205,19 +199,14 @@
         sslServerPolicy.setSessionCaching(true);
         sslServerPolicy.setMaxChainLength(new Long(2));
         sslServerPolicy.setCertValidator("Anything"); 
-
-        
         
         sslServerPolicy.setTrustStore(null);
-        TestHandler handler = new TestHandler();
-        JettySslListenerConfigurer jettySslListenerConfigurer = 
-                            createJettySslListenerConfigurer(sslServerPolicy, 
-                                                           "https://dummyurl",
-                                                           handler);
-
-        jettySslListenerConfigurer.configure();
-        SslListener sslListener = 
-                jettySslListenerConfigurer.getSslListener();
+        TestLogHandler handler = new TestLogHandler();
+        JettySslListenerFactory factory = createFactory(sslServerPolicy, 
+                                                        "https://dummyurl",
+                                                        handler);
+
+        factory.decorate(sslListener);
         
         assertTrue("Keystore not set properly, sslListener.getKeystore() = " + sslListener.getKeystore(),

                    sslListener.getKeystore().contains(".keystore"));
@@ -253,8 +242,7 @@
                                                   + "CertValidator"));
     }
 
-    public void testAllValidDataJKS() {
-        
+    public void testAllValidDataJKS() {        
         String keyStoreStr = getPath("resources/defaultkeystore");
         SSLServerPolicy sslServerPolicy = new SSLServerPolicy();
         sslServerPolicy.setKeystore(keyStoreStr);
@@ -264,19 +252,15 @@
         sslServerPolicy.setKeystoreType("JKS");
         String trustStoreStr = getPath("resources/defaulttruststore");
         sslServerPolicy.setTrustStore(trustStoreStr);
-        TestHandler handler = new TestHandler();
-        JettySslListenerConfigurer jettySslListenerConfigurer = 
-                            createJettySslListenerConfigurer(sslServerPolicy, 
-                                                           "https://dummyurl",
-                                                           handler);
-
-        jettySslListenerConfigurer.configure();
+        TestLogHandler handler = new TestLogHandler();
+        JettySslListenerFactory factory = createFactory(sslServerPolicy, 
+                                                        "https://dummyurl",
+                                                        handler);
 
-        
+        factory.decorate(sslListener);
     }
     
     public void testAllValidDataPKCS12() {
-        
         String keyStoreStr = getPath("resources/celtix.p12");
         SSLServerPolicy sslServerPolicy = new SSLServerPolicy();
         sslServerPolicy.setKeystore(keyStoreStr);
@@ -286,64 +270,39 @@
         sslServerPolicy.setKeystoreType("PKCS12");
         String trustStoreStr = getPath("resources/abigcompany_ca.pem");
         sslServerPolicy.setTrustStore(trustStoreStr);
-        TestHandler handler = new TestHandler();
-        JettySslListenerConfigurer jettySslListenerConfigurer = 
-                            createJettySslListenerConfigurer(sslServerPolicy, 
-                                                           "https://dummyurl",
-                                                           handler);
-
-        jettySslListenerConfigurer.configure();
+        TestLogHandler handler = new TestLogHandler();
+        JettySslListenerFactory factory = createFactory(sslServerPolicy, 
+                                                        "https://dummyurl",
+                                                        handler);
 
-        
+        factory.decorate(sslListener);
     }
 
-    
-        
-    
     public void testAllElementsHaveSetupMethod() {
-        SSLServerPolicy sslServerPolicy = new SSLServerPolicy();
-        TestHandler handler = new TestHandler(); 
-        JettySslListenerConfigurer jettySslListenerConfigurer = 
-            createJettySslListenerConfigurer(sslServerPolicy, 
-                                           "https://dummyurl",
-                                           handler);
+        SSLServerPolicy policy = new SSLServerPolicy();
+        TestLogHandler handler = new TestLogHandler(); 
+        JettySslListenerFactory factory = createFactory(policy, 
+                                                        "https://dummyurl",
+                                                         handler);
         assertTrue("A new element has been "
                    + "added to SSLServerPolicy without a corresponding "
                    + "setup method in the configurer.",
-                   jettySslListenerConfigurer.testAllDataHasSetupMethod());
+                   SSLUtils.testAllDataHasSetupMethod(policy, factory.getUnSupported()));
     }
     
-    
-    private JettySslListenerConfigurer createJettySslListenerConfigurer(
-                                             SSLServerPolicy sslServerPolicy,
-                                             String urlStr, 
-                                            TestHandler handler) {
-        EasyMock.expect(configuration.getId()).andReturn(HTTP_LISTENER_CONFIG_ID);
-        EasyMock.replay(configuration);
-        try {
-            
-            
-            
-            SslListener sslListener = new SslListener();
-            JettySslListenerConfigurer jettySslListenerConfigurer = 
-                new JettySslListenerConfigurer(configuration,
-                                               sslServerPolicy,
-                                               sslListener);
-            
-            jettySslListenerConfigurer.addLogHandler(handler);
-            return jettySslListenerConfigurer;
-            
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        EasyMock.verify(configuration);
-        return null;
+    private JettySslListenerFactory createFactory(SSLServerPolicy policy,
+                                                  String urlStr, 
+                                                  TestLogHandler handler) {
+        JettySslListenerFactory factory =
+            new JettySslListenerFactory(policy);
+        factory.addLogHandler(handler);
+        return factory;
     }
     
     protected static String getPath(String fileName) {
-        URL keystoreURL = JettySslListenerConfigurerTest.class.getResource(".");
+        URL keystoreURL = JettySslListenerFactoryTest.class.getResource(".");
         String str = keystoreURL.getFile(); 
-        str += DROP_BACK_SRC_DIR  + fileName;
+        str += HttpsURLConnectionFactoryTest.DROP_BACK_SRC_DIR  + fileName;
         return str;
     }
 }



Mime
View raw message