KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > detection > jndi > JNDIDetectorTestCase


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.detection.jndi;
8
9 import java.net.InetAddress JavaDoc;
10 import org.apache.log4j.Level;
11 import org.jboss.jrunit.harness.TestDriver;
12 import org.jnp.server.Main;
13
14 /**
15  * This should be used as the main test case for JNDI detector.
16  * It will start two JNDIDetectors in seperate instances. The first
17  * will detect the second and then the second will shutdown and the first
18  * will detect that the second is no longer present. This also requires
19  * this class to start an instance of the JNP
20  *
21  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
22  */

23 public class JNDIDetectorTestCase extends TestDriver
24 {
25
26    /**
27     * This method should call the addTestClasses() method with the client class to run, number of clients to run
28     * and the server class to run.
29     */

30    public void declareTestClasses()
31    {
32       try
33       {
34          // start JNDI server
35
int port = 1099;
36          //String host = "localhost";
37
String JavaDoc host = InetAddress.getLocalHost().getHostName();
38          Main JNDIServer = new Main();
39          JNDIServer.setPort(port);
40          JNDIServer.setBindAddress(host);
41          JNDIServer.start();
42          System.out.println("Started JNDI server on " + host + ":" + port);
43
44          addTestClasses(JNDIDetectorTest1.class.getName(),
45                         1,
46                         JNDIDetectorTest2.class.getName());
47       }
48       catch(Exception JavaDoc e)
49       {
50          System.out.println("Error starting JNDI server.");
51          e.printStackTrace();
52       }
53    }
54
55    protected Level getTestHarnessLogLevel()
56    {
57       return Level.DEBUG;
58    }
59
60    /**
61     * How long to wait for test results to be returned from the client(s). If goes longer than the
62     * specified limit, will throw an exception and kill the running test cases. Default value is
63     * RESULTS_TIMEOUT.
64     *
65     * @return
66     */

67    protected long getResultsTimeout()
68    {
69       return 300000;
70    }
71
72    /**
73     * How long for the server test case to wait for tear down message. If exceeds timeout,
74     * will throw exception. The default value is TEARDOWN_TIMEOUT.
75     *
76     * @return
77     */

78    protected long getTearDownTimeout()
79    {
80       return 300000;
81    }
82
83    /**
84     * How long to allow each of the test cases to run their tests. If exceeds this timeout
85     * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
86     *
87     * @return
88     */

89    protected long getRunTestTimeout()
90    {
91       return 300000;
92    }
93 }
Popular Tags