// gets the collection of the annotated attributes
List<Field> annotatedFields = SecurityActions.getFieldsWithAnnotation(testCase.getClass(),
SpringMvcResource.class);
// retrieves the captured execution context
SpringMvcResult mvcResult = getSpringMvcResult();
try {
for (Field field : annotatedFields) {
Object value = null;
if (mvcResult != null) {
if (field.getType() == SpringMvcResult.class) {
value = mvcResult;
} else if (field.getType() == ModelAndView.class) {
value = mvcResult.getModelAndView();
} else if (field.getType() == Exception.class) {
value = mvcResult.getException();
} else if (field.getType() == HandlerInterceptor[].class) {
value = mvcResult.getInterceptors();
} else if (field.getType() == Errors.class) {
value = mvcResult.getErrors();
} else if (mvcResult.getHandler() != null &&
field.getType() == mvcResult.getHandler().getClass()) {
value = mvcResult.getHandler();
}
}
field.set(testCase, value);
}