use of com.enonic.xp.web.WebResponse in project xp by enonic.
the class ImageHandlerTest method imageFound.
@Test
void imageFound() throws Exception {
setupContent();
this.request.setEndpointPath("/_/image/123456/scale-100-100/image-name.jpg");
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 ComponentHandlerTest method testComponentFragment.
@Test
public void testComponentFragment() throws Exception {
setupSite();
setupContentFragment();
setupTemplates();
final PortalResponse portalResponse = PortalResponse.create().body("component rendered").header("some-header", "some-value").status(HttpStatus.OK).build();
Mockito.when(this.postProcessor.processResponseInstructions(Mockito.any(), Mockito.any())).thenReturn(portalResponse);
setRendererResult(portalResponse);
this.request.setEndpointPath("/_/component/main-region/0");
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.web.WebResponse 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.web.WebResponse 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.web.WebResponse in project xp by enonic.
the class ErrorHandlerTest method testOptions.
@Test
public void testOptions() throws Exception {
this.request.setEndpointPath("/_/error/401");
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"));
}
Aggregations