Skip to content

Instantly share code, notes, and snippets.

@jsanda
Created January 29, 2015 16:58
Show Gist options
  • Save jsanda/5a2332c00e0429b8a901 to your computer and use it in GitHub Desktop.
Save jsanda/5a2332c00e0429b8a901 to your computer and use it in GitHub Desktop.
class TestScriptBase {
@Override
Object run() {
return null
}
def execute() {
BigDecimal.metaClass.equals = { return true }
script()
}
}
class RESTTest {
void execute(Closure test) {
def configuration = new CompilerConfiguration()
configuration.scriptBaseClass = "org.rhq.metrics.rest.TestScriptBase"
def binding = new Binding()
binding.script = test
def shell = new GroovyShell(this.class.classLoader, binding, configuration)
shell.evaluate("execute()")
}
}
class MyTest {
@Test
void testBigDecimal() {
execute {
assertTrue(new BigDecimal(34.33).equals(new BigDecimal(1)))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment