You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/09/06 18:40:57 UTC
svn commit: r1381676 - in /cxf/trunk/systests/transports: ./
src/test/java/org/apache/cxf/systest/http/
Author: dkulp
Date: Thu Sep 6 16:40:56 2012
New Revision: 1381676
URL: http://svn.apache.org/viewvc?rev=1381676&view=rev
Log:
Updates to get all the tests passing with the proxy related tests
Modified:
cxf/trunk/systests/transports/pom.xml
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java
Modified: cxf/trunk/systests/transports/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/pom.xml?rev=1381676&r1=1381675&r2=1381676&view=diff
==============================================================================
--- cxf/trunk/systests/transports/pom.xml (original)
+++ cxf/trunk/systests/transports/pom.xml Thu Sep 6 16:40:56 2012
@@ -290,6 +290,16 @@
<groupId>org.littleshoot</groupId>
<artifactId>littleproxy</artifactId>
<version>0.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java?rev=1381676&r1=1381675&r2=1381676&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java Thu Sep 6 16:40:56 2012
@@ -19,24 +19,35 @@
package org.apache.cxf.systest.http;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
/**
* This server just instantiates a Bus, full stop.
* Everything else is designed to be spring-loaded.
*/
public class BusServer extends AbstractBusTestServerBase {
- public static final String PORT0 = allocatePort(BusServer.class, 0);
- public static final String PORT1 = allocatePort(BusServer.class, 1);
- public static final String PORT2 = allocatePort(BusServer.class, 2);
- public static final String PORT3 = allocatePort(BusServer.class, 3);
- public static final String PORT4 = allocatePort(BusServer.class, 4);
- public static final String PORT5 = allocatePort(BusServer.class, 5);
- public static final String PORT6 = allocatePort(BusServer.class, 6);
- public static final String PORT7 = allocatePort(BusServer.class, 7);
- public static final String PORT8 = allocatePort(BusServer.class, 8);
+ public static final Map<String, String> PORTMAP = new HashMap<String, String>();
+ public static void resetPortMap() {
+ PORTMAP.clear();
+ for (int x = 0; x < 9; x++) {
+ PORTMAP.put("PORT" + x, TestUtil.getNewPortNumber(BusServer.class, x));
+ }
+ }
+ public static String getPort(int x) {
+ if (PORTMAP.isEmpty()) {
+ for (int y = 0; y < 9; y++) {
+ PORTMAP.put("PORT" + y, TestUtil.getPortNumber(BusServer.class, y));
+ }
+ }
+ return PORTMAP.get("PORT" + x);
+ }
+
protected void run() {
//
Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java?rev=1381676&r1=1381675&r2=1381676&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java Thu Sep 6 16:40:56 2012
@@ -29,6 +29,7 @@ import org.apache.cxf.testutil.common.Ab
import org.apache.hello_world.Greeter;
import org.apache.hello_world.services.SOAPService;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -36,19 +37,15 @@ import org.junit.Test;
* constraints logic.
*/
public class CertConstraintsTest extends AbstractBusClientServerTestBase {
- public static final String PORT0 = BusServer.PORT0;
- public static final String PORT1 = BusServer.PORT1;
- public static final String PORT2 = BusServer.PORT2;
- public static final String PORT3 = BusServer.PORT3;
- public static final String PORT4 = BusServer.PORT4;
- public static final String PORT5 = BusServer.PORT5;
- public static final String PORT6 = BusServer.PORT6;
- public static final String PORT7 = BusServer.PORT7;
- public static final String PORT8 = BusServer.PORT8;
//
// data
//
+ @BeforeClass
+ public static void allocatePorts() {
+ BusServer.resetPortMap();
+ }
+
/**
* the package path used to locate resources specific to this test
*/
@@ -130,35 +127,35 @@ public class CertConstraintsTest extends
//
// Good Subject DN
//
- testSuccessfulCall("https://localhost:" + PORT0 + "/SoapContext/HttpsPort");
+ testSuccessfulCall("https://localhost:" + BusServer.getPort(0) + "/SoapContext/HttpsPort");
//
// Bad Subject DN
//
- testFailedCall("https://localhost:" + PORT1 + "/SoapContext/HttpsPort");
+ testFailedCall("https://localhost:" + BusServer.getPort(1) + "/SoapContext/HttpsPort");
//
// Mixed Subject DN (ALL)
//
- testFailedCall("https://localhost:" + PORT2 + "/SoapContext/HttpsPort");
+ testFailedCall("https://localhost:" + BusServer.getPort(2) + "/SoapContext/HttpsPort");
//
// Mixed Subject DN (ANY)
//
- testSuccessfulCall("https://localhost:" + PORT3 + "/SoapContext/HttpsPort");
+ testSuccessfulCall("https://localhost:" + BusServer.getPort(3) + "/SoapContext/HttpsPort");
//
// Mixed Issuer DN (ALL)
//
- testFailedCall("https://localhost:" + PORT4 + "/SoapContext/HttpsPort");
+ testFailedCall("https://localhost:" + BusServer.getPort(4) + "/SoapContext/HttpsPort");
//
// Mixed Issuer DN (ANY)
//
- testSuccessfulCall("https://localhost:" + PORT5 + "/SoapContext/HttpsPort");
+ testSuccessfulCall("https://localhost:" + BusServer.getPort(5) + "/SoapContext/HttpsPort");
//
// Bad server Subject DN
//
- testFailedCall("https://localhost:" + PORT6 + "/SoapContext/HttpsPort");
+ testFailedCall("https://localhost:" + BusServer.getPort(6) + "/SoapContext/HttpsPort");
//
// Bad server Issuer DN
//
- testFailedCall("https://localhost:" + PORT7 + "/SoapContext/HttpsPort");
+ testFailedCall("https://localhost:" + BusServer.getPort(7) + "/SoapContext/HttpsPort");
stopServers();
}
Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java?rev=1381676&r1=1381675&r2=1381676&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java Thu Sep 6 16:40:56 2012
@@ -71,6 +71,7 @@ import org.apache.hello_world.Greeter;
import org.apache.hello_world.services.SOAPService;
import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
@@ -108,34 +109,12 @@ import org.springframework.context.Appli
* the Hostname Verifier.
*/
public class HTTPConduitTest extends AbstractBusClientServerTestBase {
- public static final String PORT0 = BusServer.PORT0;
- public static final String PORT1 = BusServer.PORT1;
- public static final String PORT2 = BusServer.PORT2;
- public static final String PORT3 = BusServer.PORT3;
- public static final String PORT4 = BusServer.PORT4;
- public static final String PORT5 = BusServer.PORT5;
- public static final String PORT6 = BusServer.PORT6;
- public static final String PORT7 = BusServer.PORT7;
- public static final String PORT8 = BusServer.PORT8;
-
private static final boolean IN_PROCESS = true;
private static TLSClientParameters tlsClientParameters = new TLSClientParameters();
- private static Map<String, String> addrMap = new TreeMap<String, String>();
private static List<String> servers = new ArrayList<String>();
- static {
- addrMap.put("Mortimer", "http://localhost:" + PORT0 + "/");
- addrMap.put("Tarpin", "https://localhost:" + PORT3 + "/");
- addrMap.put("Rethwel", "http://localhost:" + PORT4 + "/");
- addrMap.put("Poltim", "https://localhost:" + PORT5 + "/");
- addrMap.put("Gordy", "https://localhost:" + PORT1 + "/");
- addrMap.put("Bethal", "https://localhost:" + PORT2 + "/");
- addrMap.put("Abost", "http://localhost:" + PORT7 + "/");
- addrMap.put("Hurlon", "http://localhost:" + PORT6 + "/");
- addrMap.put("Morpit", "https://localhost:" + PORT8 + "/");
- tlsClientParameters.setDisableCNCheck(true);
- }
+ private static Map<String, String> addrMap = new TreeMap<String, String>();
static {
try {
@@ -187,6 +166,29 @@ public class HTTPConduitTest extends Abs
//new QName("http://apache.org/hello_world", "Abost");
public HTTPConduitTest() {
}
+
+
+ public static String getPort(String s) {
+ return BusServer.PORTMAP.get(s);
+ }
+
+ @BeforeClass
+ public static void allocatePorts() {
+ BusServer.resetPortMap();
+ addrMap.clear();
+ addrMap.put("Mortimer", "http://localhost:" + getPort("PORT0") + "/");
+ addrMap.put("Tarpin", "https://localhost:" + getPort("PORT3") + "/");
+ addrMap.put("Rethwel", "http://localhost:" + getPort("PORT4") + "/");
+ addrMap.put("Poltim", "https://localhost:" + getPort("PORT5") + "/");
+ addrMap.put("Gordy", "https://localhost:" + getPort("PORT1") + "/");
+ addrMap.put("Bethal", "https://localhost:" + getPort("PORT2") + "/");
+ addrMap.put("Abost", "http://localhost:" + getPort("PORT7") + "/");
+ addrMap.put("Hurlon", "http://localhost:" + getPort("PORT6") + "/");
+ addrMap.put("Morpit", "https://localhost:" + getPort("PORT8") + "/");
+ tlsClientParameters.setDisableCNCheck(true);
+ servers.clear();
+ }
+
/**
* This function is used to start up a server. It only "starts" a
@@ -197,13 +199,15 @@ public class HTTPConduitTest extends Abs
* server approach allieviates the pain in starting them all just to run
* a particular test in the debugger.
*/
- public static synchronized boolean startServer(String name) {
+ public synchronized boolean startServer(String name) {
if (servers.contains(name)) {
return true;
}
Bus bus = BusFactory.getThreadDefaultBus(false);
URL serverC =
Server.class.getResource("resources/" + name + ".cxf");
+ BusFactory.setDefaultBus(null);
+ BusFactory.setThreadDefaultBus(null);
boolean server = launchServer(Server.class, null,
new String[] {
name,
@@ -301,7 +305,7 @@ public class HTTPConduitTest extends Abs
Greeter mortimer = service.getPort(mortimerQ, Greeter.class);
assertNotNull("Port is null", mortimer);
- updateAddressPort(mortimer, PORT0);
+ updateAddressPort(mortimer, getPort("PORT0"));
configureProxy(ClientProxy.getClient(mortimer));
return mortimer;
@@ -357,7 +361,7 @@ public class HTTPConduitTest extends Abs
Greeter rethwel = service.getPort(rethwelQ, Greeter.class);
assertNotNull("Port is null", rethwel);
- updateAddressPort(rethwel, PORT4);
+ updateAddressPort(rethwel, getPort("PORT4"));
configureProxy(ClientProxy.getClient(rethwel));
String answer = null;
@@ -407,7 +411,7 @@ public class HTTPConduitTest extends Abs
assertNotNull("Service is null", service);
Greeter rethwel = service.getPort(rethwelQ, Greeter.class);
- updateAddressPort(rethwel, PORT4);
+ updateAddressPort(rethwel, getPort("PORT4"));
assertNotNull("Port is null", rethwel);
configureProxy(ClientProxy.getClient(rethwel));
@@ -443,7 +447,7 @@ public class HTTPConduitTest extends Abs
Greeter hurlon = service.getPort(hurlonQ, Greeter.class);
assertNotNull("Port is null", hurlon);
- updateAddressPort(hurlon, PORT6);
+ updateAddressPort(hurlon, getPort("PORT6"));
configureProxy(ClientProxy.getClient(hurlon));
String answer = null;
@@ -480,7 +484,7 @@ public class HTTPConduitTest extends Abs
Greeter bethal = service.getPort(bethalQ, Greeter.class);
assertNotNull("Port is null", bethal);
- updateAddressPort(bethal, PORT2);
+ updateAddressPort(bethal, getPort("PORT2"));
verifyBethalClient(bethal);
}
@@ -496,7 +500,7 @@ public class HTTPConduitTest extends Abs
ApplicationContext context = bus.getExtension(BusApplicationContext.class);
Greeter bethal = (Greeter)context.getBean("Bethal");
- updateAddressPort(bethal, PORT2);
+ updateAddressPort(bethal, getPort("PORT2"));
// verify the client side's setting
verifyBethalClient(bethal);
}
@@ -558,7 +562,7 @@ public class HTTPConduitTest extends Abs
Greeter bethal = service.getPort(bethalQ, Greeter.class);
assertNotNull("Port is null", bethal);
- updateAddressPort(bethal, PORT2);
+ updateAddressPort(bethal, getPort("PORT2"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
@@ -601,7 +605,7 @@ public class HTTPConduitTest extends Abs
Greeter poltim = service.getPort(poltimQ, Greeter.class);
assertNotNull("Port is null", poltim);
- updateAddressPort(poltim, PORT5);
+ updateAddressPort(poltim, getPort("PORT5"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
@@ -690,7 +694,7 @@ public class HTTPConduitTest extends Abs
Greeter bethal = service.getPort(bethalQ, Greeter.class);
assertNotNull("Port is null", bethal);
- updateAddressPort(bethal, PORT2);
+ updateAddressPort(bethal, getPort("PORT2"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
@@ -751,7 +755,7 @@ public class HTTPConduitTest extends Abs
Greeter tarpin = service.getPort(tarpinQ, Greeter.class);
assertNotNull("Port is null", tarpin);
- updateAddressPort(tarpin, PORT3);
+ updateAddressPort(tarpin, getPort("PORT3"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
@@ -897,7 +901,7 @@ public class HTTPConduitTest extends Abs
Greeter gordy = service.getPort(gordyQ, Greeter.class);
assertNotNull("Port is null", gordy);
- updateAddressPort(gordy, PORT1);
+ updateAddressPort(gordy, getPort("PORT1"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java?rev=1381676&r1=1381675&r2=1381676&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java Thu Sep 6 16:40:56 2012
@@ -36,6 +36,7 @@ import org.apache.cxf.testutil.common.Ab
import org.apache.hello_world.Greeter;
import org.apache.hello_world.services.SOAPService;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -43,12 +44,6 @@ import org.junit.Test;
* HTTP/S service.
*/
public class HTTPSClientTest extends AbstractBusClientServerTestBase {
- public static final String PORT1 = BusServer.PORT1;
- public static final String PORT2 = BusServer.PORT2;
- public static final String PORT3 = BusServer.PORT3;
- public static final String PORT4 = BusServer.PORT4;
- public static final String PORT5 = BusServer.PORT5;
- public static final String PORT6 = BusServer.PORT6;
//
// data
//
@@ -67,6 +62,11 @@ public class HTTPSClientTest extends Abs
e.printStackTrace();
}
}
+
+ @BeforeClass
+ public static void setupPorts() {
+ BusServer.resetPortMap();
+ }
public void startServers() throws Exception {
assertTrue(
@@ -137,39 +137,39 @@ public class HTTPSClientTest extends Abs
@Test
public final void testJaxwsServer() throws Exception {
testSuccessfulCall("resources/jaxws-server.xml",
- "https://localhost:" + PORT2 + "/SoapContext/HttpsPort");
+ "https://localhost:" + BusServer.getPort(2) + "/SoapContext/HttpsPort");
}
@Test
public final void testJaxwsServerChangeHttpsToHttp() throws Exception {
testSuccessfulCall("resources/jaxws-server.xml",
- "http://localhost:" + PORT3 + "/SoapContext/HttpPort");
+ "http://localhost:" + BusServer.getPort(3) + "/SoapContext/HttpPort");
}
@Test
public final void testJaxwsEndpoint() throws Exception {
testSuccessfulCall("resources/jaxws-publish.xml",
- "https://localhost:" + PORT1 + "/SoapContext/HttpsPort");
+ "https://localhost:" + BusServer.getPort(1) + "/SoapContext/HttpsPort");
}
@Test
public final void testJaxwsTLSRefsEndpoint() throws Exception {
testSuccessfulCall("resources/jaxws-tlsrefs-publish.xml",
- "https://localhost:" + PORT1 + "/SoapContext/HttpsPort");
+ "https://localhost:" + BusServer.getPort(1) + "/SoapContext/HttpsPort");
}
@Test
public final void testPKCS12Endpoint() throws Exception {
testSuccessfulCall("resources/pkcs12.xml",
- "https://localhost:" + PORT6 + "/SoapContext/HttpsPort");
+ "https://localhost:" + BusServer.getPort(6) + "/SoapContext/HttpsPort");
}
@Test
public final void testResourceKeySpecEndpoint() throws Exception {
testSuccessfulCall("resources/resource-key-spec.xml",
- "https://localhost:" + PORT4 + "/SoapContext/HttpsPort");
+ "https://localhost:" + BusServer.getPort(4) + "/SoapContext/HttpsPort");
}
@Test
public final void testResourceKeySpecEndpointURL() throws Exception {
testSuccessfulCall("resources/resource-key-spec-url.xml",
- "https://localhost:" + PORT5 + "/SoapContext/HttpsPort",
- new URL("https://localhost:" + PORT5 + "/SoapContext/HttpsPort?wsdl"),
+ "https://localhost:" + BusServer.getPort(5) + "/SoapContext/HttpsPort",
+ new URL("https://localhost:" + BusServer.getPort(5) + "/SoapContext/HttpsPort?wsdl"),
true);
}