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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
     
    void
    Test that a blank rule is true.
    void
    Confirms MVEL failure for special overloaded method case.
    void
    Confirms repeated success for method overload workaround in SelectizeCollectionUtils
    void
    Test that a null rule is true.
    void
    Tests MVEL syntax for accessing request property map values.
    void
    Test rule that evaluates to true
    void
    Test rule that evaluates to true
    void
    Test rule with parse errors

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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

      public void testMvelMethodOverloadFailureCase() throws IOException
      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

      public void testMvelMethodOverloadWorkaroundCase() throws IOException
      Confirms repeated success for method overload workaround in SelectizeCollectionUtils

      See testMvelMethodOverloadFailureCase() for a more complete description of the problem case.
      Throws:
      IOException
    • executeExternalJavaProcess

      protected String executeExternalJavaProcess(Class<?> mainClass) throws IOException
      Throws:
      IOException