diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-11 16:03:25 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-11 16:03:25 +0100 |
commit | 77a11fb4c2cc35a31e325efdf828f625be219207 (patch) | |
tree | ab93481ac37dd201f631edab5ddf7668ffcd29af /jsonrpc/src/test/java | |
parent | ee0b57e81fce368e931a0d7282d8d84a9ecffd71 (diff) |
Add setState() operation.
- State is synchronized between all clients.
- Failure handling remains poor.
Diffstat (limited to 'jsonrpc/src/test/java')
-rw-r--r-- | jsonrpc/src/test/java/com/orbekk/same/SameStateTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/jsonrpc/src/test/java/com/orbekk/same/SameStateTest.java b/jsonrpc/src/test/java/com/orbekk/same/SameStateTest.java index 7e21e7a..4c2a11d 100644 --- a/jsonrpc/src/test/java/com/orbekk/same/SameStateTest.java +++ b/jsonrpc/src/test/java/com/orbekk/same/SameStateTest.java @@ -43,6 +43,22 @@ public class SameStateTest { connections.connections.put(state3.getUrl(), service3); } + public void joinNetwork() { + connections.getConnection(state1.getUrl()). + participateNetwork("Network1", state2.getClientId(), + state2.getUrl()); + connections.getConnection(state1.getUrl()). + participateNetwork("Network1", state3.getClientId(), + state3.getUrl()); + state1.internalRun(); + state2.internalRun(); + state3.internalRun(); + + assertTrue(state1.getParticipants().size() == 3); + assertTrue(state2.getParticipants().size() == 3); + assertTrue(state3.getParticipants().size() == 3); + } + @Test public void testJoinNetwork() { connections.getConnection(state1.getUrl()). participateNetwork("Network1", state2.getClientId(), @@ -69,5 +85,19 @@ public class SameStateTest { assertTrue(state3.getParticipants().size() == 3); assertEquals(state1.getNetworkName(), state2.getNetworkName()); assertEquals(state2.getNetworkName(), state3.getNetworkName()); + + assertEquals("Client1", state1.getMasterId()); + assertEquals("Client1", state2.getMasterId()); + assertEquals("Client1", state3.getMasterId()); + } + + @Test public void setState() { + joinNetwork(); + state1.librarySetNewState("New state1"); + state1.internalRun(); + state2.internalRun(); + state3.internalRun(); + assertEquals(state1.getCurrentState(), state2.getCurrentState()); + assertEquals(state2.getCurrentState(), state3.getCurrentState()); } } |