1 15 package org.apache.tapestry.valid; 16 17 import java.util.Locale ; 18 19 import org.apache.tapestry.IPage; 20 import org.apache.tapestry.form.IFormComponent; 21 import org.apache.tapestry.junit.TapestryTestCase; 22 import org.easymock.MockControl; 23 24 30 public abstract class BaseValidatorTestCase extends TapestryTestCase 31 { 32 33 protected IFormComponent newField() 34 { 35 return (IFormComponent) newMock(IFormComponent.class); 36 } 37 38 protected IFormComponent newField(String displayName) 39 { 40 return newField(displayName, 1); 41 } 42 43 protected IFormComponent newField(String displayName, int count) 44 { 45 return newField(displayName, Locale.ENGLISH, count); 46 } 47 48 protected IFormComponent newField(String displayName, Locale locale) 49 { 50 return newField(displayName, locale, 1); 51 } 52 53 protected IFormComponent newField(String displayName, Locale locale, int count) 54 { 55 IPage page = newPage(locale, count); 56 57 MockControl control = newControl(IFormComponent.class); 58 IFormComponent component = (IFormComponent) control.getMock(); 59 60 for (int i = 0; i < count; i++) 61 { 62 component.getPage(); 63 control.setReturnValue(page); 64 65 component.getDisplayName(); 66 control.setReturnValue(displayName); 67 } 68 69 return component; 70 } 71 72 protected IPage newPage(Locale locale) 73 { 74 return newPage(locale, 1); 75 } 76 77 protected IPage newPage(Locale locale, int count) 78 { 79 MockControl pagec = newControl(IPage.class); 80 IPage page = (IPage) pagec.getMock(); 81 82 page.getLocale(); 83 pagec.setReturnValue(locale, count); 84 85 return page; 86 } 87 88 } | Popular Tags |