From c207b80dd642dd8d5c18340fa5982a3c61ead460 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Thu, 24 Nov 2016 00:24:20 +0700 Subject: simple thymeleaf test is added --- .../com/juick/www/ThymeleafTestsJunitRunner.java | 40 ++++++++++++++++++++++ .../src/test/resources/tests/simple.thtest | 25 ++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 juick-spring-www/src/test/java/com/juick/www/ThymeleafTestsJunitRunner.java create mode 100644 juick-spring-www/src/test/resources/tests/simple.thtest (limited to 'juick-spring-www/src/test') diff --git a/juick-spring-www/src/test/java/com/juick/www/ThymeleafTestsJunitRunner.java b/juick-spring-www/src/test/java/com/juick/www/ThymeleafTestsJunitRunner.java new file mode 100644 index 00000000..4fd1f1f5 --- /dev/null +++ b/juick-spring-www/src/test/java/com/juick/www/ThymeleafTestsJunitRunner.java @@ -0,0 +1,40 @@ +package com.juick.www; + +import nz.net.ultraq.thymeleaf.LayoutDialect; +import org.junit.Assert; +import org.junit.Test; +import org.thymeleaf.dialect.IDialect; +import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect; +import org.thymeleaf.spring4.dialect.SpringStandardDialect; +import org.thymeleaf.testing.templateengine.context.web.SpringWebProcessingContextBuilder; +import org.thymeleaf.testing.templateengine.engine.TestExecutor; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by aalexeev on 11/24/16. + */ +public class ThymeleafTestsJunitRunner { + + @Test + public void runThymeleafTest() { + final List dialects = new ArrayList<>(); + dialects.add(new SpringStandardDialect()); + dialects.add(new LayoutDialect()); + dialects.add(new SpringSecurityDialect()); + + final SpringWebProcessingContextBuilder springPCBuilder = new SpringWebProcessingContextBuilder(); + + springPCBuilder.setApplicationContextConfigLocation(null); + + final TestExecutor executor = new TestExecutor(); + executor.setProcessingContextBuilder(springPCBuilder); + executor.setDialects(dialects); + + executor.execute("classpath:tests"); + + Assert.assertTrue(executor.isAllOK()); + executor.reset(); + } +} diff --git a/juick-spring-www/src/test/resources/tests/simple.thtest b/juick-spring-www/src/test/resources/tests/simple.thtest new file mode 100644 index 00000000..1505a382 --- /dev/null +++ b/juick-spring-www/src/test/resources/tests/simple.thtest @@ -0,0 +1,25 @@ +%TEMPLATE_MODE HTML +# ------------ separator comment ----------- +%CONTEXT +onevar = 'Goodbye,' +# ------------------------------------------ +%MESSAGES +one.msg = Crisis +# ------------------------------------------ +%INPUT + + + + Hello, + World! + + +# ------------------------------------------ +%OUTPUT + + + + Goodbye, + Crisis + + \ No newline at end of file -- cgit v1.2.3