-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for thymeleaf/thymeleaf#809 on Spring 4 (SpEL)
- Loading branch information
1 parent
d25fb15
commit 93a267f
Showing
15 changed files
with
193 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 0 additions & 88 deletions
88
...t/java/org/thymeleaf/templateengine/springintegration/util/SpringExpressionUtilsTest.java
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
...rg/thymeleaf/templateengine/springintegration/util/SpringStandardExpressionUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* ============================================================================= | ||
* | ||
* Copyright (c) 2011-2016, The THYMELEAF team (http://www.thymeleaf.org) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ============================================================================= | ||
*/ | ||
package org.thymeleaf.templateengine.springintegration.util; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.thymeleaf.spring5.util.SpringStandardExpressionUtils; | ||
|
||
|
||
public final class SpringStandardExpressionUtilsTest { | ||
|
||
|
||
|
||
@Test | ||
public void testcontainsSpELInstantiationOrStatic() { | ||
|
||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abcnew")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abcnew ")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc3new ")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc_new ")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc$new ")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc-new ")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc new ")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc.new ")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc newnew")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abcnew ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc new ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc new w ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc new w ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc (new )w ewnew")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc (new)w ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("abc +new )w ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("new ")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("new ")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("newnew")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("new ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("new w ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("new w ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("(new )w ewnew")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("(new)w ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("+new )w ewnew")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("!new )w ewnew")); | ||
|
||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T()")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T(a)")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T(a.b.SomeClass)")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T(a.b.SomenewClass)")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T(a.b.Some Class)")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T(a.b.Some newClass)")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T(a.b.Some new Class)")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T(a.b.Some newClass)new")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("T(a.b.Some newClass)new ")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("newT(a.b.Some newClass)new")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("aT(a.b.Some newClass)a")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.Some newClass) a")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic(" aT(a.b.Some newClass)a ")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a-T(a.b.SomeClass)a")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("aT(a.b.SomeClass)a")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.SomeClass) a")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic(" aT(a.b.SomeClass)a ")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic(" a T(a.b.SomeClass)a ")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.SomeClass) a T(a.b.Some Class)")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.Some Class) a T(a.b.SomeClass)")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.Some Class) a T(a.b.Some Class)")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.SomeClass) )")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.SomeClass))")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.Some(Class) )")); | ||
Assert.assertTrue(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.Some)Class) )")); | ||
Assert.assertFalse(SpringStandardExpressionUtils.containsSpELInstantiationOrStatic("a T(a.b.Som(e)Class) )")); | ||
|
||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions01.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:text="${new java.lang.String('hello')}">ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%OUTPUT | ||
<p>hello</p> |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions02.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:text="${__${new java.lang.String('hello')}__}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions03.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:at0="${new java.lang.String('hello')}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions04.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:attr="at0=${new java.lang.String('hello')}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions05.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:href="~{${new java.lang.String('hello')}}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions06.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:insert="${new java.lang.String('hello')}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions07.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:text="@{${new java.lang.String('hello')}}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions08.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:text="${T(org.thymeleaf.TemplateEngine).TIMER_LOGGER_NAME}">ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%OUTPUT | ||
<p>org.thymeleaf.TemplateEngine.TIMER</p> |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions09.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:text="${__${T(org.thymeleaf.TemplateEngine).TIMER_LOGGER_NAME}__}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions10.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:at0="${T(org.thymeleaf.TemplateEngine).TIMER_LOGGER_NAME}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions11.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:href="~{${T(org.thymeleaf.TemplateEngine).TIMER_LOGGER_NAME}}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |
7 changes: 7 additions & 0 deletions
7
.../templateengine/springbase/instancestaticrestrictions/instancestaticrestrictions12.thtest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%TEMPLATE_MODE HTML | ||
# ------------------------------------------------------------ | ||
%INPUT | ||
<p th:text="@{${T(org.thymeleaf.TemplateEngine).TIMER_LOGGER_NAME}}">NOT ALLOWED</p> | ||
# ------------------------------------------------------------ | ||
%EXCEPTION org.thymeleaf.exceptions.TemplateProcessingException | ||
%EXCEPTION_MESSAGE_PATTERN (.*)\Qforbidden in this context\E(.*) |