From fb2e4d30c84dbf90437606dd6f2a082538b0abe6 Mon Sep 17 00:00:00 2001 From: Eric Bussieres Date: Wed, 21 Sep 2022 13:52:13 -0400 Subject: [PATCH 1/2] Upgrade spring deps and remove support for spring-boot 1.5.x --- README.md | 8 +- .../CHANGELOG.md | 6 - .../pebble-legacy-spring-boot-starter/pom.xml | 56 ----- .../PebbleAutoConfiguration.java | 121 ---------- .../boot/autoconfigure/PebbleProperties.java | 45 ---- .../PebbleTemplateAvailabilityProvider.java | 26 --- .../boot/autoconfigure/package-info.java | 4 - .../main/resources/META-INF/spring.factories | 6 - .../main/resources/META-INF/spring.provides | 1 - .../pebble/boot/Application.java | 62 ----- .../pebble/boot/ControllerTest.java | 75 ------- .../pebble/boot/Controllers.java | 30 --- .../pebble/boot/CoreTests.java | 26 --- .../pebble/boot/NonWebApplication.java | 26 --- ...rvletComponenRegisteringPostProcessor.java | 85 ------- .../pebble/boot/ServletComponentHandler.java | 61 ----- .../pebble/boot/ServletComponentScan.java | 43 ---- .../boot/ServletComponentScanRegistrar.java | 73 ------ .../pebble/boot/WebFilterHandler.java | 54 ----- .../pebble/boot/WebListenerHandler.java | 25 --- .../pebble/boot/WebServletHandler.java | 37 --- .../src/test/resources/messages.properties | 1 - .../src/test/resources/messages_es.properties | 1 - .../resources/templates/contextPath.pebble | 1 - .../resources/templates/extensions.pebble | 1 - .../src/test/resources/templates/hello.pebble | 1 - .../src/test/resources/templates/index.pebble | 1 - .../pebble-spring-boot-starter/pom.xml | 2 +- pebble-spring/pebble-spring4/pom.xml | 85 ------- .../pebble/spring4/PebbleView.java | 113 ---------- .../pebble/spring4/PebbleViewResolver.java | 55 ----- .../pebble/spring4/context/Beans.java | 97 -------- .../spring4/extension/SpringExtension.java | 52 ----- .../extension/function/HrefFunction.java | 84 ------- .../function/MessageSourceFunction.java | 65 ------ .../BaseBindingResultFunction.java | 51 ----- .../bindingresult/GetAllErrorsFunction.java | 59 ----- .../bindingresult/GetFieldErrorsFunction.java | 65 ------ .../GetGlobalErrorsFunction.java | 59 ----- .../bindingresult/HasErrorsFunction.java | 38 ---- .../bindingresult/HasFieldErrorsFunction.java | 48 ---- .../HasGlobalErrorsFunction.java | 38 ---- .../spring4/PebbleViewResolverTest.java | 211 ------------------ .../pebble/spring4/bean/SomeBean.java | 19 -- .../pebble/spring4/config/MVCConfig.java | 70 ------ .../spring4/expectedResponse/beansTest.html | 10 - .../expectedResponse/bindingResultTest.html | 21 -- .../bindingResultWithMacroTest.html | 21 -- .../expectedResponse/hrefFunctionTest.html | 13 -- .../expectedResponse/messageEnTest.html | 12 - .../expectedResponse/messageFrTest.html | 12 - .../spring4/expectedResponse/requestTest.html | 11 - .../expectedResponse/responseTest.html | 12 - .../spring4/expectedResponse/sessionTest.html | 11 - .../pebble/spring4/messages_en.properties | 5 - .../pebble/spring4/messages_fr.properties | 5 - .../pebble/spring4/template/beansTest.html | 10 - .../spring4/template/bindingResultTest.html | 26 --- .../template/bindingResultWithMacroTest.html | 29 --- .../spring4/template/hrefFunctionTest.html | 13 -- .../spring4/template/messageEnTest.html | 12 - .../spring4/template/messageFrTest.html | 12 - .../pebble/spring4/template/requestTest.html | 11 - .../pebble/spring4/template/responseTest.html | 12 - .../pebble/spring4/template/sessionTest.html | 11 - pebble-spring/pebble-spring5/pom.xml | 6 +- pebble-spring/pom.xml | 2 - 67 files changed, 8 insertions(+), 2356 deletions(-) delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/CHANGELOG.md delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/pom.xml delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleAutoConfiguration.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleProperties.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleTemplateAvailabilityProvider.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/package-info.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/main/resources/META-INF/spring.factories delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/main/resources/META-INF/spring.provides delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Application.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ControllerTest.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Controllers.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/CoreTests.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/NonWebApplication.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponenRegisteringPostProcessor.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentHandler.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentScan.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentScanRegistrar.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebFilterHandler.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebListenerHandler.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebServletHandler.java delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/messages.properties delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/messages_es.properties delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/contextPath.pebble delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/extensions.pebble delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/hello.pebble delete mode 100644 pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/index.pebble delete mode 100644 pebble-spring/pebble-spring4/pom.xml delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/PebbleView.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/PebbleViewResolver.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/context/Beans.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/SpringExtension.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/HrefFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/MessageSourceFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/BaseBindingResultFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetAllErrorsFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetFieldErrorsFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetGlobalErrorsFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasErrorsFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasFieldErrorsFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasGlobalErrorsFunction.java delete mode 100644 pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/PebbleViewResolverTest.java delete mode 100644 pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/bean/SomeBean.java delete mode 100644 pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/config/MVCConfig.java delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/beansTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/bindingResultTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/bindingResultWithMacroTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/hrefFunctionTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/messageEnTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/messageFrTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/requestTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/responseTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/sessionTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/messages_en.properties delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/messages_fr.properties delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/beansTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/bindingResultTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/bindingResultWithMacroTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/hrefFunctionTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/messageEnTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/messageFrTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/requestTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/responseTest.html delete mode 100644 pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/sessionTest.html diff --git a/README.md b/README.md index 446d31ba7..acbbd0823 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ For more information please visit the [website](https://pebbletemplates.io). # Artifact id renaming for pebble-spring-boot-starter As of version 3.1.0 and in order to follow this naming [recommendation](https://github.com/spring-projects/spring-boot/wiki/Building-On-Spring-Boot#naming), the artifactId of pebble-spring-boot-starter has been renamed as is: -| Old artifactId | New artifactId | spring-boot version | -| --- | --- | --- | -| pebble-spring-boot-starter | pebble-legacy-spring-boot-starter | 1.5.x | -| pebble-spring-boot-2-starter | pebble-spring-boot-starter | 2.x.x | +| Old artifactId | New artifactId | spring-boot version | +| --- |--------------------------------------------------------------------| --- | +| pebble-spring-boot-starter | pebble-legacy-spring-boot-starter (No longer supported as of 3.1.6 | 1.5.x | +| pebble-spring-boot-2-starter | pebble-spring-boot-starter | 2.x.x | # New group id Please note that the pebble's groupId has been updated as of version 2.5.0 diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/CHANGELOG.md b/pebble-spring/pebble-legacy-spring-boot-starter/CHANGELOG.md deleted file mode 100644 index 8d16ef7a3..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -## v2.X.X (unreleased) -- Automatically add the SpringExtension in pebble-spring4 to the default engine - -## v2.2.1 (2016-03-29) -Tested with Spring Boot 1.2.1 & 1.3.3 -- Initial project features diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/pom.xml b/pebble-spring/pebble-legacy-spring-boot-starter/pom.xml deleted file mode 100644 index 081c21db1..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - 4.0.0 - - io.pebbletemplates - pebble-spring - 3.1.6-SNAPSHOT - - - pebble-legacy-spring-boot-starter - - Pebble Spring Boot Starter - Spring Boot starter for Pebble Template Engine - http://pebbletemplates.io - - - 1.5.22.RELEASE - - - - - org.springframework.boot - spring-boot-starter-web - ${boot.version} - true - - - io.pebbletemplates - pebble-spring4 - ${project.version} - - - - - org.springframework.boot - spring-boot-starter-test - ${boot.version} - test - - - - - - - maven-jar-plugin - - - - io.pebbletemplates.spring.boot - - - - - - - diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleAutoConfiguration.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleAutoConfiguration.java deleted file mode 100644 index c39977697..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleAutoConfiguration.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.mitchellbosecke.pebble.boot.autoconfigure; - -import com.mitchellbosecke.pebble.PebbleEngine; -import com.mitchellbosecke.pebble.extension.Extension; -import com.mitchellbosecke.pebble.loader.ClasspathLoader; -import com.mitchellbosecke.pebble.loader.Loader; -import com.mitchellbosecke.pebble.spring4.PebbleViewResolver; -import com.mitchellbosecke.pebble.spring4.extension.SpringExtension; -import java.util.List; -import javax.servlet.Servlet; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ConditionalOnClass(PebbleEngine.class) -@AutoConfigureAfter(WebMvcAutoConfiguration.class) -@EnableConfigurationProperties(PebbleProperties.class) -public class PebbleAutoConfiguration { - - @Configuration - @ConditionalOnMissingBean(name = "pebbleLoader") - public static class DefaultLoaderConfiguration { - - @Autowired - private PebbleProperties properties; - - @Bean - public Loader pebbleLoader() { - ClasspathLoader loader = new ClasspathLoader(); - loader.setCharset(this.properties.getCharsetName()); - // classpath loader does not like leading slashes in resource paths - loader.setPrefix(stripLeadingSlash(this.properties.getPrefix())); - loader.setSuffix(this.properties.getSuffix()); - return loader; - } - - } - - @Configuration - @ConditionalOnMissingBean(name = "pebbleEngine") - public static class PebbleDefaultConfiguration { - - @Autowired - private PebbleProperties properties; - - @Autowired - private Loader pebbleLoader; - - @Autowired(required = false) - private List extensions; - - @Bean - public SpringExtension pebbleSpringExtension() { - return new SpringExtension(); - } - - @Bean - public PebbleEngine pebbleEngine() { - PebbleEngine.Builder builder = new PebbleEngine.Builder(); - builder.loader(this.pebbleLoader); - builder.extension(this.pebbleSpringExtension()); - if (this.extensions != null && !this.extensions.isEmpty()) { - builder.extension(this.extensions.toArray(new Extension[this.extensions.size()])); - } - if (!this.properties.isCache()) { - builder.cacheActive(false); - } - if (this.properties.getDefaultLocale() != null) { - builder.defaultLocale(this.properties.getDefaultLocale()); - } - builder.strictVariables(this.properties.isStrictVariables()); - builder.greedyMatchMethod(this.properties.isGreedyMatchMethod()); - return builder.build(); - } - } - - @Configuration - @ConditionalOnWebApplication - @ConditionalOnClass({Servlet.class}) - public static class PebbleViewResolverConfiguration { - - @Autowired - private PebbleProperties properties; - - @Autowired - private PebbleEngine pebbleEngine; - - @Bean - @ConditionalOnMissingBean(name = "pebbleViewResolver") - public PebbleViewResolver pebbleViewResolver() { - PebbleViewResolver pvr = new PebbleViewResolver(); - this.properties.applyToViewResolver(pvr); - - pvr.setPebbleEngine(this.pebbleEngine); - if (this.pebbleEngine.getLoader() instanceof ClasspathLoader) { - // classpathloader doesn't like leading slashes in paths - pvr.setPrefix(stripLeadingSlash(this.properties.getPrefix())); - } - - return pvr; - } - } - - private static String stripLeadingSlash(String value) { - if (value == null) { - return null; - } - if (value.startsWith("/")) { - return value.substring(1); - } - return value; - } - -} diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleProperties.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleProperties.java deleted file mode 100644 index 53a421e98..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleProperties.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.mitchellbosecke.pebble.boot.autoconfigure; - -import java.util.Locale; -import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; - -@ConfigurationProperties("pebble") -public class PebbleProperties extends AbstractTemplateViewResolverProperties { - - public static final String DEFAULT_PREFIX = "/templates/"; - public static final String DEFAULT_SUFFIX = ".pebble"; - - private Locale defaultLocale; - private boolean strictVariables; - private boolean greedyMatchMethod; - - public PebbleProperties() { - super(DEFAULT_PREFIX, DEFAULT_SUFFIX); - this.setCache(true); - } - - public Locale getDefaultLocale() { - return this.defaultLocale; - } - - public void setDefaultLocale(Locale defaultLocale) { - this.defaultLocale = defaultLocale; - } - - public boolean isStrictVariables() { - return this.strictVariables; - } - - public void setStrictVariables(boolean strictVariables) { - this.strictVariables = strictVariables; - } - - public boolean isGreedyMatchMethod() { - return this.greedyMatchMethod; - } - - public void setGreedyMatchMethod(boolean greedyMatchMethod) { - this.greedyMatchMethod = greedyMatchMethod; - } -} diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleTemplateAvailabilityProvider.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleTemplateAvailabilityProvider.java deleted file mode 100644 index 4f40db35f..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleTemplateAvailabilityProvider.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mitchellbosecke.pebble.boot.autoconfigure; - -import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider; -import org.springframework.boot.bind.RelaxedPropertyResolver; -import org.springframework.core.env.Environment; -import org.springframework.core.env.PropertyResolver; -import org.springframework.core.io.ResourceLoader; -import org.springframework.util.ClassUtils; - -import static org.springframework.core.io.ResourceLoader.CLASSPATH_URL_PREFIX; - -public class PebbleTemplateAvailabilityProvider implements TemplateAvailabilityProvider { - - @Override - public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, - ResourceLoader resourceLoader) { - if (ClassUtils.isPresent("com.mitchellbosecke.pebble.PebbleEngine", classLoader)) { - PropertyResolver resolver = new RelaxedPropertyResolver(environment, "pebble."); - String prefix = resolver.getProperty("prefix", PebbleProperties.DEFAULT_PREFIX); - String suffix = resolver.getProperty("suffix", PebbleProperties.DEFAULT_SUFFIX); - return resourceLoader.getResource(CLASSPATH_URL_PREFIX + prefix + view + suffix).exists(); - } - return false; - } - -} diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/package-info.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/package-info.java deleted file mode 100644 index 2066b0801..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/java/com/mitchellbosecke/pebble/boot/autoconfigure/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Auto-configuration for Pebble Template Engine. - */ -package com.mitchellbosecke.pebble.boot.autoconfigure; \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/resources/META-INF/spring.factories b/pebble-spring/pebble-legacy-spring-boot-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 803001fae..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,6 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.mitchellbosecke.pebble.boot.autoconfigure.PebbleAutoConfiguration -# Template availability providers -org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider=\ -com.mitchellbosecke.pebble.boot.autoconfigure.PebbleTemplateAvailabilityProvider \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/resources/META-INF/spring.provides b/pebble-spring/pebble-legacy-spring-boot-starter/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 65aecbb1d..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1 +0,0 @@ -provides: pebble,pebble-spring4 diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Application.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Application.java deleted file mode 100644 index a02caf2cf..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Application.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import com.mitchellbosecke.pebble.extension.AbstractExtension; -import com.mitchellbosecke.pebble.extension.Extension; -import com.mitchellbosecke.pebble.extension.Function; -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.web.servlet.LocaleResolver; -import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver; - -@SpringBootApplication -@ServletComponentScan -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - - @Bean - public LocaleResolver localeResolver() { - return new AcceptHeaderLocaleResolver(); - } - - @Bean - public Extension testExtension() { - return new TestExtension(); - } - - public static class TestExtension extends AbstractExtension { - - @Override - public Map getFunctions() { - Map functions = new HashMap(); - functions.put("testFunction", new TestFunction()); - return functions; - } - - public static class TestFunction implements Function { - - @Override - public List getArgumentNames() { - return Collections.emptyList(); - } - - @Override - public Object execute(Map args, PebbleTemplate self, - EvaluationContext context, int lineNumber) { - return "Tested!"; - } - } - } - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ControllerTest.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ControllerTest.java deleted file mode 100644 index 08792e1e2..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ControllerTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, webEnvironment=WebEnvironment.RANDOM_PORT) -public class ControllerTest { - - @Autowired - private WebApplicationContext wac; - - protected MockMvc mockMvc; - - @Before - public void setup() { - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); - } - - @Test - public void testOk() throws Exception { - mockMvc.perform(get("/index.action")).andExpect(status().isOk()) - .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) - .andExpect(content().string("Hello Pebbleworld!")); - } - - @Test - public void testRequestAccess() throws Exception { - MvcResult result = mockMvc.perform(get("/contextPath.action")).andExpect(status().isOk()) - .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)).andReturn(); - Assert.assertEquals("ctx path:" + result.getRequest().getContextPath(), - result.getResponse().getContentAsString()); - } - - @Test - public void testEnglishHello() throws Exception { - mockMvc.perform(get("/hello.action").locale(Locale.forLanguageTag("en"))) - .andExpect(status().isOk()) - .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) - .andExpect(content().string("Hello Boot!")); - } - - @Test - public void testSpanishHello() throws Exception { - mockMvc.perform(get("/hello.action").locale(Locale.forLanguageTag("es"))) - .andExpect(status().isOk()) - .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) - .andExpect(content().string("Hola Boot!")); - } - - @Test - public void testAdditionalExtensions() throws Exception { - mockMvc.perform(get("/extensions.action").locale(Locale.forLanguageTag("es"))) - .andExpect(status().isOk()) - .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) - .andExpect(content().string("Hola Boot! Tested!")); - } - -} diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Controllers.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Controllers.java deleted file mode 100644 index d99625b08..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/Controllers.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -public class Controllers { - - @RequestMapping("/hello.action") - public String hello() { - return "hello"; - } - - @RequestMapping("/index.action") - public String index(ModelMap model) { - return "index"; - } - - @RequestMapping("/contextPath.action") - public String contextPath(ModelMap model) { - return "contextPath"; - } - - @RequestMapping("/extensions.action") - public String extensions(ModelMap model) { - return "extensions"; - } - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/CoreTests.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/CoreTests.java deleted file mode 100644 index 4f4ef0a27..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/CoreTests.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import com.mitchellbosecke.pebble.PebbleEngine; -import java.io.StringWriter; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = NonWebApplication.class) -public class CoreTests { - - @Autowired - private PebbleEngine pebbleEngine; - - @Test - public void testOk() throws Exception { - StringWriter sw = new StringWriter(); - pebbleEngine.getTemplate("hello").evaluate(sw); - Assert.assertTrue(sw.toString() != null && !sw.toString().isEmpty()); - } - -} diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/NonWebApplication.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/NonWebApplication.java deleted file mode 100644 index bbfc12225..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/NonWebApplication.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.support.ResourceBundleMessageSource; - -@SpringBootApplication -public class NonWebApplication { - - public static void main(String[] args) { - SpringApplication sa = new SpringApplicationBuilder(NonWebApplication.class).web(false).build(); - sa.run(args); - } - - @Bean - public MessageSource messageSource() { - ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); - messageSource.setBasename("messages"); - messageSource.setFallbackToSystemLocale(false); - return messageSource; - } - -} diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponenRegisteringPostProcessor.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponenRegisteringPostProcessor.java deleted file mode 100644 index 54d229963..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponenRegisteringPostProcessor.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; -import org.springframework.context.annotation.ScannedGenericBeanDefinition; - -class ServletComponentRegisteringPostProcessor implements BeanFactoryPostProcessor, - ApplicationContextAware { - - private static final List HANDLERS; - - static { - List handlers = new ArrayList(); - handlers.add(new WebServletHandler()); - handlers.add(new WebFilterHandler()); - handlers.add(new WebListenerHandler()); - HANDLERS = Collections.unmodifiableList(handlers); - } - - private final Set packagesToScan; - - private ApplicationContext applicationContext; - - ServletComponentRegisteringPostProcessor(Set packagesToScan) { - this.packagesToScan = packagesToScan; - } - - @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) - throws BeansException { - if (isRunningInEmbeddedContainer()) { - ClassPathScanningCandidateComponentProvider componentProvider = createComponentProvider(); - for (String packageToScan : this.packagesToScan) { - scanPackage(componentProvider, packageToScan); - } - } - } - - private void scanPackage(ClassPathScanningCandidateComponentProvider componentProvider, - String packageToScan) { - for (BeanDefinition candidate : componentProvider.findCandidateComponents(packageToScan)) { - if (candidate instanceof ScannedGenericBeanDefinition) { - for (ServletComponentHandler handler : HANDLERS) { - handler.handle(((ScannedGenericBeanDefinition) candidate), - (BeanDefinitionRegistry) this.applicationContext); - } - } - } - } - - private boolean isRunningInEmbeddedContainer() { - return this.applicationContext instanceof EmbeddedWebApplicationContext - && ((EmbeddedWebApplicationContext) this.applicationContext).getServletContext() == null; - } - - private ClassPathScanningCandidateComponentProvider createComponentProvider() { - ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider( - false); - for (ServletComponentHandler handler : HANDLERS) { - componentProvider.addIncludeFilter(handler.getTypeFilter()); - } - return componentProvider; - } - - Set getPackagesToScan() { - return Collections.unmodifiableSet(this.packagesToScan); - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentHandler.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentHandler.java deleted file mode 100644 index c57882a97..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import java.lang.annotation.Annotation; -import java.util.HashMap; -import java.util.Map; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.context.annotation.ScannedGenericBeanDefinition; -import org.springframework.core.annotation.AnnotationAttributes; -import org.springframework.core.type.filter.AnnotationTypeFilter; -import org.springframework.core.type.filter.TypeFilter; -import org.springframework.util.Assert; - -abstract class ServletComponentHandler { - - private final Class annotationType; - - private final TypeFilter typeFilter; - - protected ServletComponentHandler(Class annotationType) { - this.typeFilter = new AnnotationTypeFilter(annotationType); - this.annotationType = annotationType; - } - - TypeFilter getTypeFilter() { - return this.typeFilter; - } - - protected String[] extractUrlPatterns(String attribute, Map attributes) { - String[] value = (String[]) attributes.get("value"); - String[] urlPatterns = (String[]) attributes.get("urlPatterns"); - if (urlPatterns.length > 0) { - Assert - .state(value.length == 0, "The urlPatterns and value attributes are mutually exclusive."); - return urlPatterns; - } - return value; - } - - protected final Map extractInitParameters(Map attributes) { - Map initParameters = new HashMap(); - for (AnnotationAttributes initParam : (AnnotationAttributes[]) attributes.get("initParams")) { - String name = (String) initParam.get("name"); - String value = (String) initParam.get("value"); - initParameters.put(name, value); - } - return initParameters; - } - - void handle(ScannedGenericBeanDefinition beanDefinition, BeanDefinitionRegistry registry) { - Map attributes = beanDefinition.getMetadata() - .getAnnotationAttributes(this.annotationType.getName()); - if (attributes != null) { - doHandle(attributes, beanDefinition, registry); - } - } - - protected abstract void doHandle(Map attributes, BeanDefinition beanDefinition, - BeanDefinitionRegistry registry); - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentScan.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentScan.java deleted file mode 100644 index ba3bb3361..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentScan.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import org.springframework.context.annotation.Import; - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Import(ServletComponentScanRegistrar.class) -public @interface ServletComponentScan { - - /** - * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation - * declarations e.g.: {@code @ServletComponentScan("org.my.pkg")} instead of {@code - * - * @return the base packages to scan - * @ServletComponentScan(basePackages="org.my.pkg")}. - */ - String[] value() default {}; - - /** - * Base packages to scan for annotated servlet components. {@link #value()} is an alias for (and - * mutually exclusive with) this attribute. - *

- * Use {@link #basePackageClasses()} for a type-safe alternative to String-based package names. - * - * @return the base packages to scan - */ - String[] basePackages() default {}; - - /** - * Type-safe alternative to {@link #basePackages()} for specifying the packages to scan for - * annotated servlet components. The package of each class specified will be scanned. - * - * @return classes from the base packages to scan - */ - Class[] basePackageClasses() default {}; - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentScanRegistrar.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentScanRegistrar.java deleted file mode 100644 index b5c1dadee..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ServletComponentScanRegistrar.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.GenericBeanDefinition; -import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; -import org.springframework.core.annotation.AnnotationAttributes; -import org.springframework.core.type.AnnotationMetadata; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; -import org.springframework.util.ObjectUtils; - -class ServletComponentScanRegistrar implements ImportBeanDefinitionRegistrar { - - private static final String BEAN_NAME = "servletComponentRegisteringPostProcessor"; - - @Override - public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, - BeanDefinitionRegistry registry) { - Set packagesToScan = getPackagesToScan(importingClassMetadata); - if (registry.containsBeanDefinition(BEAN_NAME)) { - updatePostProcessor(registry, packagesToScan); - } else { - addPostProcessor(registry, packagesToScan); - } - } - - private void updatePostProcessor(BeanDefinitionRegistry registry, Set packagesToScan) { - BeanDefinition definition = registry.getBeanDefinition(BEAN_NAME); - ValueHolder constructorArguments = definition.getConstructorArgumentValues() - .getGenericArgumentValue(Set.class); - @SuppressWarnings("unchecked") - Set mergedPackages = (Set) constructorArguments.getValue(); - mergedPackages.addAll(packagesToScan); - constructorArguments.setValue(mergedPackages); - } - - private void addPostProcessor(BeanDefinitionRegistry registry, Set packagesToScan) { - GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); - beanDefinition.setBeanClass(ServletComponentRegisteringPostProcessor.class); - beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(packagesToScan); - beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); - registry.registerBeanDefinition(BEAN_NAME, beanDefinition); - } - - private Set getPackagesToScan(AnnotationMetadata metadata) { - AnnotationAttributes attributes = AnnotationAttributes - .fromMap(metadata.getAnnotationAttributes(ServletComponentScan.class.getName())); - String[] value = attributes.getStringArray("value"); - String[] basePackages = attributes.getStringArray("basePackages"); - Class[] basePackageClasses = attributes.getClassArray("basePackageClasses"); - if (!ObjectUtils.isEmpty(value)) { - Assert.state(ObjectUtils.isEmpty(basePackages), - "@ServletComponentScan basePackages and value attributes are" + " mutually exclusive"); - } - Set packagesToScan = new LinkedHashSet(); - packagesToScan.addAll(Arrays.asList(value)); - packagesToScan.addAll(Arrays.asList(basePackages)); - for (Class basePackageClass : basePackageClasses) { - packagesToScan.add(ClassUtils.getPackageName(basePackageClass)); - } - if (packagesToScan.isEmpty()) { - return Collections.singleton(ClassUtils.getPackageName(metadata.getClassName())); - } - return packagesToScan; - } - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebFilterHandler.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebFilterHandler.java deleted file mode 100644 index 3d5bd9e9e..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebFilterHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import java.util.Arrays; -import java.util.EnumSet; -import java.util.Map; -import javax.servlet.DispatcherType; -import javax.servlet.annotation.WebFilter; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.util.StringUtils; - -class WebFilterHandler extends ServletComponentHandler { - - WebFilterHandler() { - super(WebFilter.class); - } - - @Override - public void doHandle(Map attributes, BeanDefinition beanDefinition, - BeanDefinitionRegistry registry) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder - .rootBeanDefinition(FilterRegistrationBean.class); - builder.addPropertyValue("asyncSupported", attributes.get("asyncSupported")); - builder.addPropertyValue("dispatcherTypes", extractDispatcherTypes(attributes)); - builder.addPropertyValue("filter", beanDefinition); - builder.addPropertyValue("initParameters", extractInitParameters(attributes)); - String name = determineName(attributes, beanDefinition); - builder.addPropertyValue("name", name); - builder.addPropertyValue("servletNames", attributes.get("servletNames")); - builder.addPropertyValue("urlPatterns", extractUrlPatterns("urlPatterns", attributes)); - registry.registerBeanDefinition(name, builder.getBeanDefinition()); - } - - private EnumSet extractDispatcherTypes(Map attributes) { - DispatcherType[] dispatcherTypes = (DispatcherType[]) attributes.get("dispatcherTypes"); - if (dispatcherTypes.length == 0) { - return EnumSet.noneOf(DispatcherType.class); - } - if (dispatcherTypes.length == 1) { - return EnumSet.of(dispatcherTypes[0]); - } - return EnumSet - .of(dispatcherTypes[0], Arrays.copyOfRange(dispatcherTypes, 1, dispatcherTypes.length)); - } - - private String determineName(Map attributes, BeanDefinition beanDefinition) { - return (String) (StringUtils.hasText((String) attributes.get("filterName")) ? attributes - .get("filterName") - : beanDefinition.getBeanClassName()); - } - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebListenerHandler.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebListenerHandler.java deleted file mode 100644 index 4658858e2..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebListenerHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import java.util.Map; -import javax.servlet.annotation.WebListener; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; - -class WebListenerHandler extends ServletComponentHandler { - - WebListenerHandler() { - super(WebListener.class); - } - - @Override - protected void doHandle(Map attributes, BeanDefinition beanDefinition, - BeanDefinitionRegistry registry) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder - .rootBeanDefinition(ServletListenerRegistrationBean.class); - builder.addPropertyValue("listener", beanDefinition); - registry.registerBeanDefinition(beanDefinition.getBeanClassName(), builder.getBeanDefinition()); - } - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebServletHandler.java b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebServletHandler.java deleted file mode 100644 index 740c83bdd..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/WebServletHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.mitchellbosecke.pebble.boot; - -import java.util.Map; -import javax.servlet.annotation.WebServlet; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.util.StringUtils; - -class WebServletHandler extends ServletComponentHandler { - - WebServletHandler() { - super(WebServlet.class); - } - - @Override - public void doHandle(Map attributes, BeanDefinition beanDefinition, - BeanDefinitionRegistry registry) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder - .rootBeanDefinition(ServletRegistrationBean.class); - builder.addPropertyValue("asyncSupported", attributes.get("asyncSupported")); - builder.addPropertyValue("initParameters", extractInitParameters(attributes)); - builder.addPropertyValue("loadOnStartup", attributes.get("loadOnStartup")); - String name = determineName(attributes, beanDefinition); - builder.addPropertyValue("name", name); - builder.addPropertyValue("servlet", beanDefinition); - builder.addPropertyValue("urlMappings", extractUrlPatterns("urlPatterns", attributes)); - registry.registerBeanDefinition(name, builder.getBeanDefinition()); - } - - private String determineName(Map attributes, BeanDefinition beanDefinition) { - return (String) (StringUtils.hasText((String) attributes.get("name")) ? attributes.get("name") - : beanDefinition.getBeanClassName()); - } - -} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/messages.properties b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/messages.properties deleted file mode 100644 index 88f15adee..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/messages.properties +++ /dev/null @@ -1 +0,0 @@ -hello.boot=Hello Boot! \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/messages_es.properties b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/messages_es.properties deleted file mode 100644 index a9af80a5b..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/messages_es.properties +++ /dev/null @@ -1 +0,0 @@ -hello.boot=Hola Boot! \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/contextPath.pebble b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/contextPath.pebble deleted file mode 100644 index 6b2af7875..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/contextPath.pebble +++ /dev/null @@ -1 +0,0 @@ -ctx path:{{request.contextPath}} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/extensions.pebble b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/extensions.pebble deleted file mode 100644 index f7020c4ae..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/extensions.pebble +++ /dev/null @@ -1 +0,0 @@ -{{ message('hello.boot') }} {{ testFunction() }} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/hello.pebble b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/hello.pebble deleted file mode 100644 index 113ac77e3..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/hello.pebble +++ /dev/null @@ -1 +0,0 @@ -{{ message('hello.boot') }} \ No newline at end of file diff --git a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/index.pebble b/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/index.pebble deleted file mode 100644 index 3222a1e37..000000000 --- a/pebble-spring/pebble-legacy-spring-boot-starter/src/test/resources/templates/index.pebble +++ /dev/null @@ -1 +0,0 @@ -{{'Hello Pebbleworld!'}} \ No newline at end of file diff --git a/pebble-spring/pebble-spring-boot-starter/pom.xml b/pebble-spring/pebble-spring-boot-starter/pom.xml index e6b614870..350f30839 100644 --- a/pebble-spring/pebble-spring-boot-starter/pom.xml +++ b/pebble-spring/pebble-spring-boot-starter/pom.xml @@ -14,7 +14,7 @@ http://pebbletemplates.io - 2.4.2 + 2.7.3 diff --git a/pebble-spring/pebble-spring4/pom.xml b/pebble-spring/pebble-spring4/pom.xml deleted file mode 100644 index 38ddaf2c5..000000000 --- a/pebble-spring/pebble-spring4/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - 4.0.0 - - io.pebbletemplates - pebble-spring - 3.1.6-SNAPSHOT - - - pebble-spring4 - - Pebble Integration with Spring 4.x - Pebble Integration with Spring 4.x - http://pebbletemplates.io - - - 3.0.1 - 4.3.29.RELEASE - 4.12 - 2.3.5 - - - - - - org.springframework - spring-framework-bom - ${spring-framework.version} - pom - import - - - - - - - io.pebbletemplates - pebble - - - javax.servlet - javax.servlet-api - ${servlet-api.version} - provided - - - org.springframework - spring-webmvc - provided - - - - - org.springframework - spring-test - test - - - org.mockito - mockito-core - ${mockito.version} - test - - - junit - junit - ${junit.version} - test - - - - - - - maven-jar-plugin - - - - io.pebbletemplates.spring - - - - - - - diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/PebbleView.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/PebbleView.java deleted file mode 100644 index fe0215c71..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/PebbleView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4; - -import com.mitchellbosecke.pebble.PebbleEngine; -import com.mitchellbosecke.pebble.error.PebbleException; -import com.mitchellbosecke.pebble.spring4.context.Beans; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.io.IOException; -import java.io.Writer; -import java.util.Locale; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.servlet.support.RequestContextUtils; -import org.springframework.web.servlet.view.AbstractTemplateView; - -public class PebbleView extends AbstractTemplateView { - - public static final String REQUEST_VARIABLE_NAME = "request"; - public static final String RESPONSE_VARIABLE_NAME = "response"; - public static final String SESSION_VARIABLE_NAME = "session"; - - private static final String BEANS_VARIABLE_NAME = "beans"; - private static final int NANO_PER_SECOND = 1000000; - /** - *

- * TIMER logger. This logger will output the time required for executing each template processing - * operation. - *

- *

- * The value of this constant is - * com.mitchellbosecke.pebble.spring.PebbleView.timer. This allows - * you to set a specific configuration and/or appenders for timing info at your logging system - * configuration. - *

- */ - private static final Logger TIMER_LOGGER = LoggerFactory - .getLogger(PebbleView.class.getName() + ".timer"); - - private String characterEncoding = "UTF-8"; - private PebbleEngine pebbleEngine; - private String templateName; - - @Override - protected void renderMergedTemplateModel(Map model, HttpServletRequest request, - HttpServletResponse response) throws Exception { - long startNanoTime = System.nanoTime(); - - this.setCharacterEncoding(response); - this.addVariablesToModel(model, request, response); - this.evaluateTemplate(model, request, response); - this.logElapsedTime(startNanoTime, request); - } - - private void setCharacterEncoding(HttpServletResponse response) { - if (this.characterEncoding != null) { - response.setCharacterEncoding(this.characterEncoding); - } - } - - private void addVariablesToModel(Map model, HttpServletRequest request, - HttpServletResponse response) { - model.put(BEANS_VARIABLE_NAME, new Beans(this.getApplicationContext())); - model.put(REQUEST_VARIABLE_NAME, request); - model.put(RESPONSE_VARIABLE_NAME, response); - model.put(SESSION_VARIABLE_NAME, request.getSession(false)); - } - - private void evaluateTemplate(Map model, HttpServletRequest request, - HttpServletResponse response) throws IOException, PebbleException { - Locale locale = RequestContextUtils.getLocale(request); - - Writer writer = response.getWriter(); - try { - PebbleTemplate template = this.pebbleEngine.getTemplate(this.templateName); - template.evaluate(writer, model, locale); - } finally { - writer.flush(); - } - } - - private void logElapsedTime(long startNanoTime, HttpServletRequest request) { - if (TIMER_LOGGER.isDebugEnabled()) { - Locale locale = RequestContextUtils.getLocale(request); - long endNanoTime = System.nanoTime(); - - long elapsed = endNanoTime - startNanoTime; - long elapsedMs = elapsed / NANO_PER_SECOND; - TIMER_LOGGER - .debug("Pebble template \"{}\" with locale {} processed in {} nanoseconds (approx. {}ms)", - this.templateName, locale, elapsed, elapsedMs); - } - } - - public void setCharacterEncoding(String characterEncoding) { - this.characterEncoding = characterEncoding; - } - - public void setPebbleEngine(PebbleEngine pebbleEngine) { - this.pebbleEngine = pebbleEngine; - } - - public void setTemplateName(String name) { - this.templateName = name; - } -} \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/PebbleViewResolver.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/PebbleViewResolver.java deleted file mode 100644 index b5328cd40..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/PebbleViewResolver.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4; - -import com.mitchellbosecke.pebble.PebbleEngine; -import com.mitchellbosecke.pebble.loader.Loader; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Required; -import org.springframework.web.servlet.view.AbstractTemplateViewResolver; -import org.springframework.web.servlet.view.AbstractUrlBasedView; - -public class PebbleViewResolver extends AbstractTemplateViewResolver implements InitializingBean { - - private String characterEncoding = "UTF-8"; - private PebbleEngine pebbleEngine; - - public PebbleViewResolver() { - this.setViewClass(this.requiredViewClass()); - } - - @Override - public void afterPropertiesSet() { - Loader templateLoader = this.pebbleEngine.getLoader(); - templateLoader.setPrefix(this.getPrefix()); - templateLoader.setSuffix(this.getSuffix()); - } - - public void setCharacterEncoding(String characterEncoding) { - this.characterEncoding = characterEncoding; - } - - @Required - public void setPebbleEngine(PebbleEngine pebbleEngine) { - this.pebbleEngine = pebbleEngine; - } - - @Override - protected AbstractUrlBasedView buildView(String viewName) throws Exception { - PebbleView view = (PebbleView) super.buildView(viewName); - view.setTemplateName(viewName); - view.setPebbleEngine(this.pebbleEngine); - view.setCharacterEncoding(this.characterEncoding); - - return view; - } - - @Override - protected Class requiredViewClass() { - return PebbleView.class; - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/context/Beans.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/context/Beans.java deleted file mode 100644 index 920aecf60..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/context/Beans.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.context; - -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import org.springframework.context.ApplicationContext; -import org.springframework.util.Assert; - -/** - *

- * Special object made available to templates in Spring MVC applications in order to access beans in - * the Application Context. - *

- * - * @author Eric Bussieres - */ -public class Beans implements Map { - - private final ApplicationContext ctx; - - public Beans(ApplicationContext ctx) { - Assert.notNull(ctx, "Application Context cannot be null"); - this.ctx = ctx; - } - - @Override - public void clear() { - throw new UnsupportedOperationException("Method \"clear\" not supported in Beans object"); - } - - @Override - public boolean containsKey(Object key) { - Assert.notNull(key, "Key cannot be null"); - return this.ctx.containsBean(key.toString()); - } - - @Override - public boolean containsValue(Object value) { - throw new UnsupportedOperationException( - "Method \"containsValue\" not supported in Beans object"); - } - - @Override - public Set> entrySet() { - throw new UnsupportedOperationException("Method \"entrySet\" not supported in Beans object"); - } - - @Override - public Object get(Object key) { - Assert.notNull(key, "Key cannot be null"); - return this.ctx.getBean(key.toString()); - } - - @Override - public boolean isEmpty() { - return this.size() <= 0; - } - - @Override - public Set keySet() { - return new LinkedHashSet<>(Arrays.asList(this.ctx.getBeanDefinitionNames())); - } - - @Override - public Object put(String key, Object value) { - throw new UnsupportedOperationException("Method \"put\" not supported in Beans object"); - } - - @Override - public void putAll(Map m) { - throw new UnsupportedOperationException("Method \"putAll\" not supported in Beans object"); - } - - @Override - public Object remove(Object key) { - throw new UnsupportedOperationException("Method \"remove\" not supported in Beans object"); - } - - @Override - public int size() { - return this.ctx.getBeanDefinitionCount(); - } - - @Override - public Collection values() { - throw new UnsupportedOperationException("Method \"values\" not supported in Beans object"); - } - -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/SpringExtension.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/SpringExtension.java deleted file mode 100644 index 3dd821a63..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/SpringExtension.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension; - -import com.mitchellbosecke.pebble.extension.AbstractExtension; -import com.mitchellbosecke.pebble.extension.Function; -import com.mitchellbosecke.pebble.spring4.extension.function.HrefFunction; -import com.mitchellbosecke.pebble.spring4.extension.function.MessageSourceFunction; -import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.GetAllErrorsFunction; -import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.GetFieldErrorsFunction; -import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.GetGlobalErrorsFunction; -import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.HasErrorsFunction; -import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.HasFieldErrorsFunction; -import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.HasGlobalErrorsFunction; -import java.util.HashMap; -import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; - -/** - *

- * Extension for PebbleEngine to add spring functionality - *

- * - * @author Eric Bussieres - */ -public class SpringExtension extends AbstractExtension { - - @Autowired - private MessageSource messageSource; - - @Override - public Map getFunctions() { - Map functions = new HashMap<>(); - functions - .put(MessageSourceFunction.FUNCTION_NAME, new MessageSourceFunction(this.messageSource)); - functions.put(HasErrorsFunction.FUNCTION_NAME, new HasErrorsFunction()); - functions.put(HasGlobalErrorsFunction.FUNCTION_NAME, new HasGlobalErrorsFunction()); - functions.put(HasFieldErrorsFunction.FUNCTION_NAME, new HasFieldErrorsFunction()); - functions.put(GetAllErrorsFunction.FUNCTION_NAME, new GetAllErrorsFunction(this.messageSource)); - functions.put(GetGlobalErrorsFunction.FUNCTION_NAME, - new GetGlobalErrorsFunction(this.messageSource)); - functions - .put(GetFieldErrorsFunction.FUNCTION_NAME, new GetFieldErrorsFunction(this.messageSource)); - functions.put(HrefFunction.FUNCTION_NAME, new HrefFunction()); - return functions; - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/HrefFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/HrefFunction.java deleted file mode 100644 index e41b9a76d..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/HrefFunction.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.mitchellbosecke.pebble.spring4.extension.function; - -import com.mitchellbosecke.pebble.extension.Function; -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; - -import org.springframework.util.StringUtils; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -/** - * Pebble function which adds the context path to the given url - * - * @author Eric Bussieres - */ -public class HrefFunction implements Function { - - public static final String FUNCTION_NAME = "href"; - - protected static final String PARAM_URL = "url"; - - protected List argumentNames; - private String contextPath; - - /** - * Constructor - */ - public HrefFunction() { - this.argumentNames = new ArrayList<>(); - this.argumentNames.add(PARAM_URL); - } - - /** - * {@inheritDoc} - * - * @see com.mitchellbosecke.pebble.extension.Function#execute(Map, PebbleTemplate, - * EvaluationContext, int) - */ - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, - int lineNumber) { - StringBuffer result = new StringBuffer(); - - result.append(this.getContextPath()); - this.addUrlParameter(args, result); - - return result.toString(); - } - - private void addUrlParameter(Map args, StringBuffer result) { - String url = (String) args.get(PARAM_URL); - if (StringUtils.hasText(url)) { - result.append(url); - } - } - - private String getContextPath() { - if (this.contextPath == null) { - this.contextPath = this.getRequest().getContextPath(); - } - return this.contextPath; - } - - private HttpServletRequest getRequest() { - ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes(); - return attr.getRequest(); - } - - /** - * {@inheritDoc} - * - * @see com.mitchellbosecke.pebble.extension.NamedArguments#getArgumentNames() - */ - @Override - public List getArgumentNames() { - return this.argumentNames; - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/MessageSourceFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/MessageSourceFunction.java deleted file mode 100644 index 84bc7e3f5..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/MessageSourceFunction.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension.function; - -import com.mitchellbosecke.pebble.extension.Function; -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.springframework.context.MessageSource; - -/** - *

- * Function available to templates in Spring MVC applications in order to resolve message in the - * application context - *

- * - * @author Eric Bussieres - */ -public class MessageSourceFunction implements Function { - - public static final String FUNCTION_NAME = "message"; - - private final MessageSource messageSource; - - public MessageSourceFunction(MessageSource messageSource) { - this.messageSource = messageSource; - } - - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, - int lineNumber) { - String key = this.extractKey(args); - List arguments = this.extractArguments(args); - Locale locale = context.getLocale(); - - return this.messageSource.getMessage(key, arguments.toArray(), "???" + key + "???", locale); - } - - private String extractKey(Map args) { - return (String) args.get("0"); - } - - private List extractArguments(Map args) { - int i = 1; - List arguments = new ArrayList<>(); - while (args.containsKey(String.valueOf(i))) { - Object param = args.get(String.valueOf(i)); - arguments.add(param); - i++; - } - return arguments; - } - - @Override - public List getArgumentNames() { - return null; - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/BaseBindingResultFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/BaseBindingResultFunction.java deleted file mode 100644 index 0a4c25e43..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/BaseBindingResultFunction.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension.function.bindingresult; - -import com.mitchellbosecke.pebble.extension.Function; -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.GlobalContext; - -import org.springframework.validation.BindingResult; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Base class of the function interacting with the BindingResult - * - * @author Eric Bussieres - */ -public abstract class BaseBindingResultFunction implements Function { - - protected static final String PARAM_FIELD_NAME = "fieldName"; - protected static final String PARAM_FORM_NAME = "formName"; - - private final List argumentNames = new ArrayList<>(); - - protected BaseBindingResultFunction(String... argumentsName) { - Collections.addAll(this.argumentNames, argumentsName); - } - - @Override - public List getArgumentNames() { - return this.argumentNames; - } - - protected BindingResult getBindingResult(String formName, EvaluationContext context) { - String attribute = BindingResult.MODEL_KEY_PREFIX + formName; - BindingResult bindingResult = (BindingResult) context.getVariable(attribute); - if (bindingResult == null) { - GlobalContext globalContext = (GlobalContext) context.getVariable("_context"); - if (globalContext != null) { - return (BindingResult) globalContext.get(attribute); - } - } - return bindingResult; - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetAllErrorsFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetAllErrorsFunction.java deleted file mode 100644 index cf3565cbb..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetAllErrorsFunction.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension.function.bindingresult; - -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.springframework.context.MessageSource; -import org.springframework.validation.BindingResult; -import org.springframework.validation.ObjectError; - -/** - *

- * Function available to templates in Spring MVC applications in order to access the BindingResult - * of a form - *

- * - * @author Eric Bussieres - */ -public class GetAllErrorsFunction extends BaseBindingResultFunction { - - public static final String FUNCTION_NAME = "getAllErrors"; - - private final MessageSource messageSource; - - public GetAllErrorsFunction(MessageSource messageSource) { - super(PARAM_FORM_NAME); - this.messageSource = messageSource; - } - - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, - int lineNumber) { - String formName = (String) args.get(PARAM_FORM_NAME); - - Locale locale = context.getLocale(); - BindingResult bindingResult = this.getBindingResult(formName, context); - - return this.constructErrorMessage(locale, bindingResult); - } - - private List constructErrorMessage(Locale locale, BindingResult bindingResult) { - List errorMessages = new ArrayList<>(); - if (bindingResult != null) { - for (ObjectError error : bindingResult.getAllErrors()) { - String msg = this.messageSource.getMessage(error, locale); - errorMessages.add(msg); - } - } - return errorMessages; - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetFieldErrorsFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetFieldErrorsFunction.java deleted file mode 100644 index a423a8691..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetFieldErrorsFunction.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension.function.bindingresult; - -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.springframework.context.MessageSource; -import org.springframework.validation.BindingResult; -import org.springframework.validation.FieldError; - -/** - *

- * Function available to templates in Spring MVC applications in order to access the BindingResult - * of a form - *

- * - * @author Eric Bussieres - */ -public class GetFieldErrorsFunction extends BaseBindingResultFunction { - - public static final String FUNCTION_NAME = "getFieldErrors"; - - private final MessageSource messageSource; - - public GetFieldErrorsFunction(MessageSource messageSource) { - super(PARAM_FORM_NAME, PARAM_FIELD_NAME); - this.messageSource = messageSource; - } - - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, - int lineNumber) { - String formName = (String) args.get(PARAM_FORM_NAME); - String field = (String) args.get(PARAM_FIELD_NAME); - - if (field == null) { - throw new IllegalArgumentException("Field parameter is required in GetFieldErrorsFunction"); - } - - Locale locale = context.getLocale(); - BindingResult bindingResult = this.getBindingResult(formName, context); - - return this.constructErrorMessages(field, locale, bindingResult); - } - - private List constructErrorMessages(String field, Locale locale, - BindingResult bindingResult) { - List errorMessages = new ArrayList<>(); - if (bindingResult != null) { - for (FieldError error : bindingResult.getFieldErrors(field)) { - String msg = this.messageSource.getMessage(error, locale); - errorMessages.add(msg); - } - } - return errorMessages; - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetGlobalErrorsFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetGlobalErrorsFunction.java deleted file mode 100644 index a9080ff51..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/GetGlobalErrorsFunction.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension.function.bindingresult; - -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.springframework.context.MessageSource; -import org.springframework.validation.BindingResult; -import org.springframework.validation.ObjectError; - -/** - *

- * Function available to templates in Spring MVC applications in order to access the BindingResult - * of a form - *

- * - * @author Eric Bussieres - */ -public class GetGlobalErrorsFunction extends BaseBindingResultFunction { - - public static final String FUNCTION_NAME = "getGlobalErrors"; - - private final MessageSource messageSource; - - public GetGlobalErrorsFunction(MessageSource messageSource) { - super(PARAM_FORM_NAME); - this.messageSource = messageSource; - } - - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, - int lineNumber) { - String formName = (String) args.get(PARAM_FORM_NAME); - - Locale locale = context.getLocale(); - BindingResult bindingResult = this.getBindingResult(formName, context); - - return this.constructErrorMessages(locale, bindingResult); - } - - private List constructErrorMessages(Locale locale, BindingResult bindingResult) { - List errorMessages = new ArrayList<>(); - if (bindingResult != null) { - for (ObjectError error : bindingResult.getGlobalErrors()) { - String msg = this.messageSource.getMessage(error, locale); - errorMessages.add(msg); - } - } - return errorMessages; - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasErrorsFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasErrorsFunction.java deleted file mode 100644 index 326dfc840..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasErrorsFunction.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension.function.bindingresult; - -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.util.Map; -import org.springframework.validation.BindingResult; - -/** - *

- * Function available to templates in Spring MVC applications in order to access the BindingResult - * of a form - *

- * - * @author Eric Bussieres - */ -public class HasErrorsFunction extends BaseBindingResultFunction { - - public static final String FUNCTION_NAME = "hasErrors"; - - public HasErrorsFunction() { - super(PARAM_FORM_NAME); - } - - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, - int lineNumber) { - String formName = (String) args.get(PARAM_FORM_NAME); - - BindingResult bindingResult = this.getBindingResult(formName, context); - return bindingResult != null && bindingResult.hasErrors(); - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasFieldErrorsFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasFieldErrorsFunction.java deleted file mode 100644 index cea02b499..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasFieldErrorsFunction.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension.function.bindingresult; - -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.util.Map; -import org.springframework.validation.BindingResult; - -/** - *

- * Function available to templates in Spring MVC applications in order to access the BindingResult - * of a form - *

- * - * @author Eric Bussieres - */ -public class HasFieldErrorsFunction extends BaseBindingResultFunction { - - public static final String FUNCTION_NAME = "hasFieldErrors"; - - public HasFieldErrorsFunction() { - super(PARAM_FORM_NAME, PARAM_FIELD_NAME); - } - - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, - int lineNumber) { - String formName = (String) args.get(PARAM_FORM_NAME); - String fieldName = (String) args.get(PARAM_FIELD_NAME); - - BindingResult bindingResult = this.getBindingResult(formName, context); - - if (bindingResult != null) { - if (fieldName == null) { - return bindingResult.hasFieldErrors(); - } else { - return bindingResult.hasFieldErrors(fieldName); - } - } else { - return false; - } - } -} diff --git a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasGlobalErrorsFunction.java b/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasGlobalErrorsFunction.java deleted file mode 100644 index 60786ff4a..000000000 --- a/pebble-spring/pebble-spring4/src/main/java/com/mitchellbosecke/pebble/spring4/extension/function/bindingresult/HasGlobalErrorsFunction.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.extension.function.bindingresult; - -import com.mitchellbosecke.pebble.template.EvaluationContext; -import com.mitchellbosecke.pebble.template.PebbleTemplate; -import java.util.Map; -import org.springframework.validation.BindingResult; - -/** - *

- * Function available to templates in Spring MVC applications in order to access the BindingResult - * of a form - *

- * - * @author Eric Bussieres - */ -public class HasGlobalErrorsFunction extends BaseBindingResultFunction { - - public static final String FUNCTION_NAME = "hasGlobalErrors"; - - public HasGlobalErrorsFunction() { - super(PARAM_FORM_NAME); - } - - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, - int lineNumber) { - String formName = (String) args.get(PARAM_FORM_NAME); - - BindingResult bindingResult = this.getBindingResult(formName, context); - return bindingResult != null && bindingResult.hasGlobalErrors(); - } -} diff --git a/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/PebbleViewResolverTest.java b/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/PebbleViewResolverTest.java deleted file mode 100644 index cf3dd71e8..000000000 --- a/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/PebbleViewResolverTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4; - -import com.mitchellbosecke.pebble.spring4.config.MVCConfig; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.validation.BindingResult; -import org.springframework.validation.FieldError; -import org.springframework.validation.ObjectError; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.servlet.ViewResolver; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * Unit test for the PebbleViewResolver - * - * @author Eric Bussieres - */ -@RunWith(SpringJUnit4ClassRunner.class) -@WebAppConfiguration -@ContextConfiguration(classes = {MVCConfig.class}) -public class PebbleViewResolverTest { - - private static final String CONTEXT_PATH = "/testContextPath"; - private static final Locale DEFAULT_LOCALE = Locale.CANADA; - private static final String EXPECTED_RESPONSE_PATH = "/com/mitchellbosecke/pebble/spring4/expectedResponse"; - private static final String FORM_NAME = "formName"; - - private BindingResult mockBindingResult = mock(BindingResult.class); - private MockHttpServletRequest mockRequest = new MockHttpServletRequest(); - private MockHttpServletResponse mockResponse = new MockHttpServletResponse(); - - @Autowired - private ViewResolver viewResolver; - - @Before - public void initRequest() { - this.mockRequest.setContextPath(CONTEXT_PATH); - this.mockRequest.getSession().setMaxInactiveInterval(600); - - RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(this.mockRequest)); - } - - @Before - public void initBindingResult() { - this.initBindingResultAllErrors(); - this.initBindingResultGlobalErrors(); - this.initBindingResultFieldErrors(); - } - - private void initBindingResultAllErrors() { - when(this.mockBindingResult.hasErrors()).thenReturn(true); - - List allErrors = new ArrayList<>(); - allErrors.add( - new ObjectError(FORM_NAME, new String[]{"error.test"}, new String[]{}, "???error.test???")); - when(this.mockBindingResult.getAllErrors()).thenReturn(allErrors); - } - - private void initBindingResultGlobalErrors() { - when(this.mockBindingResult.hasGlobalErrors()).thenReturn(true); - - List globalErrors = new ArrayList<>(); - globalErrors.add(new ObjectError(FORM_NAME, new String[]{"error.global.test.params"}, - new String[]{"param1", "param2"}, "???error.global.test.params???")); - when(this.mockBindingResult.getGlobalErrors()).thenReturn(globalErrors); - } - - private void initBindingResultFieldErrors() { - when(this.mockBindingResult.hasFieldErrors("testField")).thenReturn(true); - - List fieldErrors = new ArrayList<>(); - fieldErrors.add( - new FieldError(FORM_NAME, "testField", null, false, new String[]{"error.field.test.params"}, - new String[]{"param1", "param2"}, "???error.field.test.params???")); - when(this.mockBindingResult.getFieldErrors("testField")).thenReturn(fieldErrors); - } - - @Test - public void whenRenderingAPage_givenPageWithBeanVariable_thenRenderingIsOK() throws Exception { - String result = this.render("beansTest", new HashMap()); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/beansTest.html"); - } - - @Test - public void whenRenderingAPage_givenPageWithBindingResult_thenRenderingIsOK() throws Exception { - Map model = this.givenBindingResult(); - - String result = this.render("bindingResultTest", model); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/bindingResultTest.html"); - } - - private Map givenBindingResult() { - Map model = new HashMap<>(); - model.put(BindingResult.MODEL_KEY_PREFIX + FORM_NAME, this.mockBindingResult); - return model; - } - - @Test - public void whenRenderingAPage_givenPageWithBindingResultAndMacro_thenRenderingIsOK() throws Exception { - Map model = this.givenBindingResult(); - - String result = this.render("bindingResultWithMacroTest", model); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/bindingResultWithMacroTest.html"); - } - - @Test - public void whenRenderingAPage_givenPageWithHrefFunction_thenRenderingIsOK() throws Exception { - String result = this.render("hrefFunctionTest", new HashMap()); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/hrefFunctionTest.html"); - } - - @Test - public void whenRenderingAPageInEnglish_givenPageWithResourceBundleMessage_thenRenderingIsOK() - throws Exception { - String result = this.render("messageEnTest", new HashMap()); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/messageEnTest.html"); - } - - @Test - public void whenRenderingAPageInFrench_givenPageWithResourceBundleMessage_thenRenderingIsOK() - throws Exception { - this.mockRequest.addPreferredLocale(Locale.CANADA_FRENCH); - - String result = this.render("messageFrTest", new HashMap()); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/messageFrTest.html"); - } - - @Test - public void whenRenderingAPage_givenPageWithHttpRequestVariable_thenRenderingIsOK() - throws Exception { - String result = this.render("requestTest", new HashMap()); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/requestTest.html"); - } - - @Test - public void whenRenderingAPage_givenPageWithHttpResponseVariable_thenRenderingIsOK() - throws Exception { - String result = this.render("responseTest", new HashMap()); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/responseTest.html"); - } - - @Test - public void whenRenderingAPage_givenPageWithHttpSessionVariable_thenRenderingIsOK() - throws Exception { - String result = this.render("sessionTest", new HashMap()); - - this.assertOutput(result, EXPECTED_RESPONSE_PATH + "/sessionTest.html"); - } - - private void assertOutput(String output, String expectedOutput) throws IOException { - assertEquals(this.readExpectedOutputResource(expectedOutput), output.replaceAll("\\s", "")); - } - - private String readExpectedOutputResource(String expectedOutput) throws IOException { - BufferedReader reader = new BufferedReader( - new InputStreamReader(this.getClass().getResourceAsStream(expectedOutput))); - - StringBuilder builder = new StringBuilder(); - for (String currentLine = reader.readLine(); currentLine != null; - currentLine = reader.readLine()) { - builder.append(currentLine); - } - - return this.removeAllWhitespaces(builder.toString()); - } - - private String removeAllWhitespaces(String source) { - return source.replaceAll("\\s", ""); - } - - private String render(String location, Map model) throws Exception { - this.viewResolver.resolveViewName(location, DEFAULT_LOCALE) - .render(model, this.mockRequest, this.mockResponse); - return this.mockResponse.getContentAsString(); - } -} diff --git a/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/bean/SomeBean.java b/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/bean/SomeBean.java deleted file mode 100644 index a678922a9..000000000 --- a/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/bean/SomeBean.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.bean; - -/** - * Spring bean for unit test - * - * @author Eric Bussieres - */ -public class SomeBean { - - public String foo() { - return "foo"; - } -} diff --git a/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/config/MVCConfig.java b/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/config/MVCConfig.java deleted file mode 100644 index 9cd0eb40d..000000000 --- a/pebble-spring/pebble-spring4/src/test/java/com/mitchellbosecke/pebble/spring4/config/MVCConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2013 by Mitchell Bösecke - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -package com.mitchellbosecke.pebble.spring4.config; - -import com.mitchellbosecke.pebble.PebbleEngine; -import com.mitchellbosecke.pebble.loader.ClasspathLoader; -import com.mitchellbosecke.pebble.loader.Loader; -import com.mitchellbosecke.pebble.spring4.PebbleViewResolver; -import com.mitchellbosecke.pebble.spring4.bean.SomeBean; -import com.mitchellbosecke.pebble.spring4.extension.SpringExtension; -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.web.servlet.ViewResolver; - -/** - * Spring configuration for unit test - * - * @author Eric Bussieres - */ -@Configuration -public class MVCConfig { - - @Bean - public SomeBean foo() { - return new SomeBean(); - } - - @Bean - public MessageSource messageSource() { - ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); - messageSource.setBasename("com.mitchellbosecke.pebble.spring4.messages"); - - return messageSource; - } - - @Bean - public PebbleEngine pebbleEngine(SpringExtension springExtension) { - return new PebbleEngine.Builder() - .loader(this.templateLoader()) - .strictVariables(false) - .extension(springExtension) - .build(); - } - - @Bean - public SpringExtension springExtension() { - return new SpringExtension(); - } - - @Bean - public Loader templateLoader() { - return new ClasspathLoader(); - } - - @Bean - public ViewResolver viewResolver(PebbleEngine pebbleEngine) { - PebbleViewResolver viewResolver = new PebbleViewResolver(); - viewResolver.setPrefix("com/mitchellbosecke/pebble/spring4/template/"); - viewResolver.setSuffix(".html"); - viewResolver.setPebbleEngine(pebbleEngine); - viewResolver.setContentType("text/html"); - return viewResolver; - } -} diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/beansTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/beansTest.html deleted file mode 100644 index d4e7ab655..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/beansTest.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - foo - - - - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/bindingResultTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/bindingResultTest.html deleted file mode 100644 index d48671b3e..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/bindingResultTest.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - test - - - -true -true -true - -false -false -false - -Some error -Some global error with params param1 and param2 -Some field error with params param1 and param2 - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/bindingResultWithMacroTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/bindingResultWithMacroTest.html deleted file mode 100644 index d48671b3e..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/bindingResultWithMacroTest.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - test - - - -true -true -true - -false -false -false - -Some error -Some global error with params param1 and param2 -Some field error with params param1 and param2 - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/hrefFunctionTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/hrefFunctionTest.html deleted file mode 100644 index 02d2040e0..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/hrefFunctionTest.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - test - - - -HrefFunction string interpolation = /testContextPath/foo -HrefFunction static = /testContextPath/foobar -HrefFunction expression = /testContextPath/foo - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/messageEnTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/messageEnTest.html deleted file mode 100644 index 8e8c535a8..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/messageEnTest.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - test - - - -Label = Some label -Label with params = Some label with params params1 and params2 - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/messageFrTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/messageFrTest.html deleted file mode 100644 index c94d10eea..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/messageFrTest.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - test - - - -Label = Un libellé -Label with params = Un libellé avec les paramètres params1 et params2 - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/requestTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/requestTest.html deleted file mode 100644 index e5db6c754..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/requestTest.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - test - - - -Context path = /testContextPath - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/responseTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/responseTest.html deleted file mode 100644 index b50bcdb8d..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/responseTest.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - test - - - -Response contentType = text/html -Response character encoding = UTF-8 - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/sessionTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/sessionTest.html deleted file mode 100644 index 71313d1a1..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/expectedResponse/sessionTest.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - test - - - -Session maxInactiveInterval = 600 - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/messages_en.properties b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/messages_en.properties deleted file mode 100644 index 83bd8f773..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/messages_en.properties +++ /dev/null @@ -1,5 +0,0 @@ -label.test=Some label -label.test.params=Some label with params {0} and {1} -error.test=Some error -error.global.test.params=Some global error with params {0} and {1} -error.field.test.params=Some field error with params {0} and {1} \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/messages_fr.properties b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/messages_fr.properties deleted file mode 100644 index 24c990fd7..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/messages_fr.properties +++ /dev/null @@ -1,5 +0,0 @@ -label.test=Un libell� -label.test.params=Un libell� avec les param�tres {0} et {1} -error.test=Une erreur -error.global.test.params=Une erreur globale avec les param�tres {0} et {1} -error.field.test.params=Une erreur sur un champ avec les param�tres {0} et {1} \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/beansTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/beansTest.html deleted file mode 100644 index acc8a913b..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/beansTest.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - {{ beans.foo.foo() }} - - - - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/bindingResultTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/bindingResultTest.html deleted file mode 100644 index 3df8bdf4c..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/bindingResultTest.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - test - - - -{{ hasErrors('formName') }} -{{ hasGlobalErrors('formName') }} -{{ hasFieldErrors('formName', 'testField') }} - -{{ hasErrors('') }} -{{ hasGlobalErrors('') }} -{{ hasFieldErrors('formName', '') }} - -{% for err in getAllErrors('formName') %}{{ err }}{% endfor %} -{% for err in getGlobalErrors('formName') %}{{ err }}{% endfor %} -{% for err in getFieldErrors('formName', 'testField') %}{{ err }}{% endfor %} - -{% for err in getAllErrors('') %}{{ err }}{% endfor %} -{% for err in getGlobalErrors('') %}{{ err }}{% endfor %} -{% for err in getFieldErrors('', 'testField') %}{{ err }}{% endfor %} -{% for err in getFieldErrors('formName', '') %}{{ err }}{% endfor %} - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/bindingResultWithMacroTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/bindingResultWithMacroTest.html deleted file mode 100644 index d60aa6c1d..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/bindingResultWithMacroTest.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - test - - - -{{ test(_context) }} -{% macro test(_context) %} - {{ hasErrors('formName') }} - {{ hasGlobalErrors('formName') }} - {{ hasFieldErrors('formName', 'testField') }} - - {{ hasErrors('') }} - {{ hasGlobalErrors('') }} - {{ hasFieldErrors('formName', '') }} - - {% for err in getAllErrors('formName') %}{{ err }}{% endfor %} - {% for err in getGlobalErrors('formName') %}{{ err }}{% endfor %} - {% for err in getFieldErrors('formName', 'testField') %}{{ err }}{% endfor %} - - {% for err in getAllErrors('') %}{{ err }}{% endfor %} - {% for err in getGlobalErrors('') %}{{ err }}{% endfor %} - {% for err in getFieldErrors('', 'testField') %}{{ err }}{% endfor %} - {% for err in getFieldErrors('formName', '') %}{{ err }}{% endfor %} -{% endmacro %} - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/hrefFunctionTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/hrefFunctionTest.html deleted file mode 100644 index 9c6781027..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/hrefFunctionTest.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - test - - - -HrefFunction string interpolation = {{ href("/#{beans.foo.foo}") }} -HrefFunction static = {{ href('/foobar') }} -HrefFunction expression = {{ href('/' + beans.foo.foo) }} - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/messageEnTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/messageEnTest.html deleted file mode 100644 index db8f0ff96..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/messageEnTest.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - test - - - -Label = {{ message('label.test') }} -Label with params = {{ message('label.test.params', 'params1', 'params2') }} - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/messageFrTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/messageFrTest.html deleted file mode 100644 index db8f0ff96..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/messageFrTest.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - test - - - -Label = {{ message('label.test') }} -Label with params = {{ message('label.test.params', 'params1', 'params2') }} - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/requestTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/requestTest.html deleted file mode 100644 index 36bae1c17..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/requestTest.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - test - - - -Context path = {{ request.contextPath }} - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/responseTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/responseTest.html deleted file mode 100644 index d468d1ee9..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/responseTest.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - test - - - -Response contentType = {{ response.contentType }} -Response character encoding = {{ response.characterEncoding }} - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/sessionTest.html b/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/sessionTest.html deleted file mode 100644 index 856fd1113..000000000 --- a/pebble-spring/pebble-spring4/src/test/resources/com/mitchellbosecke/pebble/spring4/template/sessionTest.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - test - - - -Session maxInactiveInterval = {{ session.maxInactiveInterval }} - - \ No newline at end of file diff --git a/pebble-spring/pebble-spring5/pom.xml b/pebble-spring/pebble-spring5/pom.xml index 0d88cca66..f66384873 100644 --- a/pebble-spring/pebble-spring5/pom.xml +++ b/pebble-spring/pebble-spring5/pom.xml @@ -15,9 +15,9 @@ 3.1.0 - 5.3.3 - 3.1.0 - 5.5.2 + 5.3.23 + 4.8.0 + 5.9.1 diff --git a/pebble-spring/pom.xml b/pebble-spring/pom.xml index c54a1545f..54734b028 100644 --- a/pebble-spring/pom.xml +++ b/pebble-spring/pom.xml @@ -11,9 +11,7 @@ pom - pebble-spring4 pebble-spring5 - pebble-legacy-spring-boot-starter pebble-spring-boot-starter From cd56a1d2a054ae32de75da770cd967d8ed8880da Mon Sep 17 00:00:00 2001 From: Eric Bussieres Date: Wed, 21 Sep 2022 13:54:58 -0400 Subject: [PATCH 2/2] Update travis-ci JDK --- .travis.yml | 1 - pebble/CHANGELOG.md | 328 -------------------------------------------- 2 files changed, 329 deletions(-) delete mode 100644 pebble/CHANGELOG.md diff --git a/.travis.yml b/.travis.yml index ea05cdff4..864e3f765 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ language: java jdk: - openjdk8 - openjdk11 - - openjdk14 after_success: - export VERSION=$(echo "cat //*[local-name()='project']/*[local-name()='version']/text()" | xmllint --nocdata --shell pom.xml | sed '1d;$d') diff --git a/pebble/CHANGELOG.md b/pebble/CHANGELOG.md deleted file mode 100644 index ce49d2525..000000000 --- a/pebble/CHANGELOG.md +++ /dev/null @@ -1,328 +0,0 @@ -## v3.0.5 (2018-09-30) -- Cannot access List methods (#402) -- Implement to boolean smart-casting in OR and AND operators (#405) - -## v3.0.4 (2018-09-09) -- Make NOT operator more tolerant to argument type (#394) -- Make ternary if operator more tolerant to argument type (#399) -- Adjust AndExpression and OrExpression logic (#398) -- Add JSON escaping as part of the default escaping strategies (#395) - -## v3.0.3 (2018-08-26) -- Support more expressions for `if` operator (#387) -- Consider adding greedyMatchMethod to PebbleProperties (#388) -- Use locale from context for lower/upper filter (#390) -- Restore cache:invalidateAll method (#393) - -## v3.0.2 (2018-08-11) -- Add PebbleCache interface and use ConcurrentMap instead of Caffeine as default template/tag cache (#381) -- Use unbescape instead of Coverity Escapers (#380) - -## v3.0.1 (2018-07-26) -- Macros are restricted to a local scope (#371) -- Macros have access to global attributes via "_context" variable (#242) - -## v3.0.0 (2018-07-13) -- Java 8 -- Macros have access to all variables within the template and are no longer restricted to a "local scope" -- New signature for filters/functions/tests that accepts the PebbleTemplate, EvaluationContext, and line number -- Converted EvaluationContext to an interface with limited access to the underlying implementation -- A "null" used as a boolean expression now throws an error if strict variables is true, treated as "false" otherwise -- Improved error reporting -- Java8 Date API support on date filter -- Replace guava cache with caffeine -- Add String Interpolation (#235) -- Add the possibility to extend attribute access (#258) -- Remove DynamicAttributeProvider -- Render content on demand. Expose getLiteralTemplate(String templateName) (#295) -- Introduce SpecializedWriter, (#358) -- Many performance enhancements -- Method resolution with overloaded method signatures (#367) -- Use AbstractTemplateViewResolverProperties for spring-boot (#369) - -## v2.6.2 -- loop.length and loop.revindex is not of type Number (#362) - -## v2.6.1 -- Implement [java.util.Long] timestamp argument support in date filter (#346) -- Handle strict mode when accessing map attribute (#356) - -## v2.6.0 (2018-05-20) -- Add support for 'as' and 'from' in import statement (#271) -- Add support for spring-boot-2 (#340) -- Supports empty collection for first filter (#342) -- Add options for literal number types and method finding strategy (#268) - - support L type suffix for literal number which will be treated as Long, such as '123L'. - - Add literalDecimalTreatedAsInteger option for toggling to enable/disable literal decimal treated as integer. - - Add 'greedyMatchMethod' option for toggling to enable/disable greedy matching mode for finding java method. Reduce the limit of the parameter type, try to find other method which has compatible parameter types. - -## v2.5.1 (2018-05-04) -- Bugfix introduced when accessing getClass which will always return null (#338) - -## v2.5.0 (2018-05-02) -- Handle all Iterables and Arrays in JoinFilter (#273) -- Fix NPE in GetAttributeExpression (#299) -- Remove redundant null check before calling operator "instanceof" in OperatorUtils. (#298) -- Handle null values passed to an include statement (#283) -- Fix performance regression issues (#326, #328) -- Add Reverse filter (#315) -- Make "loop.length" and "loop.revindex" be lazy evaluated (#279) -- Fixed security issue which allowed to execute shell command (by having access to Java's Class object) (#329) -- Throw ParserException when endBlock not found (#308) -- For tag : add enumeration support (#292) -- Fix operator precedence (#290) - -## v2.4.0 (2017-06-04) -- Add arrays support for iterable test (#254) -- Bugfix for variable which was accessible outside a loop (#250) -- Syntax builder return itself for method chaining (#259) -- Macros are called too often if included multiple times -- Fix potential null pointer exception in PebbleException (#243) -- Fix for accessing map via primitive (#196) -- Output filename and line number of non-existent macro -- Fix for null pointer and index out of bounds exceptions when invalid or no endif/endfor tags are used in template (#266) -- Add DynamicAttributeProvider interface. When implemented by an object, tells the expression parser that this object is able to provide attributes dynamically, given their names and the potential arguments(#230) -- Add rendering of single blocks, similar to the Twig renderBlock() method. - -## v2.3.0 (2016-11-13) -- Upgrade SLF4J from 1.6.1 to 1.7.21 -- "raw" filter works for all variables, not just strings -- Improved error reporting for binary operators -- Added setting to disable the trimming of newlines after pebble tags - -## v2.2.3 (2016-10-01) -- Bug fix: Fix the use of the "set" tag within a for loop -- Bug fix: Fix the concatenation of SafeString (ex. the output of two macros) -- Added misc getters to various internal nodes - -## v2.2.2 (2016-07-03) -- Improved error when attempting to iterate over a non-iterable object -- [Updates to pebble-spring-boot-starter](https://github.com/PebbleTemplates/pebble-spring-boot-starter/blob/master/CHANGELOG.md) - -## v2.2.1 (2016-03-28) -- **Security Fix**: Pebble was only escaping Strings; now it escapes the toString() output of all objects -- [Official spring4 extension](https://github.com/PebbleTemplates/pebble-spring4) -- [Official spring boot starter](https://github.com/PebbleTemplates/pebble-spring-boot-starter) -- Bug fix: ConcurrentModificationException when importing macros in nested parallel blocks -- Bug fix: Exceptions in parallel blocks were being swallowed -- Bug fix: Obtaining a dynamic attribute of a variable was being incorrectly cached -- Improved error reporting - - -## v2.2.0 (2016-03-06) -- Added "merge" filter -- Add support for strings to the "contains" operator -- Bug fix: Couldn't invoke methods that had boolean arguments -- Bug fix: Unexpected results when comparing the outputs of the "raw" filter - -## v2.1.0 (2016-01-31) -- Added method in PebbleEngine.Builder class to completely disable cache -- Improved error message with malformed ternary expression -- Bug fix: NPE when calling bean method will null argument -- Bug fix: relative paths were not platform agnostic -- Bug fix: slice filter failed on integer argument -- Bug fix: Pebble didn't work on GAE due to a restricted class in the JRE -- **Backwards incompatibility: Removed method on PebbleEngine.Builder to register a filter as safe and not requiring escaping. -The filter should return an instance of SafeString instead.** -- **Backwards incompatibility: Functions are now escaped unless they return instance of SafeString** - -### pebble-spring3 -* Spring beans are available in the evaluation context by default -* HTTP request is available in the evaluation context by default -* HTTP session is available in the evaluation context by default - - -## v2.0.0 (2015-12-13) -- Support for relative template paths -- Added a "cache" tag to cache portions of a template -- String concatenation with "~" operator -- Added two global variables into the context - - "locale": the current locale - - "template": reference to the actual template. Can be used to get the template name with {{ template.name }} -- "Length" filter -- "Replace" filter -- Support for parallel template parsing -- Additional loop variables: last, first, revindex -- "equals" support for enums -- Added a range function and ability to iterate over a range of characters/numbers -- Added support for BigDecimals -- Expressions are permitted within square bracket notation when accessing maps/arrays/lists -- Better error handling with more informative exceptions -- Ability to add extra variables to the context when "including" another template -- Bug fix: "defined" test did not work as expected in strict mode -- Bug fix: fixed broken "less than equal" comparison -- **Backwards incompatibility: "Included" templates run in their own dedicated scope and no longer affect the variables of the template that included it.** -- **Backwards incompatibility: Constructor for PebbleEngine is now private, must use PebbleEngine.Builder** -- **Backwards incompatibility: PebbleEngine is immutable once constructed** -- **Backwards incompatibility: Removed "getExtension" method from PebbleEngine, core extensions must be configured during construction of the PebbleEngine object** -- **Backwards incompatibility: Removed deprecated LocaleAware interface** -- **Backwards incompatibility: Extensions are now expected to return NodeVisitorFactory objects instead of NodeVisitors** - -## v1.6.0 (2015-09-06) -- Support for custom escaping strategies -- Support for calling bean methods with primitive argument types -- Bug fix: Fixed issue with delegating loader where it would only use last loader in list of children loaders. - -## v1.5.2 (2015-08-30) -- Added rsort filter -- i18n extension now supports dynamic variables -- Bug fix: Failure to subscript an array of primitive type -- Bug fix: Global variables were not accessible in template -- Bug fix: Removed invocation of Character.isAlphabetic which is not supported on older android APIs - -## v1.5.1 (2015-06-29) -- New runtime exception thrown if there's an error invoking a member found via reflection -- New constructor in ClasspathLoader that accepts a custom classloader -- Bug fix: Fixed path separator used in ClasspathLoader to work on Windows -- Bug fix: Fixed path separator used in ServletLoader to work on Windows - -## v1.5.0 (2015-06-07) -- Added array and map syntax - -## v1.4.5 (2015-04-17) -- Fixed stack overflow error when using multiple levels of the parent() function -- Fixed platform dependent issues with junit tests -- Bug fix regarding the use of different data types passed to same template which broke an internal cache in the GetAttributeExpression - -## v1.4.4 (2015-03-29) -- Bug fix regarding NPE with internal cache -- Bug fix when using suffix with the file loader - -## v1.4.3 (2015-03-01) -- Bug fix for issue regarding multiple for loops only rendering first one - -## v1.4.2 (2015-03-01) -- Performance improvements - -## v1.4.1 (2015-02-21) -- Performance improvements - -## v1.4.0 (2015-02-09) -- Added ServletLoader which is the only built-in loader that works with JBoss/Wildfly -- Added "first" filter -- Added "last" filter -- Added "join" filter - -## v1.3.1 (2015-01-24) -- Fixed lexing issue on windows -- Fixed number comparison issue - -## v1.3.0 (2014-12-08) -- Added "filter" tag -- Added "abs" filter -- Added "sort" filter -- Pebble now uses the exact Map implementation provided by user instead of moving variables into it's own map implementation. This allows for custom "lazy" maps and other unique implementations. -- Arrays and lists can now be accessed by index - -## v1.2.0 (2014-12-02) -- Added verbatim tag -- Removed the LocaleAware interface; filters/functions/tests now get the locale via the EvaluationContext that is passed as a "_context" argument in the argument map -- Added a whitespace control character: "-" -- Fixed bug where macros were being secretly evaluated one too many times - -## v1.1.0 (2014-10-09) -- The ability to call bean methods that require arguments. -- For loop now works with primitive arrays (i.e. no longer just Iterable objects). -- Added "subscript syntax" support for accessing attributes. -- Continuous integration with travis-ci. -- Fixed NPE occurring in ternary expressions. -- Fixed issue with if-then-else expressions -- General code and testing improvements. - -## v1.0.0 (2014-03-29) -- Some code cleanup and fixed an incorrect unit test. - -## v0.4.0-beta (2014-03-05) -- No more code generation, all nodes of the AST are rendered during template evaluation phase. - -## v0.3.0-beta (2014-02-22) -- Autoescaping, more escaping strategies, autoescape tag, and raw filter. -- Extensions can now provide node visitors to traverse the AST. -- Macros can have default argument values. -- Implemented dynamic inheritance. -- Renamed 'message' function to 'i18n' -- Fixed issue where compilation failed in JBoss. -- Code cleanup and misc small bugs - -## v0.2.0-beta (2014-02-08) -- Implemented named arguments. -- Added dependency on google guava for template cache. -- Split the default loader class into multiple discrete loaders. -- Added the `title` filter. -- Fixed issue where compilation mutex might not have been released. -- Fixed parsing issues if variable names were prefixed with operator names. -- Fixed issue where included templates didn't have access to context. -- Fixed issue where `if` tag could not be used directly on a boolean variable. -- Removed the `format` filter. -- Fixed misc other smaller bugs. - -## v0.1.5-beta (2014-01-27) -- Fixed major bug from v0.1.4 that prevented macros from being invoked more than once. - -## v0.1.4-beta (2014-01-27) -- The i18n extension is now enabled by default. -- Improved exception handling (storing cause where applicable). -- PebbleEngine now returns a PebbleTemplate interface with a small subset of original methods. -- Refactored function/filter/test interfaces into functional interfaces (preparation for Java 8). - -## v0.1.3-beta (2014-01-25) -- More unit tests and minor bug fixes. -- Fixed issue where child templates were being inappropriately cached. -- All core filters now perform null checking. -- Performance optimization with variable attributes. -- Renamed the number_format filter to numberformat - -## v0.1.2-beta (2014-01-19) -- Fixed issue where parent block didn’t have access to context. -- Macros no longer have access to context (only local vars). -- Fixed issue where macro output coudn’t be filtered/tested. -- Refactored how blocks and macros are implemented . -- Renamed number filter to number_format. -- Added a cache interface for user’s to provide their own cache. Also removed the “cacheTemplates” setting. -- Default cache is now thread safe. -- Templates can now be evaluated concurrently. -- Users can now safely attempt a concurrent compilation. -- Fixed issue where provided writer was being closed by pebble engine. -- Fixed memory leak in file manager. -- Removed json filter. -- Removed some third party dependencies. -- Added parallel tag. -- More unit tests and misc code cleanup. - -## v0.1.1-beta (2014-01-02) -- Fixed issue where templates of same name but different path were overriding each other in main template cache. -- Made sure byte code stored in memory in InMemoryJavaFileManager is cleared when no longer required. -- Removed caching of Reader objects from PebbleDefaultLoader which was causing more harm than good. This can be added back later if it is deemed necessary. -- Completely changed how operators are compiled into Java due to a bunch of bugs regarding operand types. -- Changed the behaviour of the == operator and added the equals operator as an alias. -- Extensions can now provide custom functions. -- Added source, min, and max functions. -- The setting, cacheTemplates, now defaults to true. -- Renamed the main entry points into the main Engine from “loadTemplate/render” to “compile/evaluate”. -- Added i18n extension (disabled by default) and a default locale setting on the main pebble engine. The extension adds one new function: message() -- Small performance improvements when looking up variable attributes. - -## v0.1.0-beta (2013-12-27) -- Refined PebbleEngine’s available public methods. -- Added “strictVariables” setting to PebbleEngine. -- Cleaned up how pebble-spring is to be configured. -- More bug fixes and unit tests. - -## v0.0.3-alpha (2013-11-17) -- Configuration changes in order to have the project hosted in the Maven Central Repository. - -## v0.0.2-alpha (2013-11-16) -- Dedicated website with documentation. -- Code refactoring, more unit tests, bug fixes. -- Conditional (ternary) operator. -- Escape filter. -- Macro overloading. - -## v0.0.1-alpha (2013-09-30) -This is the first functioning version of Pebble. The following has been implemented: -- tags: block, extends, for, if, import, include, macro, set -- filters: abbreviate, capitalize, date, default, format, json, lower, number, trim, upper, urlencode -- functions: block, parent -- tests: empty, even, null, odd, iterable, equalTo -- operators: in, is, is not, +, -, /, *, %, and, or, (), ==, !=, <, >, <=, >=, |, . -- unit tests