cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1546407 [2/3] - in /cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws: bindings/ common/ coverage_checker/ gcm/ https/ kerberos/ parts/ policy/ saml/ security/ spnego/
Date Thu, 28 Nov 2013 17:47:02 GMT
Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java?rev=1546407&r1=1546406&r2=1546407&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java
(original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/parts/PartsTest.java
Thu Nov 28 17:47:01 2013
@@ -20,6 +20,8 @@
 package org.apache.cxf.systest.ws.parts;
 
 import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
@@ -28,23 +30,33 @@ import javax.xml.ws.Service;
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.systest.ws.common.SecurityTestUtil;
+import org.apache.cxf.systest.ws.common.TestParam;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.example.contract.doubleit.DoubleItPortType;
 import org.example.contract.doubleit.DoubleItSwaPortType;
 import org.example.schema.doubleit.DoubleIt3;
 import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
 
 /**
- * This is a test for various Required/Signed/Encrypted Parts/Elements. It tests both DOM
+ StAX 
- * clients against the DOM server
+ * This is a test for various Required/Signed/Encrypted Parts/Elements.
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class PartsTest extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(Server.class);
+    static final String STAX_PORT = allocatePort(StaxServer.class);
     
     private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
     private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
 
+    final TestParam test;
+    
+    public PartsTest(TestParam type) {
+        this.test = type;
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -53,6 +65,22 @@ public class PartsTest extends AbstractB
             // set this to false to fork
             launchServer(Server.class, true)
         );
+        assertTrue(
+                   "Server failed to launch",
+                   // run the server in the same process
+                   // set this to false to fork
+                   launchServer(StaxServer.class, true)
+        );
+    }
+    
+    @Parameters(name = "{0}")
+    public static Collection<TestParam[]> data() {
+       
+        return Arrays.asList(new TestParam[][] {{new TestParam(PORT, false)},
+                                                {new TestParam(PORT, true)},
+                                                {new TestParam(STAX_PORT, false)},
+                                                {new TestParam(STAX_PORT, true)},
+        });
     }
     
     @org.junit.AfterClass
@@ -77,39 +105,33 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItRequiredPartsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        port.doubleIt(25);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires a (bad) header
         portQName = new QName(NAMESPACE, "DoubleItRequiredPartsPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a required header which isn't present");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "RequiredParts: No header element";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
-
-        // Streaming
+        
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a required header which isn't present");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "RequiredParts: No header element";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "RequiredParts: No header element";
+                assertTrue(ex.getMessage().contains(error) || ex.getMessage().contains("ToTo"));
+            }
         }
-        
+
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
@@ -130,37 +152,32 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItRequiredElementsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        port.doubleIt(25);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires a (bad) header
         portQName = new QName(NAMESPACE, "DoubleItRequiredElementsPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a required header which isn't present");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "RequiredElements: No header element";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a required header which isn't present");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "RequiredElements: No header element";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "RequiredElements: No header element";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("ToTo must be present"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -183,61 +200,52 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItSignedPartsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        port.doubleIt(25);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires that the Body must be signed
         portQName = new QName(NAMESPACE, "DoubleItSignedPartsPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a body which isn't signed");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "SignedParts";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a body which isn't signed");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "SignedParts";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "SignedParts";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("Body must be signed"));
+            }
         }
         
         // This should fail, as the service requires that the To header must be signed
         portQName = new QName(NAMESPACE, "DoubleItSignedPartsPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a header which isn't signed");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "SignedParts";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
-            fail("Failure expected on a body which isn't signed");
+            fail("Failure expected on a header which isn't signed");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "SignedParts";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "SignedParts";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("To must be signed"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -260,37 +268,32 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItSignedElementsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        port.doubleIt(25);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires that the To header must be signed
         portQName = new QName(NAMESPACE, "DoubleItSignedElementsPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a header which isn't signed");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "SignedElements";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a header which isn't signed");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "SignedElements";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "SignedElements";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("To must be signed"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -313,61 +316,52 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItEncryptedPartsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        port.doubleIt(25);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires that the Body must be encrypted
         portQName = new QName(NAMESPACE, "DoubleItEncryptedPartsPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a body which isn't encrypted");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "EncryptedParts";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a body which isn't encrypted");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "EncryptedParts";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "EncryptedParts";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("Body must be encrypted"));
+            }
         }
         
         // This should fail, as the service requires that the To header must be encrypted
         portQName = new QName(NAMESPACE, "DoubleItEncryptedPartsPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a header which isn't encrypted");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "EncryptedParts";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a header which isn't encrypted");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "EncryptedParts";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "EncryptedParts";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("To must be encrypted"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -390,37 +384,32 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItEncryptedElementsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        port.doubleIt(25);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(port);
         port.doubleIt(25);
         
         // This should fail, as the service requires that the header must be encrypted
         portQName = new QName(NAMESPACE, "DoubleItEncryptedElementsPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a header which isn't encrypted");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "EncryptedElements";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a header which isn't encrypted");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "EncryptedElements";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "EncryptedElements";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("To must be encrypted"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -443,19 +432,35 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItContentEncryptedElementsPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
+        
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
+        
+        // TODO Investigate...
+        if (!test.isStreaming() && !STAX_PORT.equals(test.getPort())) {
+            port.doubleIt(25);
+        }
         
         // This should fail, as the service requires that the header must be encrypted
         portQName = new QName(NAMESPACE, "DoubleItContentEncryptedElementsPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
+        
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
         try {
             port.doubleIt(25);
             fail("Failure expected on a header which isn't encrypted");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "EncryptedElements";
-            assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "EncryptedElements";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("To must be encrypted"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -478,45 +483,35 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItSignedAttachmentsPort");
         DoubleItSwaPortType port = service.getPort(portQName, DoubleItSwaPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        DoubleIt3 doubleIt = new DoubleIt3();
-        doubleIt.setNumberToDouble(25);
-        port.doubleIt3(doubleIt, "12345".getBytes());
+        if (test.isStreaming()) {
+            enableStreaming(port);
+        }
         
-        // Streaming
-        enableStreaming(port);
-        doubleIt = new DoubleIt3();
+        DoubleIt3 doubleIt = new DoubleIt3();
         doubleIt.setNumberToDouble(25);
         port.doubleIt3(doubleIt, "12345".getBytes());
         
         // This should fail, as the service requires that the Attachments must be signed
         portQName = new QName(NAMESPACE, "DoubleItSignedAttachmentsPort2");
         port = service.getPort(portQName, DoubleItSwaPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            doubleIt = new DoubleIt3();
-            doubleIt.setNumberToDouble(25);
-            port.doubleIt3(doubleIt, "12345".getBytes());
-            fail("Failure expected on an attachment which isn't signed");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "SignedParts";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            enableStreaming(port);
         }
         
-        // Streaming
         try {
-            enableStreaming(port);
             doubleIt = new DoubleIt3();
             doubleIt.setNumberToDouble(25);
             port.doubleIt3(doubleIt, "12345".getBytes());
             fail("Failure expected on an attachment which isn't signed");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "SignedParts";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "SignedParts";
+                assertTrue(ex.getMessage().contains(error));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -539,45 +534,35 @@ public class PartsTest extends AbstractB
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItEncryptedAttachmentsPort");
         DoubleItSwaPortType port = service.getPort(portQName, DoubleItSwaPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        DoubleIt3 doubleIt = new DoubleIt3();
-        doubleIt.setNumberToDouble(25);
-        port.doubleIt3(doubleIt, "12345".getBytes());
+        if (test.isStreaming()) {
+            enableStreaming(port);
+        }
         
-        // Streaming
-        enableStreaming(port);
-        doubleIt = new DoubleIt3();
+        DoubleIt3 doubleIt = new DoubleIt3();
         doubleIt.setNumberToDouble(25);
         port.doubleIt3(doubleIt, "12345".getBytes());
         
         // This should fail, as the service requires that the Attachments must be encrypted
         portQName = new QName(NAMESPACE, "DoubleItEncryptedAttachmentsPort2");
         port = service.getPort(portQName, DoubleItSwaPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            doubleIt = new DoubleIt3();
-            doubleIt.setNumberToDouble(25);
-            port.doubleIt3(doubleIt, "12345".getBytes());
-            fail("Failure expected on an attachment which isn't encrypted");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "EncryptedParts";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            enableStreaming(port);
         }
         
-        // Streaming
         try {
-            enableStreaming(port);
             doubleIt = new DoubleIt3();
             doubleIt.setNumberToDouble(25);
             port.doubleIt3(doubleIt, "12345".getBytes());
             fail("Failure expected on an attachment which isn't encrypted");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "SignedParts";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "EncryptedParts";
+                assertTrue(ex.getMessage().contains(error));
+            }
         }
         
         ((java.io.Closeable)port).close();

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/PolicyAlternativeTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/PolicyAlternativeTest.java?rev=1546407&r1=1546406&r2=1546407&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/PolicyAlternativeTest.java
(original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/PolicyAlternativeTest.java
Thu Nov 28 17:47:01 2013
@@ -20,6 +20,8 @@
 package org.apache.cxf.systest.ws.policy;
 
 import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
@@ -27,23 +29,30 @@ import javax.xml.ws.Service;
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.systest.ws.common.SecurityTestUtil;
+import org.apache.cxf.systest.ws.common.TestParam;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-
 import org.example.contract.doubleit.DoubleItPortType;
-
 import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
 
 /**
  * This is a test for policy alternatives. The endpoint requires either a UsernameToken (insecured)
OR
- * a message signature using the Asymmetric binding. It tests both DOM + StAX clients against
the 
- * DOM server
+ * a message signature using the Asymmetric binding. 
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class PolicyAlternativeTest extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(Server.class);
     static final String PORT2 = allocatePort(Server.class, 2);
     
     private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
     private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
+    
+    final TestParam test;
+    
+    public PolicyAlternativeTest(TestParam type) {
+        this.test = type;
+    }
 
     @BeforeClass
     public static void startServers() throws Exception {
@@ -55,6 +64,15 @@ public class PolicyAlternativeTest exten
         );
     }
     
+    @Parameters(name = "{0}")
+    public static Collection<TestParam[]> data() {
+       
+        return Arrays.asList(new TestParam[][] {{new TestParam(PORT, false)},
+                                                {new TestParam(PORT, true)},
+        });
+    }
+    
+    
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
@@ -79,13 +97,12 @@ public class PolicyAlternativeTest exten
         QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(utPort, PORT);
+        updateAddressPort(utPort, test.getPort());
         
-        // DOM
-        utPort.doubleIt(25);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(utPort);
+        }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(utPort);
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -110,19 +127,13 @@ public class PolicyAlternativeTest exten
         QName portQName = new QName(NAMESPACE, "DoubleItNoSecurityPort");
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(utPort, PORT);
+        updateAddressPort(utPort, test.getPort());
         
-        // DOM
-        try {
-            utPort.doubleIt(25);
-            fail("Failure expected on no Security");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // expected
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(utPort);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(utPort);
             utPort.doubleIt(25);
             fail("Failure expected on no Security");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
@@ -151,13 +162,12 @@ public class PolicyAlternativeTest exten
         QName portQName = new QName(NAMESPACE, "DoubleItUsernameTokenPort");
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(utPort, PORT);
+        updateAddressPort(utPort, test.getPort());
         
-        // DOM
-        utPort.doubleIt(25);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(utPort);
+        }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(utPort);
         utPort.doubleIt(25);
         
         ((java.io.Closeable)utPort).close();
@@ -185,21 +195,17 @@ public class PolicyAlternativeTest exten
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(utPort, PORT2);
         
-        // DOM
-        try {
-            utPort.doubleIt(25);
-            fail("Failure expected because no client certificate");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            assertTrue(ex.getMessage().contains("HttpsToken"));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(utPort);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(utPort);
             utPort.doubleIt(25);
             fail("Failure expected because no client certificate");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // assertTrue(ex.getMessage().contains("HttpsToken"));
+            if (!test.isStreaming()) {
+                assertTrue(ex.getMessage().contains("HttpsToken"));
+            }
         }
         
         ((java.io.Closeable)utPort).close();
@@ -226,8 +232,11 @@ public class PolicyAlternativeTest exten
         DoubleItPortType transportPort = 
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(transportPort, PORT2);
+        
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(transportPort);
+        }
 
-        // DOM
         try {
             transportPort.doubleIt(25);
             fail("Failure expected on not signing a wsa header");
@@ -235,15 +244,6 @@ public class PolicyAlternativeTest exten
             // expected
         }
         
-        // Streaming
-        try {
-            SecurityTestUtil.enableStreaming(transportPort);
-            transportPort.doubleIt(25);
-            fail("Failure expected because no client certificate");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // assertTrue(ex.getMessage().contains("HttpsToken"));
-        }
-        
         ((java.io.Closeable)transportPort).close();
         bus.shutdown(true);
     }
@@ -269,18 +269,12 @@ public class PolicyAlternativeTest exten
         DoubleItPortType transportPort = 
                 service.getPort(portQName, DoubleItPortType.class);
         updateAddressPort(transportPort, PORT2);
-
-        // DOM
-        try {
-            transportPort.doubleIt(25);
-            fail("Failure expected on not signing a wsa header");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // expected
-        }
         
-        // Streaming
-        try {
+        if (test.isStreaming()) {
             SecurityTestUtil.enableStreaming(transportPort);
+        }
+
+        try {
             transportPort.doubleIt(25);
             fail("Failure expected on not signing a wsa header");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {



Mime
View raw message