1 15 package org.apache.tapestry.annotations; 16 17 import java.lang.reflect.Method ; 18 19 import org.apache.tapestry.enhance.EnhancementOperation; 20 import org.apache.tapestry.enhance.InjectObjectWorker; 21 import org.apache.tapestry.services.InjectedValueProvider; 22 import org.apache.tapestry.spec.IComponentSpecification; 23 import org.easymock.MockControl; 24 25 31 32 public class TestInjectObjectAnnotationWorker extends BaseAnnotationTestCase 33 { 34 public void testDefault() 35 { 36 InjectObjectAnnotationWorker worker = new InjectObjectAnnotationWorker(); 37 38 assertNotNull(worker._delegate); 39 } 40 41 public void testDelegation() 42 { 43 EnhancementOperation op = newOp(); 44 IComponentSpecification spec = newSpec(); 45 46 InjectObjectWorker delegate = (InjectObjectWorker) newMock(InjectObjectWorker.class); 47 48 InjectedValueProvider provider = (InjectedValueProvider) newMock(InjectedValueProvider.class); 49 50 delegate.setProvider(provider); 51 52 replayControls(); 53 54 InjectObjectAnnotationWorker worker = new InjectObjectAnnotationWorker(delegate); 55 worker.setProvider(provider); 56 57 verifyControls(); 58 59 Method m = findMethod(AnnotatedPage.class, "getInjectedObject"); 60 61 delegate.injectObject(op, "barney", "injectedObject", null); 62 63 replayControls(); 64 65 worker.performEnhancement(op, spec, m, null); 66 67 verifyControls(); 68 } 69 70 } 71 | Popular Tags |