cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1546579 [1/2] - in /cxf/trunk/systests/ws-security/src/test: java/org/apache/cxf/systest/ws/swa/ java/org/apache/cxf/systest/ws/tokens/ java/org/apache/cxf/systest/ws/ut/ java/org/apache/cxf/systest/ws/wssc/ java/org/apache/cxf/systest/ws/...
Date Fri, 29 Nov 2013 15:14:27 GMT
Author: coheigea
Date: Fri Nov 29 15:14:27 2013
New Revision: 1546579

URL: http://svn.apache.org/r1546579
Log:
Finished porting the WS-Security system tests to use parameterized tests

Removed:
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/StaxSWAPolicyTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/StaxEndorsingSupportingTokenTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/StaxSupportingTokenTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/StaxUsernameTokenPolicyTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/StaxUsernameTokenTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/StaxWSSCTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec10/StaxWSSecurity10Test.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/StaxWSSecurity111Test.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/StaxWSSecurity112Test.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/StaxX509TokenTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/xkms/StaxXKMSTest.java
Modified:
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/EndorsingSupportingTokenTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/SupportingTokenTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenPolicyTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCUnitTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec10/WSSecurity10Test.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/WSSecurity111Test.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/WSSecurity112Test.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/WSSecurity11Common.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server11Restricted.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server12Restricted.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/StaxServer11Restricted.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/StaxServer12Restricted.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/xkms/XKMSTest.java
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/server.xml
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/xkms/stax-server.xml

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java?rev=1546579&r1=1546578&r2=1546579&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java (original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/swa/SWAPolicyTest.java Fri Nov 29 15:14:27 2013
@@ -20,6 +20,8 @@
 package org.apache.cxf.systest.ws.swa;
 
 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,32 @@ 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.DoubleItSwaPortType;
 import org.example.schema.doubleit.DoubleIt3;
 import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
 
 /**
  * A set of tests for the SwA specification (SOAP with Attachments) via WS-SecurityPolicy.
- * 
- * It tests both DOM + StAX clients against the DOM server
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class SWAPolicyTest extends AbstractBusClientServerTestBase {
     public static final String PORT = allocatePort(PolicyServer.class);
+    public static final String STAX_PORT = allocatePort(StaxPolicyServer.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 SWAPolicyTest(TestParam type) {
+        this.test = type;
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -53,6 +64,22 @@ public class SWAPolicyTest extends Abstr
                 // set this to false to fork
                 launchServer(PolicyServer.class, true)
         );
+        assertTrue(
+                   "Server failed to launch",
+                   // run the server in the same process
+                   // set this to false to fork
+                   launchServer(StaxPolicyServer.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
@@ -76,16 +103,13 @@ public class SWAPolicyTest extends Abstr
         QName portQName = new QName(NAMESPACE, "DoubleItSWASignatureContentPolicyPort");
         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());
         
@@ -108,16 +132,13 @@ public class SWAPolicyTest extends Abstr
         QName portQName = new QName(NAMESPACE, "DoubleItSWASignatureCompletePolicyPort");
         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());
         
@@ -140,16 +161,13 @@ public class SWAPolicyTest extends Abstr
         QName portQName = new QName(NAMESPACE, "DoubleItSWAEncryptionPolicyPort");
         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());
         
@@ -172,16 +190,13 @@ public class SWAPolicyTest extends Abstr
         QName portQName = new QName(NAMESPACE, "DoubleItSWACombinedPolicyPort");
         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());
         
@@ -204,16 +219,13 @@ public class SWAPolicyTest extends Abstr
         QName portQName = new QName(NAMESPACE, "DoubleItSWACombinedAsymmetricPolicyPort");
         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());
         

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/EndorsingSupportingTokenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/EndorsingSupportingTokenTest.java?rev=1546579&r1=1546578&r2=1546579&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/EndorsingSupportingTokenTest.java (original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/EndorsingSupportingTokenTest.java Fri Nov 29 15:14:27 2013
@@ -20,6 +20,8 @@
 package org.apache.cxf.systest.ws.tokens;
 
 import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
@@ -27,24 +29,31 @@ 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 various properties associated with SupportingTokens, i.e.
  * Signed, Encrypted etc.
- * 
- * It tests DOM clients against the DOM server
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class EndorsingSupportingTokenTest extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(EndorsingServer.class);
+    static final String STAX_PORT = allocatePort(StaxEndorsingServer.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 EndorsingSupportingTokenTest(TestParam type) {
+        this.test = type;
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -53,6 +62,20 @@ public class EndorsingSupportingTokenTes
             // set this to false to fork
             launchServer(EndorsingServer.class, true)
         );
+        assertTrue(
+                   "Server failed to launch",
+                   // run the server in the same process
+                   // set this to false to fork
+                   launchServer(StaxEndorsingServer.class, true)
+        );
+    }
+    
+    @Parameters(name = "{0}")
+    public static Collection<TestParam[]> data() {
+       
+        return Arrays.asList(new TestParam[][] {{new TestParam(PORT, false)},
+                                                {new TestParam(STAX_PORT, false)},
+        });
     }
     
     @org.junit.AfterClass
@@ -77,13 +100,14 @@ public class EndorsingSupportingTokenTes
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItEndorsingSupportingPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
+        
         port.doubleIt(25);
         
         // This should fail, as the client is signing (but not endorsing) the X.509 Token
         portQName = new QName(NAMESPACE, "DoubleItEndorsingSupportingPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
         try {
             port.doubleIt(25);
@@ -91,13 +115,14 @@ public class EndorsingSupportingTokenTes
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
             String error = 
                 "The received token does not match the endorsing supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+            assertTrue(ex.getMessage().contains(error)
+                       || ex.getMessage().contains("EncryptedKey must sign the main signature"));
         }
         
         // This should fail, as the client is not endorsing the X.509 Token
         portQName = new QName(NAMESPACE, "DoubleItEndorsingSupportingPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
         try {
             port.doubleIt(25);
@@ -105,7 +130,8 @@ public class EndorsingSupportingTokenTes
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
             String error = 
                 "The received token does not match the endorsing supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+            assertTrue(ex.getMessage().contains(error)
+                       || ex.getMessage().contains("X509Token not satisfied"));
         }
         
         ((java.io.Closeable)port).close();
@@ -128,13 +154,14 @@ public class EndorsingSupportingTokenTes
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItSignedEndorsingSupportingPort");
         DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
+        
         port.doubleIt(25);
         
         // This should fail, as the client is signing (but not endorsing) the X.509 Token
         portQName = new QName(NAMESPACE, "DoubleItSignedEndorsingSupportingPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
         try {
             port.doubleIt(25);
@@ -142,13 +169,14 @@ public class EndorsingSupportingTokenTes
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
             String error = 
                 "The received token does not match the signed endorsing supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+            assertTrue(ex.getMessage().contains(error)
+                       || ex.getMessage().contains("EncryptedKey must sign the main signature"));
         }
         
         // This should fail, as the client is endorsing but not signing the X.509 Token
         portQName = new QName(NAMESPACE, "DoubleItSignedEndorsingSupportingPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
         try {
             port.doubleIt(25);
@@ -156,7 +184,8 @@ public class EndorsingSupportingTokenTes
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
             String error = 
                 "The received token does not match the signed endorsing supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+            assertTrue(ex.getMessage().contains(error)
+                       || ex.getMessage().contains("X509Token not satisfied"));
         }
         
         ((java.io.Closeable)port).close();

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/SupportingTokenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/SupportingTokenTest.java?rev=1546579&r1=1546578&r2=1546579&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/SupportingTokenTest.java (original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/tokens/SupportingTokenTest.java Fri Nov 29 15:14:27 2013
@@ -20,6 +20,8 @@
 package org.apache.cxf.systest.ws.tokens;
 
 import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
@@ -27,24 +29,31 @@ 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 various properties associated with SupportingTokens, i.e.
  * Signed, Encrypted etc.
- * 
- * It tests both DOM + StAX clients against the DOM server
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class SupportingTokenTest 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 SupportingTokenTest(TestParam type) {
+        this.test = type;
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -53,6 +62,22 @@ public class SupportingTokenTest extends
             // 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,62 +102,52 @@ public class SupportingTokenTest extends
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItSignedSupportingPort");
         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 client is not signing the UsernameToken
         portQName = new QName(NAMESPACE, "DoubleItSignedSupportingPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not signing the UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "The received token does not match the signed supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not signing the UsernameToken");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "The received token does not match the signed supporting token requirement";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "The received token does not match the signed supporting token requirement";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken not satisfied"));
+            }
         }
         
-        
         // This should fail, as the client is (encrypting) but not signing the UsernameToken
         portQName = new QName(NAMESPACE, "DoubleItSignedSupportingPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not signing the UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "The received token does not match the signed supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not signing the UsernameToken");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "The received token does not match the signed supporting token requirement";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "The received token does not match the signed supporting token requirement";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken not satisfied"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -155,61 +170,52 @@ public class SupportingTokenTest extends
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItEncryptedSupportingPort");
         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 client is not encrypting the UsernameToken
         portQName = new QName(NAMESPACE, "DoubleItEncryptedSupportingPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not encrypting the UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "The received token does not match the encrypted supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not encrypting the UsernameToken");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "The received token does not match the encrypted supporting token requirement";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "The received token does not match the encrypted supporting token requirement";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken not satisfied"));
+            }
         }
         
         // This should fail, as the client is (signing) but not encrypting the UsernameToken
         portQName = new QName(NAMESPACE, "DoubleItEncryptedSupportingPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not encrypting the UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "The received token does not match the encrypted supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not encrypting the UsernameToken");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "The received token does not match the encrypted supporting token requirement";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "The received token does not match the encrypted supporting token requirement";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken not satisfied"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -232,65 +238,54 @@ public class SupportingTokenTest extends
         // Successful invocation
         QName portQName = new QName(NAMESPACE, "DoubleItSignedEncryptedSupportingPort");
         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 client is not encrypting the UsernameToken
         portQName = new QName(NAMESPACE, "DoubleItSignedEncryptedSupportingPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not encrypting the UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = 
-                "The received token does not match the signed encrypted supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not encrypting the UsernameToken");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = 
-            //    "The received token does not match the signed encrypted supporting token requirement";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = 
+                    "The received token does not match the signed encrypted supporting token requirement";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken not satisfied"));
+            }
         }
         
         // This should fail, as the client is (encrypting) but not signing the UsernameToken
         portQName = new QName(NAMESPACE, "DoubleItSignedEncryptedSupportingPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not encrypting the UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = 
-                "The received token does not match the signed encrypted supporting token requirement";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not encrypting the UsernameToken");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            //String error = 
-            //    "The received token does not match the signed encrypted supporting token requirement";
-            //assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = 
+                    "The received token does not match the signed encrypted supporting token requirement";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken not satisfied"));
+            }
         }
         
         ((java.io.Closeable)port).close();

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenPolicyTest.java?rev=1546579&r1=1546578&r2=1546579&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenPolicyTest.java (original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenPolicyTest.java Fri Nov 29 15:14:27 2013
@@ -20,6 +20,8 @@
 package org.apache.cxf.systest.ws.ut;
 
 import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
@@ -27,20 +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;
 
 /**
  * A set of (negative) tests for Username Tokens policies over the Transport Binding.
- * It tests both DOM + StAX clients against the DOM server
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class UsernameTokenPolicyTest extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(PolicyServer.class);
+    static final String STAX_PORT = allocatePort(StaxPolicyServer.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 UsernameTokenPolicyTest(TestParam type) {
+        this.test = type;
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -49,6 +61,22 @@ public class UsernameTokenPolicyTest ext
             // set this to false to fork
             launchServer(PolicyServer.class, true)
         );
+        assertTrue(
+                   "Server failed to launch",
+                   // run the server in the same process
+                   // set this to false to fork
+                   launchServer(StaxPolicyServer.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
@@ -72,37 +100,32 @@ public class UsernameTokenPolicyTest ext
         QName portQName = new QName(NAMESPACE, "DoubleItSupportingTokenPort");
         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 client is not sending a UsernameToken Supporting Token
         portQName = new QName(NAMESPACE, "DoubleItSupportingTokenPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not sending a UsernameToken Supporting Token");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "These policy alternatives can not be satisfied";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not sending a UsernameToken Supporting Token");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "These policy alternatives can not be satisfied";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "These policy alternatives can not be satisfied";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken not satisfied"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -124,55 +147,44 @@ public class UsernameTokenPolicyTest ext
         QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort");
         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 client is sending a hashed password
         portQName = new QName(NAMESPACE, "DoubleItPlaintextPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a hashed password");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "These policy alternatives can not be satisfied";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a hashed password");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "These policy alternatives can not be satisfied";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "These policy alternatives can not be satisfied";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("password must not be hashed"));
+            }
         }
         
         // This should fail, as the client is not sending any password
         portQName = new QName(NAMESPACE, "DoubleItPlaintextPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not sending a password");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // expected
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not sending a password");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
@@ -198,55 +210,44 @@ public class UsernameTokenPolicyTest ext
         QName portQName = new QName(NAMESPACE, "DoubleItHashPort");
         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 client is sending a plaintext password
         portQName = new QName(NAMESPACE, "DoubleItHashPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on a plaintext password");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "These policy alternatives can not be satisfied";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on a plaintext password");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "These policy alternatives can not be satisfied";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "These policy alternatives can not be satisfied";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken does not contain a hashed password"));
+            }
         }
         
         // This should fail, as the client is not sending any password
         portQName = new QName(NAMESPACE, "DoubleItHashPort3");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not sending a password");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // expected
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not sending a password");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
@@ -272,37 +273,32 @@ public class UsernameTokenPolicyTest ext
         QName portQName = new QName(NAMESPACE, "DoubleItCreatedPort");
         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 client is not sending a Created element
         portQName = new QName(NAMESPACE, "DoubleItCreatedPort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not sending a Created element");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "These policy alternatives can not be satisfied";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
-            SecurityTestUtil.enableStreaming(port);
             port.doubleIt(25);
             fail("Failure expected on not sending a Created element");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "These policy alternatives can not be satisfied";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "These policy alternatives can not be satisfied";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken does not contain a created"));
+            }
         }
         
         ((java.io.Closeable)port).close();
@@ -324,36 +320,32 @@ public class UsernameTokenPolicyTest ext
         QName portQName = new QName(NAMESPACE, "DoubleItNoncePort");
         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 client is not sending a Nonce element
         portQName = new QName(NAMESPACE, "DoubleItNoncePort2");
         port = service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
         
-        // DOM
-        try {
-            port.doubleIt(25);
-            fail("Failure expected on not sending a Nonce element");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "These policy alternatives can not be satisfied";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
         }
         
-        // Streaming
         try {
             port.doubleIt(25);
             fail("Failure expected on not sending a Nonce element");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "These policy alternatives can not be satisfied";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "These policy alternatives can not be satisfied";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains("UsernameToken does not contain a nonce"));
+            }
         }
         
         ((java.io.Closeable)port).close();

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java?rev=1546579&r1=1546578&r2=1546579&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java (original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java Fri Nov 29 15:14:27 2013
@@ -20,6 +20,8 @@
 package org.apache.cxf.systest.ws.ut;
 
 import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
@@ -30,21 +32,31 @@ import org.apache.cxf.bus.spring.SpringB
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.frontend.ClientProxy;
 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.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
 
 /**
- * A set of tests for Username Tokens over the Transport Binding. It tests both DOM + StAX clients against the 
- * DOM server
+ * A set of tests for Username Tokens over the Transport Binding. 
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class UsernameTokenTest 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 UsernameTokenTest(TestParam type) {
+        this.test = type;
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -53,6 +65,22 @@ public class UsernameTokenTest extends A
             // 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
@@ -76,13 +104,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort");
         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();
@@ -104,13 +131,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItPlaintextCreatedPort");
         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();
@@ -132,13 +158,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItPlaintextSupportingPort");
         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();
@@ -160,13 +185,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItHashedPort");
         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();
@@ -188,13 +212,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItNoPasswordPort");
         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();
@@ -216,13 +239,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItSignedEndorsingPort");
         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();
@@ -244,13 +266,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItSignedEncryptedPort");
         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();
@@ -272,13 +293,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItEncryptedPort");
         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();
@@ -300,26 +320,23 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItInlinePolicyPort");
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(utPort, PORT);
+        updateAddressPort(utPort, test.getPort());
         
-        // DOM
-        try {
-            utPort.doubleIt(25);
-            fail("Failure expected on no UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "The received token does not match the token inclusion requirement";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(utPort);
         }
-
-        // Streaming
-        SecurityTestUtil.enableStreaming(utPort);
+        
         try {
             utPort.doubleIt(25);
             fail("Failure expected on no UsernameToken");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            assertTrue(ex.getMessage().contains("PolicyViolationException"));
+            if (!test.isStreaming()) {
+                String error = "The received token does not match the token inclusion requirement";
+                assertTrue(ex.getMessage().contains(error)
+                       || ex.getMessage().contains("UsernameToken not satisfied"));
+            }
         }
-        
+
         ((java.io.Closeable)utPort).close();
         bus.shutdown(true);
     }
@@ -340,21 +357,25 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItHashedPort");
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(utPort, PORT);
-        
-        Client cxfClient = ClientProxy.getClient(utPort);
-        SecurityHeaderCacheInterceptor cacheInterceptor =
-            new SecurityHeaderCacheInterceptor();
-        cxfClient.getOutInterceptors().add(cacheInterceptor);
+        updateAddressPort(utPort, test.getPort());
         
-        // Make two invocations with the same UsernameToken
-        utPort.doubleIt(25);
-        try {
+        if (!test.isStreaming()) {
+            Client cxfClient = ClientProxy.getClient(utPort);
+            SecurityHeaderCacheInterceptor cacheInterceptor =
+                new SecurityHeaderCacheInterceptor();
+            cxfClient.getOutInterceptors().add(cacheInterceptor);
+            
+            // Make two invocations with the same UsernameToken
             utPort.doubleIt(25);
-            fail("Failure expected on a replayed UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "A replay attack has been detected";
-            assertTrue(ex.getMessage().contains(error));
+            try {
+                utPort.doubleIt(25);
+                fail("Failure expected on a replayed UsernameToken");
+            } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+                String error = "A replay attack has been detected";
+                assertTrue(ex.getMessage().contains(error)
+                           || ex.getMessage().contains(
+                               "The security token could not be authenticated or authorized"));
+            }
         }
         
         ((java.io.Closeable)utPort).close();
@@ -379,21 +400,23 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItDigestNoBindingPort");
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(utPort, PORT);
-        
-        Client cxfClient = ClientProxy.getClient(utPort);
-        SecurityHeaderCacheInterceptor cacheInterceptor =
-            new SecurityHeaderCacheInterceptor();
-        cxfClient.getOutInterceptors().add(cacheInterceptor);
+        updateAddressPort(utPort, test.getPort());
         
-        // Make two invocations with the same UsernameToken
-        utPort.doubleIt(25);
-        try {
+        if (!test.isStreaming() && PORT.equals(test.getPort())) {
+            Client cxfClient = ClientProxy.getClient(utPort);
+            SecurityHeaderCacheInterceptor cacheInterceptor =
+                new SecurityHeaderCacheInterceptor();
+            cxfClient.getOutInterceptors().add(cacheInterceptor);
+            
+            // Make two invocations with the same UsernameToken
             utPort.doubleIt(25);
-            fail("Failure expected on a replayed UsernameToken");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "A replay attack has been detected";
-            assertTrue(ex.getMessage().contains(error));
+            try {
+                utPort.doubleIt(25);
+                fail("Failure expected on a replayed UsernameToken");
+            } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+                String error = "A replay attack has been detected";
+                assertTrue(ex.getMessage().contains(error));
+            }
         }
         
         ((java.io.Closeable)utPort).close();
@@ -415,23 +438,12 @@ public class UsernameTokenTest extends A
         QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPrincipalPort");
         DoubleItPortType utPort = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(utPort, PORT);
-        
-        // DOM
-        ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "Alice");
-        utPort.doubleIt(25);
+        updateAddressPort(utPort, test.getPort());
         
-        try {
-            ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "Frank");
-            utPort.doubleIt(30);
-            fail("Failure expected on a user with the wrong role");
-        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            String error = "Unauthorized";
-            assertTrue(ex.getMessage().contains(error));
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(utPort);
         }
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(utPort);
         ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "Alice");
         utPort.doubleIt(25);
         
@@ -440,8 +452,10 @@ public class UsernameTokenTest extends A
             utPort.doubleIt(30);
             fail("Failure expected on a user with the wrong role");
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "Unauthorized";
-            // assertTrue(ex.getMessage().contains(error));
+            if (!test.isStreaming()) {
+                String error = "Unauthorized";
+                assertTrue(ex.getMessage().contains(error));
+            }
         }
         
         ((java.io.Closeable)utPort).close();

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java?rev=1546579&r1=1546578&r2=1546579&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java (original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java Fri Nov 29 15:14:27 2013
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.systest.ws.wssc;
 
+import java.util.Arrays;
+import java.util.Collection;
+
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
 
@@ -28,23 +31,44 @@ import org.apache.cxf.bus.spring.SpringB
 import org.apache.cxf.systest.ws.common.SecurityTestUtil;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.ws.security.SecurityConstants;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
 
 /**
  * SecureConversation tests.
- * 
- * It tests both DOM + StAX clients against the DOM server
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class WSSCTest extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(Server.class);
+    static final String STAX_PORT = allocatePort(StaxServer.class);
 
-       
     private static final String OUT = "CXF : ping";
     private static wssec.wssc.PingService svc;
     private static Bus bus;
     
+    final TestParam test;
+    
+    public WSSCTest(TestParam type) {
+        this.test = type;
+    }
+    
+    static class TestParam {
+        final String prefix;
+        final boolean streaming;
+        final String port;
+        
+        public TestParam(String p, String port, boolean b) {
+            prefix = p;
+            this.port = port;
+            streaming = b;
+        }
+        public String toString() {
+            return prefix + ":" + port + ":" + (streaming ? "streaming" : "dom");
+        }
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -53,6 +77,12 @@ public class WSSCTest extends AbstractBu
             // 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)
+        );
         
         bus = new SpringBusFactory().createBus("org/apache/cxf/systest/ws/wssc/client.xml");
         BusFactory.setDefaultBus(bus);
@@ -61,198 +91,166 @@ public class WSSCTest extends AbstractBu
         svc = new wssec.wssc.PingService();
     }
     
+    @Parameters(name = "{0}")
+    public static Collection<TestParam[]> data() {
+        return Arrays.asList(new TestParam[][] {
+            {new TestParam("SecureConversation_MutualCertificate10SignEncrypt_IPingService", PORT, false)},
+            {new TestParam("AC_IPingService", PORT, false)},
+            {new TestParam("ADC_IPingService", PORT, false)},
+            {new TestParam("ADC-ES_IPingService", PORT, false)},
+            {new TestParam("_A_IPingService", PORT, false)},
+            {new TestParam("_AD_IPingService", PORT, false)},
+            {new TestParam("_AD-ES_IPingService", PORT, false)},
+            {new TestParam("UXC_IPingService", PORT, false)},
+            {new TestParam("UXDC_IPingService", PORT, false)},
+            {new TestParam("UXDC-SEES_IPingService", PORT, false)},
+            {new TestParam("_UX_IPingService", PORT, false)},
+            {new TestParam("_UXD_IPingService", PORT, false)},
+            {new TestParam("_UXD-SEES_IPingService", PORT, false)},
+            {new TestParam("XC_IPingService", PORT, false)},
+            {new TestParam("XDC_IPingService", PORT, false)},
+            {new TestParam("XDC_IPingService1", PORT, false)},
+            {new TestParam("XDC-ES_IPingService", PORT, false)},
+            {new TestParam("XDC-SEES_IPingService", PORT, false)},
+            {new TestParam("_X_IPingService", PORT, false)},
+            {new TestParam("_X10_IPingService", PORT, false)},
+            {new TestParam("_XD_IPingService", PORT, false)},
+            {new TestParam("_XD-SEES_IPingService", PORT, false)},
+            {new TestParam("_XD-ES_IPingService", PORT, false)},
+                
+            // TODO Endorsing streaming not supported
+            // {new TestParam("SecureConversation_MutualCertificate10SignEncrypt_IPingService", PORT, true)},
+            {new TestParam("AC_IPingService", PORT, true)},
+            {new TestParam("ADC_IPingService", PORT, true)},
+            // TODO Error with "EncryptBeforeSigning" ordering.
+            // {new TestParam("ADC-ES_IPingService", PORT, true)},
+            {new TestParam("_A_IPingService", PORT, true)},
+            {new TestParam("_AD_IPingService", PORT, true)},
+            // TODO Error with "EncryptBeforeSigning" ordering.
+            // {new TestParam("_AD-ES_IPingService", PORT, true)},
+            {new TestParam("UXC_IPingService", PORT, true)},
+            {new TestParam("UXDC_IPingService", PORT, true)},
+            {new TestParam("UXDC-SEES_IPingService", PORT, true)},
+            {new TestParam("_UX_IPingService", PORT, true)},
+            {new TestParam("_UXD_IPingService", PORT, true)},
+            {new TestParam("_UXD-SEES_IPingService", PORT, true)},
+            // TODO Streaming endorsing not working
+            // {new TestParam("XC_IPingService", PORT, true)},
+            // {new TestParam("XDC_IPingService", PORT, true)},
+            // {new TestParam("XDC_IPingService1", PORT, true)},
+            // {new TestParam("XDC-ES_IPingService", PORT, true)},
+            // {new TestParam("XDC-SEES_IPingService", PORT, true)},
+            // {new TestParam("_X_IPingService", PORT, true)},
+            {new TestParam("_X10_IPingService", PORT, true)},
+            // TODO Streaming endorsing not working
+            // {new TestParam("_XD_IPingService", PORT, true)},
+            // {new TestParam("_XD-SEES_IPingService", PORT, true)},
+            // {new TestParam("_XD-ES_IPingService", PORT, true)},
+
+            // TODO Endorsing derived keys not supported.
+            // {new TestParam("SecureConversation_MutualCertificate10SignEncrypt_IPingService", 
+            //               STAX_PORT, false)},
+            {new TestParam("AC_IPingService", STAX_PORT, false)},
+            {new TestParam("ADC_IPingService", STAX_PORT, false)},
+            {new TestParam("ADC-ES_IPingService", STAX_PORT, false)},
+            {new TestParam("_A_IPingService", STAX_PORT, false)},
+            {new TestParam("_AD_IPingService", STAX_PORT, false)},
+            {new TestParam("_AD-ES_IPingService", STAX_PORT, false)},
+            {new TestParam("UXC_IPingService", STAX_PORT, false)},
+            {new TestParam("UXDC_IPingService", STAX_PORT, false)},
+            {new TestParam("UXDC-SEES_IPingService", STAX_PORT, false)},
+            {new TestParam("_UX_IPingService", STAX_PORT, false)},
+            {new TestParam("_UXD_IPingService", STAX_PORT, false)},
+            {new TestParam("_UXD-SEES_IPingService", STAX_PORT, false)},
+            {new TestParam("XC_IPingService", STAX_PORT, false)},
+            {new TestParam("XDC_IPingService", STAX_PORT, false)},
+            {new TestParam("XDC_IPingService1", STAX_PORT, false)},
+            {new TestParam("XDC-ES_IPingService", STAX_PORT, false)},
+            {new TestParam("XDC-SEES_IPingService", STAX_PORT, false)},
+            {new TestParam("_X_IPingService", STAX_PORT, false)},
+            {new TestParam("_X10_IPingService", STAX_PORT, false)},
+            {new TestParam("_XD_IPingService", STAX_PORT, false)},
+            {new TestParam("_XD-SEES_IPingService", STAX_PORT, false)},
+            {new TestParam("_XD-ES_IPingService", STAX_PORT, false)},
+
+            // TODO Endorsing derived keys not supported.
+            // {new TestParam("SecureConversation_MutualCertificate10SignEncrypt_IPingService", 
+            //               STAX_PORT, true)},
+            {new TestParam("AC_IPingService", STAX_PORT, true)},
+            {new TestParam("ADC_IPingService", STAX_PORT, true)},
+            // TODO Error with "EncryptBeforeSigning" ordering.
+            // {new TestParam("ADC-ES_IPingService", STAX_PORT, true)},
+            {new TestParam("_A_IPingService", STAX_PORT, true)},
+            {new TestParam("_AD_IPingService", STAX_PORT, true)},
+            // TODO Error with "EncryptBeforeSigning" ordering.
+            // {new TestParam("_AD-ES_IPingService", STAX_PORT, true)},
+            {new TestParam("UXC_IPingService", STAX_PORT, true)},
+            {new TestParam("UXDC_IPingService", STAX_PORT, true)},
+            {new TestParam("UXDC-SEES_IPingService", STAX_PORT, true)},
+            {new TestParam("_UX_IPingService", STAX_PORT, true)},
+            {new TestParam("_UXD_IPingService", STAX_PORT, true)},
+            {new TestParam("_UXD-SEES_IPingService", STAX_PORT, true)},
+            // TODO Streaming endorsing not working 
+            // {new TestParam("XC_IPingService", STAX_PORT, true)},
+            // {new TestParam("XDC_IPingService", STAX_PORT, true)},
+            // {new TestParam("XDC_IPingService1", STAX_PORT, true)},
+            // {new TestParam("XDC-ES_IPingService", STAX_PORT, true)},
+            // {new TestParam("XDC-SEES_IPingService", STAX_PORT, true)},
+            // {new TestParam("_X_IPingService", STAX_PORT, true)},
+            {new TestParam("_X10_IPingService", STAX_PORT, true)},
+            // TODO Streaming endorsing not working 
+            // {new TestParam("_XD_IPingService", STAX_PORT, true)},
+            // {new TestParam("_XD-SEES_IPingService", STAX_PORT, true)},
+            // {new TestParam("_XD-ES_IPingService", STAX_PORT, true)},
+                
+        });
+    }
+    
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
         bus.shutdown(true);
         stopAllServers();
     }
-    
-    @Test
-    public void testSecureConversationMutualCertificate10SignEncryptIPingService() throws Exception {
-        runTest(false, "SecureConversation_MutualCertificate10SignEncrypt_IPingService");
-        // TODO Endorsing streaming not supported
-        // runTest(true, "SecureConversation_MutualCertificate10SignEncrypt_IPingService");
-    }
-
-    @Test
-    public void testACIPingService() throws Exception {
-        runTest(false, "AC_IPingService");
-        runTest(true, "AC_IPingService");
-    }
-
-    @Test
-    public void testADCIPingService() throws Exception {
-        runTest(false, "ADC_IPingService");
-        runTest(true, "ADC_IPingService");
-    }
-
-    @Test
-    public void testADCESIPingService() throws Exception {
-        runTest(false, "ADC-ES_IPingService");
-        // TODO Error with "EncryptBeforeSigning" ordering.
-        // runTest(true, "ADC-ES_IPingService");
-    }
-
-    @Test
-    public void testAIPingService() throws Exception {
-        runTest(false, "_A_IPingService");
-        runTest(true, "_A_IPingService");
-    }
-
-    @Test
-    public void testADIPingService() throws Exception {
-        runTest(false, "_AD_IPingService");
-        runTest(true, "_AD_IPingService");
-    }
-
-    @Test
-    public void testADESIPingService() throws Exception {
-        runTest(false, "_AD-ES_IPingService");
-        // TODO Error with "EncryptBeforeSigning" ordering.
-        // runTest(true, "_AD-ES_IPingService");
-    }
-
-    @Test
-    public void testUXCIPingService() throws Exception {
-        runTest(false, "UXC_IPingService");
-        runTest(true, "UXC_IPingService");
-    }
-
-    @Test
-    public void testUXDCIPingService() throws Exception {
-        runTest(false, "UXDC_IPingService");
-        runTest(true, "UXDC_IPingService");
-    }
-
-    @Test
-    public void testUXDCSEESIPingService() throws Exception {
-        runTest(false, "UXDC-SEES_IPingService");
-        runTest(true, "UXDC-SEES_IPingService");
-    }
-
-    @Test
-    public void testUXIPingService() throws Exception {
-        runTest(false, "_UX_IPingService");
-        runTest(true, "_UX_IPingService");
-    }
-
-    @Test
-    public void testUXDIPingService() throws Exception {
-        runTest(false, "_UXD_IPingService");
-        runTest(true, "_UXD_IPingService");
-    }
-
-    @Test
-    public void testUXDSEESIPingService() throws Exception {
-        runTest(false, "_UXD-SEES_IPingService");
-        runTest(true, "_UXD-SEES_IPingService");
-    }
-
-    @Test
-    public void testXCIPingService() throws Exception {
-        runTest(false, "XC_IPingService");
-        // TODO Streaming endorsing not working runTest(true, "XC_IPingService");
-    }
-
-    @Test
-    public void testXDCIPingService() throws Exception {
-        runTest(false, "XDC_IPingService");
-        // TODO Streaming endorsing not working runTest(true, "XDC_IPingService");
-    }
-
-    @Test
-    public void testXDCIPingService1() throws Exception {
-        runTest(false, "XDC_IPingService1");
-        // TODO Streaming endorsing not working runTest(true, "XDC_IPingService1");
-    }
-
-    @Test
-    public void testXDCESIPingService() throws Exception {
-        runTest(false, "XDC-ES_IPingService");
-        // TODO Streaming endorsing not working runTest(true, "XDC-ES_IPingService");
-    }
-
-    @Test
-    public void testXDCSEESIPingService() throws Exception {
-        runTest(false, "XDC-SEES_IPingService");
-        // TODO runTest(true, "XDC-SEES_IPingService");
-    }
-
+  
     @Test
-    public void testXIPingService() throws Exception {
-        runTest(false, "_X_IPingService");
-        // TODO Streaming endorsing not working runTest(true, "_X_IPingService");
-    }
-
-    @Test
-    public void testX10IPingService() throws Exception {
-        runTest(false, "_X10_IPingService");
-        runTest(true, "_X10_IPingService");
-    }
-
-    @Test
-    public void testXDIPingService() throws Exception {
-        runTest(false, "_XD_IPingService");
-        // TODO Streaming endorsing not working runTest(true, "_XD_IPingService");
-    }
-
-    @Test
-    public void testXDSEESIPingService() throws Exception {
-        runTest(false, "_XD-SEES_IPingService");
-        // TODO Streaming endorsing not working runTest(true, "_XD-SEES_IPingService");
-    }
-
-    @Test
-    public void testXDESIPingService() throws Exception {
-        runTest(false, "_XD-ES_IPingService");
-        // TODO "EncryptBeforeSigning" ordering issue
-        // runTest(true, "_XD-ES_IPingService");
-    }
+    public void testSecureConversation() throws Exception {
+        final wssec.wssc.IPingService port = 
+            svc.getPort(
+                new QName("http://WSSec/wssc", test.prefix),
+                wssec.wssc.IPingService.class
+            );
+
+        ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                                                        "http://localhost:" + test.port + "/" + test.prefix);
+        if (test.prefix.charAt(0) == '_') {
+            //MS would like the _ versions to send a cancel
+            ((BindingProvider)port).getRequestContext()
+                .put(SecurityConstants.STS_TOKEN_DO_CANCEL, Boolean.TRUE);
+        }
 
+        if (test.streaming) {
+            ((BindingProvider)port).getRequestContext().put(
+                SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+            );
+            ((BindingProvider)port).getResponseContext().put(
+                SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
+            );
+        }
 
-    private void runTest(boolean streaming, String ... argv) throws Exception {
-        for (String portPrefix : argv) {
-            final wssec.wssc.IPingService port = 
-                svc.getPort(
-                    new QName(
-                        "http://WSSec/wssc",
-                        portPrefix
-                    ),
-                    wssec.wssc.IPingService.class
-                );
-           
-            ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
-                                                            "http://localhost:" + PORT + "/" + portPrefix);
-            if (portPrefix.charAt(0) == '_') {
-                //MS would like the _ versions to send a cancel
-                ((BindingProvider)port).getRequestContext()
-                    .put(SecurityConstants.STS_TOKEN_DO_CANCEL, Boolean.TRUE);
-            }
-            
-            if (streaming) {
-                ((BindingProvider)port).getRequestContext().put(
-                    SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
-                );
-                ((BindingProvider)port).getResponseContext().put(
-                    SecurityConstants.ENABLE_STREAMING_SECURITY, "true"
-                );
-            }
-            
-            wssec.wssc.PingRequest params = new wssec.wssc.PingRequest();
-            org.xmlsoap.ping.Ping ping = new org.xmlsoap.ping.Ping();
-            ping.setOrigin("CXF");
-            ping.setScenario("Scenario5");
-            ping.setText("ping");
-            params.setPing(ping);
-            try {
-                wssec.wssc.PingResponse output = port.ping(params);
-                assertEquals(OUT, output.getPingResponse().getText());
-            } catch (Exception ex) {
-                throw new Exception("Error doing " + portPrefix, ex);
-            }
-            ((java.io.Closeable)port).close();
+        wssec.wssc.PingRequest params = new wssec.wssc.PingRequest();
+        org.xmlsoap.ping.Ping ping = new org.xmlsoap.ping.Ping();
+        ping.setOrigin("CXF");
+        ping.setScenario("Scenario5");
+        ping.setText("ping");
+        params.setPing(ping);
+        try {
+            wssec.wssc.PingResponse output = port.ping(params);
+            assertEquals(OUT, output.getPingResponse().getText());
+        } catch (Exception ex) {
+            throw new Exception("Error doing " + test.prefix, ex);
         }
+        ((java.io.Closeable)port).close();
     }
 
     

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCUnitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCUnitTest.java?rev=1546579&r1=1546578&r2=1546579&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCUnitTest.java (original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCUnitTest.java Fri Nov 29 15:14:27 2013
@@ -22,6 +22,8 @@ package org.apache.cxf.systest.ws.wssc;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,6 +37,7 @@ 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.addressing.policy.MetadataConstants;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
@@ -55,12 +58,13 @@ import org.apache.wss4j.policy.model.X50
 import org.example.contract.doubleit.DoubleItPortType;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
 
 /**
  * Some unit tests for SecureConversation.
- * 
- * It tests both DOM + StAX clients against the DOM server
  */
+@RunWith(value = org.junit.runners.Parameterized.class)
 public class WSSCUnitTest extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(UnitServer.class);
     static final String PORT2 = allocatePort(UnitServer.class, 2);
@@ -68,6 +72,12 @@ public class WSSCUnitTest extends Abstra
     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 WSSCUnitTest(TestParam type) {
+        this.test = type;
+    }
+    
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue(
@@ -78,6 +88,14 @@ public class WSSCUnitTest extends Abstra
         );
     }
     
