WebRequestCycle cycle = tester.createRequestCycle();
cycle.setResponse(new StringResponse());
try
{
// Decompose processRequestCycle() as error pages are not rendered in WicketTester, the exception is thrown instead
cycle.request(new BookmarkablePageRequestTarget(BrokenPage.class));
Method method = MockWebApplication.class.getDeclaredMethod("generateLastRenderedPage", new Class[]{WebRequestCycle.class});
method.setAccessible(true);
Page page = (Page)method.invoke(tester, new Object[]{cycle});
assertTrue("Page is not an ExceptionErrorPage", page instanceof ExceptionErrorPage);
WebRequestCycle cycle2 = tester.createRequestCycle();