diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-05-07 15:37:39 +0200 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-05-07 15:37:39 +0200 |
commit | d820490376742bb1b08c12d75cffafa05108459c (patch) | |
tree | 2f0a1829473f439f4385fc159e90e3b76698a89e /same/src/test/java | |
parent | acb7a2cd0794d8ed6f623ad6b279f193aa76188e (diff) |
Remove some network metadata from State.
Remove .masterUrl, .masterLocation and networkName.
Diffstat (limited to 'same/src/test/java')
-rw-r--r-- | same/src/test/java/com/orbekk/same/FunctionalTest.java | 19 | ||||
-rw-r--r-- | same/src/test/java/com/orbekk/same/MasterTest.java | 4 | ||||
-rw-r--r-- | same/src/test/java/com/orbekk/same/VariableFactoryTest.java | 2 |
3 files changed, 11 insertions, 14 deletions
diff --git a/same/src/test/java/com/orbekk/same/FunctionalTest.java b/same/src/test/java/com/orbekk/same/FunctionalTest.java index 078de58..0d13796 100644 --- a/same/src/test/java/com/orbekk/same/FunctionalTest.java +++ b/same/src/test/java/com/orbekk/same/FunctionalTest.java @@ -82,7 +82,7 @@ public class FunctionalTest { } Client newClient(String clientName, String clientUrl, String location) { - Client client = new Client(new State(clientName), connections, + Client client = new Client(new State(), connections, clientUrl, location, rpcf, executor); connections.clientMap0.put(location, client.getNewService()); clients.add(client); @@ -127,7 +127,6 @@ public class FunctionalTest { } for (Client c : clients) { assertThat(c.getConnectionState(), is(ConnectionState.STABLE)); - assertThat(c.getMaster().getMasterUrl(), is(masterUrl)); assertThat(c.getMaster().getMasterLocation(), is(masterLocation)); } } @@ -152,7 +151,7 @@ public class FunctionalTest { joinClients(); MasterController controller = new MasterController() { @Override - public void enableMaster(State lastKnownState, int masterId) { + public void enableMaster(String networkName, State lastKnownState, int masterId) { newMaster.resumeFrom(lastKnownState, masterId); } @Override @@ -170,15 +169,14 @@ public class FunctionalTest { } @Test public void onlyOneNewMaster() throws Exception { - String newMasterUrl = "http://newMaster/MasterService.json"; String newMasterLocation = "newMaster:1"; final Master newMaster = Master.create(connections, - newMasterUrl, "TestMaster", newMasterLocation, rpcf); + "NetworkName", "TestMaster", newMasterLocation, rpcf); joinClients(); MasterController controller = new MasterController() { boolean firstMaster = true; @Override - public synchronized void enableMaster(State lastKnownState, + public synchronized void enableMaster(String networkName, State lastKnownState, int masterId) { assertThat(firstMaster, is(true)); newMaster.resumeFrom(lastKnownState, masterId); @@ -194,8 +192,7 @@ public class FunctionalTest { client1.startMasterElection(master.getMasterInfo()); awaitExecution(); newMaster.performWork(); - assertThat(client1.getMaster().getMasterUrl(), is(newMasterUrl)); - assertThat(client2.getMaster().getMasterUrl(), is(newMasterUrl)); + assertThat(client2.getMaster().getMasterLocation(), is(newMasterLocation)); } @Test public void masterFails() throws Exception { @@ -206,7 +203,7 @@ public class FunctionalTest { joinClients(); MasterController controller = new MasterController() { @Override - public synchronized void enableMaster(State lastKnownState, + public synchronized void enableMaster(String networkName, State lastKnownState, int masterId) { newMaster.resumeFrom(lastKnownState, masterId); } @@ -224,7 +221,7 @@ public class FunctionalTest { awaitExecution(); performWork(); newMaster.performWork(); - assertThat(client1.getMaster().getMasterUrl(), is(newMasterUrl)); - assertThat(client2.getMaster().getMasterUrl(), is(newMasterUrl)); + assertThat(client1.getMaster().getMasterLocation(), is(newMasterLocation)); + assertThat(client2.getMaster().getMasterLocation(), is(newMasterLocation)); } } diff --git a/same/src/test/java/com/orbekk/same/MasterTest.java b/same/src/test/java/com/orbekk/same/MasterTest.java index e6f9686..85f737a 100644 --- a/same/src/test/java/com/orbekk/same/MasterTest.java +++ b/same/src/test/java/com/orbekk/same/MasterTest.java @@ -27,7 +27,7 @@ import org.junit.Test; public class MasterTest { private ExecutorService executor = Executors.newCachedThreadPool(); - private State state = new State("TestNetwork"); + private State state = new State(); private TestConnectionManager connections = new TestConnectionManager(); private Master master; private RpcFactory rpcf = new RpcFactory(5000); @@ -45,7 +45,7 @@ public class MasterTest { @Test public void clientJoin() throws Exception { Client client = new Client( - new State("ClientNetwork"), connections, + new State(), connections, "http://client/ClientService.json", "clientLocation", rpcf, executor); connections.clientMap0.put("clientLocation", client.getNewService()); diff --git a/same/src/test/java/com/orbekk/same/VariableFactoryTest.java b/same/src/test/java/com/orbekk/same/VariableFactoryTest.java index c60ceab..e96bba8 100644 --- a/same/src/test/java/com/orbekk/same/VariableFactoryTest.java +++ b/same/src/test/java/com/orbekk/same/VariableFactoryTest.java @@ -46,7 +46,7 @@ public class VariableFactoryTest { } public void initializeSampleState() { - sampleState = new State("TestState"); + sampleState = new State(); sampleState.update("TestVariable", "1", 1); sampleState.update("TestList", "[]", 1); } |