use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class ComponentHandlerTest method testOptions.
@Test
public void testOptions() throws Exception {
setupSite();
setupContent();
setupTemplates();
final PortalResponse portalResponse = PortalResponse.create().status(HttpStatus.METHOD_NOT_ALLOWED).build();
setRendererResult(portalResponse);
Mockito.when(this.postProcessor.processResponseInstructions(Mockito.any(), Mockito.any())).thenReturn(portalResponse);
this.request.setMethod(HttpMethod.OPTIONS);
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("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 IdProviderControllerServiceImplTest method executeMissingIdProvider.
@Test
public void executeMissingIdProvider() throws IOException {
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().portalRequest(new PortalRequest()).idProviderKey(IdProviderKey.from("missingidprovider")).functionName("missingfunction").build();
final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
assertNull(portalResponse);
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class IdProviderControllerServiceImplTest method executeMissingFunction.
@Test
public void executeMissingFunction() throws IOException {
final IdProviderControllerExecutionParams executionParams = IdProviderControllerExecutionParams.create().portalRequest(new PortalRequest()).idProviderKey(IdProviderKey.from("myemptyidprovider")).functionName("missingfunction").build();
final PortalResponse portalResponse = idProviderControllerService.execute(executionParams);
assertNull(portalResponse);
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class PostProcessorImplTest method testPostProcessingInjections.
private void testPostProcessingInjections(final HttpMethod httpMethod) throws Exception {
final String html = readResource("postProcessSource2.html");
final PostProcessorImpl postProcessor = new PostProcessorImpl();
postProcessor.addInjection(new TestPostProcessInjection());
final PortalResponse.Builder portalResponseBuilder = PortalResponse.create().contentType(MediaType.HTML_UTF_8).body(html);
final PortalRequest portalRequest = new PortalRequest();
portalRequest.setMethod(httpMethod);
final PortalResponse portalResponse = postProcessor.processResponse(portalRequest, portalResponseBuilder.build());
final String outputHtml = portalResponse.getBody().toString();
final String expectedResult = readResource("postProcessResult2.html");
assertEqualsTrimmed(expectedResult, outputHtml);
}
use of com.enonic.xp.portal.PortalResponse in project xp by enonic.
the class PostProcessorImplTest method processResponse_skip_non_html.
@Test
public void processResponse_skip_non_html() throws Exception {
final PostProcessorImpl postProcessor = new PostProcessorImpl();
final PortalResponse portalResponse = PortalResponse.create().contentType(MediaType.JAVASCRIPT_UTF_8).body("").build();
final PortalRequest portalRequest = new PortalRequest();
portalRequest.setMethod(HttpMethod.GET);
final PortalResponse result = postProcessor.processResponse(portalRequest, portalResponse);
assertSame(portalResponse, result);
}
Aggregations