use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method test9.
/**
*/
@Test
public void test9() {
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("a/b/q/d/e")));
assertEquals("../../../q/c/d/e", r1.renderUrl(Url.parse("a/q/c/d/e")));
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class UrlRendererTest method renderFullUrlAsRelativeToAnAbsoluteBaseUrl.
@Test
public void renderFullUrlAsRelativeToAnAbsoluteBaseUrl() {
Url baseUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b/c/d");
Url encodedFullUrl = Url.parse("http://host:8080/contextPath/filterPath/a/b;jsessionid=123456");
UrlRenderer renderer = new UrlRenderer(new MockWebRequest(baseUrl));
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 removeCommonPrefixesWithJSessionId.
/**
* https://issues.apache.org/jira/browse/WICKET-5202
*/
@Test
public void removeCommonPrefixesWithJSessionId() {
Url baseUrl = new Url(Arrays.asList("", "SomePage;jsessionid=1234"), Arrays.<Url.QueryParameter>asList());
MockWebRequest request = new MockWebRequest(baseUrl);
request.setContextPath("/");
request.setFilterPath("filter");
UrlRenderer renderer = new UrlRenderer(request);
renderer.setBaseUrl(baseUrl);
String rendered = renderer.renderRelativeUrl(Url.parse("/filter;jsessionid=1234"));
assertEquals("../", rendered);
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class WebSessionTest method readsLocaleFromRequestOnConstruction.
/**
* testReadsLocaleFromRequestOnConstruction()
*/
@Test
public void readsLocaleFromRequestOnConstruction() {
final Locale locale = Locale.TRADITIONAL_CHINESE;
MockWebRequest request = new MockWebRequest(Url.parse("/")) {
@Override
public Locale getLocale() {
return locale;
}
};
WebSession session = new WebSession(request);
assertEquals(locale, session.getLocale());
}
use of org.apache.wicket.mock.MockWebRequest in project wicket by apache.
the class SessionDestroyTest method whenSessionIsDestroyed_thenItShouldResetItsState.
/**
* https://issues.apache.org/jira/browse/WICKET-6310
*/
@Test
public void whenSessionIsDestroyed_thenItShouldResetItsState() {
final Locale locale = Locale.ENGLISH;
MockWebRequest request = new MockWebRequest(Url.parse("/")) {
@Override
public Locale getLocale() {
return locale;
}
};
final WebSession session = spy(new WebSession(request));
// initially #invalidateNow() (and destroy()) are not called
verify(session, never()).invalidateNow();
assertThat(session.isSessionInvalidated(), is(false));
// schedule invalidation
session.invalidate();
// the invalidation will happen on #detach(), so #destroy() is still not called
verify(session, never()).invalidateNow();
assertThat(session.isSessionInvalidated(), is(true));
session.detach();
// the session has been detached so #destroy() has been called and 'sessionInvalidated' is reset
verify(session, times(1)).invalidateNow();
assertThat(session.isSessionInvalidated(), is(false));
// no matter how many times #detach() is called #destroy() should not be called
session.detach();
verify(session, times(1)).invalidateNow();
session.detach();
session.detach();
verify(session, times(1)).invalidateNow();
assertThat(session.isSessionInvalidated(), is(false));
}
Aggregations