Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerMisc.java Thu Jun 3 20:33:29 2010 @@ -35,16 +35,19 @@ import org.apache.cxf.testutil.common.Ab public class ServerMisc extends AbstractBusTestServerBase { + public static final String PORT = allocatePort(ServerMisc.class); + + public static final String DOCLIT_CODEFIRST_URL = - "http://localhost:9003/DocLitWrappedCodeFirstService/"; + "http://localhost:" + PORT + "/DocLitWrappedCodeFirstService/"; public static final String RPCLIT_CODEFIRST_URL = - "http://localhost:9003/RpcLitCodeFirstService/"; + "http://localhost:" + PORT + "/RpcLitCodeFirstService/"; public static final String DOCLIT_CODEFIRST_BASE_URL = - "http://localhost:9003/DocLitWrappedCodeFirstServiceBaseService/"; + "http://localhost:" + PORT + "/DocLitWrappedCodeFirstServiceBaseService/"; public static final String DOCLITBARE_CODEFIRST_URL = - "http://localhost:9003/DocLitBareCodeFirstService/"; + "http://localhost:" + PORT + "/DocLitBareCodeFirstService/"; public static final String DOCLIT_CODEFIRST_SETTINGS_URL = - "http://localhost:9003/DocLitWrappedCodeFirstServiceSettings/"; + "http://localhost:" + PORT + "/DocLitWrappedCodeFirstServiceSettings/"; protected void run() { @@ -85,15 +88,15 @@ public class ServerMisc extends Abstract Endpoint.publish(DOCLIT_CODEFIRST_BASE_URL, implementor6); Object implementor1 = new AnonymousComplexTypeImpl(); - String address = "http://localhost:9000/anonymous_complex_typeSOAP"; + String address = "http://localhost:" + PORT + "/anonymous_complex_typeSOAP"; Endpoint.publish(address, implementor1); Object implementor2 = new JaxbElementTestImpl(); - address = "http://localhost:9001/jaxb_element_test"; + address = "http://localhost:" + PORT + "/jaxb_element_test"; Endpoint.publish(address, implementor2); Object implementor3 = new OrderedParamHolderImpl(); - address = "http://localhost:9002/ordered_param_holder/"; + address = "http://localhost:" + PORT + "/ordered_param_holder/"; Endpoint.publish(address, implementor3); //Object implementor4 = new DocLitWrappedCodeFirstServiceImpl(); @@ -102,7 +105,7 @@ public class ServerMisc extends Abstract Object implementor5 = new RpcLitCodeFirstServiceImpl(); Endpoint.publish(RPCLIT_CODEFIRST_URL, implementor5); - Endpoint.publish("http://localhost:9000/InheritContext/InheritPort", + Endpoint.publish("http://localhost:" + PORT + "/InheritContext/InheritPort", new InheritImpl()); }
Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerMixedStyle.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerMixedStyle.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerMixedStyle.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerMixedStyle.java Thu Jun 3 20:33:29 2010 @@ -31,13 +31,14 @@ import org.apache.hello_world_mixedstyle public class ServerMixedStyle extends AbstractBusTestServerBase { + static final String PORT = allocatePort(ServerMixedStyle.class); protected void run() { Object implementor = new GreeterImplMixedStyle(); - String address = "http://localhost:9027/SoapContext/SoapPort"; + String address = "http://localhost:" + PORT + "/SoapContext/SoapPort"; Endpoint.publish(address, implementor); - Endpoint.publish("http://localhost:9027/cxf885", new MixedTestImpl()); + Endpoint.publish("http://localhost:" + PORT + "/cxf885", new MixedTestImpl()); } public static void main(String[] args) { Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerXMLBinding.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerXMLBinding.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerXMLBinding.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerXMLBinding.java Thu Jun 3 20:33:29 2010 @@ -28,26 +28,29 @@ import org.apache.hello_world_xml_http.w public class ServerXMLBinding extends AbstractBusTestServerBase { + static final String REG_PORT = allocatePort(ServerXMLBinding.class); + static final String WRAP_PORT = allocatePort(ServerXMLBinding.class, 1); + static final String MIX_PORT = allocatePort(ServerXMLBinding.class, 2); protected void run() { Object implementor = new GreeterImpl(); - String address = "http://localhost:9031/XMLService/XMLPort"; + String address = "http://localhost:" + REG_PORT + "/XMLService/XMLPort"; Endpoint.publish(address, implementor); Object implementor1 = new org.apache.hello_world_xml_http.wrapped.GreeterImpl(); - address = "http://localhost:9032/XMLService/XMLPort"; + address = "http://localhost:" + WRAP_PORT + "/XMLService/XMLPort"; Endpoint.publish(address, implementor1); Object faultImplementor = new GreeterFaultImpl(); - String faultAddress = "http://localhost:9033/XMLService/XMLFaultPort"; + String faultAddress = "http://localhost:" + REG_PORT + "/XMLService/XMLFaultPort"; Endpoint.publish(faultAddress, faultImplementor); Object implementor2 = new HeaderTesterImpl(); - address = "http://localhost:9034/XMLContext/XMLPort"; + address = "http://localhost:" + REG_PORT + "/XMLContext/XMLPort"; Endpoint.publish(address, implementor2); Object implementor3 = new org.apache.hello_world_xml_http.mixed.GreeterImpl(); - address = "http://localhost:9028/XMLService/XMLPort"; + address = "http://localhost:" + MIX_PORT + "/XMLService/XMLPort"; Endpoint.publish(address, implementor3); } Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java Thu Jun 3 20:33:29 2010 @@ -36,7 +36,8 @@ import org.junit.BeforeClass; import org.junit.Test; public class AttachmentProviderXMLClientServerTest extends AbstractBusClientServerTestBase { - + private static final String ADDRESS = AttachmentServer.ADDRESS; + @BeforeClass public static void startServers() throws Exception { assertTrue("server did not launch correctly", @@ -47,7 +48,7 @@ public class AttachmentProviderXMLClient public void testRequestWithAttachment() throws Exception { HttpURLConnection connection = - (HttpURLConnection)new URL("http://localhost:9033/XMLServiceAttachment").openConnection(); + (HttpURLConnection)new URL(ADDRESS).openConnection(); connection.setRequestMethod("POST"); String ct = "multipart/related; type=\"text/xml\"; " + "start=\"rootPart\"; " Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentServer.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentServer.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentServer.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AttachmentServer.java Thu Jun 3 20:33:29 2010 @@ -22,13 +22,15 @@ package org.apache.cxf.systest.provider; import javax.xml.ws.Endpoint; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.testutil.common.TestUtil; public class AttachmentServer extends AbstractBusTestServerBase { - + public static final String ADDRESS + = "http://localhost:" + TestUtil.getPortNumber(AttachmentServer.class) + + "/XMLServiceAttachment"; protected void run() { Object implementor = new AttachmentStreamSourceXMLProvider(); - String address = "http://localhost:9033/XMLServiceAttachment"; - Endpoint.publish(address, implementor); + Endpoint.publish(ADDRESS, implementor); } public static void main(String[] args) { Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderClientServerTest.java Thu Jun 3 20:33:29 2010 @@ -27,18 +27,22 @@ import javax.xml.ws.Endpoint; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.testutil.common.TestUtil; import org.apache.hello_world_soap_http.Greeter; import org.apache.hello_world_soap_http.SOAPService; import org.junit.BeforeClass; import org.junit.Test; public class ProviderClientServerTest extends AbstractBusClientServerTestBase { + public static final String ADDRESS + = "http://localhost:" + TestUtil.getPortNumber(Server.class) + + "/SoapContext/SoapProviderPort"; + public static class Server extends AbstractBusTestServerBase { protected void run() { Object implementor = new HWSoapMessageDocProvider(); - String address = "http://localhost:9003/SoapContext/SoapProviderPort"; - Endpoint.publish(address, implementor); + Endpoint.publish(ADDRESS, implementor); } public static void main(String[] args) { @@ -77,6 +81,7 @@ public class ProviderClientServerTest ex String response2 = new String("Bonjour"); try { Greeter greeter = service.getPort(portName, Greeter.class); + setAddress(greeter, ADDRESS); try { greeter.greetMe("Return sayHi"); fail("Should have thrown an exception"); Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java Thu Jun 3 20:33:29 2010 @@ -39,7 +39,8 @@ import org.junit.BeforeClass; import org.junit.Test; public class ProviderRPCClientServerTest extends AbstractBusClientServerTestBase { - + private static final String PORT = Server.PORT; + @BeforeClass public static void startServers() throws Exception { assertTrue("server did not launch correctly", launchServer(Server.class)); @@ -63,7 +64,8 @@ public class ProviderRPCClientServerTest msg.saveChanges(); SOAPConnection con = conFac.createConnection(); - URL endpoint = new URL("http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1"); + URL endpoint = new URL("http://localhost:" + PORT + + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1"); SOAPMessage response = con.call(msg, endpoint); QName sayHiResp = new QName("http://apache.org/hello_world_rpclit", "sayHiResponse"); assertNotNull(response.getSOAPBody().getChildElements(sayHiResp)); @@ -74,21 +76,11 @@ public class ProviderRPCClientServerTest QName portName, int count, boolean doFault) throws Exception { - doGreeterRPCLit(service, portName, count, doFault, null); - } - private void doGreeterRPCLit(SOAPServiceRPCLit service, - QName portName, - int count, - boolean doFault, - String address) throws Exception { String response1 = new String("TestGreetMeResponse"); String response2 = new String("TestSayHiResponse"); try { GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); - if (address != null) { - ((BindingProvider)greeter).getRequestContext() - .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address); - } + updateAddressPort(greeter, PORT); for (int idx = 0; idx < count; idx++) { String greeting = greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service", greeting); @@ -128,6 +120,8 @@ public class ProviderRPCClientServerTest String response1 = new String("TestGreetMeResponseServerLogicalHandlerServerSOAPHandler"); String response2 = new String("TestSayHiResponse"); GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); + updateAddressPort(greeter, PORT); + String greeting = greeter.greetMe("Milestone-0"); assertNotNull("no response received from service", greeting); assertEquals(response1, greeting); @@ -177,12 +171,18 @@ public class ProviderRPCClientServerTest assertNotNull(service); String addresses[] = { - "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8", - "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-dom", - "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-sax", - "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-cxfstax", - "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stax", - "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stream" + "http://localhost:" + PORT + + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8", + "http://localhost:" + PORT + + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-dom", + "http://localhost:" + PORT + + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-sax", + "http://localhost:" + PORT + + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-cxfstax", + "http://localhost:" + PORT + + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stax", + "http://localhost:" + PORT + + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stream" }; String response1 = new String("TestGreetMeResponseServerLogicalHandlerServerSOAPHandler"); GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/ProviderXMLClientServerTest.java Thu Jun 3 20:33:29 2010 @@ -38,6 +38,8 @@ import org.junit.BeforeClass; import org.junit.Test; public class ProviderXMLClientServerTest extends AbstractBusClientServerTestBase { + public static final String ADDRESS = XMLServer.ADDRESS; + private final QName serviceName = new QName( "http://apache.org/hello_world_xml_http/wrapped", "XMLService"); @@ -52,7 +54,7 @@ public class ProviderXMLClientServerTest @Test public void testEmptyPost() throws Exception { - URL url = new URL("http://localhost:9022/XMLService/XMLProviderPort"); + URL url = new URL(ADDRESS); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("POST"); connection.setDoInput(true); @@ -76,6 +78,7 @@ public class ProviderXMLClientServerTest Dispatch<DOMSource> disp = service.createDispatch(portName, DOMSource.class, Service.Mode.PAYLOAD); + setAddress(disp, ADDRESS); DOMSource result = disp.invoke(reqMsg); assertNotNull(result); Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/Server.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/Server.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/Server.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/Server.java Thu Jun 3 20:33:29 2010 @@ -26,73 +26,75 @@ import javax.xml.ws.Endpoint; import org.apache.cxf.databinding.source.SourceDataBinding; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.testutil.common.TestUtil; public class Server extends AbstractBusTestServerBase { + public static final String PORT = TestUtil.getPortNumber(Server.class); protected void run() { Object implementor = new HWSourcePayloadProvider(); - String address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8"; + String address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8"; Endpoint ep = Endpoint.create(implementor); ep.publish(address); Map<String, Object> map = new HashMap<String, Object>(); map.put(SourceDataBinding.PREFERRED_FORMAT, "dom"); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-dom"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-dom"; ep = Endpoint.create(implementor); ep.setProperties(map); ep.publish(address); map.put(SourceDataBinding.PREFERRED_FORMAT, "sax"); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-sax"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-sax"; ep = Endpoint.create(implementor); ep.setProperties(map); ep.publish(address); map.put(SourceDataBinding.PREFERRED_FORMAT, "stax"); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stax"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stax"; ep = Endpoint.create(implementor); ep.setProperties(map); ep.publish(address); map.put(SourceDataBinding.PREFERRED_FORMAT, "cxf.stax"); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-cxfstax"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-cxfstax"; ep = Endpoint.create(implementor); ep.setProperties(map); ep.publish(address); map.put(SourceDataBinding.PREFERRED_FORMAT, "stream"); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stream"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stream"; ep = Endpoint.create(implementor); ep.setProperties(map); ep.publish(address); implementor = new HWSoapMessageProvider(); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1"; Endpoint.publish(address, implementor); implementor = new HWDOMSourceMessageProvider(); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit2"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit2"; Endpoint.publish(address, implementor); implementor = new HWDOMSourcePayloadProvider(); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit3"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit3"; Endpoint.publish(address, implementor); implementor = new HWSAXSourceMessageProvider(); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit4"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit4"; Endpoint.publish(address, implementor); implementor = new HWStreamSourceMessageProvider(); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit5"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit5"; Endpoint.publish(address, implementor); implementor = new HWSAXSourcePayloadProvider(); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit6"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit6"; Endpoint.publish(address, implementor); implementor = new HWStreamSourcePayloadProvider(); - address = "http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit7"; + address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit7"; Endpoint.publish(address, implementor); } Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/XMLServer.java Thu Jun 3 20:33:29 2010 @@ -25,17 +25,20 @@ import java.util.Map; import javax.xml.ws.Endpoint; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.testutil.common.TestUtil; public class XMLServer extends AbstractBusTestServerBase { - + public static final String ADDRESS + = "http://localhost:" + TestUtil.getPortNumber(XMLServer.class) + + "/XMLService/XMLProviderPort"; + protected void run() { Object implementor = new HWDOMSourcePayloadXMLBindingProvider(); - String address = "http://localhost:9022/XMLService/XMLProviderPort"; Endpoint ep = Endpoint.create(implementor); Map<String, Object> map = new HashMap<String, Object>(); map.put("schema-validation-enabled", Boolean.TRUE); ep.setProperties(map); - ep.publish(address); + ep.publish(ADDRESS); } public static void main(String[] args) { Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/DataSourceProviderTest.java Thu Jun 3 20:33:29 2010 @@ -42,11 +42,14 @@ import javax.xml.transform.stream.Stream import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.apache.cxf.testutil.common.TestUtil; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; public class DataSourceProviderTest extends AbstractBusClientServerTestBase { + static String serverPort = TestUtil.getPortNumber(Server.class); static final Logger LOG = LogUtils.getLogger(DataSourceProviderTest.class); private static final String BOUNDARY = "----=_Part_4_701508.1145579811786"; @@ -61,7 +64,7 @@ public class DataSourceProviderTest exte @Before public void createConnection() throws Exception { - url = new URL("http://localhost:9000/test/foo"); + url = new URL("http://localhost:" + serverPort + "/test/foo"); conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); } @@ -69,7 +72,7 @@ public class DataSourceProviderTest exte @Test public void invokeOnServer() throws Exception { - url = new URL("http://localhost:9000/test/foo"); + url = new URL("http://localhost:" + serverPort + "/test/foo"); conn = (HttpURLConnection) url.openConnection(); printSource(new StreamSource(conn.getInputStream())); } Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/Server.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/Server.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/Server.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/datasource/Server.java Thu Jun 3 20:33:29 2010 @@ -20,13 +20,15 @@ package org.apache.cxf.systest.provider.datasource; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.testutil.common.TestUtil; public class Server extends AbstractBusTestServerBase { - protected void run() { + protected void run() { + String port = TestUtil.getPortNumber(Server.class); TestProvider servant = new TestProvider(); - servant.publish("http://localhost:9000/test/foo"); + servant.publish("http://localhost:" + port + "/test/foo"); } public static void main(String[] args) throws Exception { Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java Thu Jun 3 20:33:29 2010 @@ -47,11 +47,14 @@ import org.apache.cxf.swa.types.DataStru import org.apache.cxf.swa.types.OutputResponseAll; import org.apache.cxf.swa.types.VoidRequest; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; +import org.apache.cxf.testutil.common.TestUtil; + import org.junit.BeforeClass; import org.junit.Test; public class ClientServerSwaTest extends AbstractBusClientServerTestBase { - + static String serverPort = TestUtil.getPortNumber(Server.class); + @BeforeClass public static void startServers() throws Exception { assertTrue("server did not launch correctly", launchServer(Server.class, true)); @@ -62,8 +65,7 @@ public class ClientServerSwaTest extends org.apache.cxf.swa_nomime.SwAService service = new org.apache.cxf.swa_nomime.SwAService(); org.apache.cxf.swa_nomime.SwAServiceInterface port = service.getSwAServiceHttpPort(); -// ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, -// "http://localhost:9037/swa"); + setAddress(port, "http://localhost:" + serverPort + "/swa-nomime"); Holder<String> textHolder = new Holder<String>("Hi"); Holder<byte[]> data = new Holder<byte[]>("foobar".getBytes()); @@ -105,9 +107,8 @@ public class ClientServerSwaTest extends SwAService service = new SwAService(); SwAServiceInterface port = service.getSwAServiceHttpPort(); -// ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, -// "http://localhost:9037/swa"); - + setAddress(port, "http://localhost:" + serverPort + "/swa"); + Holder<String> textHolder = new Holder<String>(); Holder<DataHandler> data = new Holder<DataHandler>(); @@ -133,8 +134,7 @@ public class ClientServerSwaTest extends SwAService service = new SwAService(); SwAServiceInterface port = service.getSwAServiceHttpPort(); -// ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, -// "http://localhost:9037/swa"); + setAddress(port, "http://localhost:" + serverPort + "/swa"); Holder<String> textHolder = new Holder<String>(); Holder<String> headerHolder = new Holder<String>(); @@ -164,8 +164,7 @@ public class ClientServerSwaTest extends SwAService service = new SwAService(); SwAServiceInterface port = service.getSwAServiceHttpPort(); -// ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, -// "http://localhost:9037/swa"); + setAddress(port, "http://localhost:" + serverPort + "/swa"); Holder<DataStruct> structHolder = new Holder<DataStruct>(); @@ -197,6 +196,7 @@ public class ClientServerSwaTest extends SwAService service = new SwAService(); SwAServiceInterface port = service.getSwAServiceHttpPort(); + setAddress(port, "http://localhost:" + serverPort + "/swa"); URL url1 = this.getClass().getResource("resources/attach.text"); URL url2 = this.getClass().getResource("resources/attach.html"); @@ -262,6 +262,7 @@ public class ClientServerSwaTest extends .createDispatch(SwAService.SwAServiceHttpPort, SOAPMessage.class, Service.Mode.MESSAGE); + setAddress(disp, "http://localhost:" + serverPort + "/swa"); SOAPMessage msg = MessageFactory.newInstance().createMessage(); Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/Server.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/Server.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/Server.java (original) +++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/Server.java Thu Jun 3 20:33:29 2010 @@ -23,12 +23,15 @@ import javax.xml.ws.Endpoint; import org.apache.cxf.jaxws.EndpointImpl; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.cxf.testutil.common.TestUtil; public class Server extends AbstractBusTestServerBase { protected void run() { + String port = TestUtil.getPortNumber(Server.class); + Object implementor = new SwAServiceImpl(); - String address = "http://localhost:9036/swa"; + String address = "http://localhost:" + port + "/swa"; EndpointImpl ep; try { ep = (EndpointImpl) Endpoint.create(new SwANoMimeServiceImpl()); Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java (original) +++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusClientServerTestBase.java Thu Jun 3 20:33:29 2010 @@ -28,7 +28,6 @@ import java.util.concurrent.LinkedBlocki import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; - import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.junit.After; @@ -109,7 +108,6 @@ public abstract class AbstractBusClientS bus = b; } - protected HttpURLConnection getHttpConnection(String target) throws Exception { URL url = new URL(target); Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java (original) +++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractClientServerTestBase.java Thu Jun 3 20:33:29 2010 @@ -20,10 +20,16 @@ package org.apache.cxf.testutil.common; import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; +import javax.xml.ws.BindingProvider; + +import org.apache.cxf.endpoint.Client; + import org.junit.AfterClass; import org.junit.Assert; @@ -100,4 +106,48 @@ public abstract class AbstractClientServ return ok; } + + + // extra methods to help support the dynamic port allocations + protected void setAddress(Object o, String address) { + if (o instanceof BindingProvider) { + ((BindingProvider)o).getRequestContext() + .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, + address); + } else if (o instanceof Client) { + Client c = (Client)o; + c.getEndpoint().getEndpointInfo().setAddress(address); + } + //maybe simple frontend proxy? + } + protected void updateAddressPort(Object o, String port) + throws NumberFormatException, MalformedURLException { + updateAddressPort(o, Integer.parseInt(port)); + } + protected void updateAddressPort(Object o, int port) throws MalformedURLException { + String address = null; + if (o instanceof BindingProvider) { + address = ((BindingProvider)o).getRequestContext() + .get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY).toString(); + } else if (o instanceof Client) { + Client c = (Client)o; + address = c.getEndpoint().getEndpointInfo().getAddress(); + } + if (address != null) { + URL url = new URL(address); + url = new URL(url.getProtocol(), url.getHost(), + port, url.getFile()); + setAddress(o, url.toString()); + } + //maybe simple frontend proxy? + } + + protected static String allocatePort(Class<?> cls) { + return TestUtil.getPortNumber(cls); + } + protected static String allocatePort(Class<?> cls, int count) { + return TestUtil.getPortNumber(cls, count); + } + + } Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractTestServerBase.java URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractTestServerBase.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractTestServerBase.java (original) +++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractTestServerBase.java Thu Jun 3 20:33:29 2010 @@ -116,5 +116,13 @@ public abstract class AbstractTestServer */ protected boolean verify(Logger log) { return true; - } + } + + protected static String allocatePort(Class<?> cls) { + return TestUtil.getPortNumber(cls); + } + protected static String allocatePort(Class<?> cls, int i) { + return TestUtil.getPortNumber(cls, i); + } + } Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java (original) +++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java Thu Jun 3 20:33:29 2010 @@ -340,6 +340,9 @@ public class ServerLauncher { cmd.add("-D" + entry.getKey() + "=" + entry.getValue()); } } + for (Map.Entry<Object, Object> entry : TestUtil.getAllPorts().entrySet()) { + cmd.add("-D" + entry.getKey() + "=" + entry.getValue()); + } if (Boolean.getBoolean("java.awt.headless")) { cmd.add("-Djava.awt.headless=true"); } Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java?rev=951144&r1=951143&r2=951144&view=diff ============================================================================== --- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java (original) +++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/TestUtil.java Thu Jun 3 20:33:29 2010 @@ -20,14 +20,18 @@ package org.apache.cxf.testutil.common; import java.io.File; +import java.io.IOException; import java.lang.reflect.Method; +import java.net.ServerSocket; import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; +import java.util.Properties; public final class TestUtil { - + static Properties ports = new Properties(); + private TestUtil() { //Complete } @@ -73,5 +77,35 @@ public final class TestUtil { } } return null; - } + } + public static Properties getAllPorts() { + return ports; + } + public static String getPortNumber(Class<?> cls) { + return getPortNumber(cls.getSimpleName()); + } + public static String getPortNumber(Class<?> cls, int count) { + return getPortNumber(cls.getSimpleName() + "." + count); + } + public static String getPortNumber(String name) { + String p = ports.getProperty("testutil.ports." + name); + if (p == null) { + p = System.getProperty("testutil.ports." + name); + if (p != null) { + ports.setProperty("testutil.ports." + name, p); + } + } + if (p == null) { + try { + ServerSocket sock = new ServerSocket(0); + p = Integer.toString(sock.getLocalPort()); + ports.put("testutil.ports." + name, p); + System.setProperty("testutil.ports." + name, p); + sock.close(); + } catch (IOException ex) { + // + } + } + return p; + } }
