before.setBody("{" + setUpSrc() + "}");
before.setExceptionTypes(new CtClass[]{exceptionClass});
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
String beforeClassName = Before.class.getName();
constPool.addUtf8Info(beforeClassName);
Annotation annotation = new Annotation(beforeClassName, constPool);
attr.addAnnotation(annotation);
before.getMethodInfo().addAttribute(attr);
clazz.addMethod(before);
CtMethod after = new CtMethod(voidClass, "after" + random.nextInt(), new CtClass[]{}, clazz);
after.setModifiers(Modifier.PUBLIC);
after.setBody("{" + tearDownSrc() + "}");
after.setExceptionTypes(new CtClass[]{exceptionClass});
attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
String afterClassName = After.class.getName();
constPool.addUtf8Info(afterClassName);
annotation = new Annotation(afterClassName, constPool);
attr.addAnnotation(annotation);
after.getMethodInfo().addAttribute(attr);
clazz.addMethod(after);
}