summaryrefslogtreecommitdiff
path: root/same/src/test/java/com/orbekk
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-23 21:36:18 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-23 21:36:18 +0100
commitc0839711b16c4d5af4d6818deae97fd7e5f28930 (patch)
treed8e320eb3c2cfbadb5a503df4bc7a723c90dc322 /same/src/test/java/com/orbekk
parent92e46bea722a2dcf038353101c7f705d38c08097 (diff)
Start implementing a functional test for PaxosService.
Diffstat (limited to 'same/src/test/java/com/orbekk')
-rw-r--r--same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java b/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java
new file mode 100644
index 0000000..c537d18
--- /dev/null
+++ b/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java
@@ -0,0 +1,57 @@
+package com.orbekk.paxos;
+
+import com.googlecode.jsonrpc4j.JsonRpcServer;
+import com.orbekk.same.ConnectionManagerImpl;
+import com.orbekk.same.RpcHandler;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PaxosServiceFunctionalTest {
+ ConnectionManagerImpl connections = new ConnectionManagerImpl(500, 500);
+ List<String> paxosUrls = new ArrayList<String>();
+ RpcHandler handler = new RpcHandler(null);
+ TestServer server;
+ String myUrl;
+
+ @Before
+ public void setUp() throws Exception {
+ server = TestServer.create(handler);
+ myUrl = "http://localhost:" + server.port + "/";
+ setupPaxos(5);
+ }
+
+ public void setupPaxos(int instances) {
+ for (int i = 1; i <= instances; i++) {
+ JsonRpcServer jsonServer = new JsonRpcServer(
+ new PaxosServiceImpl("" + i), PaxosService.class);
+ String serviceId = "/PaxosService" + i + ".json";
+ handler.addRpcServer(serviceId, jsonServer);
+ }
+ }
+
+ @Test
+ public void nullTest() {
+ }
+
+ public static class TestServer {
+ public Server server;
+ public int port;
+
+ public static TestServer create(Handler handler) throws Exception {
+ Server server = new Server(0);
+ server.setHandler(handler);
+ server.start();
+ int port = server.getConnectors()[0].getLocalPort();
+ return new TestServer(server, port);
+ }
+
+ private TestServer(Server server, int port) {
+ this.server = server;
+ this.port = port;
+ }
+ }
+}