use of com.enonic.xp.web.WebResponse in project xp by enonic.
the class ImageHandlerTest method imageWithFilter.
@Test
void imageWithFilter() throws Exception {
setupContent();
this.request.setEndpointPath("/_/image/123456/scale-100-100/image-name.jpg");
this.request.getParams().put("filter", "sepia()");
this.request.getParams().put("quality", "75");
this.request.getParams().put("background", "0x0");
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertEquals(MediaType.PNG, res.getContentType());
assertTrue(res.getBody() instanceof ByteSource);
}
use of com.enonic.xp.web.WebResponse in project xp by enonic.
the class AttachmentHandlerTest method options.
@Test
void options() throws Exception {
this.request.setEndpointPath("/_/attachment/download/123456/logo.png");
this.request.setMethod(HttpMethod.OPTIONS);
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertEquals("GET,HEAD,OPTIONS", res.getHeaders().get("Allow"));
}
use of com.enonic.xp.web.WebResponse in project xp by enonic.
the class AssetHandlerTest method testCacheHeader_FingerprintDoesntMatch.
@Test
public void testCacheHeader_FingerprintDoesntMatch() throws Exception {
addResource("demo:/assets/css/main.css");
this.request.setEndpointPath("/_/asset/demo:123/css/main.css");
final ResourceKey resourceKey = ResourceKey.from(ApplicationKey.from("demo"), "META-INF/MANIFEST.MF");
when(this.resourceService.getResource(resourceKey)).thenReturn(MockResource.empty(resourceKey, 1));
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertNull(res.getHeaders().get("Cache-Control"));
}
use of com.enonic.xp.web.WebResponse in project xp by enonic.
the class AssetHandlerTest method testNoCacheHeader.
@Test
public void testNoCacheHeader() throws Exception {
addResource("demo:/assets/css/main.css");
this.request.setMode(RenderMode.EDIT);
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertNull(res.getHeaders().get("Cache-Control"));
}
use of com.enonic.xp.web.WebResponse in project xp by enonic.
the class AssetHandlerTest method testRootResourceFound.
@Test
public void testRootResourceFound() throws Exception {
final Resource resource = addResource("demo:/assets/css/main.css");
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertEquals(MediaType.CSS_UTF_8.withoutParameters(), res.getContentType());
assertSame(resource, res.getBody());
}
Aggregations