Search in sources :

Example 1 with DialectSetConfiguration

use of org.thymeleaf.DialectSetConfiguration in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation07.

@Test
public void testProcessorComputation07() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildXMLDialect("standard", "TH", "N-CDATA_SECTION-10-some,CD-4-other,N-COMMENT-10-some,C-4-other,N-DOC_TYPE-10-some,DT-4-other,N-PROCESSING_INSTRUCTION-10-some,PI-4-other,N-TEXT-10-some,T-4-other,N-XML_DECLARATION-10-some,XD-4-other");
    final DialectConfiguration dialectConfiguration = new DialectConfiguration(dialect);
    final DialectSetConfiguration dialectSetConfiguration = DialectSetConfiguration.build(Collections.singleton(dialectConfiguration));
    Assert.assertEquals("TH", dialect.getPrefix());
    Assert.assertEquals("[CD-4-other, N-CDATA_SECTION-10-some]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[C-4-other, N-COMMENT-10-some]", dialectSetConfiguration.getCommentProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[DT-4-other, N-DOC_TYPE-10-some]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[PI-4-other, N-PROCESSING_INSTRUCTION-10-some]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[T-4-other, N-TEXT-10-some]", dialectSetConfiguration.getTextProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[XD-4-other, N-XML_DECLARATION-10-some]", dialectSetConfiguration.getXMLDeclarationProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getCommentProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getTextProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getXMLDeclarationProcessors(TemplateMode.HTML).toString());
}
Also used : DialectSetConfiguration(org.thymeleaf.DialectSetConfiguration) DialectConfiguration(org.thymeleaf.DialectConfiguration) IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) Test(org.junit.Test)

Example 2 with DialectSetConfiguration

use of org.thymeleaf.DialectSetConfiguration in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation06.

@Test
public void testProcessorComputation06() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "TH", "N-CDATA_SECTION-10-some,CD-4-other,N-COMMENT-10-some,C-4-other,N-DOC_TYPE-10-some,DT-4-other,N-PROCESSING_INSTRUCTION-10-some,PI-4-other,N-TEXT-10-some,T-4-other,N-XML_DECLARATION-10-some,XD-4-other");
    final DialectConfiguration dialectConfiguration = new DialectConfiguration(dialect);
    final DialectSetConfiguration dialectSetConfiguration = DialectSetConfiguration.build(Collections.singleton(dialectConfiguration));
    Assert.assertEquals("TH", dialect.getPrefix());
    Assert.assertEquals("[CD-4-other, N-CDATA_SECTION-10-some]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[C-4-other, N-COMMENT-10-some]", dialectSetConfiguration.getCommentProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[DT-4-other, N-DOC_TYPE-10-some]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[PI-4-other, N-PROCESSING_INSTRUCTION-10-some]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[T-4-other, N-TEXT-10-some]", dialectSetConfiguration.getTextProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[XD-4-other, N-XML_DECLARATION-10-some]", dialectSetConfiguration.getXMLDeclarationProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getCommentProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getTextProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getXMLDeclarationProcessors(TemplateMode.XML).toString());
}
Also used : DialectSetConfiguration(org.thymeleaf.DialectSetConfiguration) DialectConfiguration(org.thymeleaf.DialectConfiguration) IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) Test(org.junit.Test)

Example 3 with DialectSetConfiguration

use of org.thymeleaf.DialectSetConfiguration in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation03.

