forked from mvel/mvel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CRNT-54055: Added test case MVELTestCase as described at mikebrock/mv…
…el#27 - on unpatched sources it failes with Java8, patched it runs fine.
- Loading branch information
Stephan Born
committed
Mar 14, 2019
1 parent
6e9afec
commit e26660a
Showing
3 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.mvel2.patches; | ||
|
||
import org.junit.Test; | ||
import org.mvel2.MVEL; | ||
import org.mvel2.patches.domain.Name; | ||
import org.mvel2.patches.domain.Person; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class MVELTestCase { | ||
|
||
//public static void main(String[] args) { | ||
// testCase(); | ||
//} | ||
|
||
@Test | ||
public void testCase() { | ||
Collection<Person> persons = getPersons(200); | ||
Map<String, Object> vars = new HashMap<String, Object>(); | ||
vars.put("persons", persons); | ||
|
||
Object eval = MVEL.eval("(name.first in persons)", vars); | ||
System.out.println(eval); | ||
} | ||
|
||
private static Collection<Person> getPersons(int number) { | ||
Collection<Person> persons = new ArrayList<Person>(); | ||
for (int i = 0; i < number; i++) | ||
{ | ||
Person person2 = new Person(); | ||
person2.setName(new Name(toLetter(i) + "name", "Last")); | ||
persons.add(person2); | ||
} | ||
return persons; | ||
} | ||
|
||
private static char toLetter(int i) { | ||
return (char) (i % (90 - 65 + 1) + 65); | ||
} | ||
} |
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,15 @@ | ||
package org.mvel2.patches.domain; | ||
|
||
public class Name { | ||
|
||
private String first; | ||
|
||
public Name(String first, String string2) { | ||
this.first = first; | ||
} | ||
|
||
public String getFirst() { | ||
return first; | ||
} | ||
|
||
} |
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,16 @@ | ||
package org.mvel2.patches.domain; | ||
|
||
public class Person { | ||
|
||
private Name name; | ||
|
||
public void setName(Name name) { | ||
this.name = name; | ||
|
||
} | ||
|
||
public Name getName() { | ||
return name; | ||
} | ||
|
||
} |