1 package org.sapia.gumby; 2 3 import junit.framework.TestCase; 4 5 14 public class DefaultGuiEnvTest extends TestCase{ 15 16 private DefaultGuiEnv _parent; 17 private DefaultGuiEnv _child; 18 19 public DefaultGuiEnvTest(String name){ 20 super(name); 21 } 22 23 26 protected void setUp() throws Exception { 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 e) { 46 } 48 try { 49 _child.acquire("value1", "parent"); 50 fail("Should not have been able to acquire value"); 51 } catch(RuntimeException e) { 52 } 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 |