我想为RMI客户机应用程序编写一组系统集成测试。我想在JUnit3.8.2中启动RMI服务器,然后运行这些测试。有人这样做吗?
我在POJO中使用类似的东西,主要是:
import java.rmi.registry.*;
....
//setup
try {
java.rmi.registry.LocateRegistry.createRegistry(1099);
System.out.println("RMI registry ready.");
this.StartMyServer();
// client set up
MyClient m = null;
m = (MyClient) Naming.lookup("//MyHost/MyServer", m);
// tests here
} catch (MyClientException me) {
System.out.println("MyClient fall down go boom");
} catch (MyServerException me) {
System.out.println("MyServer fall down go boom");
} catch (Exception e) {
System.out.println("Exception starting RMI registry:");
}
把它转换成JUnit测试的最好方法是什么,这样注册表只启动一次,测试只在注册表实际启动时运行?我可以避免用一种测试方法来进行一个测试类,其中包含了来自主测试的所有测试代码,这就是我在来到这里之前所做的。
另外,在编写测试时,我应该注意什么?有没有RMI测试?