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());
}
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());
}
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());
}
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);
}
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());
}
Aggregations