1 15 package org.apache.tapestry.form; 16 17 import org.apache.hivemind.util.ClasspathResource; 18 import org.apache.tapestry.IEngine; 19 import org.apache.tapestry.IForm; 20 import org.apache.tapestry.IPage; 21 import org.apache.tapestry.IRequestCycle; 22 import org.apache.tapestry.PageRenderSupport; 23 import org.apache.tapestry.junit.TapestryTestCase; 24 import org.easymock.MockControl; 25 26 32 public abstract class FormComponentContributorTestCase extends TapestryTestCase 33 { 34 41 protected MockControl _componentControl = MockControl.createControl(IFormComponent.class); 42 protected IFormComponent _component = (IFormComponent) _componentControl.getMock(); 43 44 protected MockControl _pageControl = MockControl.createControl(IPage.class); 45 protected IPage _page = (IPage) _pageControl.getMock(); 46 47 protected MockControl _cycleControl = MockControl.createControl(IRequestCycle.class); 48 protected IRequestCycle _cycle = (IRequestCycle) _cycleControl.getMock(); 49 50 protected MockControl _formControl = MockControl.createControl(IForm.class); 51 protected IForm _form = (IForm) _formControl.getMock(); 52 53 protected MockControl _engineControl = MockControl.createControl(IEngine.class); 54 protected IEngine _engine = (IEngine) _engineControl.getMock(); 55 56 protected MockControl _pageRenderSupportControl = MockControl.createControl(PageRenderSupport.class); 57 protected PageRenderSupport _pageRenderSupport = (PageRenderSupport) _pageRenderSupportControl.getMock(); 58 59 62 protected void tearDown() throws Exception 63 { 64 _componentControl.reset(); 65 _pageControl.reset(); 66 _cycleControl.reset(); 67 _formControl.reset(); 68 _engineControl.reset(); 69 _pageRenderSupportControl.reset(); 70 71 super.tearDown(); 72 } 73 74 protected void replay() 75 { 76 _componentControl.replay(); 77 _pageControl.replay(); 78 _cycleControl.replay(); 79 _formControl.replay(); 80 _engineControl.replay(); 81 _pageRenderSupportControl.replay(); 82 } 83 84 protected void verify() 85 { 86 _componentControl.verify(); 87 _pageControl.verify(); 88 _cycleControl.verify(); 89 _formControl.verify(); 90 _engineControl.verify(); 91 _pageRenderSupportControl.verify(); 92 } 93 94 protected void addScript(String script) 95 { 96 _cycle.getEngine(); 97 _cycleControl.setReturnValue(_engine); 98 99 _engine.getClassResolver(); 100 _engineControl.setReturnValue(null); 101 102 _cycle.getAttribute("org.apache.tapestry.PageRenderSupport"); 103 _cycleControl.setReturnValue(_pageRenderSupport); 104 105 _pageRenderSupport.addExternalScript(new ClasspathResource(null, script)); 106 _pageRenderSupportControl.setVoidCallable(); 107 } 108 } 109 | Popular Tags |