1 30 package org.objectweb.asm.signature; 31 32 import junit.framework.TestSuite; 33 34 import org.objectweb.asm.AbstractTest; 35 import org.objectweb.asm.ClassReader; 36 import org.objectweb.asm.FieldVisitor; 37 import org.objectweb.asm.MethodVisitor; 38 import org.objectweb.asm.commons.EmptyVisitor; 39 40 45 public class SignatureWriterTest extends AbstractTest { 46 47 public static TestSuite suite() throws Exception { 48 return new SignatureWriterTest().getSuite(); 49 } 50 51 public void test() throws Exception { 52 ClassReader cr = new ClassReader(is); 53 cr.accept(new EmptyVisitor() { 54 public void visit( 55 int version, 56 int access, 57 String name, 58 String signature, 59 String superName, 60 String [] interfaces) 61 { 62 if (signature != null) { 63 SignatureReader sr = new SignatureReader(signature); 64 SignatureWriter sw = new SignatureWriter(); 65 sr.accept(sw); 66 assertEquals(signature, sw.toString()); 67 toto(signature); 68 } 69 } 70 71 public FieldVisitor visitField( 72 int access, 73 String name, 74 String desc, 75 String signature, 76 Object value) 77 { 78 if (signature != null) { 79 SignatureReader sr = new SignatureReader(signature); 80 SignatureWriter sw = new SignatureWriter(); 81 sr.acceptType(sw); 82 assertEquals(signature, sw.toString()); 83 toto(signature); 84 } 85 return null; 86 } 87 88 public MethodVisitor visitMethod( 89 int access, 90 String name, 91 String desc, 92 String signature, 93 String [] exceptions) 94 { 95 if (signature != null) { 96 SignatureReader sr = new SignatureReader(signature); 97 SignatureWriter sw = new SignatureWriter(); 98 sr.accept(sw); 99 assertEquals(signature, sw.toString()); 100 toto(signature); 101 } 102 return null; 103 } 104 105 }, 0); 106 } 107 private void toto(String s) { 108 if (s.indexOf('.') != -1) { 109 System.out.println(s); 110 } 111 } 112 } 113 | Popular Tags |