1 30 package org.objectweb.asm.commons; 31 32 import java.io.IOException ; 33 import java.io.Serializable ; 34 import java.security.NoSuchAlgorithmException ; 35 36 import org.objectweb.asm.ClassReader; 37 import org.objectweb.asm.ClassVisitor; 38 39 import junit.framework.TestCase; 40 41 47 public class SerialVersionUIDAdderTest extends TestCase implements Serializable 48 { 49 50 protected final static int aField = 32; 51 52 static { 53 System.gc(); 54 } 55 56 public Object [] aMethod() { 57 return null; 58 } 59 60 private long computeSerialVersionUID(String className) throws IOException { 61 final long[] svuid = new long[1]; 62 ClassVisitor cv = new SerialVersionUIDAdder(new EmptyVisitor()) { 63 protected long computeSVUID() 64 throws IOException , NoSuchAlgorithmException 65 { 66 svuid[0] = super.computeSVUID(); 67 return svuid[0]; 68 } 69 }; 70 new ClassReader(className).accept(cv, false); 71 return svuid[0]; 72 } 73 74 public void test() throws Throwable { 75 long UID = computeSerialVersionUID(getClass().getName()); 76 assertEquals(3047446532799341501L, UID); 77 } 78 } 79 | Popular Tags |