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/07/25 15:59:02 UTC
svn commit: r559460 -
/webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java
Author: dims
Date: Wed Jul 25 06:59:01 2007
New Revision: 559460
URL: http://svn.apache.org/viewvc?view=rev&rev=559460
Log:
start and stop the simple http server just once. Trying to fix build break on ws.zones
Modified:
webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java
Modified: webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java?view=diff&rev=559460&r1=559459&r2=559460
==============================================================================
--- webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java (original)
+++ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java Wed Jul 25 06:59:01 2007
@@ -26,6 +26,9 @@
import java.rmi.RemoteException;
import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.extensions.TestSetup;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.ConfigurationContext;
@@ -39,54 +42,10 @@
*/
public class FastInfosetTest extends TestCase {
- private SimpleHTTPServer server;
- private static int serverCount = 0;
-
- private AxisService service;
-
- private EndpointReference target;
- private ConfigurationContext configurationContext;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- System.out.println("Setting up the Simple HTTP Server");
-
- if (serverCount == 0) {
- int port = findAvailablePort();
- port = 5555; //Uncomment to test with tcpmon
- target = new EndpointReference("http://127.0.0.1:" + (port)
- + "/axis2/services/SimpleAddService");
-
- File configFile = new File(System.getProperty("basedir",".") + "/test-resources/axis2.xml");
- configurationContext = ConfigurationContextFactory
- .createConfigurationContextFromFileSystem("target/test-classes", configFile
- .getAbsolutePath());
-
- server = new SimpleHTTPServer(configurationContext, port);
-
- server.start();
- }
-
- serverCount++;
-
- service = AxisService.createService("org.apache.axis2.fastinfoset.SimpleAddService",
- server.getConfigurationContext().getAxisConfiguration());
-
- server.getConfigurationContext().getAxisConfiguration().addService(
- service);
-
- System.out.println("Simple HTTP Server is started");
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- if(serverCount == 1) {
- server.stop();
- serverCount = 0;
- System.out.println("Stopped the Simple HTTP Server");
- }
- }
+ private static SimpleHTTPServer server;
+ private static AxisService service;
+ private static EndpointReference target;
+ private static ConfigurationContext configurationContext;
public void testAdd() throws RemoteException {
SimpleAddServiceClient client = new SimpleAddServiceClient(target); //Comment to test with tcpmon.
@@ -123,7 +82,7 @@
TestCase.assertEquals(50.0f, result2, 0.0005f);
}
- private int findAvailablePort() throws SocketException, IOException {
+ private static int findAvailablePort() throws SocketException, IOException {
//Create a server socket on any free socket to find a free socket.
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
@@ -132,21 +91,39 @@
return port;
}
- /**
- * Run this class as a Java application, will host this SimpleAddService for further testing.
- * There is a main method in SimpleAddServiceClient which can be used with this.
- *
- * Note: Useful when debugging.
- *
- * @param args - Not required.
- */
- public static void main(String args[]) {
- FastInfosetTest test = new FastInfosetTest();
- try {
- test.setUp();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ public static Test suite() {
+ return new TestSetup(new TestSuite(FastInfosetTest.class)) {
+ public void setUp() throws Exception {
+
+ System.out.println("Setting up the Simple HTTP Server");
+
+ int port = findAvailablePort();
+ port = 5555; //Uncomment to test with tcpmon
+ target = new EndpointReference("http://127.0.0.1:" + (port)
+ + "/axis2/services/SimpleAddService");
+
+ File configFile = new File(System.getProperty("basedir",".") + "/test-resources/axis2.xml");
+ configurationContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem("target/test-classes", configFile
+ .getAbsolutePath());
+
+ server = new SimpleHTTPServer(configurationContext, port);
+
+ server.start();
+
+ service = AxisService.createService("org.apache.axis2.fastinfoset.SimpleAddService",
+ server.getConfigurationContext().getAxisConfiguration());
+
+ server.getConfigurationContext().getAxisConfiguration().addService(
+ service);
+
+ System.out.println("Simple HTTP Server is started");
+ }
+
+ public void tearDown() throws Exception {
+ server.stop();
+ System.out.println("Stopped the Simple HTTP Server");
+ }
+ };
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org