use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class PageHandlerTest method getContentFound.
@Test
public void getContentFound() throws Exception {
setupSite();
setupContent();
setupTemplates();
final PortalResponse portalResponse = PortalResponse.create().body("component rendered").header("some-header", "some-value").status(HttpStatus.OK).build();
setRendererResult(portalResponse);
this.request.setContentPath(ContentPath.from("/site/somepath/content"));
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertEquals(MediaType.PLAIN_TEXT_UTF_8, res.getContentType());
assertEquals("some-value", res.getHeaders().get("some-header"));
assertEquals("component rendered", res.getBody());
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class PageHandlerTest method renderCustomizedTemplate.
@Test
public void renderCustomizedTemplate() throws Exception {
setupCustomizedTemplateContentAndSite();
setupController();
final PortalResponse portalResponse = PortalResponse.create().body("content rendered").header("some-header", "some-value").status(HttpStatus.OK).build();
setRendererResult(portalResponse);
this.request.setContentPath(ContentPath.from("/id"));
this.request.setMode(RenderMode.EDIT);
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertEquals(MediaType.PLAIN_TEXT_UTF_8, res.getContentType());
assertEquals("some-value", res.getHeaders().get("some-header"));
assertEquals("content rendered", res.getBody());
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class PageHandlerTest method testOptions.
@Test
public void testOptions() throws Exception {
setupSite();
setupContent();
setupTemplates();
final PortalResponse portalResponse = PortalResponse.create().status(HttpStatus.METHOD_NOT_ALLOWED).build();
setRendererResult(portalResponse);
this.request.setContentPath(ContentPath.from("/site/somepath/content"));
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,POST,HEAD,OPTIONS,PUT,DELETE,TRACE", res.getHeaders().get("Allow"));
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class PageHandlerTest method renderForNoPageDescriptor.
@Test
public void renderForNoPageDescriptor() throws Exception {
setupSite();
setupContent();
setupTemplates();
final PortalResponse portalResponse = PortalResponse.create().body("content rendered").header("some-header", "some-value").status(HttpStatus.OK).build();
setRendererResult(portalResponse);
this.request.setContentPath(ContentPath.from("/site/somepath/content"));
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.OK, res.getStatus());
assertEquals(MediaType.PLAIN_TEXT_UTF_8, res.getContentType());
assertEquals("some-value", res.getHeaders().get("some-header"));
assertEquals("content rendered", res.getBody());
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class AttachmentHandlerTest method cacheHeader.
@Test
void cacheHeader() throws Exception {
this.request.setEndpointPath("/_/attachment/inline/123456:98765/logo.png");
final PortalResponse res = (PortalResponse) this.handler.handle(this.request, PortalResponse.create().build(), null);
assertEquals("public, max-age=31536000, immutable", res.getHeaders().get("Cache-Control"));
}
Aggregations