KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > performance > synchronous > PerformanceTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.remoting.performance.synchronous;
8
9 import java.io.IOException JavaDoc;
10 import org.apache.log4j.Level;
11 import org.jboss.jrunit.harness.TestDriver;
12
13 /**
14  * @author <a HREF="mailto:tom.elrod@jboss.com">Tom Elrod</a>
15  */

16 public class PerformanceTestCase extends TestDriver
17 {
18    protected int numberOfClients = 1;
19
20    public static final String JavaDoc REMOTING_TRANSPORT = "remoting.transport";
21    public static final String JavaDoc PAYLOAD_SIZE = "remoting.payload.size";
22    public static final String JavaDoc NUMBER_OF_CLIENTS = "remoting.number_of_clients";
23    public static final String JavaDoc NUMBER_OF_CALLS = "remoting.number_of_calls";
24
25    public void declareTestClasses()
26    {
27       //**************** LOGGING ***********************
28
org.apache.log4j.BasicConfigurator.configure();
29       org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
30       //org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
31

32       org.apache.log4j.SimpleLayout layout = new org.apache.log4j.SimpleLayout();
33
34       try
35       {
36          org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log");
37          fileAppender.setThreshold(Level.DEBUG);
38          fileAppender.setAppend(false);
39          org.apache.log4j.Category.getRoot().addAppender(fileAppender);
40       }
41       catch(IOException JavaDoc e)
42       {
43          e.printStackTrace();
44       }
45       //*************** END LOGGING ***********************
46

47
48
49       String JavaDoc numOfClients = System.getProperty(NUMBER_OF_CLIENTS);
50       if(numOfClients != null && numOfClients.length() > 0)
51       {
52          try
53          {
54             numberOfClients = Integer.parseInt(numOfClients);
55          }
56          catch(NumberFormatException JavaDoc e)
57          {
58             e.printStackTrace();
59          }
60       }
61
62       addTestClasses(PerformanceClientTest.class.getName(),
63                      numberOfClients,
64                      PerformanceServerTest.class.getName());
65    }
66
67    protected Level getTestHarnessLogLevel()
68    {
69       return Level.INFO;
70       //return Level.DEBUG;
71
}
72
73    /**
74     * The log level to run as for the test case.
75     *
76     * @return
77     */

78    protected Level getTestLogLevel()
79    {
80       return Level.INFO;
81       //return Level.DEBUG;
82
}
83
84    /**
85     * Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness).
86     * The default value is null.
87     *
88     * @return
89     */

90    protected String JavaDoc getClientJVMArguments()
91    {
92       return getJVMArguments();
93 // String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 ";
94
// args = args + getJVMArguments();
95
// return args;
96
}
97
98    /**
99     * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness).
100     * The default value is null.
101     *
102     * @return
103     */

104    protected String JavaDoc getServerJVMArguments()
105    {
106       return getJVMArguments();
107    }
108
109    /**
110     * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness).
111     * The default value is null.
112     *
113     * @return
114     */

115    private String JavaDoc getJVMArguments()
116    {
117       String JavaDoc vmArgs = "";
118
119       String JavaDoc transport = System.getProperty(REMOTING_TRANSPORT);
120       if(transport != null && transport.length() > 0)
121       {
122          vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport;
123       }
124       String JavaDoc payloadSize = System.getProperty(PAYLOAD_SIZE);
125       if(payloadSize != null && payloadSize.length() > 0)
126       {
127          vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize;
128       }
129       String JavaDoc numOfCalls = System.getProperty(NUMBER_OF_CALLS);
130       if(numOfCalls != null && numOfCalls.length() > 0)
131       {
132          vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls;
133       }
134
135       return vmArgs;
136    }
137
138    /**
139     * How long to wait for test results to be returned from the client(s). If goes longer than the
140     * specified limit, will throw an exception and kill the running test cases. Default value is
141     * RESULTS_TIMEOUT.
142     *
143     * @return
144     */

145    protected long getResultsTimeout()
146    {
147       return 300000;
148    }
149
150    /**
151     * How long for the server test case to wait for tear down message. If exceeds timeout,
152     * will throw exception. The default value is TEARDOWN_TIMEOUT.
153     *
154     * @return
155     */

156    protected long getTearDownTimeout()
157    {
158       return 300000;
159    }
160
161    /**
162     * How long to allow each of the test cases to run their tests. If exceeds this timeout
163     * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
164     *
165     * @return
166     */

167    protected long getRunTestTimeout()
168    {
169       return 300000;
170    }
171
172 }
173
Popular Tags