Merge pull request #19 from BruceEckel/rmi_test
+RMITests & put remote classes in package
This commit is contained in:
commit
84baf7143d
@ -4,6 +4,8 @@
|
||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||
// Uses remote object PerfectTime
|
||||
// {ValidateByHand}
|
||||
package remote;
|
||||
|
||||
import java.rmi.registry.*;
|
||||
|
||||
public class DisplayPerfectTime {
|
||||
|
@ -3,6 +3,8 @@
|
||||
// We make no guarantees that this code is fit for any purpose.
|
||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||
// The PerfectTime remote interface
|
||||
package remote;
|
||||
|
||||
import java.rmi.*;
|
||||
|
||||
public interface PerfectTime extends Remote {
|
||||
|
@ -3,6 +3,8 @@
|
||||
// We make no guarantees that this code is fit for any purpose.
|
||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||
// Implementing the PerfectTime remote object
|
||||
package remote;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
public class PerfectTimeImpl implements PerfectTime {
|
||||
|
@ -4,6 +4,8 @@
|
||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||
// Server for the PerfectTime remote object
|
||||
// {ValidateByHand}
|
||||
package remote;
|
||||
|
||||
import java.rmi.registry.Registry;
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
import java.rmi.RemoteException;
|
||||
|
25
remote/tests/RMITests.java
Normal file
25
remote/tests/RMITests.java
Normal file
@ -0,0 +1,25 @@
|
||||
// remote/tests/RMITests.java
|
||||
// (c)2016 MindView LLC: see Copyright.txt
|
||||
// We make no guarantees that this code is fit for any purpose.
|
||||
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
||||
package remote;
|
||||
|
||||
import java.rmi.registry.*;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
public class RMITests {
|
||||
@Test
|
||||
void test_remote_time() throws Exception {
|
||||
LocateRegistry.createRegistry(1099);
|
||||
PerfectTimeServer timeServer = new PerfectTimeServer();
|
||||
timeServer.main(null);
|
||||
Registry reg =
|
||||
LocateRegistry.getRegistry("localhost");
|
||||
PerfectTime pt =
|
||||
(PerfectTime) reg.lookup("PerfectTime");
|
||||
for (int i = 0; i < 10; i++)
|
||||
System.out.println("Time: " + pt.getPerfectTime());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user