Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6df70d5

Browse files
author
bfrasure
committed
+RMITests & put remote classes in package
1 parent 13a6e2c commit 6df70d5

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

remote/DisplayPerfectTime.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Uses remote object PerfectTime
66
// {ValidateByHand}
7+
package remote;
8+
79
import java.rmi.registry.*;
810

911
public class DisplayPerfectTime {

remote/PerfectTime.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// The PerfectTime remote interface
6+
package remote;
7+
68
import java.rmi.*;
79

810
public interface PerfectTime extends Remote {

remote/PerfectTimeImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Implementing the PerfectTime remote object
6+
package remote;
7+
68
import java.rmi.RemoteException;
79

810
public class PerfectTimeImpl implements PerfectTime {

remote/PerfectTimeServer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// Server for the PerfectTime remote object
66
// {ValidateByHand}
7+
package remote;
8+
79
import java.rmi.registry.Registry;
810
import java.rmi.registry.LocateRegistry;
911
import java.rmi.RemoteException;

remote/tests/RMITests.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// remote/tests/RMITests.java
2+
// (c)2016 MindView LLC: see Copyright.txt
3+
// We make no guarantees that this code is fit for any purpose.
4+
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+
package remote;
6+
7+
import java.rmi.registry.*;
8+
9+
import org.junit.jupiter.api.*;
10+
import org.junit.jupiter.api.TestInfo;
11+
12+
public class RMITests {
13+
@Test
14+
void test_remote_time() throws Exception {
15+
LocateRegistry.createRegistry(1099);
16+
PerfectTimeServer timeServer = new PerfectTimeServer();
17+
timeServer.main(null);
18+
Registry reg =
19+
LocateRegistry.getRegistry("localhost");
20+
PerfectTime pt =
21+
(PerfectTime) reg.lookup("PerfectTime");
22+
for (int i = 0; i < 10; i++)
23+
System.out.println("Time: " + pt.getPerfectTime());
24+
}
25+
}

0 commit comments

Comments
 (0)