summaryrefslogtreecommitdiff
path: root/same/src
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-23 20:13:26 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-23 20:13:26 +0100
commit675d39342eeee15dda340557c88321edb431de98 (patch)
treea8c0edc234e44c0bbebbc221b7f96468fe921b02 /same/src
parent1ae55b79f849cfd2e8b24311b63caa04baa5d3c2 (diff)
Add Paxos integration test.
Diffstat (limited to 'same/src')
-rw-r--r--same/src/main/java/com/orbekk/paxos/MasterProposer.java2
-rw-r--r--same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java19
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));
+ }
}