Search in sources :

Example 1 with Dialect01

use of org.thymeleaf.dialect.dialectwrapping.Dialect01 in project thymeleaf-tests by thymeleaf.

the class DialectProcessWrappingTest method testDialectWrapping.

@Test
public void testDialectWrapping() throws Exception {
    final Dialect01 dialect01 = new Dialect01();
    final TemplateEngine templateEngine = new TemplateEngine();
    templateEngine.setDialect(dialect01);
    final IEngineConfiguration config = templateEngine.getConfiguration();
    final List<IElementProcessor> elementProcessors = new ArrayList<IElementProcessor>(config.getElementProcessors(TemplateMode.HTML));
    final List<ICDATASectionProcessor> cdataSectionProcessors = new ArrayList<ICDATASectionProcessor>(config.getCDATASectionProcessors(TemplateMode.HTML));
    final List<ICommentProcessor> commentProcessors = new ArrayList<ICommentProcessor>(config.getCommentProcessors(TemplateMode.HTML));
    final List<IDocTypeProcessor> docTypeProcessors = new ArrayList<IDocTypeProcessor>(config.getDocTypeProcessors(TemplateMode.HTML));
    final List<IProcessingInstructionProcessor> processingInstructionProcessors = new ArrayList<IProcessingInstructionProcessor>(config.getProcessingInstructionProcessors(TemplateMode.HTML));
    final List<ITemplateBoundariesProcessor> templateBoundariesProcessors = new ArrayList<ITemplateBoundariesProcessor>(config.getTemplateBoundariesProcessors(TemplateMode.HTML));
    final List<ITextProcessor> textProcessors = new ArrayList<ITextProcessor>(config.getTextProcessors(TemplateMode.HTML));
    final List<IXMLDeclarationProcessor> xmlDeclarationProcessors = new ArrayList<IXMLDeclarationProcessor>(config.getXMLDeclarationProcessors(TemplateMode.HTML));
    Assert.assertEquals(2, elementProcessors.size());
    Assert.assertEquals(1, cdataSectionProcessors.size());
    Assert.assertEquals(1, commentProcessors.size());
    Assert.assertEquals(1, docTypeProcessors.size());
    Assert.assertEquals(1, processingInstructionProcessors.size());
    Assert.assertEquals(1, templateBoundariesProcessors.size());
    Assert.assertEquals(1, textProcessors.size());
    Assert.assertEquals(1, xmlDeclarationProcessors.size());
    // We will use the class names because the classes are package-protected
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$ElementModelProcessorWrapper", elementProcessors.get(0).getClass().getName());
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper", elementProcessors.get(1).getClass().getName());
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$CDATASectionProcessorWrapper", cdataSectionProcessors.get(0).getClass().getName());
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$CommentProcessorWrapper", commentProcessors.get(0).getClass().getName());
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$DocTypeProcessorWrapper", docTypeProcessors.get(0).getClass().getName());
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$ProcessingInstructionProcessorWrapper", processingInstructionProcessors.get(0).getClass().getName());
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$TemplateBoundariesProcessorWrapper", templateBoundariesProcessors.get(0).getClass().getName());
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$TextProcessorWrapper", textProcessors.get(0).getClass().getName());
    Assert.assertEquals("org.thymeleaf.util.ProcessorConfigurationUtils$XMLDeclarationProcessorWrapper", xmlDeclarationProcessors.get(0).getClass().getName());
    Assert.assertEquals(100, elementProcessors.get(0).getPrecedence());
    Assert.assertEquals(110, elementProcessors.get(1).getPrecedence());
    Assert.assertEquals(100, cdataSectionProcessors.get(0).getPrecedence());
    Assert.assertEquals(100, commentProcessors.get(0).getPrecedence());
    Assert.assertEquals(100, docTypeProcessors.get(0).getPrecedence());
    Assert.assertEquals(100, processingInstructionProcessors.get(0).getPrecedence());
    Assert.assertEquals(100, templateBoundariesProcessors.get(0).getPrecedence());
    Assert.assertEquals(100, textProcessors.get(0).getPrecedence());
    Assert.assertEquals(100, xmlDeclarationProcessors.get(0).getPrecedence());
}
Also used : IEngineConfiguration(org.thymeleaf.IEngineConfiguration) ITextProcessor(org.thymeleaf.processor.text.ITextProcessor) IProcessingInstructionProcessor(org.thymeleaf.processor.processinginstruction.IProcessingInstructionProcessor) ArrayList(java.util.ArrayList) ITemplateBoundariesProcessor(org.thymeleaf.processor.templateboundaries.ITemplateBoundariesProcessor) Dialect01(org.thymeleaf.dialect.dialectwrapping.Dialect01) IDocTypeProcessor(org.thymeleaf.processor.doctype.IDocTypeProcessor) IElementProcessor(org.thymeleaf.processor.element.IElementProcessor) ICommentProcessor(org.thymeleaf.processor.comment.ICommentProcessor) TemplateEngine(org.thymeleaf.TemplateEngine) IXMLDeclarationProcessor(org.thymeleaf.processor.xmldeclaration.IXMLDeclarationProcessor) ICDATASectionProcessor(org.thymeleaf.processor.cdatasection.ICDATASectionProcessor) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 IEngineConfiguration (org.thymeleaf.IEngineConfiguration)1 TemplateEngine (org.thymeleaf.TemplateEngine)1 Dialect01 (org.thymeleaf.dialect.dialectwrapping.Dialect01)1 ICDATASectionProcessor (org.thymeleaf.processor.cdatasection.ICDATASectionProcessor)1 ICommentProcessor (org.thymeleaf.processor.comment.ICommentProcessor)1 IDocTypeProcessor (org.thymeleaf.processor.doctype.IDocTypeProcessor)1 IElementProcessor (org.thymeleaf.processor.element.IElementProcessor)1 IProcessingInstructionProcessor (org.thymeleaf.processor.processinginstruction.IProcessingInstructionProcessor)1 ITemplateBoundariesProcessor (org.thymeleaf.processor.templateboundaries.ITemplateBoundariesProcessor)1 ITextProcessor (org.thymeleaf.processor.text.ITextProcessor)1 IXMLDeclarationProcessor (org.thymeleaf.processor.xmldeclaration.IXMLDeclarationProcessor)1