use of org.apache.wicket.protocol.http.BufferedWebResponse in project wicket by apache.
the class WebPageRendererTest method testRedirectToBufferIsFallback.
/**
* Tests that when all the conditions fail the redirect_to_buffer should be used as a fallback
*/
@Test
public void testRedirectToBufferIsFallback() {
final AtomicBoolean stored = new AtomicBoolean(false);
PageRenderer renderer = new TestPageRenderer(handler) {
@Override
protected boolean isRedirectToBuffer() {
return false;
}
@Override
protected boolean isOnePassRender() {
return false;
}
@Override
protected boolean isRedirectToRender() {
return false;
}
@Override
protected boolean isSessionTemporary() {
return false;
}
@Override
protected void storeBufferedResponse(Url url, BufferedWebResponse response) {
stored.set(true);
}
};
when(page.isPageStateless()).thenReturn(false);
when(provider.isNewPageInstance()).thenReturn(false);
// needed for earlier checks
when(urlRenderer.getBaseUrl()).thenReturn(Url.parse("url1"));
when(requestCycle.mapUrlFor(eq(handler))).thenReturn(Url.parse("url2"));
renderer.respond(requestCycle);
verify(response, never()).write(any(byte[].class));
verify(response).sendRedirect(isNull());
Assert.assertTrue(stored.get());
}
use of org.apache.wicket.protocol.http.BufferedWebResponse in project wicket by apache.
the class WebPageRendererTest method testRedirectToBufferStatefulPage.
/**
* Tests that when the page is stateful and the urls are different then there should be a
* redirect
*/
@Test
public void testRedirectToBufferStatefulPage() {
final AtomicBoolean stored = new AtomicBoolean(false);
PageRenderer renderer = new TestPageRenderer(handler) {
@Override
protected boolean isRedirectToBuffer() {
return true;
}
@Override
protected void storeBufferedResponse(Url url, BufferedWebResponse response) {
stored.set(true);
}
};
// needed for earlier checks
when(urlRenderer.getBaseUrl()).thenReturn(Url.parse("a"));
when(requestCycle.mapUrlFor(eq(handler))).thenReturn(Url.parse("b"));
renderer.respond(requestCycle);
verify(response, never()).write(any(byte[].class));
verify(response).sendRedirect(isNull());
Assert.assertTrue(stored.get());
}
Aggregations