Skip to content

Commit

Permalink
CRNT-54055: Added test case MVELTestCase as described at mikebrock/mv…
Browse files Browse the repository at this point in the history
…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
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/test/java/org/mvel2/patches/MVELTestCase.java
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);
}
}
15 changes: 15 additions & 0 deletions src/test/java/org/mvel2/patches/domain/Name.java
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;
}

}
16 changes: 16 additions & 0 deletions src/test/java/org/mvel2/patches/domain/Person.java
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;
}

}

0 comments on commit e26660a

Please sign in to comment.