1 15 package org.apache.tapestry.error; 16 17 import org.apache.hivemind.test.HiveMindTestCase; 18 import org.apache.tapestry.IPage; 19 import org.apache.tapestry.IRequestCycle; 20 import org.apache.tapestry.error.TestExceptionPresenter.ExceptionFixture; 21 import org.apache.tapestry.services.ResponseRenderer; 22 import org.apache.tapestry.test.Creator; 23 import org.easymock.MockControl; 24 25 31 public abstract class BaseErrorTestCase extends HiveMindTestCase 32 { 33 34 protected IPage newPage() 35 { 36 Creator c = new Creator(); 37 38 return (IPage) c.newInstance(ExceptionFixture.class); 39 } 40 41 protected IRequestCycle newCycle(String pageName, IPage page) 42 { 43 MockControl control = newControl(IRequestCycle.class); 44 IRequestCycle cycle = (IRequestCycle) control.getMock(); 45 46 cycle.getPage(pageName); 47 control.setReturnValue(page); 48 49 return cycle; 50 } 51 52 protected ResponseRenderer newRenderer(IRequestCycle cycle, Throwable throwable) throws Exception 53 { 54 MockControl control = newControl(ResponseRenderer.class); 55 ResponseRenderer renderer = (ResponseRenderer) control.getMock(); 56 57 renderer.renderResponse(cycle); 58 59 if (throwable != null) 60 control.setThrowable(throwable); 61 62 return renderer; 63 } 64 65 protected RequestExceptionReporter newReporter() 66 { 67 return (RequestExceptionReporter) newMock(RequestExceptionReporter.class); 68 } 69 70 } 71 | Popular Tags |