KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > gumby > DefaultGuiEnvTest


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

14 public class DefaultGuiEnvTest extends TestCase{
15   
16   private DefaultGuiEnv _parent;
17   private DefaultGuiEnv _child;
18   
19   public DefaultGuiEnvTest(String JavaDoc name){
20     super(name);
21   }
22   
23   /**
24    * @see junit.framework.TestCase#setUp()
25    */

26   protected void setUp() throws Exception JavaDoc {
27     _parent = new DefaultGuiEnv();
28     _parent.addScope("parent", new MapScope());
29     _child = new DefaultGuiEnv(_parent);
30   }
31
32   public void testPutGet(){
33     _child.put("name1", "value1", "child");
34     assertTrue(_parent.get("name1") == null);
35     assertTrue(_child.get("name1") != null);
36     _child.put("name2", "value2", "parent");
37     assertTrue(_parent.get("name2") != null);
38     assertTrue(_child.get("name2") != null);
39   }
40   
41   public void testAcquire(){
42     try {
43       _child.acquire("value1");
44       fail("Should not have been able to acquire value");
45     } catch(RuntimeException JavaDoc e) {
46       // ok
47
}
48     try {
49       _child.acquire("value1", "parent");
50       fail("Should not have been able to acquire value");
51     } catch(RuntimeException JavaDoc e) {
52       // ok
53
}
54   }
55   
56   public void testRemoveScope(){
57     _child.put("name1", "value1", "someScope");
58     _child.acquire("name1");
59     _child.removeScope("someScope");
60     assertTrue(_child.get("name1") == null);
61   }
62 }
63
Popular Tags