use of org.apache.wicket.request.IExceptionMapper in project wicket by apache.
the class RequestCycleUrlForTest method before.
@Before
public void before() {
Request request = mock(Request.class);
Url baseUrl = Url.parse("");
when(request.getClientUrl()).thenReturn(baseUrl);
Response response = new StringResponse() {
@Override
public String encodeURL(CharSequence url) {
return url + JSESSIONID;
}
};
IRequestMapper mapper = mock(IRequestMapper.class);
Url bookmarkablePageUrl = Url.parse(BOOKMARKABLE_PAGE_URL);
when(mapper.mapHandler(argThat(new ExactClassMatcher<BookmarkablePageRequestHandler>(BookmarkablePageRequestHandler.class)))).thenReturn(bookmarkablePageUrl);
Url resourceUrl = Url.parse(RESOURCE_URL);
when(mapper.mapHandler(argThat(new ExactClassMatcher<ResourceRequestHandler>(ResourceRequestHandler.class)))).thenReturn(resourceUrl);
Url resourceReferenceUrl = Url.parse(RES_REF_URL);
when(mapper.mapHandler(argThat(new ExactClassMatcher<ResourceReferenceRequestHandler>(ResourceReferenceRequestHandler.class)))).thenReturn(resourceReferenceUrl);
IExceptionMapper exceptionMapper = mock(IExceptionMapper.class);
RequestCycleContext context = new RequestCycleContext(request, response, mapper, exceptionMapper);
requestCycle = new RequestCycle(context);
requestCycle.getUrlRenderer().setBaseUrl(baseUrl);
}
use of org.apache.wicket.request.IExceptionMapper in project wicket by apache.
the class RequestCycleListenerTest method newRequestCycle.
private RequestCycle newRequestCycle(final RuntimeException exception) {
final Response originalResponse = newResponse();
Request request = new MockWebRequest(Url.parse("http://wicket.apache.org"));
handler = new IRequestHandler() {
@Override
public void respond(IRequestCycle requestCycle) {
if (exception != null) {
throw exception;
}
responses++;
}
@Override
public void detach(IRequestCycle requestCycle) {
detaches++;
}
};
IRequestMapper requestMapper = new IRequestMapper() {
@Override
public IRequestHandler mapRequest(Request request) {
return handler;
}
@Override
public Url mapHandler(IRequestHandler requestHandler) {
throw new UnsupportedOperationException();
}
@Override
public int getCompatibilityScore(Request request) {
throw new UnsupportedOperationException();
}
};
IExceptionMapper exceptionMapper = new IExceptionMapper() {
@Override
public IRequestHandler map(Exception e) {
exceptionsMapped++;
return null;
}
};
RequestCycleContext context = new RequestCycleContext(request, originalResponse, requestMapper, exceptionMapper);
RequestCycle cycle = new RequestCycle(context);
if (Application.exists()) {
cycle.getListeners().add(Application.get().getRequestCycleListeners());
}
return cycle;
}
Aggregations