From: Niki Roo Date: Tue, 30 Apr 2019 16:49:56 +0000 (+0200) Subject: re-add a test X-Git-Tag: fanfix-3.0.1~29^2~88 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=c1e7c70dbaaaf8efb5d977ed0e5b1128827355ed;p=fanfix.git re-add a test --- diff --git a/src/be/nikiroo/utils/test_code/SerialServerTest.java b/src/be/nikiroo/utils/test_code/SerialServerTest.java index 382d9a6..9c346fd 100644 --- a/src/be/nikiroo/utils/test_code/SerialServerTest.java +++ b/src/be/nikiroo/utils/test_code/SerialServerTest.java @@ -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];