aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www
diff options
context:
space:
mode:
Diffstat (limited to 'juick-spring-www')
-rw-r--r--juick-spring-www/build.gradle7
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java3
-rw-r--r--juick-spring-www/src/test/java/com/juick/www/ThymeleafTestsJunitRunner.java40
-rw-r--r--juick-spring-www/src/test/resources/tests/simple.thtest25
4 files changed, 75 insertions, 0 deletions
diff --git a/juick-spring-www/build.gradle b/juick-spring-www/build.gradle
index e405506b..9ba9bebf 100644
--- a/juick-spring-www/build.gradle
+++ b/juick-spring-www/build.gradle
@@ -30,11 +30,18 @@ dependencies {
compile "org.thymeleaf:thymeleaf:${thymeleafVersion}"
compile "org.thymeleaf:thymeleaf-spring4:${thymeleafVersion}"
compile "org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.0.RELEASE"
+ compile "org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.1.RELEASE"
compile "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.1.1"
compile "org.springframework.security:spring-security-web:${springSecurityVersion}"
compile "org.springframework.security:spring-security-config:${springSecurityVersion}"
+
+ testCompile 'junit:junit:4.12'
+ testCompile "org.mockito:mockito-core:1.+"
+
testRuntime "org.thymeleaf:thymeleaf-testing:3.0.1.RELEASE"
+
providedCompile "javax.servlet:javax.servlet-api:3.1.0"
+
providedRuntime "mysql:mysql-connector-java:5.1.40"
}
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
index 089e43a8..5c17897c 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
@@ -16,6 +16,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.resource.PathResourceResolver;
+import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
@@ -61,6 +62,8 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport {
templateEngine.setEnableSpringELCompiler(true);
// Thymeleaf Layout Dialect
templateEngine.addDialect(new LayoutDialect());
+ // Thymeleaf Spring Security integration dialect
+ templateEngine.addDialect(new SpringSecurityDialect());
return templateEngine;
}
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<IDialect> 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
+<!DOCTYPE html>
+<html>
+ <body>
+ <span th:text="${onevar}">Hello,</span>
+ <span th:text="#{one.msg}">World!</span>
+ </body>
+</html>
+# ------------------------------------------
+%OUTPUT
+<!DOCTYPE html>
+<html>
+ <body>
+ <span>Goodbye,</span>
+ <span>Crisis</span>
+ </body>
+</html> \ No newline at end of file