Test code updates


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664823 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/java/src/TestClient.java b/test/java/src/TestClient.java
index fda37de..46a4ca5 100644
--- a/test/java/src/TestClient.java
+++ b/test/java/src/TestClient.java
@@ -3,7 +3,9 @@
 // Generated code
 import thrift.test.*;
 
+import com.facebook.thrift.transport.TTransport;
 import com.facebook.thrift.transport.TSocket;
+import com.facebook.thrift.transport.THttpClient;
 import com.facebook.thrift.transport.TTransportException;
 import com.facebook.thrift.protocol.TBinaryProtocol;
 
@@ -23,24 +25,41 @@
     try {
       String host = "localhost";
       int port = 9090;
+      String url = null;
       int numTests = 1;
-      
-      if (args.length > 0) {
-        host = args[0];
-      }
-      if (args.length > 1) {
-        port = Integer.valueOf(args[1]);
-      }
-      if (args.length > 2) {
-        numTests = Integer.valueOf(args[2]);
+
+      try {
+        for (int i = 0; i < args.length; ++i) {
+          if (args[i].equals("-h")) {
+            String[] hostport = (args[++i]).split(";");
+            host = hostport[0];
+            port = Integer.valueOf(hostport[1]);            
+          }
+
+          if (args[i].equals("-u")) {
+            url = args[++i];
+          }
+
+          if (args[i].equals("-n")) {
+            numTests = Integer.valueOf(args[++i]);
+          }
+        }
+      } catch (Exception x) {
+        x.printStackTrace();
       }
       
-      TSocket tSocket =
-        new TSocket(host, port);
+      TTransport transport;
+      
+      if (url != null) {
+        transport = new THttpClient(url);
+      } else {
+        transport = new TSocket(host, port);
+      }
+
       TBinaryProtocol binaryProtocol =
         new TBinaryProtocol();
       ThriftTest.Client testClient =
-        new ThriftTest.Client(tSocket, binaryProtocol);
+        new ThriftTest.Client(transport, binaryProtocol);
 
       long timeMin = 0;
       long timeMax = 0;
@@ -53,7 +72,7 @@
          */
         System.out.println("Test #" + (test+1) + ", " + "connect " + host + ":" + port);
         try {
-          tSocket.open();
+          transport.open();
         } catch (TTransportException ttx) {
           System.out.println("Connect failed: " + ttx.getMessage());
           continue;
@@ -322,7 +341,7 @@
         }
         timeTot += tot;
 
-        tSocket.close();
+        transport.close();
       }
 
       long timeAvg = timeTot / numTests;