Search in sources :

Example 76 with PortalResponse

use of com.enonic.xp.portal.PortalResponse in project xp by enonic.

the class LiveEditAttributeInjectionTest method injectHtmlWithBom.

@Test
public void injectHtmlWithBom() throws Exception {
    final String html = readResource("part1SourceBom.html");
    final LiveEditAttributeInjection liveEditAttributeInjection = new LiveEditAttributeInjection();
    final PortalResponse.Builder responseBuilder = PortalResponse.create().body(html);
    final PortalResponse portalResponse = liveEditAttributeInjection.injectLiveEditAttribute(responseBuilder.build(), TextComponentType.INSTANCE);
    final String outputHtml = portalResponse.getBody().toString();
    final String expectedResult = readResource("part1RenderedBom.html");
    assertEquals(expectedResult, outputHtml);
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) Test(org.junit.jupiter.api.Test)

Example 77 with PortalResponse

use of com.enonic.xp.portal.PortalResponse in project xp by enonic.

the class LiveEditAttributeInjectionTest method simpleInjection.

@Test
public void simpleInjection() throws Exception {
    final String html = readResource("part1Source.html");
    final LiveEditAttributeInjection liveEditAttributeInjection = new LiveEditAttributeInjection();
    final PortalResponse.Builder responseBuilder = PortalResponse.create().body(html);
    final PortalResponse portalResponse = liveEditAttributeInjection.injectLiveEditAttribute(responseBuilder.build(), TextComponentType.INSTANCE);
    final String outputHtml = portalResponse.getBody().toString();
    final String expectedResult = readResource("part1Rendered.html");
    assertEquals(expectedResult, outputHtml);
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) Test(org.junit.jupiter.api.Test)

Example 78 with PortalResponse

use of com.enonic.xp.portal.PortalResponse in project xp by enonic.

the class LiveEditAttributeInjectionTest method injectWithAttributes.

@Test
public void injectWithAttributes() throws Exception {
    final String html = readResource("part2Source.html");
    final LiveEditAttributeInjection liveEditAttributeInjection = new LiveEditAttributeInjection();
    final PortalResponse.Builder responseBuilder = PortalResponse.create().body(html);
    final PortalResponse portalResponse = liveEditAttributeInjection.injectLiveEditAttribute(responseBuilder.build(), TextComponentType.INSTANCE);
    final String outputHtml = portalResponse.getBody().toString();
    final String expectedResult = readResource("part2Rendered.html");
    assertEquals(expectedResult, outputHtml);
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) Test(org.junit.jupiter.api.Test)

Example 79 with PortalResponse

use of com.enonic.xp.portal.PortalResponse in project xp by enonic.

the class LiveEditAttributeInjectionTest method injectWithXmlDeclaration.

@Test
public void injectWithXmlDeclaration() throws Exception {
    final String html = readResource("part4Source.html");
    final LiveEditAttributeInjection liveEditAttributeInjection = new LiveEditAttributeInjection();
    final PortalResponse.Builder responseBuilder = PortalResponse.create().body(html);
    final PortalResponse portalResponse = liveEditAttributeInjection.injectLiveEditAttribute(responseBuilder.build(), TextComponentType.INSTANCE);
    final String outputHtml = portalResponse.getBody().toString();
    final String expectedResult = readResource("part4Rendered.html");
    assertEquals(expectedResult, outputHtml);
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) Test(org.junit.jupiter.api.Test)

Example 80 with PortalResponse

use of com.enonic.xp.portal.PortalResponse in project xp by enonic.

the class LiveEditAttributeInjectionTest method injectEmptySingleTag.

@Test
public void injectEmptySingleTag() throws Exception {
    final String html = readResource("part3Source.html");
    final LiveEditAttributeInjection liveEditAttributeInjection = new LiveEditAttributeInjection();
    final PortalResponse.Builder responseBuilder = PortalResponse.create().body(html);
    final PortalResponse portalResponse = liveEditAttributeInjection.injectLiveEditAttribute(responseBuilder.build(), TextComponentType.INSTANCE);
    final String outputHtml = portalResponse.getBody().toString();
    final String expectedResult = readResource("part3Rendered.html");
    assertEquals(expectedResult, outputHtml);
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) Test(org.junit.jupiter.api.Test)

Aggregations

PortalResponse (com.enonic.xp.portal.PortalResponse)104 Test (org.junit.jupiter.api.Test)78 PortalRequest (com.enonic.xp.portal.PortalRequest)21 WebException (com.enonic.xp.web.WebException)14 BaseHandlerTest (com.enonic.xp.web.handler.BaseHandlerTest)14 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)13 PostProcessInstruction (com.enonic.xp.portal.postprocess.PostProcessInstruction)10 WebResponse (com.enonic.xp.web.WebResponse)10 ContentService (com.enonic.xp.content.ContentService)9 ControllerScript (com.enonic.xp.portal.controller.ControllerScript)9 ResourceKey (com.enonic.xp.resource.ResourceKey)9 RenderMode (com.enonic.xp.portal.RenderMode)8 HtmlTag (com.enonic.xp.portal.postprocess.HtmlTag)8 PostProcessInjection (com.enonic.xp.portal.postprocess.PostProcessInjection)8 ByteSource (com.google.common.io.ByteSource)8 InputStream (java.io.InputStream)8 StandardCharsets (java.nio.charset.StandardCharsets)8 Arrays (java.util.Arrays)8 Collections (java.util.Collections)8 List (java.util.List)8