use of com.enonic.xp.web.WebResponse in project xp by enonic.
the class ServiceHandlerTest method executeScript_validSite.
@Test
public void executeScript_validSite() throws Exception {
setupContentAndSite();
this.request.setEndpointPath("/_/service/demo/test");
final WebResponse response = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertEquals(HttpStatus.OK, response.getStatus());
Mockito.verify(this.controllerScript).execute(this.request);
assertNotNull(this.request.getApplicationKey());
assertNotNull(this.request.getSite());
assertNotNull(this.request.getContent());
assertEquals("/site/draft/site/somepath/content/_/service/demo/test", this.request.getContextPath());
}
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 ServiceHandlerTest method executeScript_validApplication.
@Test
public void executeScript_validApplication() throws Exception {
this.request.setRawPath("/webapp/demo/_/service/demo/test");
this.request.setEndpointPath("/_/service/demo/test");
final WebResponse response = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertEquals(HttpStatus.OK, response.getStatus());
Mockito.verify(this.controllerScript).execute(this.request);
assertNotNull(this.request.getApplicationKey());
}
use of com.enonic.xp.web.WebResponse in project xp by enonic.
the class IdentityHandlerTest method testHandle.
@Test
public void testHandle() throws Exception {
final WebResponse portalResponse = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertEquals(HttpStatus.OK, portalResponse.getStatus());
assertEquals(HttpStatus.OK, portalResponse.getStatus());
assertEquals("/site/draft/_/idprovider/myidprovider", this.request.getContextPath());
}
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());
}
Aggregations