use of org.apache.wicket.request.handler.resource.ResourceRequestHandler in project wicket by apache.
the class RequestCycleUrlForTest method urlForStaticResource.
/**
* IStaticCacheableResource should not have the jsessionid encoded in the url
*
* @throws Exception
*/
@Test
public void urlForStaticResource() throws Exception {
IStaticCacheableResource resource = mock(IStaticCacheableResource.class);
ResourceRequestHandler handler = new ResourceRequestHandler(resource, new PageParameters());
CharSequence url = requestCycle.urlFor(handler);
assertEquals("./" + RESOURCE_URL, url);
}
use of org.apache.wicket.request.handler.resource.ResourceRequestHandler in project wicket by apache.
the class RequestCycle method renderUrl.
private String renderUrl(Url url, IRequestHandler handler) {
if (url != null) {
boolean shouldEncodeStaticResource = Application.exists() && Application.get().getResourceSettings().isEncodeJSessionId();
String renderedUrl = getUrlRenderer().renderUrl(url);
if (handler instanceof ResourceReferenceRequestHandler) {
ResourceReferenceRequestHandler rrrh = (ResourceReferenceRequestHandler) handler;
IResource resource = rrrh.getResource();
if (resource != null && !(resource instanceof IStaticCacheableResource) || shouldEncodeStaticResource) {
renderedUrl = getOriginalResponse().encodeURL(renderedUrl);
}
} else if (handler instanceof ResourceRequestHandler) {
ResourceRequestHandler rrh = (ResourceRequestHandler) handler;
IResource resource = rrh.getResource();
if (resource != null && !(resource instanceof IStaticCacheableResource) || shouldEncodeStaticResource) {
renderedUrl = getOriginalResponse().encodeURL(renderedUrl);
}
} else {
renderedUrl = getOriginalResponse().encodeURL(renderedUrl);
}
return renderedUrl;
} else {
return null;
}
}
use of org.apache.wicket.request.handler.resource.ResourceRequestHandler in project wicket by apache.
the class RequestCycleUrlForTest method urlForDynamicResource.
/**
* Non-IStaticCacheableResource should have the jsessionid encoded in the url
*
* @throws Exception
*/
@Test
public void urlForDynamicResource() throws Exception {
ByteArrayResource resource = new ByteArrayResource(null, new byte[] { 1, 2 }, "test.bin");
ResourceRequestHandler handler = new ResourceRequestHandler(resource, new PageParameters());
CharSequence url = requestCycle.urlFor(handler);
assertEquals("./" + RESOURCE_URL + JSESSIONID, url);
}
Aggregations