You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by di...@apache.org on 2004/11/05 21:39:12 UTC

svn commit: rev 56696 - in geronimo/trunk/modules/axis/src: java/org/apache/geronimo/axis test/org/apache/geronimo/axis test/org/apache/geronimo/axis/preconditions

Author: dims
Date: Fri Nov  5 12:39:11 2004
New Revision: 56696

Modified:
   geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGeronimoUtils.java
   geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisGBeanTest.java
   geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java
   geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/EchoHeadersTest.java
   geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java
   geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java
   geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java
   geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/GBeanConfigTest.java
Log:
- Consolidate the code that creates URL for Axis stuff.
- Check if using Axis' NetworkUtils.getLocalHostname fixes GERONIMO-445



Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGeronimoUtils.java
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGeronimoUtils.java	(original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/AxisGeronimoUtils.java	Fri Nov  5 12:39:11 2004
@@ -19,6 +19,7 @@
 import org.apache.axis.client.AdminClient;
 import org.apache.axis.client.Call;
 import org.apache.axis.utils.ClassUtils;
+import org.apache.axis.utils.NetworkUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.deployment.DeploymentException;
@@ -34,6 +35,7 @@
 import java.io.InputStream;
 import java.lang.reflect.Method;
 import java.net.URL;
+import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -228,16 +230,14 @@
      * Number one is service is deployed only once the Axis is restarted. And it is
      * best not to do this while the Axis is running.</p>
      *
-     * @param module
+     * @param deplydd
      * @throws DeploymentException
      */
     public static void addEntryToAxisDD(InputStream deplydd) throws DeploymentException {
         try {
             if (deplydd != null) {
                 AdminClient adminClient = new AdminClient();
-                URL requestUrl = new URL("http://localhost:"
-                        + AXIS_SERVICE_PORT
-                        + "/axis/services/AdminService");
+                URL requestUrl = getURL("/axis/services/AdminService");
                 Call call = adminClient.getCall();
                 call.setTargetEndpointAddress(requestUrl);
                 String result = adminClient.process(null, deplydd);
@@ -250,6 +250,11 @@
             e.printStackTrace();
             throw new DeploymentException(e);
         }
+    }
+
+    public static URL getURL(String file) throws MalformedURLException {
+        URL requestUrl = new URL("http", NetworkUtils.getLocalHostname(), AXIS_SERVICE_PORT, file);
+        return requestUrl;
     }
 
 }

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisGBeanTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisGBeanTest.java	(original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisGBeanTest.java	Fri Nov  5 12:39:11 2004
@@ -41,7 +41,6 @@
     }
 
     public void testStartAxisService() throws Exception {
-        String textFileurl = "http://localhost:" + AxisGeronimoUtils.AXIS_SERVICE_PORT + "/axis/index.html";
         ClassLoader cl = getClass().getClassLoader();
         ClassLoader myCl = new URLClassLoader(new URL[0], cl);
         GBeanMBean gbean = new GBeanMBean(AxisGbean.getGBeanInfo(), myCl);
@@ -49,7 +48,7 @@
         kernel.loadGBean(name, gbean);
         kernel.startGBean(name);
         System.out.println(kernel.getMBeanServer().getAttribute(name, "state"));
-        HttpURLConnection connection = (HttpURLConnection) new URL(textFileurl).openConnection();
+        HttpURLConnection connection = (HttpURLConnection) AxisGeronimoUtils.getURL("/axis/index.html").openConnection();
         BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
         connection.getResponseCode();
         String line = reader.readLine();

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java	(original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/ComplexTypeWebServiceTest.java	Fri Nov  5 12:39:11 2004
@@ -62,10 +62,7 @@
         Class structClass = ClassUtils.forName("org.apache.ws.echosample.EchoStruct");
         Object echoLoacater = echoLoacaterClass.newInstance();
         Method getportMethod = echoLoacaterClass.getMethod("getechoPort", new Class[]{URL.class});
-        URL serviceURL = new URL("http://localhost:"
-                + AxisGeronimoUtils.AXIS_SERVICE_PORT
-                // + 5679
-                + "/axis/services/echoPort");
+        URL serviceURL = AxisGeronimoUtils.getURL("/axis/services/echoPort");
         Object echoPort = getportMethod.invoke(echoLoacater, new Object[]{serviceURL});
         Class echoClass = echoPort.getClass();
         Method echostuctMethod = echoClass.getMethod("echoStruct", new Class[]{structClass});

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/EchoHeadersTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/EchoHeadersTest.java	(original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/EchoHeadersTest.java	Fri Nov  5 12:39:11 2004
@@ -60,7 +60,7 @@
         Service service = new Service();
         service.getEngine().setOption(AxisEngine.PROP_XML_ENCODING, "UTF-8");
         call = (Call) service.createCall();
-        call.setTargetEndpointAddress(new URL("http://localhost:5678/axis/EchoHeaders.jws"));
+        call.setTargetEndpointAddress(AxisGeronimoUtils.getURL("/axis/EchoHeaders.jws"));
     }
 
     private void runtest(String send, String get) throws Exception {
@@ -129,7 +129,7 @@
         Name name = envelope.createName("arg0");
         SOAPElement symbol = bodyElement.addChildElement(name);
         symbol.addTextNode("Hello");
-        URLEndpoint endpoint = new URLEndpoint("http://localhost:5678/axis/EchoHeaders.jws");
+        URLEndpoint endpoint = new URLEndpoint(AxisGeronimoUtils.getURL("axis/EchoHeaders.jws").toString());
         SOAPMessage response = con.call(message, endpoint);
         String responseEncoding = (String) response.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
         assertEquals(requestEncoding.toLowerCase(), responseEncoding.toLowerCase());

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java	(original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java	Fri Nov  5 12:39:11 2004
@@ -67,9 +67,7 @@
 
 
         //let us try to brows the WSDL of the service
-        URL wsdlrequestUrl = new URL("http://localhost:"
-                + AxisGeronimoUtils.AXIS_SERVICE_PORT
-                + "/axis/services/echoPort?wsdl");
+        URL wsdlrequestUrl =AxisGeronimoUtils.getURL("/axis/services/echoPort?wsdl");
         //+"/axis/services/AdminService?wsdl");
         
         HttpURLConnection connection = (HttpURLConnection) wsdlrequestUrl.openConnection();
@@ -155,9 +153,7 @@
         Class echoLoacaterClass = Class.forName("org.apache.ws.echosample.EchoServiceLocator", true, jarclassloder);
         Object echoLoacater = echoLoacaterClass.newInstance();
         Method getportMethod = echoLoacaterClass.getMethod("getechoPort", new Class[]{URL.class});
-        URL serviceURL = new URL("http://localhost:"
-                + AxisGeronimoUtils.AXIS_SERVICE_PORT
-                + "/axis/services/echoPort");
+        URL serviceURL = AxisGeronimoUtils.getURL("/axis/services/echoPort");
         Object echoPort = getportMethod.invoke(echoLoacater, new Object[]{serviceURL});
         Class echoClass = echoPort.getClass();
         Method echoStringMethod = echoClass.getMethod("echoString", new Class[]{String.class});

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java	(original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimplePOJOWebServiceTest.java	Fri Nov  5 12:39:11 2004
@@ -65,9 +65,7 @@
         kernel.getMBeanServer().invoke(configName, "startRecursive", null, null);
 
         //let us try to brows the WSDL of the service
-        URL wsdlrequestUrl = new URL("http://localhost:"
-                + AxisGeronimoUtils.AXIS_SERVICE_PORT
-                + "/axis/services/echoPort?wsdl");
+        URL wsdlrequestUrl = AxisGeronimoUtils.getURL("/axis/services/echoPort?wsdl");
         //+"/axis/services/AdminService?wsdl");
         
         HttpURLConnection connection = (HttpURLConnection) wsdlrequestUrl.openConnection();
@@ -81,10 +79,7 @@
         Class echoLoacaterClass = ClassUtils.forName("org.apache.ws.echosample.EchoServiceLocator");
         Object echoLoacater = echoLoacaterClass.newInstance();
         Method getportMethod = echoLoacaterClass.getMethod("getechoPort", new Class[]{URL.class});
-        URL serviceURL = new URL("http://localhost:"
-                + AxisGeronimoUtils.AXIS_SERVICE_PORT
-                // + 5679
-                + "/axis/services/echoPort");
+        URL serviceURL = AxisGeronimoUtils.getURL("/axis/services/echoPort");
         Object echoPort = getportMethod.invoke(echoLoacater, new Object[]{serviceURL});
         Class echoClass = echoPort.getClass();
         Method echoStringMethod = echoClass.getMethod("echoString", new Class[]{String.class});

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java	(original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/AdminClientDeploymentTest.java	Fri Nov  5 12:39:11 2004
@@ -51,15 +51,11 @@
         ClassLoader parentClassLoder = ClassUtils.getDefaultClassLoader();
         ClassUtils.setDefaultClassLoader(cl);
         AdminClient adminClient = new AdminClient();
-        URL requestUrl = new URL("http://localhost:"
-                + AxisGeronimoUtils.AXIS_SERVICE_PORT
-                + "/axis/services/AdminService");
+        URL requestUrl = AxisGeronimoUtils.getURL("/axis/services/AdminService");
         Call call = adminClient.getCall();
         call.setTargetEndpointAddress(requestUrl);
         String result = adminClient.process(null, deplydd);
-        URL wsdlrequestUrl = new URL("http://localhost:"
-                + AxisGeronimoUtils.AXIS_SERVICE_PORT
-                + "/axis/services/echoPort?wsdl");
+        URL wsdlrequestUrl = AxisGeronimoUtils.getURL("/axis/services/echoPort?wsdl");
         //+"/axis/services/AdminService?wsdl");
         
         HttpURLConnection connection = (HttpURLConnection) wsdlrequestUrl.openConnection();

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/GBeanConfigTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/GBeanConfigTest.java	(original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/preconditions/GBeanConfigTest.java	Fri Nov  5 12:39:11 2004
@@ -44,7 +44,6 @@
     }
 
     public void testStartAxisService() throws Exception {
-        String textFileurl = "http://localhost:" + AxisGeronimoUtils.AXIS_SERVICE_PORT + "/axis/index.html";
         ClassLoader cl = getClass().getClassLoader();
         ClassLoader myCl = new URLClassLoader(new URL[0], cl);
         ReferenceCollection rc = new ReferenceCollectionImpl();