+    @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();
@@ -85,7 +103,7 @@ public class WSSCUnitTest extends Abstra
     }
 
     @Test
-    public void testEndorsingSecureConverationDOM() throws Exception {
+    public void testEndorsingSecureConveration() throws Exception {
         
         SpringBusFactory bf = new SpringBusFactory();
         URL busFile = WSSCUnitTest.class.getResource("client.xml");
@@ -99,39 +117,19 @@ public class WSSCUnitTest extends Abstra
         QName portQName = new QName(NAMESPACE, "DoubleItTransportPort");
         DoubleItPortType port = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
-        
-        port.doubleIt(25);
+        updateAddressPort(port, test.getPort());
         
-        ((java.io.Closeable)port).close();
-    }
-    
-    @Test
-    public void testEndorsingSecureConverationStreaming() throws Exception {
-        
-        SpringBusFactory bf = new SpringBusFactory();
-        URL busFile = WSSCUnitTest.class.getResource("client.xml");
-
-        Bus bus = bf.createBus(busFile.toString());
-        SpringBusFactory.setDefaultBus(bus);
-        SpringBusFactory.setThreadDefaultBus(bus);
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
-        URL wsdl = WSSCUnitTest.class.getResource("DoubleItWSSC.wsdl");
-        Service service = Service.create(wsdl, SERVICE_QNAME);
-        QName portQName = new QName(NAMESPACE, "DoubleItTransportPort");
-        DoubleItPortType port = 
-                service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        port.doubleIt(25);
         
-        // Streaming
-        SecurityTestUtil.enableStreaming(port);
-        port.doubleIt(30);
-
         ((java.io.Closeable)port).close();
     }
     
     @Test
-    public void testEndorsingSecureConverationDOMSP12() throws Exception {
+    public void testEndorsingSecureConverationSP12() throws Exception {
         
         SpringBusFactory bf = new SpringBusFactory();
         URL busFile = WSSCUnitTest.class.getResource("client.xml");
@@ -145,7 +143,11 @@ public class WSSCUnitTest extends Abstra
         QName portQName = new QName(NAMESPACE, "DoubleItTransportSP12Port");
         DoubleItPortType port = 
                 service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
+        updateAddressPort(port, test.getPort());
+        
+        if (test.isStreaming()) {
+            SecurityTestUtil.enableStreaming(port);
+        }
         
         port.doubleIt(25);
         
@@ -153,32 +155,12 @@ public class WSSCUnitTest extends Abstra
     }
     
     @Test
-    public void testEndorsingSecureConverationStreamingSP12() throws Exception {
-        
-        SpringBusFactory bf = new SpringBusFactory();
-        URL busFile = WSSCUnitTest.class.getResource("client.xml");
-
-        Bus bus = bf.createBus(busFile.toString());
-        SpringBusFactory.setDefaultBus(bus);
-        SpringBusFactory.setThreadDefaultBus(bus);
-        
-        URL wsdl = WSSCUnitTest.class.getResource("DoubleItWSSC.wsdl");
-        Service service = Service.create(wsdl, SERVICE_QNAME);
-        QName portQName = new QName(NAMESPACE, "DoubleItTransportSP12Port");
-        DoubleItPortType port = 
-                service.getPort(portQName, DoubleItPortType.class);
-        updateAddressPort(port, PORT);
-        
-        // Streaming
-        SecurityTestUtil.enableStreaming(port);
-        port.doubleIt(30);
-
-        ((java.io.Closeable)port).close();
-    }
-
-    @Test
     public void testIssueUnitTest() throws Exception {
         
+        if (test.isStreaming()) {
+            return;
+        }
+        
         SpringBusFactory bf = new SpringBusFactory();
         URL busFile = WSSCUnitTest.class.getResource("client.xml");
 
@@ -186,7 +168,6 @@ public class WSSCUnitTest extends Abstra
         SpringBusFactory.setDefaultBus(bus);
         SpringBusFactory.setThreadDefaultBus(bus);
         
-        
         STSClient stsClient = new STSClient(bus);
         stsClient.setSecureConv(true);
         stsClient.setLocation("https://localhost:" + PORT + "/" + "DoubleItTransport");
@@ -207,6 +188,9 @@ public class WSSCUnitTest extends Abstra
     
     @Test
     public void testIssueAndCancelUnitTest() throws Exception {
+        if (test.isStreaming()) {
+            return;
+        }
         
         SpringBusFactory bf = new SpringBusFactory();
         URL busFile = WSSCUnitTest.class.getResource("client.xml");



Mime
View raw message