Author: veithen Date: Mon Apr 30 20:20:55 2012 New Revision: 1332369 URL: http://svn.apache.org/viewvc?rev=1332369&view=rev Log: Reuse existing code to allocate TCP port.
Modified: axis/axis2/java/core/trunk/modules/json/pom.xml axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java Modified: axis/axis2/java/core/trunk/modules/json/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/pom.xml?rev=1332369&r1=1332368&r2=1332369&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/json/pom.xml (original) +++ axis/axis2/java/core/trunk/modules/json/pom.xml Mon Apr 30 20:20:55 2012 @@ -55,6 +55,12 @@ <artifactId>xmlunit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>axis2-testutils</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <url>http://axis.apache.org/axis2/java/core/</url> <scm> Modified: axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java?rev=1332369&r1=1332368&r2=1332369&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java (original) +++ axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONIntegrationTest.java Mon Apr 30 20:20:55 2012 @@ -31,11 +31,11 @@ import org.apache.axis2.client.ServiceCl import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.axis2.description.AxisService; +import org.apache.axis2.testutils.PortAllocator; import org.apache.axis2.transport.http.SimpleHTTPServer; import org.apache.axis2.util.Utils; import java.io.File; -import java.net.ServerSocket; public class JSONIntegrationTest extends TestCase implements JSONTestConstants { @@ -56,7 +56,7 @@ public class JSONIntegrationTest extends protected void setUp() throws Exception { if (count == 0) { - int testingPort = findAvailablePort(); + int testingPort = PortAllocator.allocatePort(); targetEPR = new EndpointReference( "http://127.0.0.1:" + (testingPort) + "/axis2/services/EchoXMLService/echoOM"); @@ -135,15 +135,4 @@ public class JSONIntegrationTest extends protected void compareWithCreatedOMText(String response) { 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; - } - } }