From a1060ee59fe7c9107641543babe950250835fa4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Tue, 17 Apr 2012 15:37:31 +0200 Subject: Client.startMasterElection() uses protobuf service. --- .../test/java/com/orbekk/same/FunctionalTest.java | 30 ++++++++++++---------- same/src/test/java/com/orbekk/same/MasterTest.java | 2 ++ 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'same/src/test/java/com/orbekk') diff --git a/same/src/test/java/com/orbekk/same/FunctionalTest.java b/same/src/test/java/com/orbekk/same/FunctionalTest.java index 73f0a37..0a20fc1 100644 --- a/same/src/test/java/com/orbekk/same/FunctionalTest.java +++ b/same/src/test/java/com/orbekk/same/FunctionalTest.java @@ -38,18 +38,22 @@ public class FunctionalTest { masterServiceProxy = new MasterServiceProxy(master.getService()); connections.masterMap.put(masterUrl, masterServiceProxy); connections.masterMap0.put(masterLocation, master.getNewService()); - client1 = newClient("TestClient1", "http://client1/ClientService.json"); + client1 = newClient("TestClient1", "http://client1/ClientService.json", + "client1"); vf1 = new VariableFactory(client1.getInterface()); - client2 = newClient("TestClient2", "http://client2/ClientService.json"); + client2 = newClient("TestClient2", "http://client2/ClientService.json", + "client2"); vf2 = new VariableFactory(client2.getInterface()); - client3 = newClient("TestClient3", "http://client3/ClientService.json"); + client3 = newClient("TestClient3", "http://client3/ClientService.json", + "client3"); vf3 = new VariableFactory(client3.getInterface()); } - Client newClient(String clientName, String clientUrl) { + Client newClient(String clientName, String clientUrl, String location) { Client client = new Client(new State(clientName), connections, - clientUrl, "clientLocation", broadcaster); + clientUrl, location, broadcaster); connections.clientMap.put(clientUrl, client.getService()); + connections.clientMap0.put(location, client.getNewService()); clients.add(client); String paxosUrl = clientUrl.replace("ClientService", "PaxosService"); PaxosService paxos = new PaxosServiceImpl(paxosUrl); @@ -92,8 +96,8 @@ public class FunctionalTest { } for (Client c : clients) { assertThat(c.getConnectionState(), is(ConnectionState.STABLE)); - assertThat(c.masterUrl, is(masterUrl)); - assertThat(c.masterLocation, is(masterLocation)); + assertThat(c.getMaster().getMasterUrl(), is(masterUrl)); + assertThat(c.getMaster().getMasterLocation(), is(masterLocation)); } } @@ -130,8 +134,8 @@ public class FunctionalTest { client3.setMasterController(controller); client1.startMasterElection(); newMaster.performWork(); - assertThat(client1.masterUrl, is(newMasterUrl)); - assertThat(client2.masterUrl, is(newMasterUrl)); + assertThat(client1.getMaster().getMasterUrl(), is(newMasterUrl)); + assertThat(client2.getMaster().getMasterUrl(), is(newMasterUrl)); } @Test public void onlyOneNewMaster() { @@ -159,8 +163,8 @@ public class FunctionalTest { client3.setMasterController(controller); client1.startMasterElection(); newMaster.performWork(); - assertThat(client1.masterUrl, is(newMasterUrl)); - assertThat(client2.masterUrl, is(newMasterUrl)); + assertThat(client1.getMaster().getMasterUrl(), is(newMasterUrl)); + assertThat(client2.getMaster().getMasterUrl(), is(newMasterUrl)); } @Test public void masterFails() { @@ -190,7 +194,7 @@ public class FunctionalTest { is(DelayedOperation.Status.ERROR)); performWork(); newMaster.performWork(); - assertThat(client1.masterUrl, is(newMasterUrl)); - assertThat(client2.masterUrl, is(newMasterUrl)); + assertThat(client1.getMaster().getMasterUrl(), is(newMasterUrl)); + assertThat(client2.getMaster().getMasterUrl(), is(newMasterUrl)); } } diff --git a/same/src/test/java/com/orbekk/same/MasterTest.java b/same/src/test/java/com/orbekk/same/MasterTest.java index 8830c10..22414fe 100644 --- a/same/src/test/java/com/orbekk/same/MasterTest.java +++ b/same/src/test/java/com/orbekk/same/MasterTest.java @@ -65,6 +65,8 @@ public class MasterTest { connections.clientMap.put("http://client/ClientService.json", clientS); client.joinNetwork(master.getMasterInfo()); master.performWork(); + System.out.println(state); + System.out.println(master.state); assertTrue(state.getList(".participants").contains("http://client/ClientService.json")); assertEquals(state, client.testGetState()); } -- cgit v1.2.3