1 15 package org.apache.tapestry.annotations; 16 17 import org.apache.hivemind.Location; 18 import org.apache.tapestry.enhance.EnhancementOperation; 19 import org.apache.tapestry.spec.ComponentSpecification; 20 import org.apache.tapestry.spec.IComponentSpecification; 21 import org.easymock.MockControl; 22 23 29 public class TestComponentClassAnnotationWorker extends BaseAnnotationTestCase 30 { 31 private EnhancementOperation newOp(Class componentClass) 32 { 33 MockControl control = newControl(EnhancementOperation.class); 34 EnhancementOperation op = (EnhancementOperation) control.getMock(); 35 36 op.getBaseClass(); 37 control.setReturnValue(componentClass); 38 39 return op; 40 } 41 42 private IComponentSpecification attempt(Class baseClass, Location location) 43 { 44 EnhancementOperation op = newOp(); 45 IComponentSpecification spec = new ComponentSpecification(); 46 47 replayControls(); 48 49 new ComponentClassAnnotationWorker().performEnhancement(op, spec, baseClass, location); 50 51 verifyControls(); 52 53 return spec; 54 } 55 56 public void testBasic() 57 { 58 Location l = newLocation(); 59 IComponentSpecification spec = attempt(BasicComponent.class, l); 60 61 assertEquals(true, spec.getAllowBody()); 62 assertEquals(true, spec.getAllowInformalParameters()); 63 assertEquals(false, spec.isReservedParameterName("foo")); 64 assertEquals(false, spec.isReservedParameterName("bar")); 65 assertEquals(false, spec.isDeprecated()); 66 assertSame(l, spec.getLocation()); 67 } 68 69 public void testFormalOnly() 70 { 71 IComponentSpecification spec = attempt(FormalOnlyComponent.class, null); 72 73 assertEquals(false, spec.getAllowBody()); 74 assertEquals(false, spec.getAllowInformalParameters()); 75 assertEquals(false, spec.isDeprecated()); 76 } 77 78 public void testDeprecated() 79 { 80 IComponentSpecification spec = attempt(DeprecatedComponent.class, null); 81 82 assertEquals(true, spec.isDeprecated()); 83 } 84 85 public void testReservedParameters() 86 { 87 IComponentSpecification spec = attempt(ReservedParametersComponent.class, null); 88 89 assertEquals(true, spec.isReservedParameterName("foo")); 90 assertEquals(true, spec.isReservedParameterName("bar")); 91 } 92 } 93 | Popular Tags |