1 15 package org.apache.tapestry.bean; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.hivemind.Location; 19 import org.apache.hivemind.test.HiveMindTestCase; 20 21 27 public class TestLightweightBeanInitializer extends HiveMindTestCase 28 { 29 public void testSuccess() 30 { 31 String initializer = "required,minLength=10"; 32 TargetBean bean = new TargetBean(); 33 34 assertEquals(false, bean.isRequired()); 35 assertEquals(0, bean.getMinLength()); 36 37 IBeanInitializer bi = new LightweightBeanInitializer(initializer); 38 39 assertEquals(initializer, bi.getPropertyName()); 40 41 bi.setBeanProperty(null, bean); 42 43 assertEquals(true, bean.isRequired()); 44 assertEquals(10, bean.getMinLength()); 45 } 46 47 public void testFailure() 48 { 49 Location l = newLocation(); 50 51 IBeanInitializer bi = new LightweightBeanInitializer("zip=zap"); 52 bi.setLocation(l); 53 54 TargetBean bean = new TargetBean(); 55 56 try 57 { 58 bi.setBeanProperty(null, bean); 59 unreachable(); 60 } 61 catch (ApplicationRuntimeException ex) 62 { 63 assertEquals("Class org.apache.tapestry.bean.TargetBean " 64 + "does not contain a property named 'zip'.", ex.getMessage()); 65 assertSame(l, ex.getLocation()); 66 } 67 } 68 } 69 | Popular Tags |