1 32 33 package com.jeantessier.classreader; 34 35 import java.io.*; 36 import java.util.*; 37 38 import junit.framework.*; 39 40 public class TestLoadListenerVisitorAdapter extends TestCase implements Visitor { 41 public static final String TEST_DIR = "tests" + File.separator + "JarJarDiff"; 42 public static final String TEST_CLASS = "test"; 43 public static final String TEST_FILENAME = "classes" + File.separator + "test.class"; 44 45 private LinkedList classfiles; 46 47 private ClassfileLoader loader; 48 private LoadListenerVisitorAdapter adapter; 49 50 protected void setUp() throws Exception { 51 classfiles = new LinkedList(); 52 53 adapter = new LoadListenerVisitorAdapter(this); 54 loader = new AggregatingClassfileLoader(); 55 loader.addLoadListener(adapter); 56 } 57 58 public void testOneFile() { 59 loader.load(TEST_FILENAME); 60 61 assertEquals("First class", TEST_CLASS, ((Classfile) classfiles.getFirst()).getClassName()); 62 assertEquals("Nb visited classes", 1, classfiles.size()); 63 } 64 65 public void testManyFiles() { 66 loader.load(TEST_DIR); 67 68 assertEquals("Nb visited classes", 136, classfiles.size()); 69 } 70 71 public void visitClassfiles(Collection classfiles) { 72 this.classfiles.addAll(classfiles); 73 } 74 75 public void visitClassfile(Classfile classfile) { 76 classfiles.add(classfile); 77 } 78 79 public void visitConstantPool(ConstantPool constantPool) { 80 } 82 83 public void visitClass_info(Class_info entry) { 84 } 86 87 public void visitFieldRef_info(FieldRef_info entry) { 88 } 90 91 public void visitMethodRef_info(MethodRef_info entry) { 92 } 94 95 public void visitInterfaceMethodRef_info(InterfaceMethodRef_info entry) { 96 } 98 99 public void visitString_info(String_info entry) { 100 } 102 103 public void visitInteger_info(Integer_info entry) { 104 } 106 107 public void visitFloat_info(Float_info entry) { 108 } 110 111 public void visitLong_info(Long_info entry) { 112 } 114 115 public void visitDouble_info(Double_info entry) { 116 } 118 119 public void visitNameAndType_info(NameAndType_info entry) { 120 } 122 123 public void visitUTF8_info(UTF8_info entry) { 124 } 126 127 public void visitField_info(Field_info entry) { 128 } 130 131 public void visitMethod_info(Method_info entry) { 132 } 134 135 public void visitConstantValue_attribute(ConstantValue_attribute attribute) { 136 } 138 139 public void visitCode_attribute(Code_attribute attribute) { 140 } 142 143 public void visitExceptions_attribute(Exceptions_attribute attribute) { 144 } 146 147 public void visitInnerClasses_attribute(InnerClasses_attribute attribute) { 148 } 150 151 public void visitSynthetic_attribute(Synthetic_attribute attribute) { 152 } 154 155 public void visitSourceFile_attribute(SourceFile_attribute attribute) { 156 } 158 159 public void visitLineNumberTable_attribute(LineNumberTable_attribute attribute) { 160 } 162 163 public void visitLocalVariableTable_attribute(LocalVariableTable_attribute attribute) { 164 } 166 167 public void visitDeprecated_attribute(Deprecated_attribute attribute) { 168 } 170 171 public void visitCustom_attribute(Custom_attribute attribute) { 172 } 174 175 public void visitExceptionHandler(ExceptionHandler helper) { 176 } 178 179 public void visitInnerClass(InnerClass helper) { 180 } 182 183 public void visitLineNumber(LineNumber helper) { 184 } 186 187 public void visitLocalVariable(LocalVariable helper) { 188 } 190 191 } 192 | Popular Tags |