diff options
author | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2016-11-02 10:20:57 +0100 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2017-04-28 23:45:02 +0200 |
commit | d850ed49b22d2a0c84a3b317acec8df7e7159016 (patch) | |
tree | 1e58f1090d4c56f9c253321b37cc07b20e24ec8b /org.jacoco.core.test | |
parent | 30bc8e190e9a90fc43f5f68c499062cd58db3ebe (diff) | |
download | jacoco-d850ed49b22d2a0c84a3b317acec8df7e7159016.tar.gz |
Github #525: Simple Command Line Interface
Diffstat (limited to 'org.jacoco.core.test')
-rw-r--r-- | org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java b/org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java index 3fe1688f..80918149 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java @@ -101,7 +101,7 @@ public class ExecDumpClientTest { // 3. Retry "onConnectionFailure", "onConnecting") - , callbacks); + , callbacks); } @Test @@ -126,6 +126,12 @@ public class ExecDumpClientTest { assertTrue(resetRequested); } + @Test(expected = IOException.class) + public void testNopServer() throws IOException { + int port = createNopServer(); + client.dump((String) null, port); + } + private int getFreePort() throws IOException { final ServerSocket server = new ServerSocket(0, 0, InetAddress.getByName(null)); @@ -159,11 +165,27 @@ public class ExecDumpClientTest { dumpRequested = dump; resetRequested = reset; if (dump) { - writer.visitSessionInfo(new SessionInfo("TestId", 100, 200)); + writer.visitSessionInfo( + new SessionInfo("TestId", 100, 200)); } writer.sendCmdOk(); } }); reader.read(); } + + private int createNopServer() throws IOException { + server = new ServerSocket(0, 0, InetAddress.getByName(null)); + new Thread(new Runnable() { + public void run() { + try { + server.accept().close(); + } catch (IOException e) { + // ignore + } + } + }).start(); + return server.getLocalPort(); + } + } |