You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2001/09/10 21:48:29 UTC

cvs commit: xml-axis/java/samples/echo TestClient.java

gdaniels    01/09/10 12:48:29

  Modified:    java/samples/echo TestClient.java
  Log:
  Add performance testing option
  
  Revision  Changes    Path
  1.27      +33 -13    xml-axis/java/samples/echo/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/echo/TestClient.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- TestClient.java	2001/08/29 03:30:58	1.26
  +++ TestClient.java	2001/09/10 19:48:29	1.27
  @@ -96,7 +96,7 @@
          if (obj1 instanceof Date && obj2 instanceof Date)
              if (Math.abs(((Date)obj1).getTime()-((Date)obj2).getTime())<1000)
                  return true;
  -       
  +
          if ((obj1 instanceof Map) && (obj2 instanceof Map)) {
              Map map1 = (Map)obj1;
              Map map2 = (Map)obj2;
  @@ -134,12 +134,12 @@
       private void test(String type, Object toSend) {
   
           String method = "echo" + type;
  -        
  +
           type = type.trim();
  -        
  +
           String arg = "input" + type;
           String resultName = "output" + type;
  -        
  +
   
           try {
               // set up the argument list
  @@ -154,7 +154,7 @@
                   sd.setOutputType(map.getTypeQName(toSend.getClass()));
                   call.setServiceDescription(sd);
               }
  -            
  +
               // set the SOAPAction, optionally appending the method name
               String action = soapAction;
               if (addMethodToAction) action += method;
  @@ -181,7 +181,7 @@
       /**
        * Set up the call object.
        */
  -    public void setURL(String url) 
  +    public void setURL(String url)
           throws AxisFault
       {
           call = new ServiceClient(url);
  @@ -215,7 +215,7 @@
           test("Date        ", new Date());
           test("Decimal     ", new BigDecimal("3.14159"));
           test("Boolean     ", Boolean.TRUE);
  -        
  +
           HashMap map = new HashMap();
           map.put("stringKey", new Integer(5));
           map.put(new Date(), "string value");
  @@ -241,9 +241,20 @@
        *   -h localhost -p 8080 -s /soap/servlet/rpcrouter
        */
       public static void main(String args[]) throws Exception {
  +        Options opts = new Options(args);
  +
  +        boolean testPerformance = opts.isFlagSet('k') > 0;
   
           // set up tests so that the results are sent to System.out
  -        TestClient client = new TestClient() {
  +        TestClient client;
  +
  +        if (testPerformance) {
  +            client = new TestClient() {
  +               public void verify(String method, Object sent, Object gotBack) {
  +               }
  +            };
  +        } else {
  +            client = new TestClient() {
               public void verify(String method, Object sent, Object gotBack) {
                   if (this.equals(sent, gotBack)) {
                       System.out.println(method + "\t OK");
  @@ -255,17 +266,26 @@
                   }
               }
           };
  +        }
   
           // set up the call object
  -        Options opts = new Options(args);
           client.setURL(opts.getURL());
  -        
  +
           // support for tests with non-compliant applications
           client.addMethodToAction = (opts.isFlagSet('m') > 0);
  -        
  +
           String action = opts.isValueSet('a');
           if (action != null) client.soapAction = action;
  -        
  -        client.execute();
  +
  +        if (testPerformance) {
  +            long startTime = System.currentTimeMillis();
  +            for (int i = 0; i < 10; i++) {
  +                client.execute();
  +            }
  +            long stopTime = System.currentTimeMillis();
  +            System.out.println("That took " + (stopTime - startTime) + " milliseconds");
  +        } else {
  +            client.execute();
  +        }
       }
   }