1 package org.sonar.java.bytecode.visitor;
3 import org.junit.BeforeClass;
5 import org.sonar.java.bytecode.ClassworldsClassLoader;
6 import org.sonar.java.bytecode.asm.AsmClass;
7 import org.sonar.java.bytecode.asm.AsmClassProvider;
8 import org.sonar.java.bytecode.asm.AsmClassProviderImpl;
9 import org.sonar.java.bytecode.asm.AsmMethod;
11 import static org.junit.Assert.*;
12 import static org.sonar.java.ast.SquidTestUtils.getFile;
14 public class AccessorVisitorTest {
16 private static AsmClassProvider asmClassProvider;
17 private static AsmClass javaBean;
18 private static AccessorVisitor accessorVisitor = new AccessorVisitor();
21 public static void init() {
22 asmClassProvider = new AsmClassProviderImpl(ClassworldsClassLoader.create(getFile("/bytecode/bin/")));
23 javaBean = asmClassProvider.getClass("properties/JavaBean");
24 accessorVisitor.visitClass(javaBean);
25 for (AsmMethod method : javaBean.getMethods()) {
26 accessorVisitor.visitMethod(method);
31 public void testAccessorMethods() {
32 assertTrue(javaBean.getMethod("getName()Ljava/lang/String;").isAccessor());
33 assertTrue(javaBean.getMethod("setName(Ljava/lang/String;)V").isAccessor());
34 assertTrue(javaBean.getMethod("setFrench(Z)V").isAccessor());
35 assertTrue(javaBean.getMethod("isFrench()Z").isAccessor());
36 assertFalse(javaBean.getMethod("anotherMethod()V").isAccessor());