summaryrefslogtreecommitdiff
path: root/same/src/test
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-06 15:05:45 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-06 15:05:45 +0100
commit1d2eca2591c5747c65d52cb96f5246632f06d9d0 (patch)
treebc06817155bb2c683b25f608227dd0682d1bf009 /same/src/test
parent0ac907ad19d62cc773f6f13f74af52bd75f0b5db (diff)
Fix RpcServlet: Use POST requests.
Diffstat (limited to 'same/src/test')
-rw-r--r--same/src/test/java/com/orbekk/paxos/MasterProposerTest.java4
-rw-r--r--same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java18
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);
}
}