1 15 package org.apache.tapestry.valid; 16 17 import org.apache.hivemind.Location; 18 import org.apache.hivemind.lib.BeanFactory; 19 import org.apache.hivemind.test.HiveMindTestCase; 20 import org.apache.tapestry.IBinding; 21 import org.apache.tapestry.coerce.ValueConverter; 22 import org.easymock.MockControl; 23 24 30 public class TestValidatorBindingFactory extends HiveMindTestCase 31 { 32 public void testFactory() 33 { 34 IValidator validator = (IValidator) newMock(IValidator.class); 35 ValueConverter vc = (ValueConverter) newMock(ValueConverter.class); 36 37 MockControl vbfc = newControl(BeanFactory.class); 38 BeanFactory vbf = (BeanFactory) vbfc.getMock(); 39 40 vbf.get("foo,bar=baz"); 41 vbfc.setReturnValue(validator); 42 43 Location l = newLocation(); 44 45 replayControls(); 46 47 ValidatorBindingFactory factory = new ValidatorBindingFactory(); 48 factory.setValueConverter(vc); 49 factory.setValidatorBeanFactory(vbf); 50 51 IBinding binding = factory.createBinding(null, "validator bean", "foo,bar=baz", l); 52 53 assertSame(validator, binding.getObject()); 54 assertSame(l, binding.getLocation()); 55 56 verifyControls(); 57 } 58 } | Popular Tags |