1 15 package org.apache.tapestry.engine.state; 16 17 import java.util.HashMap ; 18 import java.util.Map ; 19 20 import org.apache.hivemind.ApplicationRuntimeException; 21 import org.apache.hivemind.Location; 22 import org.apache.hivemind.impl.DefaultClassResolver; 23 import org.apache.hivemind.test.HiveMindTestCase; 24 25 29 public class TestNamedClassStateObjectFactory extends HiveMindTestCase 30 { 31 public void testSuccess() 32 { 33 NamedClassStateObjectFactory f = new NamedClassStateObjectFactory(); 34 f.setClassResolver(new DefaultClassResolver()); 35 f.setClassName(HashMap .class.getName()); 36 37 assertTrue(f.createStateObject() instanceof HashMap ); 38 } 39 40 public void testFailure() 41 { 42 Location l = fabricateLocation(99); 43 44 NamedClassStateObjectFactory f = new NamedClassStateObjectFactory(); 45 f.setClassResolver(new DefaultClassResolver()); 46 f.setClassName(Map .class.getName()); 47 f.setLocation(l); 48 49 try 50 { 51 f.createStateObject(); 52 unreachable(); 53 } 54 catch (ApplicationRuntimeException ex) 55 { 56 assertExceptionSubstring(ex, "Unable to instantiate an instance of java.util.Map"); 57 58 assertSame(l, ex.getLocation()); 59 60 } 61 62 } 63 64 } | Popular Tags |