Skip to content
Browse files

Merge pull request #7 from ikedam/feature/JENKINS-25119_testDefaultGr…


[JENKINS-25119] a test for additional methods in the Groovy environment
  • Loading branch information
jglick committed May 28, 2015
2 parents e016e32 + d90c1f5 commit 1b3b7dc40512ca1401bb30ea280867400d85b344
@@ -395,6 +395,16 @@ private Unsafe() {}
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");

@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 =, whitelist);

0 comments on commit 1b3b7dc

Please sign in to comment.
You can’t perform that action at this time.