From c0839711b16c4d5af4d6818deae97fd7e5f28930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Mon, 23 Jan 2012 21:36:18 +0100 Subject: Start implementing a functional test for PaxosService. --- .../orbekk/paxos/PaxosServiceFunctionalTest.java | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java (limited to 'same/src/test') 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 paxosUrls = new ArrayList(); + 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; + } + } +} -- cgit v1.2.3