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