Search in sources :

Example 6 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class XmlSiteParserTest method testSiteXmlDeserializationWithMappingFilters.

@Test
public void testSiteXmlDeserializationWithMappingFilters() {
    final String xml = loadTestXml("serialized-site-with-mapping-filters.xml");
    final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
    ApplicationKey applicationKey = ApplicationKey.from("myapplication");
    this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
    SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
    assertEquals(2, siteDescriptor.getMappingDescriptors().getSize());
    final ControllerMappingDescriptor mapping1 = siteDescriptor.getMappingDescriptors().get(0);
    final ControllerMappingDescriptor mapping2 = siteDescriptor.getMappingDescriptors().get(1);
    assertEquals("myapplication:/filter1.js", mapping1.getFilter().toString());
    assertEquals("_path:'/*/fisk'", mapping1.getContentConstraint().toString());
    assertEquals("/.*", mapping1.getPattern().toString());
    assertEquals(50, mapping1.getOrder());
    assertEquals("myapplication:/filter2.js", mapping2.getFilter().toString());
    assertEquals("type:'portal:fragment'", mapping2.getContentConstraint().toString());
    assertEquals("/.*", mapping2.getPattern().toString());
    assertEquals(5, mapping2.getOrder());
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) ControllerMappingDescriptor(com.enonic.xp.site.mapping.ControllerMappingDescriptor) Test(org.junit.jupiter.api.Test)

Example 7 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class XmlSiteParserTest method testSiteXmlWithUtf8BomEncoding.

@Test
public void testSiteXmlWithUtf8BomEncoding() {
    final String xml = loadTestFile("utf8bom.xml", StandardCharsets.UTF_8);
    final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
    ApplicationKey applicationKey = ApplicationKey.from("myapplication");
    this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
    SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
    assertEquals(1, siteDescriptor.getForm().getFormItems().size());
    assertEquals(2, siteDescriptor.getXDataMappings().getSize());
    assertEquals(2, siteDescriptor.getResponseProcessors().getSize());
    assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) Test(org.junit.jupiter.api.Test)

Example 8 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class XmlSiteParserTest method testEmptySiteXmlDeserialization.

@Test
public void testEmptySiteXmlDeserialization() {
    final String xml = loadTestXml("empty-site.xml");
    final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
    ApplicationKey applicationKey = ApplicationKey.from("myapplication");
    this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
    SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
    assertEquals(0, siteDescriptor.getForm().getFormItems().size());
    assertEquals(0, siteDescriptor.getXDataMappings().getSize());
    assertEquals(0, siteDescriptor.getResponseProcessors().getSize());
    assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) Test(org.junit.jupiter.api.Test)

Example 9 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class XmlStyleDescriptorParserTest method setup.

@BeforeEach
public void setup() {
    this.parser = new XmlStyleDescriptorParser();
    final ApplicationKey app = ApplicationKey.from("myapplication");
    this.parser.currentApplication(app);
    this.builder = StyleDescriptor.create();
    this.builder.application(app);
    this.parser.styleDescriptorBuilder(this.builder);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class XmlSiteParserTest method testSiteXmlWithUtf16BeBomEncoding.

@Test
public void testSiteXmlWithUtf16BeBomEncoding() {
    final String xml = loadTestFile("utf16bebom.xml", StandardCharsets.UTF_16BE);
    final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
    ApplicationKey applicationKey = ApplicationKey.from("myapplication");
    this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
    SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
    assertEquals(1, siteDescriptor.getForm().getFormItems().size());
    assertEquals(2, siteDescriptor.getXDataMappings().getSize());
    assertEquals(2, siteDescriptor.getResponseProcessors().getSize());
    assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
Also used : SiteDescriptor(com.enonic.xp.site.SiteDescriptor) ApplicationKey(com.enonic.xp.app.ApplicationKey) Test(org.junit.jupiter.api.Test)

Aggregations

ApplicationKey (com.enonic.xp.app.ApplicationKey)78 Test (org.junit.jupiter.api.Test)40 Application (com.enonic.xp.app.Application)16 SiteDescriptor (com.enonic.xp.site.SiteDescriptor)12 Bundle (org.osgi.framework.Bundle)10 ResourceKey (com.enonic.xp.resource.ResourceKey)6 PropertyTree (com.enonic.xp.data.PropertyTree)5 ExtraData (com.enonic.xp.content.ExtraData)4 Site (com.enonic.xp.site.Site)4 Node (com.enonic.xp.node.Node)3 DescriptorKey (com.enonic.xp.page.DescriptorKey)3 PortalRequest (com.enonic.xp.portal.PortalRequest)3 PortalResponse (com.enonic.xp.portal.PortalResponse)3 XDataName (com.enonic.xp.schema.xdata.XDataName)3 ByteSource (com.google.common.io.ByteSource)3 ApplicationInvalidator (com.enonic.xp.app.ApplicationInvalidator)2 ExtraDatas (com.enonic.xp.content.ExtraDatas)2 PropertySet (com.enonic.xp.data.PropertySet)2 ControllerScript (com.enonic.xp.portal.controller.ControllerScript)2 RenderException (com.enonic.xp.portal.impl.rendering.RenderException)2