Author: dkulp Date: Tue Sep 11 18:54:15 2012 New Revision: 1383544 URL: http://svn.apache.org/viewvc?rev=1383544&view=rev Log: Merged revisions 1383524 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
........ r1383524 | dkulp | 2012-09-11 14:39:00 -0400 (Tue, 11 Sep 2012) | 10 lines Merged revisions 1381676 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1381676 | dkulp | 2012-09-06 12:40:56 -0400 (Thu, 06 Sep 2012) | 2 lines Updates to get all the tests passing with the proxy related tests ........ ........ Modified: cxf/branches/2.5.x-fixes/systests/transports/pom.xml cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java Modified: cxf/branches/2.5.x-fixes/systests/transports/pom.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transports/pom.xml?rev=1383544&r1=1383543&r2=1383544&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/transports/pom.xml (original) +++ cxf/branches/2.5.x-fixes/systests/transports/pom.xml Tue Sep 11 18:54:15 2012 @@ -296,6 +296,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/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java?rev=1383544&r1=1383543&r2=1383544&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java (original) +++ cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/BusServer.java Tue Sep 11 18:54:15 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/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java?rev=1383544&r1=1383543&r2=1383544&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java (original) +++ cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/CertConstraintsTest.java Tue Sep 11 18:54:15 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/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java?rev=1383544&r1=1383543&r2=1383544&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java (original) +++ cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java Tue Sep 11 18:54:15 2012 @@ -70,6 +70,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; @@ -107,34 +108,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 { @@ -186,6 +165,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 @@ -196,13 +198,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, @@ -300,7 +304,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; @@ -356,7 +360,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; @@ -406,7 +410,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)); @@ -442,7 +446,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; @@ -479,7 +483,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); } @@ -495,7 +499,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); } @@ -553,7 +557,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. @@ -596,7 +600,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. @@ -685,7 +689,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. @@ -746,7 +750,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. @@ -892,7 +896,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/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java?rev=1383544&r1=1383543&r2=1383544&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java (original) +++ cxf/branches/2.5.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPSClientTest.java Tue Sep 11 18:54:15 2012 @@ -30,6 +30,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; /** @@ -37,12 +38,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 // @@ -61,6 +56,11 @@ public class HTTPSClientTest extends Abs e.printStackTrace(); } } + + @BeforeClass + public static void setupPorts() { + BusServer.resetPortMap(); + } public void startServers() throws Exception { assertTrue( @@ -131,35 +131,35 @@ 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 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); }
