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 di...@apache.org on 2007/02/25 20:05:14 UTC
svn commit: r511574 - in
/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration:
IntegrationTest.java UtilServer.java
Author: dims
Date: Sun Feb 25 11:05:08 2007
New Revision: 511574
URL: http://svn.apache.org/viewvc?view=rev&rev=511574
Log:
implement the same workaround that david used for json (http://svn.apache.org/viewvc?view=rev&revision=503920)
Modified:
webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/UtilServer.java
Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java?view=diff&rev=511574&r1=511573&r2=511574
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java Sun Feb 25 11:05:08 2007
@@ -51,13 +51,7 @@
public class IntegrationTest extends TestCase {
- private static final String ADDRESS = "http://127.0.0.1:" +
- (UtilServer.TESTING_PORT) +
- "/axis2/services/Echo";
-// private static final String ADDRESS = "http://127.0.0.1:8081" +
-// "/axis2/services/Echo";
- public static final EndpointReference TARGET_EPR = new EndpointReference(ADDRESS);
-
+ static int port;
public static final QName SERVICE_NAME = new QName("Echo");
public static final QName OPERATION_NAME = new QName("echo");
@@ -67,10 +61,16 @@
super(name);
}
+ protected static String getAddress() {
+ return "http://127.0.0.1:" +
+ port +
+ "/axis2/services/Echo";
+ }
+
public static Test suite() {
return new TestSetup(new TestSuite(IntegrationTest.class)) {
public void setUp() throws Exception {
- UtilServer.start(SAAJ_REPO);
+ port = UtilServer.start(SAAJ_REPO);
Parameter eneblemtom = new Parameter("enableMTOM","true");
UtilServer.getConfigurationContext().getAxisConfiguration().addParameter(eneblemtom);
}
@@ -102,7 +102,7 @@
createSimpleSOAPPart(request);
SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
- SOAPMessage response = sCon.call(request, ADDRESS);
+ SOAPMessage response = sCon.call(request, getAddress());
assertFalse(response.getAttachments().hasNext());
assertEquals(0, response.countAttachments());
@@ -156,7 +156,7 @@
request.addAttachmentPart(jpegAttach);
SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
- SOAPMessage response = sCon.call(request, ADDRESS);
+ SOAPMessage response = sCon.call(request, getAddress());
int attachmentCount = response.countAttachments();
assertTrue(attachmentCount == 2);
@@ -213,7 +213,7 @@
SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
- SOAPMessage response = sCon.call(request, ADDRESS);
+ SOAPMessage response = sCon.call(request, getAddress());
int attachmentCount = response.countAttachments();
assertTrue(attachmentCount == 2);
Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/UtilServer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/UtilServer.java?view=diff&rev=511574&r1=511573&r2=511574
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/UtilServer.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/UtilServer.java Sun Feb 25 11:05:08 2007
@@ -31,6 +31,7 @@
import javax.xml.namespace.QName;
import java.io.File;
import java.io.FilenameFilter;
+import java.net.ServerSocket;
/**
*
@@ -40,8 +41,6 @@
private static SimpleHTTPServer receiver;
- public static final int TESTING_PORT = 5555;
-
public static synchronized void deployService(AxisService service) throws AxisFault {
receiver.getConfigurationContext().getAxisConfiguration().addService(service);
}
@@ -62,14 +61,16 @@
start(org.apache.axis2.Constants.TESTING_REPOSITORY);
}
- public static synchronized void start(String repository) throws Exception {
+ public static synchronized int start(String repository) throws Exception {
+ int testingPort = 0;
if (count == 0) {
ConfigurationContext er = getNewConfigurationContext(repository);
- receiver = new SimpleHTTPServer(er, TESTING_PORT);
+ testingPort = findAvailablePort();
+ receiver = new SimpleHTTPServer(er, testingPort);
receiver.start();
- System.out.print("Server started on port " + TESTING_PORT + ".....");
+ System.out.print("Server started on port " + testingPort + ".....");
try {
Thread.sleep(2000);
@@ -79,6 +80,7 @@
}
count++;
+ return testingPort;
}
public static ConfigurationContext getNewConfigurationContext(String repository)
@@ -146,4 +148,14 @@
.getServiceContext(service);
}
+ protected static int findAvailablePort() {
+ try {
+ ServerSocket ss = new ServerSocket(0);
+ int result = ss.getLocalPort();
+ ss.close();
+ return result;
+ } catch (Exception e) {
+ return 5555;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org