1 15 package org.apache.tapestry.binding; 16 17 import org.apache.hivemind.test.HiveMindTestCase; 18 import org.apache.tapestry.spec.IComponentSpecification; 19 import org.apache.tapestry.spec.IParameterSpecification; 20 import org.easymock.MockControl; 21 22 28 public class TestBindingUtils extends HiveMindTestCase 29 { 30 private IComponentSpecification newSpec(String name, IParameterSpecification pspec) 31 { 32 MockControl control = newControl(IComponentSpecification.class); 33 IComponentSpecification spec = (IComponentSpecification) control.getMock(); 34 35 spec.getParameter(name); 36 control.setReturnValue(pspec); 37 38 return spec; 39 } 40 41 private IParameterSpecification newParameterSpec(String defaultBindingType) 42 { 43 MockControl control = newControl(IParameterSpecification.class); 44 IParameterSpecification pspec = (IParameterSpecification) control.getMock(); 45 46 pspec.getDefaultBindingType(); 47 control.setReturnValue(defaultBindingType); 48 49 return pspec; 50 } 51 52 public void testInformalParameter() 53 { 54 IComponentSpecification spec = newSpec("informal", null); 55 56 replayControls(); 57 58 assertEquals("fred", BindingUtils.getDefaultBindingType(spec, "informal", "fred")); 59 60 verifyControls(); 61 } 62 63 public void testFormalParameterWithDefault() 64 { 65 IParameterSpecification pspec = newParameterSpec("barney"); 66 IComponentSpecification spec = newSpec("formal", pspec); 67 68 replayControls(); 69 70 assertEquals("barney", BindingUtils.getDefaultBindingType(spec, "formal", "fred")); 71 72 verifyControls(); 73 } 74 75 public void testFormalParameterWithoutDefault() 76 { 77 IParameterSpecification pspec = newParameterSpec(null); 78 IComponentSpecification spec = newSpec("formal", pspec); 79 80 replayControls(); 81 82 assertEquals("fred", BindingUtils.getDefaultBindingType(spec, "formal", "fred")); 83 84 verifyControls(); 85 } 86 } | Popular Tags |