KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hanseltest > TestBug753855


1 package org.hanseltest;
2
3 import junit.framework.TestCase;
4
5 /**
6  * Test for Bug 753855. This was caused by assuming the probe code had always the
7  * same length
8  */

9 public class TestBug753855 extends TestCase {
10     public TestBug753855(String JavaDoc name) {
11         super(name);
12     }
13
14     public void testBug() throws Exception JavaDoc {
15         throw new UnsupportedOperationException JavaDoc("No yet converted.");
16        /* TestClassLoader tcl = new TestClassLoader(Example.class);
17         Class exampleClass = tcl.loadClass(Example.class.getName());
18
19         // This line failed with an VerifyError.
20         Method m = exampleClass.getMethod("init2", new Class[] {int.class, Class.class});
21         m.invoke(null, new Object[] {new Integer(0), exampleClass});*/

22     }
23
24     /*public static class Example {
25         public static void init2(int a, Class javaClass) {
26             if (a != 0) {
27                 for (int phase = 1; phase <= 2; phase++) {
28                     for (Class cl = javaClass; cl != Object.class; cl =
29                          cl.getSuperclass()) {
30
31                         Field[] fields = cl.getDeclaredFields();
32                         for (int i = 0; i < fields.length; i++) {
33                             Field f = fields[i];
34                             int mod = f.getModifiers();
35                             if (Modifier.isStatic(mod) ||
36                                 Modifier.isFinal(mod) ||
37                                 Modifier.isTransient(mod))
38                                 continue;
39                             switch (phase) {
40                                 case 1:
41                                     a++;
42                                     break;
43                                 case 2:
44                                     a--;
45                                     break;
46                             }
47                         }
48                     }
49                 }
50             } // end if
51         }
52     }
53
54     private class TestClassLoader extends ClassLoader {
55         private String classname;
56         private Instrumenter instrumenter;
57         private ProbeTable pt;
58
59         public TestClassLoader(Class clazz) {
60             super(clazz.getClassLoader(),
61                   new String[] { "org.hansel.ProbeTable" });
62             classname = clazz.getName();
63          
64             pt = new ProbeTable(null);
65             instrumenter = new Instrumenter(pt);
66             ProbeTable.setProbeTable(pt);
67         }
68
69         protected JavaClass modifyClass(JavaClass clazz) {
70             if (clazz.getClassName().equals(classname)) {
71                 instrumenter.instrument(clazz);
72             }
73
74             return clazz;
75         }
76     }*/

77 }
78
Popular Tags