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