Class MvelExpressionValidatorTest
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.broadleafcommerce.test.common.rule.MvelExpressionValidatorTest
- All Implemented Interfaces:
junit.framework.Test
public class MvelExpressionValidatorTest
extends junit.framework.TestCase
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidMVEL calls no argument methods written as properties, so blocked methods must be blocked in that form too.voidAllowing a built-in blocked method allows only that method, e.g. for a custom field called loadvoidThe validator must agree with MVEL on where string literals and comments start and end.voidvoidvoidMVEL can compile and evaluate any expression, so the compile and execute methods are blocked, whether reached through the fully qualified org.mvel2.MVEL or the bare MVEL import, and whichever of them is used.voidSystem.exit kills the JVM, so it is blocked, like the already blocked halt.voidLong string values, with or without escapes, must not overflow the stack while being removed.voidvoidProduct, sku and other names containing "new" are values in string literals, or part of a longer name, and must not be mistaken for the new keyword.voidString literal contents are data and must never be treated as code.voidFactory methods that create or load classes without using newvoidvoidvoidExpressions generated by the rule builder, including legacy forms, and hand written rules from the tests and demo data must remain allowed.voidvoidvoidMethods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
-
Constructor Details
-
MvelExpressionValidatorTest
public MvelExpressionValidatorTest()
-
-
Method Details
-
testRuleBuilderExpressionsAreAllowed
public void testRuleBuilderExpressionsAreAllowed()Expressions generated by the rule builder, including legacy forms, and hand written rules from the tests and demo data must remain allowed. -
testNullAndEmptyExpressionsAreAllowed
public void testNullAndEmptyExpressionsAreAllowed()String literal contents are data and must never be treated as code. -
testCodeInsideStringLiteralsIsAllowed
public void testCodeInsideStringLiteralsIsAllowed() -
testNewInsideValuesAndNamesIsAllowed
public void testNewInsideValuesAndNamesIsAllowed()Product, sku and other names containing "new" are values in string literals, or part of a longer name, and must not be mistaken for the new keyword. -
testReportedPayloadIsRejected
public void testReportedPayloadIsRejected() -
testExpressionCompilationAndExecutionIsRejected
public void testExpressionCompilationAndExecutionIsRejected()MVEL can compile and evaluate any expression, so the compile and execute methods are blocked, whether reached through the fully qualified org.mvel2.MVEL or the bare MVEL import, and whichever of them is used. -
testJvmTerminationIsRejected
public void testJvmTerminationIsRejected()System.exit kills the JVM, so it is blocked, like the already blocked halt. -
testConstructorsAreRejected
public void testConstructorsAreRejected() -
testObjectCreationWithoutNewIsRejected
public void testObjectCreationWithoutNewIsRejected()Factory methods that create or load classes without using new -
testReflectionIsRejected
public void testReflectionIsRejected() -
testBlockedMethodsAreRejected
public void testBlockedMethodsAreRejected() -
testStatementSeparatorsAreRejected
public void testStatementSeparatorsAreRejected() -
testBlockedMethodsWithoutParenthesesAreRejected
public void testBlockedMethodsWithoutParenthesesAreRejected()MVEL calls no argument methods written as properties, so blocked methods must be blocked in that form too. -
testCodeHiddenFromTheValidatorIsRejected
public void testCodeHiddenFromTheValidatorIsRejected()The validator must agree with MVEL on where string literals and comments start and end. -
testLongStringLiteralsAreAllowed
public void testLongStringLiteralsAreAllowed()Long string values, with or without escapes, must not overflow the stack while being removed. -
testValidationIsEnabledByDefault
public void testValidationIsEnabledByDefault() -
testValidationCanBeTurnedOffWithProperty
public void testValidationCanBeTurnedOffWithProperty() -
testMethodsCanBeBlockedWithProperty
public void testMethodsCanBeBlockedWithProperty() -
testBuiltInMethodsCanBeAllowedWithProperty
public void testBuiltInMethodsCanBeAllowedWithProperty()Allowing a built-in blocked method allows only that method, e.g. for a custom field called load
-