use of org.apache.wicket.mock.MockWebRequest 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;
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithoutFilterPath.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithoutFilterPath() {
// base url without context path and filter path
Url baseUrl = Url.parse("a/b/c/d");
Url encodedFullUrl = Url.parse("http://host:8080/contextPath/a/b;jsessionid=123456");
MockWebRequest request = new MockWebRequest(baseUrl);
request.setContextPath("contextPath");
UrlRenderer renderer = new UrlRenderer(request);
String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
assertEquals("../../b;jsessionid=123456", encodedRelativeUrl);
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method test14.
/**
* WICKET-4920 prevent double slash
*/
@Test
public void test14() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(new Url()));
assertEquals("./;jsessionid=1p87c5424zjuvd57kljcu2bwa?0-1.IBehaviorListener.1-component", r1.renderRelativeUrl(Url.parse("http://localhost:8080/;jsessionid=1p87c5424zjuvd57kljcu2bwa?0-1.IBehaviorListener.1-component")));
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method test13.
/**
* https://issues.apache.org/jira/browse/WICKET-4401
*
* A Url should not ends with '..' because some web containers do not handle it properly. Using
* '../' works better.
*/
@Test
public void test13() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("foo/bar")));
assertEquals("../", r1.renderUrl(Url.parse("")));
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheFilterPath.
@Test
public void renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheFilterPath() {
// base url without context path and filter path
// 'filterPath' here is a normal segment with the same value
Url baseUrl = Url.parse("filterPath/a/b/c/d");
// here 'filterPath' is the actual filter path and should be ignored
Url encodedFullUrl = Url.parse("http://host:8080/filterPath/a/b;jsessionid=123456");
MockWebRequest request = new MockWebRequest(baseUrl);
request.setFilterPath("filterPath");
UrlRenderer renderer = new UrlRenderer(request);
String encodedRelativeUrl = renderer.renderRelativeUrl(encodedFullUrl);
assertEquals("../../../../a/b;jsessionid=123456", encodedRelativeUrl);
}
Aggregations