Skip to content

Commit

Permalink
add test case demostrating invocation of method implemented in abstra…
Browse files Browse the repository at this point in the history
…ct parent class
  • Loading branch information
mariofusco committed Sep 7, 2016
1 parent 6ddf1b6 commit 860984b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/test/java/org/mvel2/tests/core/CoreConfidenceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -4492,5 +4492,27 @@ public void testMethodOverloadMatch() throws Exception {
Method correct = OverloadedInterface.class.getMethod("putXX", new Class[]{int.class, String.class});
assertEquals(correct, found);
}


public static class O1 {
public O2 getObj() {
return new O2();
}
}
public static class O2 extends O3 { }
public abstract static class O3 {
public String getValue() {
return "value";
}
}

public void testInvokeMethodInAbstractClass() {
final ParserContext parserContext = new ParserContext();
parserContext.setStrictTypeEnforcement(true);
parserContext.setStrongTyping(true);
parserContext.addInput("a", O1.class);
assertEquals(String.class, MVEL.analyze("a.getObj().getValue()", parserContext));

Map vars = new HashMap() {{ put("a", new O1()); }};
assertEquals("value", MVEL.executeExpression(MVEL.compileExpression("a.getObj().getValue()", parserContext), vars));
}
}

0 comments on commit 860984b

Please sign in to comment.