diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-16 15:43:43 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-16 15:43:43 +0100 |
commit | 25d3d6d1ff6f57ad354f03a0b6cc4f1a897bb342 (patch) | |
tree | 208c70014add61dc9b5de25d6a8f502ed6b3ccc0 /same/src/test/java | |
parent | 9444d8b16c93581bbab7928304cb14622050f691 (diff) |
Implement all MasterService operations in NewMaster.
Tested with tests ported from old MasterImplTest.
Diffstat (limited to 'same/src/test/java')
-rw-r--r-- | same/src/test/java/com/orbekk/same/NewMasterTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/same/src/test/java/com/orbekk/same/NewMasterTest.java b/same/src/test/java/com/orbekk/same/NewMasterTest.java index 098b141..273fb3c 100644 --- a/same/src/test/java/com/orbekk/same/NewMasterTest.java +++ b/same/src/test/java/com/orbekk/same/NewMasterTest.java @@ -43,6 +43,26 @@ public class NewMasterTest { } @Test + public void joinNetworkAddsClient() throws Exception { + masterS.joinNetworkRequest("http://clientUrl"); + List<String> participants = state.getList(".participants"); + assertTrue(participants.contains("http://clientUrl")); + } + + @Test + public void clientJoin() { + Client client = new Client( + new State("ClientNetwork"), connections, + "http://client/ClientService.json"); + ClientService clientS = client.getService(); + connections.clientMap.put("http://client/ClientService.json", clientS); + client.joinNetwork("http://master/MasterService.json"); + master.performWork(); + assertTrue(state.getList(".participants").contains("http://client/ClientService.json")); + assertEquals(state, client.testGetState()); + } + + @Test public void updateStateRequest() throws Exception { Client client1 = new Client( new State("ClientNetwork"), connections, @@ -76,4 +96,24 @@ public class NewMasterTest { assertEquals(state, client1.testGetState()); assertEquals(state, client2.testGetState()); } + + @Test + public void masterRemovesParticipant() throws Exception { + Client client = new Client( + new State("ClientNetwork"), connections, + "http://client/ClientService.json"); + ClientService clientS = client.getService(); + connections.clientMap.put("http://client/ClientService.json", clientS); + client.joinNetwork("http://master/MasterService.json"); + master.performWork(); + assertTrue(state.getList(".participants").contains("http://client/ClientService.json")); + + connections.clientMap.put("http://client/ClientService.json", + new UnreachableClient()); + masterS.updateStateRequest("NewState", "NewStateData", 0); + master.performWork(); + + assertEquals("[]", state.getDataOf(".participants")); + } + } |