1 30 package org.objectweb.asm.commons; 31 32 import java.io.IOException ; 33 import java.io.Serializable ; 34 35 import org.objectweb.asm.ClassReader; 36 import org.objectweb.asm.ClassVisitor; 37 38 import junit.framework.TestCase; 39 40 46 public class SerialVersionUIDAdderUnitTest extends TestCase implements 47 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(final String className) 61 throws IOException 62 { 63 final long[] svuid = new long[1]; 64 ClassVisitor cv = new SerialVersionUIDAdder(new EmptyVisitor()) { 65 protected long computeSVUID() throws IOException { 66 svuid[0] = super.computeSVUID(); 67 return svuid[0]; 68 } 69 }; 70 new ClassReader(className).accept(cv, 0); 71 return svuid[0]; 72 } 73 74 public void test() throws Throwable { 75 long UID = computeSerialVersionUID(getClass().getName()); 76 assertEquals(194753646298127968L, UID); 77 } 78 } 79 | Popular Tags |