KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > SotoContainerTest


1 package org.sapia.soto;
2
3 import junit.framework.TestCase;
4
5
6 /**
7  * @author Yanick Duchesne
8  *
9  * <dl>
10  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
11  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
12  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
13  * </dl>
14  */

15 public class SotoContainerTest extends TestCase {
16   public SotoContainerTest(String JavaDoc arg0) {
17     super(arg0);
18   }
19
20   public void testInit() throws Exception JavaDoc {
21     SotoContainer cont = new SotoContainer();
22     cont.load("org/sapia/soto/singleService.xml");
23
24     TestService svc = (TestService) cont.lookup("some/service");
25     super.assertTrue("Service was not initialized", svc.init);
26     super.assertTrue("Service should not be in started mode", !svc.started);
27   }
28
29   public void testStart() throws Exception JavaDoc {
30     SotoContainer cont = new SotoContainer();
31     cont.load("org/sapia/soto/singleService.xml");
32     cont.start();
33
34     TestService svc = (TestService) cont.lookup("some/service");
35     super.assertTrue("Service was not started", svc.started);
36   }
37
38   public void testDispose() throws Exception JavaDoc {
39     SotoContainer cont = new SotoContainer();
40     cont.load("org/sapia/soto/singleService.xml");
41     cont.start();
42
43     TestService svc = (TestService) cont.lookup("some/service");
44     cont.dispose();
45     super.assertTrue("Service was not stopped", svc.disposed);
46   }
47
48   public void testBind() throws Exception JavaDoc {
49     SotoContainer cont = new SotoContainer();
50
51     try {
52       cont.load("org/sapia/soto/duplicateService.xml");
53       throw new Exception JavaDoc("Two services with same ID should not be allowed");
54     } catch (Exception JavaDoc e) {
55       //ok
56
}
57   }
58
59   public void testAssociation() throws Exception JavaDoc {
60     SotoContainer cont = new SotoContainer();
61     cont.load("org/sapia/soto/association.xml");
62     cont.start();
63
64     TestService svc = (TestService) cont.lookup("some/service");
65     super.assertTrue("Associated service is null", svc.child != null);
66     svc = (TestService) cont.lookup("some/other/service");
67     super.assertTrue("Associated service is null", svc.child != null);
68   }
69
70   public void testLayer() throws Exception JavaDoc {
71     SotoContainer cont = new SotoContainer();
72     cont.load("org/sapia/soto/layer.xml");
73     super.assertTrue("Layer not initialized", TestLayer.init);
74     cont.start();
75     super.assertTrue("Layer not started", TestLayer.started);
76   }
77 }
78
Popular Tags