use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class NonResettingRestartException method transferResponseMetaData.
private void transferResponseMetaData() {
RequestCycle cycle = RequestCycle.get();
Response response = cycle.getResponse();
if (response instanceof IMetaDataBufferingWebResponse) {
WebResponse originalResponse = (WebResponse) cycle.getOriginalResponse();
if (originalResponse != response) {
IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
bufferingWebResponse.writeMetaData(originalResponse);
}
}
}
use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class ByteArrayResourceTest method staticResource.
/**
* Unit test for {@link ByteArrayResource} with static byte array.
*/
@Test
public void staticResource() {
String contentType = "application/octet-stream";
byte[] array = new byte[] { 1, 2, 3 };
ByteArrayResource resource = new ByteArrayResource(contentType, array) {
private static final long serialVersionUID = 1L;
@Override
protected void configureCache(ResourceResponse data, Attributes attributes) {
// no caching is needed
}
};
WebRequest request = mock(WebRequest.class);
WebResponse response = mock(WebResponse.class);
Attributes attributes = new Attributes(request, response);
resource.respond(attributes);
verify(response).write(same(array));
verify(response).setContentLength(eq(3L));
verify(response).setContentType(eq(contentType));
}
use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class ByteArrayResourceTest method dynamicResource.
/**
* Unit test for {@link ByteArrayResource} with dynamically generated byte array.
*/
@Test
public void dynamicResource() {
String contentType = "application/octet-stream";
final byte[] array = new byte[] { 1, 2, 3 };
ByteArrayResource resource = new ByteArrayResource(contentType) {
private static final long serialVersionUID = 1L;
@Override
protected byte[] getData(Attributes attributes) {
return array;
}
@Override
protected void configureCache(ResourceResponse data, Attributes attributes) {
// no caching is needed
}
};
WebRequest request = mock(WebRequest.class);
WebResponse response = mock(WebResponse.class);
Attributes attributes = new Attributes(request, response);
resource.respond(attributes);
verify(response).write(same(array));
verify(response).setContentLength(eq(3L));
verify(response).setContentType(eq(contentType));
}
use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class SetCookiePage method onInitialize.
protected void onInitialize() {
super.onInitialize();
WebResponse response = (WebResponse) getResponse();
response.addCookie(cookie);
if (redirectToPageClass != null) {
setResponsePage(redirectToPageClass);
}
}
use of org.apache.wicket.request.http.WebResponse in project the-app by devops-dojo.
the class AbstractPlainTextPage method renderPage.
@Override
public void renderPage() {
WebResponse response = newStringResponse();
getRequestCycle().setResponse(response);
}
Aggregations