Navigation Menu

Skip to content

Commit

Permalink
[JENKINS-25119] Added a test for additional methods in the Groovy env…
Browse files Browse the repository at this point in the history
…ironment.
  • Loading branch information
ikedam committed Feb 1, 2015
1 parent 1261315 commit d90c1f5
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -388,6 +388,16 @@ public static final class Ambiguity {
assertEvaluate(new GenericWhitelist(), Collections.singletonMap("part0", "one\ntwo"), "def list = [['one', 'two']]; def map = [:]; for (int i = 0; i < list.size(); i++) {map[\"part${i}\"] = list.get(i).join(\"\\n\")}; map");
}

@Issue("JENKINS-25119")
@Test public void groovyAdditionalMethod() throws Exception {
try {
assertEvaluate(new ProxyWhitelist(), "should fail", "'123'.toInteger();");
} catch (RejectedAccessException x) {
assertNotNull(x.toString(), x.getSignature());
}
assertEvaluate(new StaticWhitelist("staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods toInteger java.lang.String"), new Integer(123), "'123'.toInteger();");
}

private static void assertEvaluate(Whitelist whitelist, final Object expected, final String script) {
final GroovyShell shell = new GroovyShell(GroovySandbox.createSecureCompilerConfiguration());
Object actual = GroovySandbox.run(shell.parse(script), whitelist);
Expand Down

0 comments on commit d90c1f5

Please sign in to comment.