// Path: weaver-instrumentation/src/test/java/weaver/instrumentation/test/weaving/WeavingSpec.java
// public abstract class WeavingSpec {
// 
//     protected Instrumentation instrumentation;
//     protected CtClass ctClass;
// 
//     @Before
//     public void initClassPool() throws NotFoundException {
//         ClassPool pool = ClassPool.getDefault();
//         instrumentation = new Instrumentation(pool);
//         ctClass = pool.get(getSampleClassName());
//         ctClass.setName(ctClass.getName() + getTransformedName());
//     }
// 
//     protected abstract String getSampleClassName();
// 
//     protected abstract String getTransformedName();
// 
//     protected <T> T invokeMethod(Class<T> returnType, String methodName,
//                                  Object instance) {
//         return invokeMethod(returnType, methodName, instance, null, null);
//     }
// 
//     protected <T> T invokeMethod(Class<T> returnType, String methodName,
//                                  Object instance, Class<?>[] params,Object[] args) {
//         try {
//             Method method = instance.getClass().getMethod(methodName, params);
//             method.setAccessible(true);
//             return (T) method.invoke(instance, args);
//         } catch (NoSuchMethodException e) {
//             e.printStackTrace();
//         } catch (InvocationTargetException e) {
//             e.printStackTrace();
//         } catch (IllegalAccessException e) {
//             e.printStackTrace();
//         }
//         return null;
//     }
// 
//     @After
//     public void storeCtClass() throws CannotCompileException, IOException {
//         ctClass.writeFile(getClass().getResource("/").getPath());
//     }
// }


import org.junit.Test;
import java.lang.reflect.Field;
import javassist.Modifier;
import weaver.instrumentation.test.weaving.WeavingSpec;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
package weaver.instrumentation.test.weaving.field;





/**
 * @author Saeed Masoumi (saeed@6thsolution.com)
 */
public class FieldWeavingTest extends WeavingSpec {

    @Test
    public void test_filed_injection()
            throws Exception {
        instrumentation.startWeaving(ctClass)
                .insertField(Point.class.getCanonicalName(), "$$point")
                .addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
                .initializeIt()
                .inject()
// Path: weaver-instrumentation/src/test/java/weaver/instrumentation/test/weaving/WeavingSpec.java
// public abstract class WeavingSpec {
// 
//     protected Instrumentation instrumentation;
//     protected CtClass ctClass;
// 
//     @Before
//     public void initClassPool() throws NotFoundException {
//         ClassPool pool = ClassPool.getDefault();
//         instrumentation = new Instrumentation(pool);
//         ctClass = pool.get(getSampleClassName());
//         ctClass.setName(ctClass.getName() + getTransformedName());
//     }
// 
//     protected abstract String getSampleClassName();
// 
//     protected abstract String getTransformedName();
// 
//     protected <T> T invokeMethod(Class<T> returnType, String methodName,
//                                  Object instance) {
//         return invokeMethod(returnType, methodName, instance, null, null);
//     }
// 
//     protected <T> T invokeMethod(Class<T> returnType, String methodName,
//                                  Object instance, Class<?>[] params,Object[] args) {
//         try {
//             Method method = instance.getClass().getMethod(methodName, params);
//             method.setAccessible(true);
//             return (T) method.invoke(instance, args);
//         } catch (NoSuchMethodException e) {
//             e.printStackTrace();
//         } catch (InvocationTargetException e) {
//             e.printStackTrace();
//         } catch (IllegalAccessException e) {
//             e.printStackTrace();
//         }
//         return null;
//     }
// 
//     @After
//     public void storeCtClass() throws CannotCompileException, IOException {
//         ctClass.writeFile(getClass().getResource("/").getPath());
//     }
// }


// Path: weaver-instrumentation/src/test/java/weaver/instrumentation/test/weaving/field/FieldWeavingTest.java
import org.junit.Test;
import java.lang.reflect.Field;
import javassist.Modifier;
import weaver.instrumentation.test.weaving.WeavingSpec;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

package weaver.instrumentation.test.weaving.field;





/**
 * @author Saeed Masoumi (saeed@6thsolution.com)
 */
public class FieldWeavingTest extends WeavingSpec {

    @Test
    public void test_filed_injection()
            throws Exception {
        instrumentation.startWeaving(ctClass)
                .insertField(Point.class.getCanonicalName(), "$$point")
                .addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
                .initializeIt()
                .inject()
                .insertField(int.class.getCanonicalName(), "integer")