1 17 18 package org.apache.avalon.fortress.util.test; 19 20 import junit.framework.TestCase; 21 import org.apache.avalon.fortress.util.OverridableContext; 22 import org.apache.avalon.framework.context.ContextException; 23 import org.apache.avalon.framework.context.DefaultContext; 24 25 31 public class OverridableContextTestCase extends TestCase 32 { 33 public OverridableContextTestCase( String name ) 34 { 35 super( name ); 36 } 37 38 public void testOverride() throws Exception 39 { 40 OverridableContext context = new OverridableContext( new DefaultContext() ); 41 context.put( "name", "value" ); 42 43 assertNotNull( context.get( "name" ) ); 44 assertEquals( "value", context.get( "name" ) ); 45 46 context.put( "name", "" ); 47 48 assertNotNull( context.get( "name" ) ); 49 assertEquals( "", context.get( "name" ) ); 50 51 context.put( "name", null ); 52 53 try 54 { 55 context.get( "name" ); 56 fail( "Did not throw the expected exception" ); 57 } 58 catch ( ContextException ce ) 59 { 60 } 62 catch ( Exception e ) 63 { 64 fail( "Threw the wrong exception: " + e.getClass().getName() ); 65 } 66 } 67 } 68 | Popular Tags |