* Prepares a method statement, configuring it for the test context
*/
@Override
protected Statement methodBlock(FrameworkMethod method) {
// check if either the method/class is annotated with the TestSecurity annotation
TestSecurity testSecurity = null;
if (method.getMethod().isAnnotationPresent(TestSecurity.class)) {
testSecurity = method.getMethod().getAnnotation(TestSecurity.class);
} else if (getTestClass().getJavaClass().isAnnotationPresent(TestSecurity.class)) {
testSecurity = getTestClass().getJavaClass().getAnnotation(TestSecurity.class);
}
// no security to run as, just create a normal statement
if (testSecurity == null ||
(testSecurity.authorized().length == 0 && testSecurity.unauthorized().length == 0)) {
return createUnsecuredStatement(method);
}
// security roles specified, create separate statements for them all
else {
return createSecuredStatementExecutor(method, testSecurity);