1 2 package net.sf.cglib.transform.impl; 3 4 import net.sf.cglib.transform.*; 5 import junit.framework.*; 6 import java.util.*; 7 import net.sf.cglib.core.*; 8 9 /*** 10 * 11 * @author baliuka 12 */ 13 public class TestAddClassInit extends AbstractTransformTest{ 14 15 static Class registred; 16 17 static int i = 0; 18 19 static { 20 21 i = 11; 22 23 } 24 25 public static void register(Class cls){ 26 27 registred = cls; 28 29 30 } 31 32 33 public TestAddClassInit(){ } 34 35 public void testInitTransform(){ 36 assertEquals(i,11); 37 } 38 39 public void testRegistred(){ 40 41 42 assertNotNull(registred); 43 44 45 } 46 47 public TestAddClassInit(String s){ 48 super(s); 49 } 50 51 protected ClassTransformerFactory getTransformer() throws Exception{ 52 53 return new ClassTransformerFactory (){ 54 55 public ClassTransformer newInstance(){ 56 try{ 57 return new AddStaticInitTransformer( 58 TestAddClassInit.class. 59 getMethod("register",new Class[]{Class.class}) 60 ); 61 }catch(Exception e){ 62 throw new CodeGenerationException(e); 63 } 64 } 65 }; 66 67 } 68 69 public static void main(String[] args) throws Exception{ 70 junit.textui.TestRunner.run(suite()); 71 } 72 73 public static Test suite() throws Exception{ 74 return new TestSuite( new TestAddClassInit( ).transform() ); 75 } 76 77 78 }

This page was automatically generated by Maven