@Test
public void testProcessorComputation03() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildDialect("standard", "TH", "E-20-null-src, E-10-null-src,E-20-null-href,E-20-null-text,E-10-null-text,E-10-*div-text,E-15-*div-src,E-1-form-*action,E-20-form-null,E-10-null-*action,E-50-null-null", "E-200-null-src, E-100-null-src,E-200-null-href,E-200-null-text,E-100-null-text,E-100-*div-text,E-150-*div-src,E-10-form-*action,E-200-form-null,E-100-null-*action,E-500-null-null");
    final DialectConfiguration dialectConfiguration = new DialectConfiguration(dialect);
    final DialectSetConfiguration dialectSetConfiguration = DialectSetConfiguration.build(Collections.singleton(dialectConfiguration));
    final AttributeDefinitions attributeDefinitions = dialectSetConfiguration.getAttributeDefinitions();
    final ElementDefinitions elementDefinitions = dialectSetConfiguration.getElementDefinitions();
    Assert.assertEquals("TH", dialect.getPrefix());
    Assert.assertEquals("[E-10-null-{th:src,data-th-src}, E-15-{div}-{th:src,data-th-src}, E-20-null-{th:src,data-th-src}]", attributeDefinitions.forHTMLName("th:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-1-{th:form,th-form}-{action}, E-10-null-{action}]", attributeDefinitions.forHTMLName("action").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-20-{th:form,th-form}-null, E-50-null-null]", elementDefinitions.forHTMLName("th", "form").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forHTMLName("th", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-50-null-null]", elementDefinitions.forHTMLName("p").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forXMLName("th:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-100-null-{TH:src}, E-150-{div}-{TH:src}, E-200-null-{TH:src}]", attributeDefinitions.forXMLName("TH:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-10-{TH:form}-{action}, E-100-null-{action}]", attributeDefinitions.forXMLName("action").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-200-{TH:form}-null, E-500-null-null]", elementDefinitions.forXMLName("TH", "form").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forXMLName("th", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forXMLName("TH", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-500-null-null]", elementDefinitions.forXMLName("p").getAssociatedProcessors().toString());
}
Also used : DialectSetConfiguration(org.thymeleaf.DialectSetConfiguration) AttributeDefinitions(org.thymeleaf.engine.AttributeDefinitions) ElementDefinitions(org.thymeleaf.engine.ElementDefinitions) DialectConfiguration(org.thymeleaf.DialectConfiguration) IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) Test(org.junit.Test)

Example 4 with DialectSetConfiguration

use of org.thymeleaf.DialectSetConfiguration in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation02.

@Test
public void testProcessorComputation02() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "TH", "E-20-null-src, E-10-null-src,E-20-null-href,E-20-null-text,E-10-null-text,E-10-*div-text,E-15-*div-src,E-1-form-*action,E-20-form-null,E-10-null-*action,E-50-null-null");
    final DialectConfiguration dialectConfiguration = new DialectConfiguration(dialect);
    final DialectSetConfiguration dialectSetConfiguration = DialectSetConfiguration.build(Collections.singleton(dialectConfiguration));
    final AttributeDefinitions attributeDefinitions = dialectSetConfiguration.getAttributeDefinitions();
    final ElementDefinitions elementDefinitions = dialectSetConfiguration.getElementDefinitions();
    Assert.assertEquals("TH", dialect.getPrefix());
    Assert.assertEquals("[E-10-null-{th:src,data-th-src}, E-15-{div}-{th:src,data-th-src}, E-20-null-{th:src,data-th-src}]", attributeDefinitions.forHTMLName("th:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-1-{th:form,th-form}-{action}, E-10-null-{action}]", attributeDefinitions.forHTMLName("action").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-20-{th:form,th-form}-null, E-50-null-null]", elementDefinitions.forHTMLName("th", "form").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forHTMLName("th", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[E-50-null-null]", elementDefinitions.forHTMLName("p").getAssociatedProcessors().toString());
}
Also used : DialectSetConfiguration(org.thymeleaf.DialectSetConfiguration) AttributeDefinitions(org.thymeleaf.engine.AttributeDefinitions) ElementDefinitions(org.thymeleaf.engine.ElementDefinitions) DialectConfiguration(org.thymeleaf.DialectConfiguration) IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) Test(org.junit.Test)

Example 5 with DialectSetConfiguration

use of org.thymeleaf.DialectSetConfiguration in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation01.

@Test
public void testProcessorComputation01() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildDialect("standard", "th", "CD-10-cdataone,CD-5-cdatatwo,C-20-comone,E-20-null-src,N-ELEMENT-10-test-null", "CD-5-cdataxml");
    final DialectConfiguration dialectConfiguration = new DialectConfiguration("wo", dialect);
    final DialectSetConfiguration dialectSetConfiguration = DialectSetConfiguration.build(Collections.singleton(dialectConfiguration));
    Assert.assertEquals("[standard,th,[CD-10-cdataone, CD-5-cdatatwo, C-20-comone, E-20-null-{wo:src,data-wo-src}, N-ELEMENT-10-{wo:test,wo-test}-null, CD-5-cdataxml]]", dialect.toString());
    Assert.assertEquals("[CD-5-cdatatwo, CD-10-cdataone]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[CD-5-cdataxml]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.XML).toString());
}
Also used : DialectSetConfiguration(org.thymeleaf.DialectSetConfiguration) DialectConfiguration(org.thymeleaf.DialectConfiguration) IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 DialectConfiguration (org.thymeleaf.DialectConfiguration)8 DialectSetConfiguration (org.thymeleaf.DialectSetConfiguration)8 IProcessorDialect (org.thymeleaf.dialect.IProcessorDialect)8 AttributeDefinitions (org.thymeleaf.engine.AttributeDefinitions)4 ElementDefinitions (org.thymeleaf.engine.ElementDefinitions)4