diff options
Diffstat (limited to 'same/src')
-rw-r--r-- | same/src/main/java/com/orbekk/paxos/MasterProposer.java | 2 | ||||
-rw-r--r-- | same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/same/src/main/java/com/orbekk/paxos/MasterProposer.java b/same/src/main/java/com/orbekk/paxos/MasterProposer.java index e7c6e8a..3a451d0 100644 --- a/same/src/main/java/com/orbekk/paxos/MasterProposer.java +++ b/same/src/main/java/com/orbekk/paxos/MasterProposer.java @@ -10,7 +10,7 @@ public class MasterProposer { private List<String> paxosUrls = new ArrayList<String>(); private ConnectionManager connections; - MasterProposer(String clientUrl, List<String> paxosUrls, + public MasterProposer(String clientUrl, List<String> paxosUrls, ConnectionManager connections) { this.myUrl = clientUrl; this.paxosUrls = paxosUrls; diff --git a/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java b/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java index d09ff70..a6a1f0b 100644 --- a/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java +++ b/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java @@ -2,6 +2,8 @@ package com.orbekk.paxos; import static org.junit.Assert.*; +import com.orbekk.same.TestConnectionManager; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -9,6 +11,7 @@ import org.junit.Before; import org.junit.Test; public class PaxosServiceTest { + TestConnectionManager connections = new TestConnectionManager(); private PaxosServiceImpl p1 = new PaxosServiceImpl("P1: "); private PaxosServiceImpl p2 = new PaxosServiceImpl("P2: "); private PaxosServiceImpl p3 = new PaxosServiceImpl("P3: "); @@ -25,6 +28,11 @@ public class PaxosServiceTest { @Before public void setUp() { Collections.addAll(servers, p1, p2, p3, p4, p5); + connections.paxosMap.put("p1", p1); + connections.paxosMap.put("p2", p2); + connections.paxosMap.put("p3", p3); + connections.paxosMap.put("p4", p4); + connections.paxosMap.put("p5", p5); } @Test @@ -59,4 +67,15 @@ public class PaxosServiceTest { assertFalse(p1.acceptRequest(client2, 4, 5)); assertTrue(p1.propose(client1, 5, 1)); } + + public List<String> paxosUrls() { + return new ArrayList<String>(connections.paxosMap.keySet()); + } + + @Test + public void integrationTest() { + MasterProposer proposer = new MasterProposer("client1", paxosUrls(), + connections); + assertTrue(proposer.propose(1, 1)); + } } |