use of org.apache.wicket.request.resource.IResource.Attributes in project wicket by apache.
the class ResourceStreamRequestHandler method respond.
/**
* Responds by sending the contents of the resource stream.
*
* @see org.apache.wicket.request.IRequestHandler#respond(org.apache.wicket.request.IRequestCycle)
*/
@Override
public void respond(IRequestCycle requestCycle) {
Attributes attributes = new Attributes(requestCycle.getRequest(), requestCycle.getResponse());
ResourceStreamResource resource = new ResourceStreamResource(resourceStream);
configure(resource);
resource.respond(attributes);
}
use of org.apache.wicket.request.resource.IResource.Attributes in project wicket by apache.
the class LocalizedImageResource method onResourceRequested.
/**
* @param parameters
* page parameters
*/
public final void onResourceRequested(PageParameters parameters) {
bind();
RequestCycle requestCycle = RequestCycle.get();
Attributes attributes = new Attributes(requestCycle.getRequest(), requestCycle.getResponse(), parameters);
resource.respond(attributes);
}
use of org.apache.wicket.request.resource.IResource.Attributes in project wicket by apache.
the class ResourceLink method onRequest.
@Override
public final void onRequest() {
Attributes a = new Attributes(RequestCycle.get().getRequest(), RequestCycle.get().getResponse(), null);
resource.respond(a);
super.onRequest();
}
use of org.apache.wicket.request.resource.IResource.Attributes 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.resource.IResource.Attributes 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));
}
Aggregations