KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > samples > perf > PerfService_ServiceTestCase


1 /**
2  * PerfService_ServiceTestCase.java
3  *
4  * This file was auto-generated from WSDL
5  * by the Apache Axis 1.2beta Apr 25, 2004 (11:19:16 EDT) WSDL2Java emitter.
6  */

7
8 package samples.perf;
9
10 import java.util.Date JavaDoc;
11 import org.apache.axis.components.logger.LogFactory;
12 import org.apache.commons.logging.Log;
13
14 public class PerfService_ServiceTestCase extends junit.framework.TestCase {
15     /** Field log */
16     static Log log = LogFactory.getLog(PerfService_ServiceTestCase.class.getName());
17
18     public PerfService_ServiceTestCase(java.lang.String JavaDoc name) {
19         super(name);
20     }
21
22     public void test1PerfPortHandleStringArray() throws Exception JavaDoc {
23         samples.perf.PerfPortSoapBindingStub binding;
24         try {
25             binding = (samples.perf.PerfPortSoapBindingStub)
26                           new samples.perf.PerfService_ServiceLocator().getPerfPort();
27         }
28         catch (javax.xml.rpc.ServiceException JavaDoc jre) {
29             if(jre.getLinkedCause()!=null)
30                 jre.getLinkedCause().printStackTrace();
31             throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
32         }
33         assertNotNull("binding is null", binding);
34
35         // Time out after a minute
36
binding.setTimeout(60000);
37         binding._setProperty(org.apache.axis.client.Call.STREAMING_PROPERTY, Boolean.TRUE);
38         // Time out after a minute
39
binding.setTimeout(60000);
40
41         log.info(">>>> Warming up...");
42         pump(binding, 1);
43         log.info(">>>> Running volume tests...");
44         pump(binding, 100);
45         pump(binding, 1000);
46         pump(binding, 10000);
47         pump(binding, 100000);
48     }
49
50     private static void pump(PerfPortSoapBindingStub binding, int count)
51             throws java.rmi.RemoteException JavaDoc {
52         String JavaDoc[] s = new String JavaDoc[count];
53         for (int i = 0; i < s.length; i++) {
54             s[i] = "qwertyuiopåasdfghjklöäzxcvbnm";
55         }
56         Date JavaDoc start = new Date JavaDoc();
57         String JavaDoc value = binding.handleStringArray(s);
58         Date JavaDoc end = new Date JavaDoc();
59
60         log.info("Count:" + count + " \tTime consumed: " +
61                 (end.getTime() - start.getTime()) + "\tReturn:" + value);
62     }
63
64     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
65         PerfService_ServiceTestCase tests = new PerfService_ServiceTestCase("Perf");
66         tests.test1PerfPortHandleStringArray();
67     }
68 }
69
Popular Tags