KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > magnet > test > InteropClientTest


1 package org.sapia.magnet.test;
2
3 import org.sapia.corus.interop.Param;
4 import org.sapia.corus.interop.Status;
5 import org.sapia.corus.interop.Context;
6 import org.sapia.corus.interop.client.InteropClient;
7 import org.sapia.corus.interop.http.HttpProtocol;
8
9 import junit.framework.TestCase;
10
11
12 /**
13  * Class documentation
14  *
15  * @author <a HREF="mailto:jc@sapia-oss.org">Jean-Cedric Desrochers</a>
16  * <dl>
17  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">
18  * Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
19  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
20  * <a HREF="http://www.sapia-oss.org/license.html" target="sapia-license">license page</a>
21  * at the Sapia OSS web site</dd></dt>
22  * </dl>
23  */

24 public class InteropClientTest extends TestCase {
25
26   /**
27    * Creates a new InteropClientTest instance.
28    */

29   public InteropClientTest(String JavaDoc aName) {
30     super(aName);
31   }
32   
33   public void testShutdown() throws Exception JavaDoc {
34     DummyServer aServer = new DummyServer();
35     InteropClient.getInstance().setProtocol(new HttpProtocol());
36     assertTrue("The server is already shutdown", !aServer.isShutdown());
37     
38     InteropClient.getInstance().setExitSystemOnShutdown(false);
39     InteropClient.getInstance().shutdown();
40     assertTrue("The server is not shutdown", aServer.isShutdown());
41   }
42   
43   public void testStatusRequestAndShudown() throws Exception JavaDoc {
44     DummyServer aServer = new DummyServer();
45     InteropClient.getInstance().setProtocol(new HttpProtocol());
46     assertTrue("The server is already shudown", !aServer.isShutdown());
47     
48     Status aStatus = new Status();
49     InteropClient.getInstance().processStatus(aStatus);
50     assertEquals("", 1, aStatus.getContexts().size());
51
52     Context aContext = (Context) aStatus.getContexts().get(0);
53     assertEquals("", "DummyServer", aContext.getName());
54     assertEquals("", 1, aContext.getParams().size());
55     
56     Param anParam = (Param) aContext.getParams().get(0);
57     assertEquals("", "isShutdown", anParam.getName());
58     assertEquals("", "false", anParam.getValue());
59     
60     InteropClient.getInstance().setExitSystemOnShutdown(false);
61     InteropClient.getInstance().shutdown();
62     assertTrue("The server is not shudown", aServer.isShutdown());
63   }
64   
65 }
66
Popular Tags