*
* @author <a href="bombe@freenetproject.org">David ‘Bombe’ Roden</a>
*/
-public class FakeTcpServer {
+public class FakeTcpServer implements AutoCloseable {
private final ServerSocket serverSocket;
private final ExecutorService executorService;
return clientSocket.get().collectUntil(lineMatcher);
}
- public void writeLine(String line) throws IOException {
- clientSocket.get().writeLine(line);
+ public void writeLine(String... lines) throws IOException {
+ for (String line : lines) {
+ clientSocket.get().writeLine(line);
+ }
}
public String readLine() throws IOException {
return clientSocket.get().readLine();
}
+ @Override
+ public void close() throws IOException {
+ clientSocket.get().close();
+ }
+
}