diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-03-28 17:14:22 +0200 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-03-28 17:14:22 +0200 |
commit | 8a1c8340be7151ba38eca59597b4eda04ebdcc9a (patch) | |
tree | 81f92375037796b480045ea618d26fb05cbb835b /src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java | |
parent | d317a85a7b76ee94ebc31c218dc877bfadd54902 (diff) |
Add functional test.
Diffstat (limited to 'src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java')
-rw-r--r-- | src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java b/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java index a6dd7c4..690da81 100644 --- a/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java +++ b/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java @@ -39,6 +39,10 @@ public class SimpleProtobufServer extends Thread { public SimpleProtobufServer(ServerSocket serverSocket) { this.serverSocket = serverSocket; } + + public int getPort() { + return serverSocket.getLocalPort(); + } public synchronized void registerService(Service service) { String serviceName = service.getDescriptorForType().getFullName(); @@ -120,24 +124,24 @@ public class SimpleProtobufServer extends Thread { } } - public static void main(String[] args) { - SimpleProtobufServer server = SimpleProtobufServer.create(10000); - Test.TestService testService = new Test.TestService() { - @Override public void run(RpcController controller, - Test.TestRequest request, - RpcCallback<Test.TestResponse> done) { - System.out.println("Hello from TestService!"); - done.run(Test.TestResponse.newBuilder() - .setId("Hello from server.") - .build()); - } - }; - server.registerService(testService); - server.start(); - try { - server.join(); - } catch (InterruptedException e) { - System.out.println("Stopped."); - } - } +// public static void main(String[] args) { +// SimpleProtobufServer server = SimpleProtobufServer.create(10000); +// Test.TestService testService = new Test.TestService() { +// @Override public void run(RpcController controller, +// Test.TestRequest request, +// RpcCallback<Test.TestResponse> done) { +// System.out.println("Hello from TestService!"); +// done.run(Test.TestResponse.newBuilder() +// .setId("Hello from server.") +// .build()); +// } +// }; +// server.registerService(testService); +// server.start(); +// try { +// server.join(); +// } catch (InterruptedException e) { +// System.out.println("Stopped."); +// } +// } } |