Search in sources :

Example 16 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect 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)

Example 17 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation04.

@Test
public void testProcessorComputation04() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildDialect("standard", "TH", "N-ELEMENT-20-null-src, N-ELEMENT-10-null-src,N-ELEMENT-20-null-href,N-ELEMENT-20-null-text,N-ELEMENT-10-null-text,N-ELEMENT-10-*div-text,N-ELEMENT-15-*div-src,N-ELEMENT-1-form-*action,N-ELEMENT-20-form-null,N-ELEMENT-10-null-*action,N-ELEMENT-50-null-null", "N-ELEMENT-200-null-src, N-ELEMENT-100-null-src,N-ELEMENT-200-null-href,N-ELEMENT-200-null-text,N-ELEMENT-100-null-text,N-ELEMENT-100-*div-text,N-ELEMENT-150-*div-src,N-ELEMENT-10-form-*action,N-ELEMENT-200-form-null,N-ELEMENT-100-null-*action,N-ELEMENT-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("[N-ELEMENT-10-null-{th:src,data-th-src}, N-ELEMENT-15-{div}-{th:src,data-th-src}, N-ELEMENT-20-null-{th:src,data-th-src}]", attributeDefinitions.forHTMLName("th:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-1-{th:form,th-form}-{action}, N-ELEMENT-10-null-{action}]", attributeDefinitions.forHTMLName("action").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-20-{th:form,th-form}-null, N-ELEMENT-50-null-null]", elementDefinitions.forHTMLName("th", "form").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forHTMLName("th", "utext").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-50-null-null]", elementDefinitions.forHTMLName("p").getAssociatedProcessors().toString());
    Assert.assertEquals("[]", attributeDefinitions.forXMLName("th:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-100-null-{TH:src}, N-ELEMENT-150-{div}-{TH:src}, N-ELEMENT-200-null-{TH:src}]", attributeDefinitions.forXMLName("TH:src").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-10-{TH:form}-{action}, N-ELEMENT-100-null-{action}]", attributeDefinitions.forXMLName("action").getAssociatedProcessors().toString());
    Assert.assertEquals("[N-ELEMENT-200-{TH:form}-null, N-ELEMENT-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("[N-ELEMENT-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 18 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation08.

@Test
public void testProcessorComputation08() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildDialect("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", "N-CDATA_SECTION-100-some,CD-40-other,N-COMMENT-100-some,C-40-other,N-DOC_TYPE-100-some,DT-40-other,N-PROCESSING_INSTRUCTION-100-some,PI-40-other,N-TEXT-100-some,T-40-other,N-XML_DECLARATION-100-some,XD-40-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("[CD-40-other, N-CDATA_SECTION-100-some]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[C-40-other, N-COMMENT-100-some]", dialectSetConfiguration.getCommentProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[DT-40-other, N-DOC_TYPE-100-some]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[PI-40-other, N-PROCESSING_INSTRUCTION-100-some]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[T-40-other, N-TEXT-100-some]", dialectSetConfiguration.getTextProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[XD-40-other, N-XML_DECLARATION-100-some]", 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 19 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class DialectSetConfigurationTest method testProcessorComputation05.

@Test
public void testProcessorComputation05() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildDialect("standard", "TH", "N-ELEMENT-20-null-src, N-CDATA_SECTION-10-some,N-DOC_TYPE-20-other,E-20-null-text,E-10-null-text,N-TEXT-10-whoa!,E-15-*div-src,E-1-form-*action,N-ELEMENT-20-form-null,E-10-null-*action,E-50-null-null,N-CDATA_SECTION-5-someother,T-25-uye,T-10-eo", "N-TEXT-20-whoaX!,T-10-eoX");
    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-15-{div}-{th:src,data-th-src}, N-ELEMENT-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("[N-ELEMENT-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("[N-CDATA_SECTION-5-someother, N-CDATA_SECTION-10-some]", dialectSetConfiguration.getCDATASectionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[N-TEXT-10-whoa!, T-10-eo, T-25-uye]", dialectSetConfiguration.getTextProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[T-10-eoX, N-TEXT-20-whoaX!]", dialectSetConfiguration.getTextProcessors(TemplateMode.XML).toString());
    Assert.assertEquals("[N-DOC_TYPE-20-other]", dialectSetConfiguration.getDocTypeProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getCommentProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", dialectSetConfiguration.getProcessingInstructionProcessors(TemplateMode.HTML).toString());
    Assert.assertEquals("[]", 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.getXMLDeclarationProcessors(TemplateMode.XML).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 20 with IProcessorDialect

use of org.thymeleaf.dialect.IProcessorDialect in project thymeleaf-tests by thymeleaf.

the class ElementProcessorIteratorTest method testProcessorIteration13.

@Test
public void testProcessorIteration13() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-*a-src,N-ELEMENT-2-null-one");
    final TagObtentionTemplateHandler handler = computeHtmlTag("<div class='one'><p th:src='uuuh'><a th:src='hello'>", dialect);
    final ElementProcessorIterator iterator = handler.iter;
    final OpenElementTag tag = handler.tag;
    Assert.assertEquals("N-ELEMENT-5-{a}-{th:src,data-th-src}", iterator.next(tag).toString());
    tag.getAttributes().setAttribute("th:one", "somevalue");
    Assert.assertEquals("N-ELEMENT-2-null-{th:one,data-th-one}", iterator.next(tag).toString());
    tag.getAttributes().removeAttribute("th:src");
    Assert.assertNull(iterator.next(tag));
}
Also used : IProcessorDialect(org.thymeleaf.dialect.IProcessorDialect) IOpenElementTag(org.thymeleaf.model.IOpenElementTag) Test(org.junit.Test)

Aggregations

IProcessorDialect (org.thymeleaf.dialect.IProcessorDialect)25 Test (org.junit.Test)22 IOpenElementTag (org.thymeleaf.model.IOpenElementTag)14 DialectConfiguration (org.thymeleaf.DialectConfiguration)8 DialectSetConfiguration (org.thymeleaf.DialectSetConfiguration)8 AttributeDefinitions (org.thymeleaf.engine.AttributeDefinitions)5 ElementDefinitions (org.thymeleaf.engine.ElementDefinitions)5 Map (java.util.Map)2 IDialect (org.thymeleaf.dialect.IDialect)2 IExecutionAttributeDialect (org.thymeleaf.dialect.IExecutionAttributeDialect)2 IExpressionObjectDialect (org.thymeleaf.dialect.IExpressionObjectDialect)2 IPostProcessorDialect (org.thymeleaf.dialect.IPostProcessorDialect)2 IPreProcessorDialect (org.thymeleaf.dialect.IPreProcessorDialect)2 IExpressionObjectFactory (org.thymeleaf.expression.IExpressionObjectFactory)2 IPostProcessor (org.thymeleaf.postprocessor.IPostProcessor)2 IPreProcessor (org.thymeleaf.preprocessor.IPreProcessor)2 IProcessor (org.thymeleaf.processor.IProcessor)2 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 LinkedHashMap (java.util.LinkedHashMap)1