Skip to content

Commit

Permalink
[JENKINS-33023] Expanding test case to show that binary enums are OK …
Browse files Browse the repository at this point in the history
…too.
  • Loading branch information
jglick committed May 11, 2016
1 parent 32d766a commit 57d6eb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Expand Up @@ -40,6 +40,9 @@ new java.io.StringReader java.lang.String
method java.lang.CharSequence charAt int
method java.lang.CharSequence length
method java.lang.Comparable compareTo java.lang.Object
method java.lang.Enum name
method java.lang.Enum ordinal
# could add valueOf, though currently the staticField’s need to be whitelisted, which is the more likely use case
method java.lang.Object clone
method java.lang.Object equals java.lang.Object
method java.lang.Object getClass
Expand Down
Expand Up @@ -587,6 +587,26 @@ public Object invokeMethod(String name, Object args) {
+ "Thing.values()[0].description\n";
String expected = "The first thing";
assertEvaluate(new GenericWhitelist(), expected, script);
String e = E.class.getName();
ProxyWhitelist wl = new ProxyWhitelist(new GenericWhitelist(), new AnnotatedWhitelist());
assertEvaluate(wl, 2, e + ".TWO.getN()");
assertRejected(wl, "method " + e + " explode", e + ".TWO.explode()");
assertEvaluate(wl, "TWO", e + ".TWO.name()");
assertRejected(wl, "staticField " + e + " ONE", e + ".ONE.name()");
}
public enum E {
ONE(1),
@Whitelisted
TWO(2);
private final int n;
private E(int n) {
this.n = n;
}
@Whitelisted
public int getN() {
return n;
}
public void explode() {}
}

private static void assertEvaluate(Whitelist whitelist, final Object expected, final String script) {
Expand Down

0 comments on commit 57d6eb3

Please sign in to comment.