Search in sources :

Example 6 with IProcessorDialect

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

the class ElementProcessorIteratorTest method testProcessorIteration05.

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

Example 7 with IProcessorDialect

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

the class ElementProcessorIteratorTest method testProcessorIteration06.

@Test
public void testProcessorIteration06() {
    final IProcessorDialect dialect = ProcessorAggregationTestDialect.buildHTMLDialect("standard", "th", "N-ELEMENT-10-null-src,N-ELEMENT-5-null-src,N-ELEMENT-2-null-one");
    final TagObtentionTemplateHandler handler = computeHtmlTag("<a th:src='hello'>", dialect);
    final ElementProcessorIterator iterator = handler.iter;
    final OpenElementTag tag = handler.tag;
    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)

Example 8 with IProcessorDialect

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

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

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

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