@Test
public void test() {
RMISink sink;
RMISource source;
Graph g1 = new DefaultGraph("g1");
Graph g2 = new DefaultGraph("g2");
try {
LocateRegistry.createRegistry(1099);
} catch (Exception e) {
}
try {
String name = "__test_rmi_source";
sink = new RMISink();
g1.addSink(sink);
source = new RMISource();
source.addSink(g2);
source.bind(name);
sink.register("//localhost/" + name);
} catch (RemoteException e) {
fail();
}
Node A = g1.addNode("A");
Node B = g1.addNode("B");
Node C = g1.addNode("C");
Edge AB = g1.addEdge("AB", "A", "B", false);
Edge AC = g1.addEdge("AC", "A", "C", true);
Edge BC = g1.addEdge("BC", "B", "C", false);
A.addAttribute("int", 1);
B.addAttribute("string", "test");
C.addAttribute("double", 2.0);
AB.addAttribute("points",
(Object) (new double[][] { { 1, 1 }, { 2, 2 } }));
LinkedList<Integer> list = new LinkedList<Integer>();
list.add(1);
list.add(2);
AC.addAttribute("list", list);
BC.addAttribute("boolean", true);
// -----
A = g2.getNode("A");
B = g2.getNode("B");
C = g2.getNode("C");
assertNotNull(A);
assertNotNull(B);
assertNotNull(C);
assertEquals(g2.getNodeCount(), 3);
AB = g2.getEdge("AB");
AC = g2.getEdge("AC");
BC = g2.getEdge("BC");
assertNotNull(AB);
assertNotNull(AC);
assertNotNull(BC);
assertEquals(g2.getEdgeCount(), 3);
assertEquals("A", AB.getNode0().getId());
assertEquals("B", AB.getNode1().getId());
assertEquals("A", AC.getNode0().getId());
assertEquals("C", AC.getNode1().getId());