summaryrefslogtreecommitdiff
path: root/same/src/test
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-24 11:27:57 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-24 11:27:57 +0100
commit5f36d81e47fd142ee7b7c172012917b11411db8d (patch)
tree74c85ea119184dd17dce7ce7f649433f04b6efb6 /same/src/test
parent263f3a0b4425287ef234d0dbf039e0027c4ad6c1 (diff)
Refactor Paxos: Return proposal values.
Diffstat (limited to 'same/src/test')
-rw-r--r--same/src/test/java/com/orbekk/paxos/MasterProposerTest.java8
-rw-r--r--same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java18
2 files changed, 13 insertions, 13 deletions
diff --git a/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java b/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java
index 45ee53e..dfc0b19 100644
--- a/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java
+++ b/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java
@@ -30,8 +30,8 @@ public class MasterProposerTest {
@Test public void successfulProposal() {
connections.paxosMap.put("p1", p1);
- when(p1.propose("client1", 1)).thenReturn(true);
- when(p1.acceptRequest("client1", 1)).thenReturn(true);
+ when(p1.propose("client1", 1)).thenReturn(1);
+ when(p1.acceptRequest("client1", 1)).thenReturn(1);
MasterProposer c1 = new MasterProposer(
"client1",
@@ -42,8 +42,8 @@ public class MasterProposerTest {
@Test public void unsucessfulProposal() {
connections.paxosMap.put("p1", p1);
- when(p1.propose("client1", 1)).thenReturn(true);
- when(p1.acceptRequest("client1", 1)).thenReturn(false);
+ when(p1.propose("client1", 1)).thenReturn(1);
+ when(p1.acceptRequest("client1", 1)).thenReturn(1);
MasterProposer c1 = new MasterProposer(
"client1",
diff --git a/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java b/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java
index f9ee058..0165d4c 100644
--- a/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java
+++ b/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java
@@ -37,23 +37,23 @@ public class PaxosServiceTest {
@Test
public void simpleCase() {
- assertTrue(p1.propose(client, 1));
- assertTrue(p1.acceptRequest(client, 1));
+ assertEquals(1, p1.propose(client, 1));
+ assertEquals(1, p1.acceptRequest(client, 1));
}
@Test
public void lowerProposalFails() {
- assertTrue(p1.propose(client1, 10));
- assertFalse(p1.propose(client2, 9));
- assertTrue(p1.propose(client2, 100));
+ assertEquals(10, p1.propose(client1, 10));
+ assertEquals(-10, p1.propose(client2, 9));
+ assertEquals(100, p1.propose(client2, 100));
}
@Test
public void testAccept() {
- assertTrue(p1.propose(client1, 3));
- assertTrue(p1.propose(client2, 4));
- assertFalse(p1.acceptRequest(client1, 3));
- assertTrue(p1.acceptRequest(client2, 4));
+ assertEquals(3, p1.propose(client1, 3));
+ assertEquals(4, p1.propose(client2, 4));
+ assertEquals(-4, p1.acceptRequest(client1, 3));
+ assertEquals(4, p1.acceptRequest(client2, 4));
}
public List<String> paxosUrls() {