diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-04-25 12:10:57 +0200 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-04-25 12:10:57 +0200 |
commit | 768938fa1e2bfaa5a246e28badefc7d8fe7cadd3 (patch) | |
tree | 29e17a0603922c087db4c24804ba22db290e8eaa /same/src/test/java | |
parent | a8b921e07bf4ad1936e01628049a9c6fd7349312 (diff) |
Add debug messages in Paxos service.
– Remove old PaxosService.
Diffstat (limited to 'same/src/test/java')
-rw-r--r-- | same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java | 71 | ||||
-rw-r--r-- | same/src/test/java/com/orbekk/same/FunctionalTest.java | 16 |
2 files changed, 10 insertions, 77 deletions
diff --git a/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java b/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java deleted file mode 100644 index 3160d2d..0000000 --- a/same/src/test/java/com/orbekk/paxos/PaxosServiceTest.java +++ /dev/null @@ -1,71 +0,0 @@ -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; -import org.junit.Before; -import org.junit.Ignore; -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: "); - private PaxosServiceImpl p4 = new PaxosServiceImpl("P4: "); - private PaxosServiceImpl p5 = new PaxosServiceImpl("P5: "); - private String client = "client"; - private String client1 = "client1"; - private String client2 = "client2"; - private String client3 = "client3"; - private String client4 = "client4"; - private String client5 = "client5"; - private List<PaxosServiceImpl> servers = new ArrayList<PaxosServiceImpl>(); - - @Before - public void setUp() { - Collections.addAll(servers, p1, p2, p3, p4, p5); - connections.paxosMap0.put("p1", p1.getService()); - connections.paxosMap0.put("p2", p2.getService()); - connections.paxosMap0.put("p3", p3.getService()); - connections.paxosMap0.put("p4", p4.getService()); - connections.paxosMap0.put("p5", p5.getService()); - } - - @Test - public void simpleCase() { - assertEquals(1, p1.propose(client, 1)); - assertEquals(1, p1.acceptRequest(client, 1)); - } - - @Test - public void lowerProposalFails() { - assertEquals(10, p1.propose(client1, 10)); - assertEquals(-10, p1.propose(client2, 9)); - assertEquals(100, p1.propose(client2, 100)); - } - - @Test - public void testAccept() { - 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() { - return new ArrayList<String>(connections.paxosMap0.keySet()); - } - - @Test - @Ignore - public void integrationTest() { -// MasterProposer proposer = new MasterProposer("client1", paxosUrls(), -// connections); -// assertTrue(proposer.propose(1)); - } -} diff --git a/same/src/test/java/com/orbekk/same/FunctionalTest.java b/same/src/test/java/com/orbekk/same/FunctionalTest.java index 275eaac..a69bdca 100644 --- a/same/src/test/java/com/orbekk/same/FunctionalTest.java +++ b/same/src/test/java/com/orbekk/same/FunctionalTest.java @@ -1,10 +1,8 @@ package com.orbekk.same; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.is; import java.util.ArrayList; import java.util.List; @@ -12,8 +10,8 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import com.orbekk.paxos.PaxosService; import com.orbekk.paxos.PaxosServiceImpl; +import com.orbekk.protobuf.Rpc; import com.orbekk.util.DelayedOperation; /** A functional test that runs with a master and several clients. */ @@ -29,7 +27,13 @@ public class FunctionalTest { VariableFactory vf3; List<Client> clients = new ArrayList<Client>(); TestConnectionManager connections = new TestConnectionManager(); - RpcFactory rpcf = new RpcFactory(5000); + RpcFactory rpcf = new RpcFactory(5000) { + @Override public Rpc create() { + Rpc rpc = super.create(); + rpc.complete(); + return rpc; + }; + }; @Before public void setUp() { master = Master.create(connections, |