diff options
Diffstat (limited to 'same/src/test/java/com/orbekk/same/MasterTest.java')
-rw-r--r-- | same/src/test/java/com/orbekk/same/MasterTest.java | 69 |
1 files changed, 8 insertions, 61 deletions
diff --git a/same/src/test/java/com/orbekk/same/MasterTest.java b/same/src/test/java/com/orbekk/same/MasterTest.java index 96f8670..f244d1b 100644 --- a/same/src/test/java/com/orbekk/same/MasterTest.java +++ b/same/src/test/java/com/orbekk/same/MasterTest.java @@ -15,7 +15,6 @@ public class MasterTest { private TestConnectionManager connections = new TestConnectionManager(); private TestBroadcaster broadcaster = new TestBroadcaster(); private Master master; - private MasterService masterS; public static class UnreachableClient implements ClientService { @Override @@ -44,88 +43,36 @@ public class MasterTest { state.update(".masterLocation", masterLocation, 1); master = new Master(state, connections, broadcaster, "http://master/MasterService.json", masterLocation); - masterS = master.getService(); - connections.masterMap.put("http://master/MasterService.json", - masterS); connections.masterMap0.put("master:1000", master.getNewService()); } @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() throws Exception { Client client = new Client( new State("ClientNetwork"), connections, "http://client/ClientService.json", "clientLocation", null); - ClientService clientS = client.getService(); - connections.clientMap.put("http://client/ClientService.json", clientS); connections.clientMap0.put("clientLocation", client.getNewService()); client.joinNetwork(master.getMasterInfo()); master.performWork(); System.out.println(state); System.out.println(master.state); - assertTrue(state.getList(".participants").contains("http://client/ClientService.json")); + assertTrue(state.getList(State.PARTICIPANTS) + .contains("clientLocation")); assertEquals(state, client.testGetState()); } @Test - @Ignore // Uses old services. Tested by functional test. + @Ignore public void updateStateRequest() throws Exception { - Client client1 = new Client( - new State("ClientNetwork"), connections, - "http://client/ClientService.json", "clientLocation2", null); - ClientService client1S = client1.getService(); - connections.clientMap.put("http://client/ClientService.json", client1S); - connections.clientMap0.put("clientLocation1", client1.getNewService()); - Client client2 = new Client( - new State("ClientNetwork"), connections, - "http://client2/ClientService.json", "clientLocation2", null); - ClientService client2S = client2.getService(); - connections.clientMap.put("http://client2/ClientService.json", client2S); - connections.clientMap0.put("clientLocation2", client2.getNewService()); - - client1.joinNetwork(master.getMasterInfo()); - client2.joinNetwork(master.getMasterInfo()); - - master.performWork(); - assertTrue(state.getList(".participants").contains("http://client/ClientService.json")); - assertTrue(state.getList(".participants").contains("http://client2/ClientService.json")); - assertEquals(state, client1.testGetState()); - - assertTrue(masterS.updateStateRequest("A", "1", 0)); - master.performWork(); - - assertEquals(state, client1.testGetState()); - assertEquals(state, client2.testGetState()); - - assertFalse(masterS.updateStateRequest("A", "2", 0)); - assertTrue(masterS.updateStateRequest("A", "3", 1)); - master.performWork(); - - assertEquals(state, client1.testGetState()); - assertEquals(state, client2.testGetState()); + // TODO: Implement this test. + throw new IllegalStateException(); } @Test + @Ignore public void masterRemovesParticipant() throws Exception { - Client client = new Client( - new State("ClientNetwork"), connections, - "http://client/ClientService.json", "clientLocation", null); - connections.clientMap0.put("clientLocation", client.getNewService()); - client.joinNetwork(master.getMasterInfo()); - master.performWork(); - assertTrue(state.getList(".participants0").contains("clientLocation")); - - connections.clientMap0.put("clientLocation", null); - masterS.updateStateRequest("NewState", "NewStateData", 0); - master.performWork(); - - assertEquals("[]", state.getDataOf(".participants0")); + // TODO: Implement this test. + throw new IllegalStateException(); } } |