in src/main/groovy/groovyShell/ArithmeticShellTest.groovy [55:107]
void testEvaluate_Failures() {
shouldFail(SecurityException) {
evaluate("Double.valueOf(\"5\")")
}
shouldFail(SecurityException) {
evaluate("import java.text.DateFormat; 5")
}
shouldFail(SecurityException) {
evaluate("import static java.lang.System.*; 6 * out")
}
shouldFail(SecurityException) {
evaluate("def x = 5+3;x.toString()")
}
shouldFail(SecurityException) {
evaluate("new File();Double.valueOf('5')")
}
shouldFail(SecurityException) {
// without statement whitelist set, this causes the arithmetic shell to
// enter an infinite loop
evaluate("while (1);")
}
shouldFail(SecurityException) {
// without statement whitelist set, security exception is still thrown as it should,
// but with the error message that closures are not allowed, which may be confusing
evaluate("for (;;);")
}
shouldFail(SecurityException) {
// without statement whitelist set, no exception is thrown
evaluate("if (1) 12 else 15")
}
shouldFail(SecurityException) {
// without expression whitelist set, no exception is thrown
evaluate("[1,2]; 1")
}
shouldFail(SecurityException) {
// without expression whitelist set, no exception is thrown
evaluate("[1:2]; 1")
}
shouldFail(SecurityException) {
// without expression whitelist set, no exception is thrown
evaluate("new Object(); 1")
}
}