1 15 package org.apache.tapestry.error; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.tapestry.IPage; 19 import org.apache.tapestry.IRequestCycle; 20 import org.apache.tapestry.StaleSessionException; 21 import org.apache.tapestry.services.ResponseRenderer; 22 23 29 public class TestStaleSessionExceptionPresenter extends BaseErrorTestCase 30 { 31 public void testSuccess() throws Exception 32 { 33 IPage page = newPage(); 34 IRequestCycle cycle = newCycle("StaleSession", page); 35 ResponseRenderer renderer = newRenderer(cycle, null); 36 37 cycle.activate(page); 38 39 replayControls(); 40 41 StaleSessionExceptionPresenterImpl presenter = new StaleSessionExceptionPresenterImpl(); 42 43 presenter.setPageName("StaleSession"); 44 presenter.setResponseRenderer(renderer); 45 46 presenter.presentStaleSessionException(cycle, new StaleSessionException()); 47 48 verifyControls(); 49 } 50 51 public void testFailure() throws Exception 52 { 53 StaleSessionException cause = new StaleSessionException(); 54 Throwable renderCause = new ApplicationRuntimeException("Some failure."); 55 56 IPage page = newPage(); 57 58 IRequestCycle cycle = newCycle("StaleSession", page); 59 ResponseRenderer renderer = newRenderer(cycle, renderCause); 60 RequestExceptionReporter reporter = newReporter(); 61 62 cycle.activate(page); 63 64 reporter.reportRequestException(ErrorMessages.unableToProcessClientRequest(cause), cause); 65 reporter.reportRequestException( 66 ErrorMessages.unableToPresentExceptionPage(renderCause), 67 renderCause); 68 69 replayControls(); 70 71 StaleSessionExceptionPresenterImpl presenter = new StaleSessionExceptionPresenterImpl(); 72 presenter.setPageName("StaleSession"); 73 presenter.setResponseRenderer(renderer); 74 presenter.setRequestExceptionReporter(reporter); 75 76 try 77 { 78 presenter.presentStaleSessionException(cycle, cause); 79 unreachable(); 80 } 81 catch (ApplicationRuntimeException ex) 82 { 83 assertSame(renderCause, ex.getRootCause()); 84 } 85 86 verifyControls(); 87 } 88 } 89 | Popular Tags |