Class MvelHelperTest
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.broadleafcommerce.test.common.rule.MvelHelperTest
- All Implemented Interfaces:
junit.framework.Test
public class MvelHelperTest
extends junit.framework.TestCase
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringexecuteExternalJavaProcess(Class<?> mainClass) voidTest that a blank rule is true.voidConfirms MVEL failure for special overloaded method case.voidConfirms repeated success for method overload workaround in SelectizeCollectionUtilsvoidTest that a null rule is true.voidTests MVEL syntax for accessing request property map values.voidTest rule that evaluates to truevoidTest rule that evaluates to truevoidTest rule with parse errorsMethods 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
-
MvelHelperTest
public MvelHelperTest()
-
-
Method Details
-
testBlankRule
public void testBlankRule()Test that a blank rule is true. -
testNullRule
public void testNullRule()Test that a null rule is true. -
testRuleWithParseErrors
public void testRuleWithParseErrors()Test rule with parse errors -
testRuleThatEvaluatesToTrue
public void testRuleThatEvaluatesToTrue()Test rule that evaluates to true -
testRuleThatEvaluatesToFalse
public void testRuleThatEvaluatesToFalse()Test rule that evaluates to true -
testRequestMapProperty
public void testRequestMapProperty()Tests MVEL syntax for accessing request property map values. -
testMvelMethodOverloadFailureCase
Confirms MVEL failure for special overloaded method case. During compilation, if an mvel expression contains a method calls with params, mvel will attempt to identify a perfect method signature match based on the types of the params. However, if the method is overloaded and one or more of the params are null, mvel will not be able to 100% identify the right method version if the overloaded methods have the same quantity of params and have type overlap. Take this example:SelectizeCollectionUtils#intersection(String param, Iterable param2);SelectizeCollectionUtils#intersection(Iterable param, Iterable param2);If a rule is executed calling the intersection method and a null is passed in for the first parameter, mvel will not know which method to pick, so it will end up picking one of them. This has proven to be undetermined at runtime, which has made the problem even harder to identify. Furthermore, once the choice is made during compilation, that compiled expression will utilize the "incorrect" choice going forward, which will cause the expression to fail, even when neither param is null. In fact, in the case above, mvel will "coerce" the first param Iterable instance into a String (i.e. flatten the list representation into a comma delimited String) in order to continue calling the method identified during compilation. This causes the expression to permanently be in an incorrect state from which it will never recover.- Throws:
IOException
-
testMvelMethodOverloadWorkaroundCase
Confirms repeated success for method overload workaround in SelectizeCollectionUtils SeetestMvelMethodOverloadFailureCase()for a more complete description of the problem case.- Throws:
IOException
-
executeExternalJavaProcess
- Throws:
IOException
-