re-add a test
authorNiki Roo <niki@nikiroo.be>
Tue, 30 Apr 2019 16:49:56 +0000 (18:49 +0200)
committerNiki Roo <niki@nikiroo.be>
Tue, 30 Apr 2019 16:49:56 +0000 (18:49 +0200)
src/be/nikiroo/utils/test_code/SerialServerTest.java

index 382d9a6b5a11a7b29edc1242a58fa132bc8d3165..9c346fd5829b880622dd05307513720f816213b3 100644 (file)
@@ -43,63 +43,63 @@ class SerialServerTest extends TestLauncher {
 
                super(title + " " + skey + sbridge, args);
 
-               // addTest(new TestCase("Simple connection " + skey) {
-               // @Override
-               // public void test() throws Exception {
-               // final String[] rec = new String[1];
-               //
-               // ServerString server = new ServerString(this.getName(), 0, key) {
-               // @Override
-               // protected String onRequest(
-               // ConnectActionServerString action, String data)
-               // throws Exception {
-               // return null;
-               // }
-               //
-               // @Override
-               // protected void onError(Exception e) {
-               // }
-               // };
-               //
-               // int port = server.getPort();
-               // assertEquals("A port should have been assigned", true, port > 0);
-               //
-               // server.start();
-               //
-               // ServerBridge br = null;
-               // if (bridge) {
-               // br = new ServerBridge(0, key, "", port, key);
-               // br.setTraceHandler(null);
-               //
-               // port = br.getPort();
-               // assertEquals(
-               // "A port should have been assigned to the bridge",
-               // true, port > 0);
-               //
-               // br.start();
-               // }
-               //
-               // try {
-               // try {
-               // new ConnectActionClientObject(null, port, key) {
-               // @Override
-               // public void action() throws Exception {
-               // rec[0] = "ok";
-               // }
-               // }.connect();
-               // } finally {
-               // server.stop();
-               // }
-               // } finally {
-               // if (br != null) {
-               // br.stop();
-               // }
-               // }
-               //
-               // assertNotNull("The client action was not run", rec[0]);
-               // assertEquals("ok", rec[0]);
-               // }
-               // });
+               addTest(new TestCase("Simple connection " + skey) {
+                       @Override
+                       public void test() throws Exception {
+                               final String[] rec = new String[1];
+
+                               ServerString server = new ServerString(this.getName(), 0, key) {
+                                       @Override
+                                       protected String onRequest(
+                                                       ConnectActionServerString action, String data)
+                                                       throws Exception {
+                                               return null;
+                                       }
+
+                                       @Override
+                                       protected void onError(Exception e) {
+                                       }
+                               };
+
+                               int port = server.getPort();
+                               assertEquals("A port should have been assigned", true, port > 0);
+
+                               server.start();
+
+                               ServerBridge br = null;
+                               if (bridge) {
+                                       br = new ServerBridge(0, key, "", port, key);
+                                       br.setTraceHandler(null);
+
+                                       port = br.getPort();
+                                       assertEquals(
+                                                       "A port should have been assigned to the bridge",
+                                                       true, port > 0);
+
+                                       br.start();
+                               }
+
+                               try {
+                                       try {
+                                               new ConnectActionClientObject(null, port, key) {
+                                                       @Override
+                                                       public void action() throws Exception {
+                                                               rec[0] = "ok";
+                                                       }
+                                               }.connect();
+                                       } finally {
+                                               server.stop();
+                                       }
+                               } finally {
+                                       if (br != null) {
+                                               br.stop();
+                                       }
+                               }
+
+                               assertNotNull("The client action was not run", rec[0]);
+                               assertEquals("ok", rec[0]);
+                       }
+               });
 
                addTest(new TestCase("Simple exchange " + skey) {
                        final String[] sent = new String[1];