@AfterClass public static void closeSocket() throws IOException, InterruptedException { in.close(); out.close(); socket.close(); nameservice.terminate(); }
@BeforeClass public static void startNameservice() throws IOException, InterruptedException { nameservice = new NameService(port); nameservice.start(); socket = new Socket(host, port); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); out = new PrintWriter(socket.getOutputStream(), true); }
@Test(expected = IllegalArgumentException.class) public void illegalPort() { NameService nameservice = new NameService(-1); nameservice.run(); }