1 15 package org.apache.tapestry.binding; 16 17 import org.apache.hivemind.Location; 18 import org.apache.tapestry.IBinding; 19 import org.apache.tapestry.coerce.ValueConverter; 20 import org.apache.tapestry.services.InjectedValueProvider; 21 import org.easymock.MockControl; 22 23 30 public class TestHiveMindBinding extends BindingTestCase 31 { 32 private IBinding newBinding(ValueConverter converter, InjectedValueProvider provider, 33 String objectReference, Location location) 34 { 35 HiveMindBindingFactory factory = new HiveMindBindingFactory(); 36 37 factory.setValueConverter(converter); 38 factory.setInjectedValueProvider(provider); 39 40 return factory.createBinding(null, "binding description", objectReference, location); 41 } 42 43 public void testSuccess() 44 { 45 Object injectedValue = new Object (); 46 Location l = fabricateLocation(12); 47 48 MockControl control = newControl(InjectedValueProvider.class); 49 InjectedValueProvider provider = (InjectedValueProvider) control.getMock(); 50 51 provider.obtainValue("spring:bean", l); 52 control.setReturnValue(injectedValue); 53 54 ValueConverter converter = newValueConverter(); 55 56 replayControls(); 57 58 IBinding binding = newBinding(converter, provider, "spring:bean", l); 59 60 assertSame(injectedValue, binding.getObject()); 61 62 verifyControls(); 63 } 64 } | Popular Tags |