You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2007/02/06 00:20:03 UTC

svn commit: r503920 - in /webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json: JSONIntegrationTest.java JSONTestConstants.java

Author: davidillsley
Date: Mon Feb  5 15:19:56 2007
New Revision: 503920

URL: http://svn.apache.org/viewvc?view=rev&rev=503920
Log:
Workaround (what I believe is) AXIS2-2033 for continuum
(which runs on Solaris)

Modified:
    webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java
    webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONTestConstants.java

Modified: webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java?view=diff&rev=503920&r1=503919&r2=503920
==============================================================================
--- webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java (original)
+++ webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java Mon Feb  5 15:19:56 2007
@@ -17,6 +17,7 @@
 package org.apache.axis2.json;
 
 import java.io.File;
+import java.net.ServerSocket;
 
 import junit.framework.TestCase;
 
@@ -25,6 +26,7 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
@@ -35,13 +37,15 @@
 
 public class JSONIntegrationTest extends TestCase implements JSONTestConstants {
 
-    private AxisService service;
+    private static AxisService service;
 
     private String expectedString;
 
-    private SimpleHTTPServer server;
+    private static SimpleHTTPServer server;
 
-    private ConfigurationContext configurationContext;
+    private static ConfigurationContext configurationContext;
+    
+    private static EndpointReference targetEPR;
 
     public JSONIntegrationTest() {
     }
@@ -49,22 +53,27 @@
     private static int count = 0;
     protected void setUp() throws Exception {
     	if(count == 0){
-        File configFile = new File(System.getProperty("basedir",".") + "/test-resources/axis2.xml");
-        configurationContext = ConfigurationContextFactory
-                .createConfigurationContextFromFileSystem(null, configFile
-                        .getAbsolutePath());
-        server = new SimpleHTTPServer(configurationContext, TESTING_PORT);
-        try {
-            server.start();
-        } finally {
-
-        }
-        service = Utils.createSimpleService(serviceName, org.apache.axis2.json.Echo.class.getName(),
-                operationName);
-        server.getConfigurationContext().getAxisConfiguration().addService(
-                service);
-        count++;
+    		int testingPort = findAvailablePort();
+    		targetEPR = new EndpointReference(
+    	            "http://127.0.0.1:" + (testingPort)
+    	                    + "/axis2/services/EchoXMLService/echoOM");
+    		
+	        File configFile = new File(System.getProperty("basedir",".") + "/test-resources/axis2.xml");
+	        configurationContext = ConfigurationContextFactory
+	                .createConfigurationContextFromFileSystem(null, configFile
+	                        .getAbsolutePath());
+	        server = new SimpleHTTPServer(configurationContext, testingPort);
+	        try {
+	            server.start();
+	        } finally {
+	
+	        }
+	        service = Utils.createSimpleService(serviceName, org.apache.axis2.json.Echo.class.getName(),
+	                operationName);
+	        server.getConfigurationContext().getAxisConfiguration().addService(
+	                service);
     	}
+    	count++;
     }
 
     protected void tearDown() throws Exception {
@@ -116,4 +125,14 @@
         TestCase.assertEquals(response, expectedString);
     }
 
+    protected static int findAvailablePort(){
+    	try{
+    		ServerSocket ss = new ServerSocket(0);
+    		int result = ss.getLocalPort();
+    		ss.close();
+    		return result;
+    	}catch(Exception e){
+    		return 5555;
+    	}
+    }
 }

Modified: webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONTestConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONTestConstants.java?view=diff&rev=503920&r1=503919&r2=503920
==============================================================================
--- webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONTestConstants.java (original)
+++ webservices/axis2/trunk/java/modules/json/test/org/apache/axis2/json/JSONTestConstants.java Mon Feb  5 15:19:56 2007
@@ -18,16 +18,8 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.axis2.addressing.EndpointReference;
-
 public interface JSONTestConstants {
     
-    public static int TESTING_PORT = 5555;
-    
-    public static final EndpointReference targetEPR = new EndpointReference(
-            "http://127.0.0.1:" + (TESTING_PORT)
-                    + "/axis2/services/EchoXMLService/echoOM");
-
     public static final QName serviceName = new QName("EchoXMLService");
 
     public static final QName operationName = new QName("echoOM");



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org