Posted By:
Giulio_Piancastelli
Posted On:
Monday, August 26, 2002 05:16 AM
I'm trying to use JUnit to test the interaction between an XML-RPC server and an XML-RPC client I have written. First thing, I'm setting up the client and the server in the setUp() method, then start the server. Finally, since I do not want the server to still be up and running after all the tests are completed, I'm trying to shutdown it in the tearDown() method. public class TestXmlRpc extends TestCase { private XmlRpcMyServer server; private XmlRpcMyClient client; public void setUp() { server = new XmlRpcMyServer(); client = new XmlRpcMyClient(); try { server.start(); } catch (Exception e) { e.printStackTrace(); } } // do some tests
More>>
I'm trying to use JUnit to test the interaction between an XML-RPC server and an XML-RPC client I have written. First thing, I'm setting up the client and the server in the setUp() method, then start the server. Finally, since I do not want the server to still be up and running after all the tests are completed, I'm trying to shutdown it in the tearDown() method.
public class TestXmlRpc extends TestCase {
private XmlRpcMyServer server;
private XmlRpcMyClient client;
public void setUp() {
server = new XmlRpcMyServer();
client = new XmlRpcMyClient();
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
// do some tests
public void tearDown() {
server.shutdown();
}
}
As I have undestand it, the JUnit framework calls setUp() and tearDown() for each test in the class. So, I end up building and starting an XmlRpcMyServer for as many times as the number of tests in the class, generating a random number of java.io.IOExceptions (Address in use: JVM_Bind) since the severs try to bind themselves to the same port.
An idea could be to start and shutdown a server in each method: not only I am not sure this would work, but also I do not understand why I can not use the same server for all the test requests.
Has anyone running in a similar problem, and/or can suggest a solution?
TIA,
Giulio Piancastelli.
<<Less