dlr 2002/08/15 13:31:57
Modified: src/test/org/apache/xmlrpc ClientServerRpcTest.java
Log:
Updated API for changes to WebServer class in CVS revision 1.15 (post
XML-RPC release 1.1).
Revision Changes Path
1.10 +51 -43 xml-rpc/src/test/org/apache/xmlrpc/ClientServerRpcTest.java
Index: ClientServerRpcTest.java
===================================================================
RCS file: /home/cvs/xml-rpc/src/test/org/apache/xmlrpc/ClientServerRpcTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -u -r1.9 -r1.10
--- ClientServerRpcTest.java 20 Feb 2002 01:38:24 -0000 1.9
+++ ClientServerRpcTest.java 15 Aug 2002 20:31:57 -0000 1.10
@@ -60,6 +60,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Vector;
import junit.framework.Test;
@@ -131,66 +132,70 @@
public ClientServerRpcTest(String testName)
{
super(testName);
- }
-
- /**
- * Return the Test
- */
- public static Test suite()
- {
- return new TestSuite(ClientServerRpcTest.class);
- }
- /**
- * Setup the server and clients.
- */
- public void setUp()
- {
- //XmlRpc.setDebug(true);
+ XmlRpc.setDebug(true);
try
{
XmlRpc.setDriver(SAX_DRIVER);
}
catch (ClassNotFoundException e)
{
- throw new Error(e.toString());
+ fail(e.toString());
}
// Server (only)
server = new XmlRpcServer();
server.addHandler(HANDLER_NAME, new TestHandler());
- // WebServer (contains its own XmlRpcServer instance)
- String serverURL = null;
- String hostName = "localhost";
+ InetAddress localhost = null;
try
{
- InetAddress localhost = InetAddress.getLocalHost();
- hostName = localhost.getHostName();
- serverURL = "http://" + hostName + ':' + SERVER_PORT + "/RPC2";
- System.out.println("Starting WebServer for url space " +
- serverURL + " ...");
- webServer = new WebServer(SERVER_PORT, localhost);
+ localhost = InetAddress.getLocalHost();
}
- catch (Exception e)
+ catch (UnknownHostException e)
{
- // Probably UnknownHostException or IOException
- e.printStackTrace();
- throw new Error(e.toString());
+ fail(e.toString());
}
+ // WebServer (contains its own XmlRpcServer instance)
+ webServer = new WebServer(SERVER_PORT, localhost);
+ webServer.addHandler(HANDLER_NAME, new TestHandler());
+
// XML-RPC client(s)
try
{
- System.out.println("Connecting client to url space " + serverURL +
- " ...");
+ String hostName = localhost.getHostName();
client = new XmlRpcClient(hostName, SERVER_PORT);
//liteClient = new XmlRpcClientLite(hostName, SERVER_PORT);
}
catch (Exception e)
{
e.printStackTrace();
- throw new Error(e.toString());
+ fail(e.toString());
+ }
+ }
+
+ /**
+ * Return the Test
+ */
+ public static Test suite()
+ {
+ return new TestSuite(ClientServerRpcTest.class);
+ }
+
+ /**
+ * Setup the server and clients.
+ */
+ public void setUp()
+ {
+ try
+ {
+ webServer.start();
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
}
}
@@ -199,13 +204,15 @@
*/
public void tearDown()
{
- liteClient = null;
- client = null;
- // TODO: Shut down server
- server = null;
- webServer.shutdown();
- webServer = null;
- XmlRpc.setDebug(false);
+ try
+ {
+ webServer.shutdown();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
}
/**
@@ -238,19 +245,20 @@
}
/**
- * Tests client/server RPC.
+ * Tests client/server RPC (via {@link WebServer}).
*/
public void testRpc()
{
- int nbrIterations = 300;
try
{
// Test the web server (which also tests the rpc server)
// by connecting via the clients
Vector params = new Vector();
params.add(REQUEST_PARAM_VALUE);
+ System.out.println("FOO");
Object response = client.execute(HANDLER_NAME + ".echo", params);
- System.out.println(response);
+ assertEquals(REQUEST_PARAM_VALUE, response);
+ //params.removeAllElements();
}
catch (Exception e)
{