1 /***************************************************************************************
2 * Copyright (c) Jonas Bon?r, Alexandre Vasseur. All rights reserved. *
3 * http://aspectwerkz.codehaus.org *
4 * ---------------------------------------------------------------------------------- *
5 * The software in this package is published under the terms of the LGPL license *
6 * a copy of which has been included with this distribution in the license.txt file. *
7 **************************************************************************************/
8 package test;
9
10 import junit.framework.TestCase;
11
12 import java.io.Serializable;
13 import java.lang.reflect.Field;
14
15 import org.codehaus.aspectwerkz.transform.inlining.weaver.SerialVersionUidVisitor;
16
17 /***
18 * Test for the SerialVerionUid computation.
19 *
20 * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
21 */
22 public class SerialVerUidTest extends TestCase implements Serializable {
23 static {
24 System.gc();
25 }
26
27 public Object[] someMethod() {
28 return null;
29 }
30
31 protected static final int someField = 32;
32
33 public void testSerialVerUid() throws Throwable {
34 long UID = SerialVersionUidVisitor.calculateSerialVersionUID(SerialVerUidTest.class);
35
36
37 Field f = SerialVerUidTest.class.getDeclaredField("serialVersionUID");
38 long uid = ((Long)f.get(null)).longValue();
39
40
41
42 try {
43 Class.forName("java.lang.annotation.Annotation");
44 assertEquals(7614081430767231713L, UID);
45 } catch (ClassNotFoundException e) {
46 assertEquals(-6289975506796941698L, UID);
47 }
48 }
49
50 public static void main(String[] args) {
51 junit.textui.TestRunner.run(suite());
52 }
53
54 public static junit.framework.Test suite() {
55 return new junit.framework.TestSuite(SerialVerUidTest.class);
56 }
57 }