Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #7 from ikedam/feature/JENKINS-25119_testDefaultGr…
…oovyMethods

[JENKINS-25119] a test for additional methods in the Groovy environment
  • Loading branch information
jglick committed May 28, 2015
2 parents e016e32 + d90c1f5 commit 1b3b7dc
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -395,6 +395,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 1b3b7dc

Please sign in to comment.