1 15 package org.apache.tapestry.form; 16 17 import org.apache.tapestry.IActionListener; 18 import org.apache.tapestry.IBinding; 19 import org.apache.tapestry.IComponent; 20 import org.apache.tapestry.IForm; 21 import org.apache.tapestry.IMarkupWriter; 22 import org.apache.tapestry.IRequestCycle; 23 import org.apache.tapestry.TapestryUtils; 24 import org.apache.tapestry.components.BaseComponentTestCase; 25 import org.apache.tapestry.valid.IValidationDelegate; 26 import org.easymock.MockControl; 27 28 34 public abstract class BaseFormComponentTest extends BaseComponentTestCase 35 { 36 37 protected IValidationDelegate newDelegate() 38 { 39 return (IValidationDelegate) newMock(IValidationDelegate.class); 40 } 41 42 protected void trainIsInError(MockControl control, IValidationDelegate delegate, 43 boolean isInError) 44 { 45 delegate.isInError(); 46 control.setReturnValue(isInError); 47 } 48 49 protected IForm newForm() 50 { 51 return (IForm) newMock(IForm.class); 52 } 53 54 protected void trainGetForm(MockControl control, IRequestCycle cycle, IForm form) 55 { 56 cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE); 57 control.setReturnValue(form); 58 } 59 60 protected void trainGetDelegate(MockControl control, IForm form, IValidationDelegate delegate) 61 { 62 form.getDelegate(); 63 control.setReturnValue(delegate); 64 } 65 66 protected void trainGetParameter(MockControl control, IRequestCycle cycle, 67 String parameterName, String parameterValue) 68 { 69 cycle.getParameter(parameterName); 70 control.setReturnValue(parameterValue); 71 } 72 73 protected void trainWasPrerendered(MockControl control, IForm form, IMarkupWriter writer, 74 IComponent component, boolean wasPrerendered) 75 { 76 form.wasPrerendered(writer, component); 77 control.setReturnValue(wasPrerendered); 78 } 79 80 protected void trainIsRewinding(MockControl control, IForm form, boolean isRewinding) 81 { 82 form.isRewinding(); 83 control.setReturnValue(isRewinding); 84 } 85 86 protected void trainGetElementId(MockControl control, IForm form, IFormComponent component, 87 String name) 88 { 89 form.getElementId(component); 90 component.setName(name); 91 control.setReturnValue(name); 92 } 93 94 protected IBinding newBinding() 95 { 96 return (IBinding) newMock(IBinding.class); 97 } 98 99 protected IActionListener newListener() 100 { 101 return (IActionListener) newMock(IActionListener.class); 102 } 103 } 104 | Popular Tags |