You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2013/11/28 13:12:35 UTC
svn commit: r1546353 - in
/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples:
common/ saml/ secconv/ ut/ x509/
Author: coheigea
Date: Thu Nov 28 12:12:34 2013
New Revision: 1546353
URL: http://svn.apache.org/r1546353
Log:
Adding parameterized tests for the WS-Security example systests
Added:
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/TestParam.java
Removed:
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/saml/StaxSamlTokenTest.java
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/secconv/StaxSecureConversationTest.java
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/ut/StaxUsernameTokenTest.java
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/x509/StaxX509TokenTest.java
Modified:
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/saml/SamlTokenTest.java
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/secconv/SecureConversationTest.java
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/ut/UsernameTokenTest.java
cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/x509/X509TokenTest.java
Added: cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/TestParam.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/TestParam.java?rev=1546353&view=auto
==============================================================================
--- cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/TestParam.java (added)
+++ cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/TestParam.java Thu Nov 28 12:12:34 2013
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.wssec.examples.common;
+
+/**
+ * This holds some parameters to pass to the tests to avoid duplicating code.
+ */
+public final class TestParam {
+ final String port;
+ final boolean streaming;
+
+ public TestParam(String p, boolean b) {
+ port = p;
+ streaming = b;
+ }
+
+ public String toString() {
+ return port + ":" + (streaming ? "streaming" : "dom");
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public boolean isStreaming() {
+ return streaming;
+ }
+
+}
Modified: cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/saml/SamlTokenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/saml/SamlTokenTest.java?rev=1546353&r1=1546352&r2=1546353&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/saml/SamlTokenTest.java (original)
+++ cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/saml/SamlTokenTest.java Thu Nov 28 12:12:34 2013
@@ -20,6 +20,8 @@
package org.apache.cxf.systest.wssec.examples.saml;
import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
@@ -28,29 +30,37 @@ import javax.xml.ws.Service;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.systest.wssec.examples.common.SecurityTestUtil;
+import org.apache.cxf.systest.wssec.examples.common.TestParam;
import org.apache.cxf.systest.wssec.examples.sts.STSServer;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.ws.security.SecurityConstants;
import org.apache.cxf.ws.security.trust.STSClient;
-
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 SAML Tokens using policies defined in the OASIS spec:
* "WS-SecurityPolicy Examples Version 1.0".
- *
- * It tests both DOM + StAX clients against the DOM server
*/
+@RunWith(value = org.junit.runners.Parameterized.class)
public class SamlTokenTest extends AbstractBusClientServerTestBase {
static final String PORT = allocatePort(Server.class);
+ static final String STAX_PORT = allocatePort(StaxServer.class);
static final String PORT2 = allocatePort(Server.class, 2);
+ static final String STAX_PORT2 = allocatePort(StaxServer.class, 2);
static final String STS_PORT = allocatePort(STSServer.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 SamlTokenTest(TestParam type) {
+ this.test = type;
+ }
+
@BeforeClass
public static void startServers() throws Exception {
assertTrue(
@@ -60,6 +70,12 @@ public class SamlTokenTest extends Abstr
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)
+ );
+ assertTrue(
"Server failed to launch",
// run the server in the same process
// set this to false to fork
@@ -67,6 +83,16 @@ public class SamlTokenTest extends Abstr
);
}
+ @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
public static void cleanup() throws Exception {
SecurityTestUtil.cleanup();
@@ -91,13 +117,12 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItBearerPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT);
+ updateAddressPort(samlPort, test.getPort());
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
@@ -122,13 +147,16 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItTLSSenderVouchesPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT2);
+ String portNumber = PORT2;
+ if (STAX_PORT.equals(test.getPort())) {
+ portNumber = STAX_PORT2;
+ }
+ updateAddressPort(samlPort, portNumber);
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
@@ -153,13 +181,16 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItTLSHOKSignedEndorsingPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT2);
+ String portNumber = PORT2;
+ if (STAX_PORT.equals(test.getPort())) {
+ portNumber = STAX_PORT2;
+ }
+ updateAddressPort(samlPort, portNumber);
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
@@ -184,13 +215,8 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSignedPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT);
-
- // DOM
- samlPort.doubleIt(25);
+ updateAddressPort(samlPort, test.getPort());
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
@@ -215,13 +241,12 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricInitiatorPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT);
+ updateAddressPort(samlPort, test.getPort());
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
@@ -247,13 +272,12 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSaml2BearerPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT);
+ updateAddressPort(samlPort, test.getPort());
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
@@ -278,13 +302,16 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItTLSSenderVouchesSaml2Port");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT2);
-
- // DOM
- samlPort.doubleIt(25);
+ String portNumber = PORT2;
+ if (STAX_PORT.equals(test.getPort())) {
+ portNumber = STAX_PORT2;
+ }
+ updateAddressPort(samlPort, portNumber);
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
+
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
@@ -309,13 +336,16 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItTLSHOKSignedEndorsingSaml2Port");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT2);
+ String portNumber = PORT2;
+ if (STAX_PORT.equals(test.getPort())) {
+ portNumber = STAX_PORT2;
+ }
+ updateAddressPort(samlPort, portNumber);
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
@@ -340,14 +370,16 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSVPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT);
+ updateAddressPort(samlPort, test.getPort());
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
// TODO Endorsing Streaming not supported yet Streaming
- // SecurityTestUtil.enableStreaming(samlPort);
- // samlPort.doubleIt(25);
+ if (!test.isStreaming()) {
+ samlPort.doubleIt(25);
+ }
((java.io.Closeable)samlPort).close();
bus.shutdown(true);
@@ -371,15 +403,18 @@ public class SamlTokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItSymmetricIssuedTokenPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT);
+ updateAddressPort(samlPort, test.getPort());
updateSTSPort((BindingProvider)samlPort, STS_PORT);
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
// TODO Endorsing SAML not supported Streaming
- // SecurityTestUtil.enableStreaming(samlPort);
- // samlPort.doubleIt(25);
+ // TODO Problem with policy validation on the StAX Server side
+ if (!test.isStreaming() && PORT.equals(test.getPort())) {
+ samlPort.doubleIt(25);
+ }
((java.io.Closeable)samlPort).close();
bus.shutdown(true);
Modified: cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/secconv/SecureConversationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/secconv/SecureConversationTest.java?rev=1546353&r1=1546352&r2=1546353&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/secconv/SecureConversationTest.java (original)
+++ cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/secconv/SecureConversationTest.java Thu Nov 28 12:12:34 2013
@@ -20,6 +20,8 @@
package org.apache.cxf.systest.wssec.examples.secconv;
import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
@@ -27,21 +29,30 @@ import javax.xml.ws.Service;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.systest.wssec.examples.common.SecurityTestUtil;
+import org.apache.cxf.systest.wssec.examples.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 tests for SecureConversation using policies defined in the OASIS spec:
* "WS-SecurityPolicy Examples Version 1.0".
- *
- * It tests both DOM + StAX clients against the DOM server
*/
+@RunWith(value = org.junit.runners.Parameterized.class)
public class SecureConversationTest 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 SecureConversationTest(TestParam type) {
+ this.test = type;
+ }
@BeforeClass
public static void startServers() throws Exception {
@@ -51,6 +62,22 @@ public class SecureConversationTest exte
// 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
@@ -78,13 +105,12 @@ public class SecureConversationTest exte
QName portQName = new QName(NAMESPACE, "DoubleItSecureConversationPort");
DoubleItPortType samlPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(samlPort, PORT);
+ updateAddressPort(samlPort, test.getPort());
- // DOM
- samlPort.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(samlPort);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(samlPort);
samlPort.doubleIt(25);
((java.io.Closeable)samlPort).close();
Modified: cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/ut/UsernameTokenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/ut/UsernameTokenTest.java?rev=1546353&r1=1546352&r2=1546353&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/ut/UsernameTokenTest.java (original)
+++ cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/ut/UsernameTokenTest.java Thu Nov 28 12:12:34 2013
@@ -20,6 +20,8 @@
package org.apache.cxf.systest.wssec.examples.ut;
import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
@@ -27,25 +29,33 @@ import javax.xml.ws.Service;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.systest.wssec.examples.common.SecurityTestUtil;
+import org.apache.cxf.systest.wssec.examples.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 tests for Username Tokens using policies defined in the OASIS spec:
* "WS-SecurityPolicy Examples Version 1.0".
- *
- * It tests both DOM + StAX clients against the DOM server
*/
+@RunWith(value = org.junit.runners.Parameterized.class)
public class UsernameTokenTest extends AbstractBusClientServerTestBase {
static final String PORT = allocatePort(Server.class);
static final String PORT2 = allocatePort(Server.class, 2);
+ static final String STAX_PORT = allocatePort(StaxServer.class);
+ static final String STAX_PORT2 = allocatePort(StaxServer.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 UsernameTokenTest(TestParam type) {
+ this.test = type;
+ }
+
@BeforeClass
public static void startServers() throws Exception {
assertTrue(
@@ -54,6 +64,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
@@ -80,13 +106,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();
@@ -111,13 +136,12 @@ public class UsernameTokenTest extends A
QName portQName = new QName(NAMESPACE, "DoubleItPlaintextNoPasswordPort");
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();
@@ -142,13 +166,12 @@ public class UsernameTokenTest extends A
QName portQName = new QName(NAMESPACE, "DoubleItDigestPort");
DoubleItPortType utPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(utPort, PORT);
-
- // DOM
- utPort.doubleIt(25);
+ updateAddressPort(utPort, test.getPort());
- // Streaming
- SecurityTestUtil.enableStreaming(utPort);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(utPort);
+ }
+
utPort.doubleIt(25);
((java.io.Closeable)utPort).close();
@@ -173,13 +196,16 @@ public class UsernameTokenTest extends A
QName portQName = new QName(NAMESPACE, "DoubleItTLSSupportingPort");
DoubleItPortType utPort =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(utPort, PORT2);
+ String portNumber = PORT2;
+ if (STAX_PORT.equals(test.getPort())) {
+ portNumber = STAX_PORT2;
+ }
+ updateAddressPort(utPort, portNumber);
+
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(utPort);
+ }
- // DOM
- utPort.doubleIt(25);
-
- // Streaming
- SecurityTestUtil.enableStreaming(utPort);
utPort.doubleIt(25);
((java.io.Closeable)utPort).close();
@@ -204,13 +230,12 @@ public class UsernameTokenTest extends A
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSESupportingPort");
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();
@@ -235,13 +260,12 @@ public class UsernameTokenTest extends A
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncrSupportingPort");
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();
@@ -266,13 +290,12 @@ public class UsernameTokenTest extends A
QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSESupportingPort");
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();
Modified: cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/x509/X509TokenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/x509/X509TokenTest.java?rev=1546353&r1=1546352&r2=1546353&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/x509/X509TokenTest.java (original)
+++ cxf/trunk/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/x509/X509TokenTest.java Thu Nov 28 12:12:34 2013
@@ -20,6 +20,8 @@
package org.apache.cxf.systest.wssec.examples.x509;
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.wssec.examples.common.SecurityTestUtil;
+import org.apache.cxf.systest.wssec.examples.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 tests for X509 Tokens using policies defined in the OASIS spec:
* "WS-SecurityPolicy Examples Version 1.0".
- *
- * It tests both DOM + StAX clients against the DOM server
*/
+@RunWith(value = org.junit.runners.Parameterized.class)
public class X509TokenTest 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 X509TokenTest(TestParam type) {
+ this.test = type;
+ }
@BeforeClass
public static void startServers() throws Exception {
@@ -53,6 +62,22 @@ public class X509TokenTest extends Abstr
// 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
@@ -79,13 +104,12 @@ public class X509TokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSignEncryptPort");
DoubleItPortType x509Port =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(x509Port, PORT);
+ updateAddressPort(x509Port, test.getPort());
- // DOM
- x509Port.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(x509Port);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(x509Port);
x509Port.doubleIt(25);
((java.io.Closeable)x509Port).close();
@@ -110,13 +134,12 @@ public class X509TokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricProtectTokensPort");
DoubleItPortType x509Port =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(x509Port, PORT);
+ updateAddressPort(x509Port, test.getPort());
- // DOM
- x509Port.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(x509Port);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(x509Port);
x509Port.doubleIt(25);
((java.io.Closeable)x509Port).close();
@@ -141,13 +164,12 @@ public class X509TokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSignEncryptPort");
DoubleItPortType x509Port =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(x509Port, PORT);
+ updateAddressPort(x509Port, test.getPort());
- // DOM
- x509Port.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(x509Port);
+ }
- // Streaming
- SecurityTestUtil.enableStreaming(x509Port);
x509Port.doubleIt(25);
((java.io.Closeable)x509Port).close();
@@ -172,14 +194,16 @@ public class X509TokenTest extends Abstr
QName portQName = new QName(NAMESPACE, "DoubleItSymmetricEndorsingPort");
DoubleItPortType x509Port =
service.getPort(portQName, DoubleItPortType.class);
- updateAddressPort(x509Port, PORT);
+ updateAddressPort(x509Port, test.getPort());
- // DOM
- x509Port.doubleIt(25);
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(x509Port);
+ }
// TODO - support endorsing Streaming
- // SecurityTestUtil.enableStreaming(x509Port);
- // x509Port.doubleIt(25);
+ if (!test.isStreaming()) {
+ x509Port.doubleIt(25);
+ }
((java.io.Closeable)x509Port).close();
bus.shutdown(true);