summaryrefslogtreecommitdiff
path: root/same/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'same/src/test')
-rw-r--r--same/src/test/java/com/orbekk/paxos/MasterProposerTest.java36
1 files changed, 16 insertions, 20 deletions
diff --git a/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java b/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java
index 74c817f..8056ab6 100644
--- a/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java
+++ b/same/src/test/java/com/orbekk/paxos/MasterProposerTest.java
@@ -8,7 +8,7 @@ import org.junit.Test;
import com.orbekk.same.TestConnectionManager;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
public class MasterProposerTest {
@@ -18,18 +18,6 @@ public class MasterProposerTest {
PaxosService p3 = mock(PaxosService.class);
PaxosService p4 = mock(PaxosService.class);
PaxosService p5 = mock(PaxosService.class);
- String master = null;
-
- private class TestMasterAction implements Runnable {
- String tag;
- TestMasterAction(String tag) {
- this.tag = tag;
- }
-
- @Override public void run() {
- master = tag;
- }
- }
@Before public void setUp() {
}
@@ -39,7 +27,7 @@ public class MasterProposerTest {
urls.addAll(connections.paxosMap.keySet());
return urls;
}
-
+
@Test public void successfulProposal() {
connections.paxosMap.put("p1", p1);
when(p1.propose("client1", 1, 1)).thenReturn(true);
@@ -48,11 +36,19 @@ public class MasterProposerTest {
MasterProposer c1 = new MasterProposer(
"client1",
paxosUrls(),
- 0,
- connections,
- MasterProposer.getTimeoutAction(0),
- new TestMasterAction("c1"));
- c1.run();
- assertEquals("c1", master);
+ connections);
+ assertTrue(c1.propose(1, 1));
+ }
+
+ @Test public void unsucessfulProposal() {
+ connections.paxosMap.put("p1", p1);
+ when(p1.propose("client1", 1, 1)).thenReturn(true);
+ when(p1.acceptRequest("client1", 1, 1)).thenReturn(false);
+
+ MasterProposer c1 = new MasterProposer(
+ "client1",
+ paxosUrls(),
+ connections);
+ assertFalse(c1.propose(1, 1));
}
}