1 15 package org.apache.tapestry.enhance; 16 17 import org.apache.hivemind.test.HiveMindTestCase; 18 import org.apache.tapestry.IComponent; 19 import org.apache.tapestry.spec.IComponentSpecification; 20 import org.easymock.MockControl; 21 22 28 public class TestInjectListenerRegistrationWorker extends HiveMindTestCase 29 { 30 private IComponentSpecification newSpec() 31 { 32 return (IComponentSpecification) newMock(IComponentSpecification.class); 33 } 34 35 public void testNonMatch() 36 { 37 MockControl control = newControl(EnhancementOperation.class); 38 EnhancementOperation op = (EnhancementOperation) control.getMock(); 39 40 IComponentSpecification spec = newSpec(); 41 42 op.implementsInterface(Runnable .class); 43 control.setReturnValue(false); 44 45 replayControls(); 46 47 InjectListenerRegistrationWorker w = new InjectListenerRegistrationWorker(); 48 w.setListenerInterface(Runnable .class); 49 50 w.performEnhancement(op, spec); 51 52 verifyControls(); 53 } 54 55 public void testMatch() 56 { 57 MockControl control = newControl(EnhancementOperation.class); 58 EnhancementOperation op = (EnhancementOperation) control.getMock(); 59 60 IComponentSpecification spec = newSpec(); 61 62 op.implementsInterface(IComponent.class); 63 control.setReturnValue(true); 64 65 op.extendMethodImplementation( 66 IComponent.class, 67 EnhanceUtils.FINISH_LOAD_SIGNATURE, 68 "getPage().addThisComponentAsListener(this);"); 69 70 replayControls(); 71 72 InjectListenerRegistrationWorker w = new InjectListenerRegistrationWorker(); 73 w.setListenerInterface(IComponent.class); 74 w.setRegisterMethodName("addThisComponentAsListener"); 75 76 w.performEnhancement(op, spec); 77 78 verifyControls(); 79 } 80 81 } | Popular Tags |