diff options
Diffstat (limited to 'same/src/test/java/com/orbekk')
-rw-r--r-- | same/src/test/java/com/orbekk/paxos/MasterProposerTest.java | 4 | ||||
-rw-r--r-- | same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java | 18 |
2 files changed, 16 insertions, 6 deletions
diff --git a/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java b/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java index 601a357..bab2005 100644 --- a/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java +++ b/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java @@ -28,7 +28,7 @@ public class MasterProposerTest { return urls; } - @Test public void successfulProposal() { + @Test public void successfulProposal() throws Exception { connections.paxosMap.put("p1", p1); when(p1.propose("client1", 1)).thenReturn(1); when(p1.acceptRequest("client1", 1)).thenReturn(1); @@ -40,7 +40,7 @@ public class MasterProposerTest { assertTrue(c1.propose(1)); } - @Test public void unsucessfulProposal() { + @Test public void unsucessfulProposal() throws Exception { connections.paxosMap.put("p1", p1); when(p1.propose("client1", 1)).thenReturn(-1); when(p1.acceptRequest("client1", 1)).thenReturn(-1); diff --git a/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java b/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java index 5042168..278f775 100644 --- a/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java +++ b/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java @@ -20,7 +20,6 @@ import org.junit.Test; public class PaxosServiceFunctionalTest { ConnectionManagerImpl connections = new ConnectionManagerImpl(500, 500); List<String> paxosUrls = new ArrayList<String>(); - // RpcHandler handler = new RpcHandler(null); ServerContainer server; String myUrl; int successfulProposals = 0; @@ -28,9 +27,12 @@ public class PaxosServiceFunctionalTest { @Before public void setUp() throws Exception { ServerBuilder builder = new ServerBuilder(0); - setupPaxos(builder, 10); + List<String> tempUrls = setupPaxos(builder, 10); server = builder.build(); + server.start(); myUrl = "http://localhost:" + server.getPort(); + addUrls(tempUrls); + System.out.println(paxosUrls); } @After @@ -38,13 +40,21 @@ public class PaxosServiceFunctionalTest { server.stop(); } - public void setupPaxos(ServerBuilder builder, int instances) { + public List<String> setupPaxos(ServerBuilder builder, int instances) { + List<String> tempUrls = new ArrayList<String>(); for (int i = 1; i <= instances; i++) { JsonRpcServer jsonServer = new JsonRpcServer( new PaxosServiceImpl("P" + i + ": "), PaxosService.class); String serviceId = "/PaxosService" + i + ".json"; builder.withServlet(new RpcServlet(jsonServer), serviceId); - paxosUrls.add(myUrl + serviceId); + tempUrls.add(serviceId); + } + return tempUrls; + } + + public void addUrls(List<String> services) { + for (String url : services) { + paxosUrls.add(myUrl + url); } } |