Add method to write several lines at once
[jFCPlib.git] / src / test / java / net / pterodactylus / fcp / fake / FakeTcpServer.java
index 07afb24..e988ff3 100644 (file)
@@ -15,7 +15,7 @@ import org.hamcrest.Matcher;
  *
  * @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;
@@ -44,12 +44,19 @@ public class FakeTcpServer {
                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();
+       }
+
 }