diff --git a/hsarback/test/de/hsadmin/remote/DomainTest.java b/hsarback/test/de/hsadmin/remote/DomainTest.java index f3446e1..8ecc1ef 100644 --- a/hsarback/test/de/hsadmin/remote/DomainTest.java +++ b/hsarback/test/de/hsadmin/remote/DomainTest.java @@ -296,11 +296,15 @@ public class DomainTest { public boolean isOptionConfigured(String domain) throws UnknownHostException, IOException { String host = "test-h99.hostsharing.net"; - String answer = socketQuery(host, 25, "HELO " + domain + "\n" - + "MAIL FROM: hsadmin-testing@" + domain + "\n" - + "RCPT TO: postmaster@" + domain + "\n" + "DATA\n" - + ".\n"); - return answer.contains("450") && answer.contains("reylisting"); + String[] query = { + "HELO " + domain + "\n" , + "MAIL FROM: hsadmin-testing@" + domain + "\n" , + "RCPT TO: postmaster@" + domain + "\n" , + "DATA\n" , + ".\n" , + "QUIT\n" } ; + String[] answer = socketQuery(host, 25, query ) ; + return answer[3].contains("450") && answer[3].contains("reylisting"); } }); } @@ -318,12 +322,12 @@ public class DomainTest { public boolean isOptionConfigured(String domain) throws UnknownHostException, IOException { String host = "test-h99.hostsharing.net"; - String answer = socketQuery(host, 80, "GET / HTTP/1.1\n" + String[] answer = socketQuery(host, 80, "GET / HTTP/1.1\n" + "Host: x.y.z." + domain + "User-Agent: hsAdmin Test\n" + "Connection: close\n"); - answer = answer.substring(0, answer.indexOf("\n")); - return answer.contains("404"); + // answer = answer.substring(0, answer.indexOf("\n")); + return answer[1].contains("404"); } }); } @@ -342,12 +346,12 @@ public class DomainTest { throws UnknownHostException, IOException { String host = "test-h99.hostsharing.net"; // TODO dieser Test ist Humbug - String answer = socketQuery(host, 80, "GET / HTTP/1.1\n" + String[] answer = socketQuery(host, 80, "GET / HTTP/1.1\n" + "Host: " + domain + "User-Agent: hsAdmin Test\n" + "Connection: close\n"); - answer = answer.substring(0, answer.indexOf("\n")); - return answer.contains("404"); + // answer = answer.substring(0, answer.indexOf("\n")); + return answer[1].contains("404"); } }); } @@ -366,12 +370,12 @@ public class DomainTest { throws UnknownHostException, IOException { String host = "test-h99.hostsharing.net"; // TODO dieser Test ist Humbug - String answer = socketQuery(host, 80, "GET / HTTP/1.1\n" + String[] answer = socketQuery(host, 80, "GET / HTTP/1.1\n" + "Host: " + domain + "User-Agent: hsAdmin Test\n" + "Connection: close\n"); - answer = answer.substring(0, answer.indexOf("\n")); - return answer.contains("404"); + // answer = answer.substring(0, answer.indexOf("\n")); + return answer[1].contains("404"); } }); } @@ -390,12 +394,12 @@ public class DomainTest { throws UnknownHostException, IOException { String host = "test-h99.hostsharing.net"; // TODO dieser Test ist Humbug - String answer = socketQuery(host, 80, "GET / HTTP/1.1\n" + String[] answer = socketQuery(host, 80, "GET / HTTP/1.1\n" + "Host: " + domain + "User-Agent: hsAdmin Test\n" + "Connection: close\n"); - answer = answer.substring(0, answer.indexOf("\n")); - return answer.contains("404"); + // answer = answer.substring(0, answer.indexOf("\n")); + return answer[1].contains("404"); } }); } @@ -469,13 +473,35 @@ public class DomainTest { return count; } - private String socketQuery( String host, int port, String query) throws UnknownHostException, IOException{ + private static String[] socketQuery( String host, int port, String command) throws UnknownHostException, IOException{ + String[] query = { command } ; + return socketQuery( host , port , query ); + } + + private static String[] socketQuery( String host, int port, String[] query) throws UnknownHostException, IOException{ Socket socket = new Socket( host, port ); - socketQueryWriter( socket, query ); - return socketQueryReader(socket); + String[] retval = socketQuery( socket, query ); + socket.close(); + return retval; + } + + private static String[] socketQuery( Socket socket, String command) throws UnknownHostException, IOException{ + String[] query = { command } ; + return socketQuery( socket , query ); + } + + private static String[] socketQuery( Socket socket, String[] query) throws UnknownHostException, IOException{ + int l = query.length; + String[] retval = new String[l]; + retval[0] = socketQueryReader(socket); + for(int i=0; i