[jboss-cvs] JBossAS SVN: r102450 - in projects/jboss-reflect/trunk/src/test/java/org/jboss/test: plugins/javassist and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 16 07:40:27 EDT 2010
Author: kabir.khan at jboss.com
Date: 2010-03-16 07:40:25 -0400 (Tue, 16 Mar 2010)
New Revision: 102450
Added:
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo2.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo3.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoBody.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoConstructor.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoField.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistBodyTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistConstructorInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistFieldInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistMutableMethodInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistMutableTypeInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistTestSuite.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistUtilTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/ModifierInfoTestCase.java
Removed:
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistBodyTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistConstructorInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistFieldInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableMethodInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableTypeInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistUtilTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/ModifierInfoTestCase.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo2.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo3.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoBody.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoConstructor.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoField.java
Modified:
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/ContainerAllTestSuite.java
Log:
Reorganise the javassist-only tests into test/ and support/ folders and add to main testsuite
Modified: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/ContainerAllTestSuite.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/ContainerAllTestSuite.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/ContainerAllTestSuite.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -27,6 +27,7 @@
import org.jboss.test.beaninfo.test.BeanInfoTestSuite;
import org.jboss.test.classinfo.test.ClassInfoTestSuite;
import org.jboss.test.joinpoint.test.JoinpointTestSuite;
+import org.jboss.test.plugins.javassist.test.JavassistTestSuite;
import org.jboss.test.typeinfo.test.TypeInfoTestSuite;
/**
@@ -50,6 +51,7 @@
suite.addTest(ClassInfoTestSuite.suite());
suite.addTest(JoinpointTestSuite.suite());
suite.addTest(BeanInfoTestSuite.suite());
+ suite.addTest(JavassistTestSuite.suite());
return suite;
}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistBodyTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistBodyTestCase.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistBodyTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-import java.lang.reflect.Method;
-
-import org.jboss.reflect.plugins.javassist.InsertAfterJavassistBody;
-import org.jboss.reflect.plugins.javassist.InsertBeforeJavassistBody;
-import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory;
-import org.jboss.reflect.spi.MutableClassInfo;
-import org.jboss.reflect.spi.MutableMethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.test.ContainerTest;
-
-/**
- * A JavassistBodyTestCase.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class JavassistBodyTestCase extends ContainerTest
-{
-
- /**
- * Create a new JavassistBodyTestCase.
- *
- * @param name
- */
- public JavassistBodyTestCase(String name)
- {
- super(name);
- }
-
- @SuppressWarnings("deprecation")
- public void testBody()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactory().getMutable("org.jboss.test.plugins.javassist.PojoBody", null);
- try
- {
- MutableMethodInfo mmi = mci.getDeclaredMethod("foo", (TypeInfo) new JavassistTypeInfoFactory().getMutable("int", null));
-
- System.out.println("got method: "+mmi.getName());
- mmi.setBody(new InsertBeforeJavassistBody("i = 42;"));
- MutableMethodInfo mmi2 = mci.getDeclaredMethod("bar");
- System.out.println("mmi2: "+mmi2.getName());
- mmi2.setBody(new InsertAfterJavassistBody("s = \"after\" + s; return s;"));
- System.out.println("mmi2: "+mmi2.getName());
-
- Class<?> clazz = mci.getType();
-
- Object pojoBody = clazz.newInstance();
- Method m1 = clazz.getDeclaredMethods()[0];
- assertEquals(42, m1.invoke(pojoBody, new Object[] {1}));
- Method m2 = clazz.getDeclaredMethods()[1];
- assertEquals("afterbar", m2.invoke(pojoBody, new Object[] {}));
-
- System.out.println();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistConstructorInfoTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistConstructorInfoTestCase.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistConstructorInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,53 +0,0 @@
-package org.jboss.test.plugins.javassist;
-
-import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl;
-import org.jboss.reflect.spi.ModifierInfo;
-import org.jboss.reflect.spi.MutableClassInfo;
-import org.jboss.reflect.spi.MutableConstructorInfo;
-import org.jboss.test.ContainerTest;
-
-public class JavassistConstructorInfoTestCase extends ContainerTest
-{
-
- public JavassistConstructorInfoTestCase(String name)
- {
- super(name);
- }
-
- public void testAddConstructor()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.PojoConstructor", null);
- try
- {
- MutableConstructorInfo intConstructor = mci.getDeclaredConstructor("int");
- assertNotNull(intConstructor);
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
-
- MutableConstructorInfo mci1 = mci.createMutableConstructor(ModifierInfo.PUBLIC, new String[] {"java.lang.String"}, new String[0]);
- mci.addConstructor(mci1);
- assertEquals(3, mci.getDeclaredConstructors().length);
- }
-
- public void testRemoveConstructor()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.PojoConstructor", null);
- MutableConstructorInfo constructor;
- try
- {
- constructor = mci.getDeclaredConstructor("int");
- mci.removeConstructor(constructor);
- assertEquals(2, mci.getDeclaredConstructors().length);
-
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
-
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistFieldInfoTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistFieldInfoTestCase.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistFieldInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,37 +0,0 @@
-package org.jboss.test.plugins.javassist;
-
-import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl;
-import org.jboss.reflect.spi.ModifierInfo;
-import org.jboss.reflect.spi.MutableClassInfo;
-import org.jboss.reflect.spi.MutableFieldInfo;
-import org.jboss.test.ContainerTest;
-
-public class JavassistFieldInfoTestCase extends ContainerTest
-{
-
- public JavassistFieldInfoTestCase(String name)
- {
- super(name);
- }
-
- public void testAddField()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.PojoField", null);
- MutableFieldInfo foo = mci.getDeclaredField("foo");
- assertEquals("java.lang.String", foo.getType().getName());
- assertEquals(ModifierInfo.PUBLIC, foo.getModifiers());
- MutableFieldInfo mfi1 = mci.createMutableField(ModifierInfo.PUBLIC, "java.lang.String", "test1");
- mci.addField(mfi1);
- assertEquals(2, mci.getDeclaredFields().length);
- }
-
- public void testRemoveField()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.PojoField", null);
- MutableFieldInfo foo = mci.getDeclaredField("foo");
- mci.removeField(foo);
- assertEquals(1, mci.getDeclaredFields().length);
-
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableMethodInfoTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableMethodInfoTestCase.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableMethodInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,119 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-import org.jboss.reflect.plugins.javassist.InsertBeforeJavassistBody;
-import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl;
-import org.jboss.reflect.spi.MutableClassInfo;
-import org.jboss.reflect.spi.MutableMethodInfo;
-import org.jboss.test.ContainerTest;
-
-/**
- * A JavassistMutableMethodInfoTestCase.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class JavassistMutableMethodInfoTestCase extends ContainerTest
-{
-
- /**
- * Create a new JavassistMutableMethodInfoTestCase.
- *
- * @param name
- */
- public JavassistMutableMethodInfoTestCase(String name)
- {
- super(name);
- }
-
- public void testMethods()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.Pojo3", null);
-
- MutableMethodInfo[] methods = mci.getDeclaredMethods();
- try
- {
- MutableMethodInfo bar = mci.getDeclaredMethod("bar", "java.lang.String");
-
- assertEquals(3, methods.length);
- assertEquals("bar", bar.getName());
- assertEquals("java.lang.String", bar.getParameterTypes()[0].getName());
-
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testRemoveMethod()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.Pojo3", null);
-
- try
- {
- MutableMethodInfo bar = mci.getDeclaredMethod("bar", "java.lang.String");
- mci.removeMethod(bar);
- assertEquals(2, mci.getDeclaredMethods().length);
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
- }
-
- @SuppressWarnings("deprecation")
- public void testNewMethods()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.Pojo3", null);
- MutableMethodInfo newMethod1 = mci.createMutableMethod(new InsertBeforeJavassistBody("public void test1() { }"));
- mci.addMethod(newMethod1);
- MutableMethodInfo newMethod2 = mci.createMutableMethod(new InsertBeforeJavassistBody("public String test2() { return \"foo\"; }"));
- try
- {
- newMethod2.setReturnType("java.lang.String");
- assertFalse("MutableMethoInfo should throw an exception!", true);
- }
- catch(RuntimeException re)
- {
- }
- newMethod2.setName("test3");
- mci.addMethod(newMethod2);
-
- assertEquals(4, mci.getDeclaredMethods().length);
- Class<?> theClass = mci.getType();
- assertEquals(4, theClass.getDeclaredMethods().length);
- try
- {
- assertNotNull(theClass.getDeclaredMethod("test3"));
- }
- catch (SecurityException e)
- {
- }
- catch (NoSuchMethodException e)
- {
- }
- }
-
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableTypeInfoTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableTypeInfoTestCase.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableTypeInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-import java.lang.reflect.Method;
-
-import org.jboss.reflect.plugins.javassist.InsertBeforeJavassistBody;
-import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.MutableClassInfo;
-import org.jboss.reflect.spi.MutableMethodInfo;
-import org.jboss.test.ContainerTest;
-
-/**
- * A JavassistMutableTypeInfoTestCase.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class JavassistMutableTypeInfoTestCase extends ContainerTest
-{
-
- /**
- * Create a new JavassistMutableTypeInfoTestCase.
- *
- * @param name
- */
- public JavassistMutableTypeInfoTestCase(String name)
- {
- super(name);
- }
-
- @SuppressWarnings("deprecation")
- public void testNewClass()
- {
- MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().createNewMutableClass("org.jboss.test.plugins.javassist.PojoNew");
- assertEquals(mci.getName(), "org.jboss.test.plugins.javassist.PojoNew");
- assertEquals(mci.isPublic(), true);
- MutableMethodInfo mmi1 = mci.createMutableMethod(new InsertBeforeJavassistBody("public String getFoo() { return \"foo\"; }"));
- mci.addMethod(mmi1);
- assertEquals(mci.getDeclaredMethods().length, 1);
- MethodInfo mi = mci.getDeclaredMethods()[0];
- assertEquals(mi.getReturnType().getName(), "java.lang.String");
-
- Class<?> clazz = mci.getType();
- try
- {
- Object pojo = clazz.newInstance();
- Method m1 = clazz.getMethod("getFoo", new Class[0]);
- assertEquals("foo", m1.invoke(pojo, new Object[0]));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistUtilTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistUtilTestCase.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistUtilTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,169 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javassist.CannotCompileException;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtField;
-import javassist.CtMethod;
-import javassist.CtNewMethod;
-import javassist.NotFoundException;
-
-import org.jboss.reflect.plugins.javassist.JavassistUtil;
-import org.jboss.test.ContainerTest;
-
-/**
- * A JavassistUtilTestCase.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class JavassistUtilTestCase extends ContainerTest
-{
-
- final static Map<String, Class<?>> primitives;
- static
- {
- primitives = new HashMap<String, Class<?>>();
- primitives.put(CtClass.booleanType.getName(), Boolean.TYPE);
- primitives.put(CtClass.byteType.getName(), Byte.TYPE);
- primitives.put(CtClass.charType.getName(), Character.TYPE);
- primitives.put(CtClass.doubleType.getName(), Double.TYPE);
- primitives.put(CtClass.floatType.getName(), Float.TYPE);
- primitives.put(CtClass.intType.getName(), Integer.TYPE);
- primitives.put(CtClass.longType.getName(), Long.TYPE);
- primitives.put(CtClass.shortType.getName(), Short.TYPE);
- primitives.put(CtClass.voidType.getName(), Void.TYPE);
- }
- /**
- * Create a new JavassistUtilTestCase.
- *
- * @param name
- */
- public JavassistUtilTestCase(String name)
- {
- super(name);
- }
-
- public void testCtClassToClass()
- {
- Class<?> clazz = loadClass("int");
- assertEquals("int", clazz.getName());
- clazz = loadClass("byte[][][]");
- assertEquals("[[[B", clazz.getName());
- clazz = loadClass("java.lang.String[][]");
- assertEquals("[[Ljava.lang.String;", clazz.getName());
- clazz = loadClass("java.lang.String[][][]");
- assertEquals("[[[Ljava.lang.String;", clazz.getName());
- }
-
- public void testGeneratedCtClassToClass()
- {
- CtClass clazz = ClassPool.getDefault().makeClass("TestClass");
- try
- {
- CtMethod foo = CtNewMethod.make("public void foo() { }", clazz);
- clazz.addMethod(foo);
- Class<?> theClass = JavassistUtil.ctClassToClass(clazz);
- assertEquals("TestClass", theClass.getName());
- }
- catch (CannotCompileException e)
- {
- e.printStackTrace();
- }
- }
-
- public void testSignature()
- {
- try
- {
- CtClass pojo = ClassPool.getDefault().get("org.jboss.test.plugins.javassist.Pojo");
-
- CtMethod[] methods = pojo.getDeclaredMethods();
- for(CtMethod m : methods)
- {
- System.out.println("Method "+m.getName()+", description: "+m.getSignature()+", get longname: "+m.getLongName());
- }
- CtField[] fields = pojo.getDeclaredFields();
- for(CtField f : fields)
- System.out.println("Field "+f.getName()+", description: "+f.getSignature());
-
- CtConstructor[] constructors = pojo.getConstructors();
- for(CtConstructor c : constructors)
- System.out.println("Constructor "+c.getName()+", description: "+c.getSignature()+", longname: "+c.getLongName());
- }
- catch (NotFoundException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void testChangedCtClassToClass()
- {
- try
- {
- CtClass clazz = ClassPool.getDefault().get("org.jboss.test.plugins.javassist.Pojo");
- CtMethod foo = CtNewMethod.make("public void test1() { }", clazz);
- clazz.addMethod(foo);
-
-
- Class<?> theClass = JavassistUtil.ctClassToClass(clazz);
- assertEquals(4, theClass.getDeclaredMethods().length);
- }
- catch (CannotCompileException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch (NotFoundException e)
- {
- e.printStackTrace();
- }
-
- }
-
-
- private Class<?> loadClass(String name)
- {
- if (primitives.containsKey(name))
- {
- return primitives.get(name);
- }
-
- try
- {
- return JavassistUtil.ctClassToClass(ClassPool.getDefault().get(name));
- }
- catch (NotFoundException e)
- {
- return null;
- }
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/ModifierInfoTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/ModifierInfoTestCase.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/ModifierInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-import javassist.Modifier;
-
-import org.jboss.reflect.spi.ModifierInfo;
-import org.jboss.test.ContainerTest;
-
-/**
- * ModifierInfoTestCase.
- *
- * @author Stale Pedersen
- * @author Flavia Rainone
- * @version $Revision: 1.1 $
- */
-public class ModifierInfoTestCase extends ContainerTest
-{
-
- public ModifierInfoTestCase(String name)
- {
- super(name);
- }
-
- public void testModifiers()
- {
- assertEquals(ModifierInfo.PUBLIC, Modifier.PUBLIC);
- assertEquals(ModifierInfo.PRIVATE, Modifier.PRIVATE);
- assertEquals(ModifierInfo.PROTECTED, Modifier.PROTECTED);
- assertEquals(ModifierInfo.STATIC, Modifier.STATIC);
- assertEquals(ModifierInfo.PUBLIC_STATIC, Modifier.PUBLIC + Modifier.STATIC);
-
- }
-
- public void testNewModifiers()
- {
- assertEquals(Modifier.PRIVATE, ModifierInfo.PRIVATE);
- }
-
- public void testIsPublic()
- {
- assertTrue(Modifier.isPublic(ModifierInfo.PUBLIC));
- assertFalse(Modifier.isPublic(ModifierInfo.STATIC));
- }
-
- public void testIsStatic()
- {
- assertTrue(Modifier.isStatic(ModifierInfo.STATIC));
- assertTrue(Modifier.isStatic(ModifierInfo.PUBLIC_STATIC));
- assertFalse(Modifier.isStatic(ModifierInfo.PACKAGE_ABSTRACT));
- }
-
-}
\ No newline at end of file
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-/**
- * A Pojo.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class Pojo
-{
-
- public String foo;
-
- public int bar;
-
- public Pojo()
- {
- }
-
- public Pojo(String s)
- {
- }
-
- public String foo()
- {
- return null;
- }
-
- public void foo(String s)
- {
- }
-
- public void bar(String s)
- {
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo2.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo2.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo2.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-/**
- * A Pojo.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class Pojo2
-{
-
- public int foo(int i)
- {
- return i;
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo3.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo3.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo3.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-/**
- * A Pojo.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class Pojo3
-{
-
- public String foo;
-
- public Pojo3()
- {
- }
-
- public Pojo3(String s)
- {
- }
-
- public String foo()
- {
- return null;
- }
-
- public void foo(String s)
- {
- }
-
- public void bar(String s)
- {
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoBody.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoBody.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoBody.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-/**
- * A Pojo.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class PojoBody
-{
-
- private String s;
-// private int i = 0;
- public int foo(int i)
- {
- return i;
- }
-
- public String bar()
- {
- s = "bar";
- return s;
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoConstructor.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoConstructor.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoConstructor.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-/**
- * A Pojo.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class PojoConstructor
-{
-
- public String foo;
-
- public PojoConstructor()
- {
- }
-
- public PojoConstructor(int i)
- {
- }
-
-}
Deleted: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoField.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoField.java 2010-03-16 09:40:12 UTC (rev 102449)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoField.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.plugins.javassist;
-
-/**
- * A Pojo.
- *
- * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
- * @version $Revision: 1.1 $
- */
-public class PojoField
-{
-
- public String foo;
-
- public PojoField()
- {
- }
-
- public PojoField(String s)
- {
- }
-
- public String foo()
- {
- return null;
- }
-
- public void foo(String s)
- {
- }
-
- public void bar(String s)
- {
- }
-
-}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.support;
+
+/**
+ * A Pojo.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class Pojo
+{
+
+ public String foo;
+
+ public int bar;
+
+ public Pojo()
+ {
+ }
+
+ public Pojo(String s)
+ {
+ }
+
+ public String foo()
+ {
+ return null;
+ }
+
+ public void foo(String s)
+ {
+ }
+
+ public void bar(String s)
+ {
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo2.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo2.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo2.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo2.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.support;
+
+/**
+ * A Pojo.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class Pojo2
+{
+
+ public int foo(int i)
+ {
+ return i;
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo3.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/Pojo3.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo3.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/Pojo3.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.support;
+
+/**
+ * A Pojo.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class Pojo3
+{
+
+ public String foo;
+
+ public Pojo3()
+ {
+ }
+
+ public Pojo3(String s)
+ {
+ }
+
+ public String foo()
+ {
+ return null;
+ }
+
+ public void foo(String s)
+ {
+ }
+
+ public void bar(String s)
+ {
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoBody.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoBody.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoBody.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoBody.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.support;
+
+/**
+ * A Pojo.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class PojoBody
+{
+
+ private String s;
+// private int i = 0;
+ public int foo(int i)
+ {
+ return i;
+ }
+
+ public String bar()
+ {
+ s = "bar";
+ return s;
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoConstructor.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoConstructor.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoConstructor.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoConstructor.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.support;
+
+/**
+ * A Pojo.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class PojoConstructor
+{
+
+ public String foo;
+
+ public PojoConstructor()
+ {
+ }
+
+ public PojoConstructor(int i)
+ {
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoField.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/PojoField.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoField.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/support/PojoField.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.support;
+
+/**
+ * A Pojo.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class PojoField
+{
+
+ public String foo;
+
+ public PojoField()
+ {
+ }
+
+ public PojoField(String s)
+ {
+ }
+
+ public String foo()
+ {
+ return null;
+ }
+
+ public void foo(String s)
+ {
+ }
+
+ public void bar(String s)
+ {
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistBodyTestCase.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistBodyTestCase.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistBodyTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistBodyTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.test;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Test;
+
+import org.jboss.reflect.plugins.javassist.InsertAfterJavassistBody;
+import org.jboss.reflect.plugins.javassist.InsertBeforeJavassistBody;
+import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactory;
+import org.jboss.reflect.spi.MutableClassInfo;
+import org.jboss.reflect.spi.MutableMethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.test.ContainerTest;
+
+/**
+ * A JavassistBodyTestCase.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistBodyTestCase extends ContainerTest
+{
+
+ /**
+ * Create a new JavassistBodyTestCase.
+ *
+ * @param name
+ */
+ public JavassistBodyTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(JavassistBodyTestCase.class);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testBody()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactory().getMutable("org.jboss.test.plugins.javassist.support.PojoBody", null);
+ try
+ {
+ MutableMethodInfo mmi = mci.getDeclaredMethod("foo", (TypeInfo) new JavassistTypeInfoFactory().getMutable("int", null));
+
+ System.out.println("got method: "+mmi.getName());
+ mmi.setBody(new InsertBeforeJavassistBody("i = 42;"));
+ MutableMethodInfo mmi2 = mci.getDeclaredMethod("bar");
+ System.out.println("mmi2: "+mmi2.getName());
+ mmi2.setBody(new InsertAfterJavassistBody("s = \"after\" + s; return s;"));
+ System.out.println("mmi2: "+mmi2.getName());
+
+ Class<?> clazz = mci.getType();
+
+ Object pojoBody = clazz.newInstance();
+ Method m1 = clazz.getDeclaredMethods()[0];
+ assertEquals(42, m1.invoke(pojoBody, new Object[] {1}));
+ Method m2 = clazz.getDeclaredMethods()[1];
+ assertEquals("afterbar", m2.invoke(pojoBody, new Object[] {}));
+
+ System.out.println();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistConstructorInfoTestCase.java (from rev 102449, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistConstructorInfoTestCase.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistConstructorInfoTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistConstructorInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,60 @@
+package org.jboss.test.plugins.javassist.test;
+
+import junit.framework.Test;
+
+import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl;
+import org.jboss.reflect.spi.ModifierInfo;
+import org.jboss.reflect.spi.MutableClassInfo;
+import org.jboss.reflect.spi.MutableConstructorInfo;
+import org.jboss.test.ContainerTest;
+
+public class JavassistConstructorInfoTestCase extends ContainerTest
+{
+
+ public JavassistConstructorInfoTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(JavassistConstructorInfoTestCase.class);
+ }
+
+ public void testAddConstructor()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.support.PojoConstructor", null);
+ try
+ {
+ MutableConstructorInfo intConstructor = mci.getDeclaredConstructor("int");
+ assertNotNull(intConstructor);
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+
+ MutableConstructorInfo mci1 = mci.createMutableConstructor(ModifierInfo.PUBLIC, new String[] {"java.lang.String"}, new String[0]);
+ mci.addConstructor(mci1);
+ assertEquals(3, mci.getDeclaredConstructors().length);
+ }
+
+ public void testRemoveConstructor()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.support.PojoConstructor", null);
+ MutableConstructorInfo constructor;
+ try
+ {
+ constructor = mci.getDeclaredConstructor("int");
+ mci.removeConstructor(constructor);
+ assertEquals(2, mci.getDeclaredConstructors().length);
+
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistFieldInfoTestCase.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistFieldInfoTestCase.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistFieldInfoTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistFieldInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,44 @@
+package org.jboss.test.plugins.javassist.test;
+
+import junit.framework.Test;
+
+import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl;
+import org.jboss.reflect.spi.ModifierInfo;
+import org.jboss.reflect.spi.MutableClassInfo;
+import org.jboss.reflect.spi.MutableFieldInfo;
+import org.jboss.test.ContainerTest;
+
+public class JavassistFieldInfoTestCase extends ContainerTest
+{
+
+ public JavassistFieldInfoTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(JavassistFieldInfoTestCase.class);
+ }
+
+ public void testAddField()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.support.PojoField", null);
+ MutableFieldInfo foo = mci.getDeclaredField("foo");
+ assertEquals("java.lang.String", foo.getType().getName());
+ assertEquals(ModifierInfo.PUBLIC, foo.getModifiers());
+ MutableFieldInfo mfi1 = mci.createMutableField(ModifierInfo.PUBLIC, "java.lang.String", "test1");
+ mci.addField(mfi1);
+ assertEquals(2, mci.getDeclaredFields().length);
+ }
+
+ public void testRemoveField()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.support.PojoField", null);
+ MutableFieldInfo foo = mci.getDeclaredField("foo");
+ mci.removeField(foo);
+ assertEquals(1, mci.getDeclaredFields().length);
+
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistMutableMethodInfoTestCase.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableMethodInfoTestCase.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistMutableMethodInfoTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistMutableMethodInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.test;
+
+import junit.framework.Test;
+
+import org.jboss.reflect.plugins.javassist.InsertBeforeJavassistBody;
+import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl;
+import org.jboss.reflect.spi.MutableClassInfo;
+import org.jboss.reflect.spi.MutableMethodInfo;
+import org.jboss.test.ContainerTest;
+
+/**
+ * A JavassistMutableMethodInfoTestCase.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMutableMethodInfoTestCase extends ContainerTest
+{
+
+ /**
+ * Create a new JavassistMutableMethodInfoTestCase.
+ *
+ * @param name
+ */
+ public JavassistMutableMethodInfoTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(JavassistMutableMethodInfoTestCase.class);
+ }
+
+ public void testMethods()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.support.Pojo3", null);
+
+ MutableMethodInfo[] methods = mci.getDeclaredMethods();
+ try
+ {
+ MutableMethodInfo bar = mci.getDeclaredMethod("bar", "java.lang.String");
+
+ assertEquals(3, methods.length);
+ assertEquals("bar", bar.getName());
+ assertEquals("java.lang.String", bar.getParameterTypes()[0].getName());
+
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testRemoveMethod()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.support.Pojo3", null);
+
+ try
+ {
+ MutableMethodInfo bar = mci.getDeclaredMethod("bar", "java.lang.String");
+ mci.removeMethod(bar);
+ assertEquals(2, mci.getDeclaredMethods().length);
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testNewMethods()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().getMutable("org.jboss.test.plugins.javassist.support.Pojo3", null);
+ MutableMethodInfo newMethod1 = mci.createMutableMethod(new InsertBeforeJavassistBody("public void test1() { }"));
+ mci.addMethod(newMethod1);
+ MutableMethodInfo newMethod2 = mci.createMutableMethod(new InsertBeforeJavassistBody("public String test2() { return \"foo\"; }"));
+ try
+ {
+ newMethod2.setReturnType("java.lang.String");
+ assertFalse("MutableMethoInfo should throw an exception!", true);
+ }
+ catch(RuntimeException re)
+ {
+ }
+ newMethod2.setName("test3");
+ mci.addMethod(newMethod2);
+
+ assertEquals(4, mci.getDeclaredMethods().length);
+ Class<?> theClass = mci.getType();
+ assertEquals(4, theClass.getDeclaredMethods().length);
+ try
+ {
+ assertNotNull(theClass.getDeclaredMethod("test3"));
+ }
+ catch (SecurityException e)
+ {
+ }
+ catch (NoSuchMethodException e)
+ {
+ }
+ }
+
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistMutableTypeInfoTestCase.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistMutableTypeInfoTestCase.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistMutableTypeInfoTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistMutableTypeInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.test;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Test;
+
+import org.jboss.reflect.plugins.javassist.InsertBeforeJavassistBody;
+import org.jboss.reflect.plugins.javassist.JavassistTypeInfoFactoryImpl;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.MutableClassInfo;
+import org.jboss.reflect.spi.MutableMethodInfo;
+import org.jboss.test.ContainerTest;
+
+/**
+ * A JavassistMutableTypeInfoTestCase.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistMutableTypeInfoTestCase extends ContainerTest
+{
+
+ /**
+ * Create a new JavassistMutableTypeInfoTestCase.
+ *
+ * @param name
+ */
+ public JavassistMutableTypeInfoTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(JavassistMutableTypeInfoTestCase.class);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testNewClass()
+ {
+ MutableClassInfo mci = new JavassistTypeInfoFactoryImpl().createNewMutableClass("org.jboss.test.plugins.javassist.PojoNew");
+ assertEquals(mci.getName(), "org.jboss.test.plugins.javassist.PojoNew");
+ assertEquals(mci.isPublic(), true);
+ MutableMethodInfo mmi1 = mci.createMutableMethod(new InsertBeforeJavassistBody("public String getFoo() { return \"foo\"; }"));
+ mci.addMethod(mmi1);
+ assertEquals(mci.getDeclaredMethods().length, 1);
+ MethodInfo mi = mci.getDeclaredMethods()[0];
+ assertEquals(mi.getReturnType().getName(), "java.lang.String");
+
+ Class<?> clazz = mci.getType();
+ try
+ {
+ Object pojo = clazz.newInstance();
+ Method m1 = clazz.getMethod("getFoo", new Class[0]);
+ assertEquals("foo", m1.invoke(pojo, new Object[0]));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistTestSuite.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistTestSuite.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistTestSuite.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.plugins.javassist.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistTestSuite
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Javassist Tests");
+
+ suite.addTest(JavassistBodyTestCase.suite());
+ suite.addTest(JavassistConstructorInfoTestCase.suite());
+ suite.addTest(JavassistFieldInfoTestCase.suite());
+ suite.addTest(JavassistMutableMethodInfoTestCase.suite());
+ suite.addTest(JavassistMutableTypeInfoTestCase.suite());
+ suite.addTest(JavassistUtilTestCase.suite());
+ suite.addTest(ModifierInfoTestCase.suite());
+
+ return suite;
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistUtilTestCase.java (from rev 102449, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/JavassistUtilTestCase.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistUtilTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/JavassistUtilTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.test;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+import javassist.NotFoundException;
+import junit.framework.Test;
+
+import org.jboss.reflect.plugins.javassist.JavassistUtil;
+import org.jboss.test.ContainerTest;
+
+/**
+ * A JavassistUtilTestCase.
+ *
+ * @author <a href="mailto:stale.pedersen at jboss.org">Stale W. Pedersen</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavassistUtilTestCase extends ContainerTest
+{
+
+ final static Map<String, Class<?>> primitives;
+ static
+ {
+ primitives = new HashMap<String, Class<?>>();
+ primitives.put(CtClass.booleanType.getName(), Boolean.TYPE);
+ primitives.put(CtClass.byteType.getName(), Byte.TYPE);
+ primitives.put(CtClass.charType.getName(), Character.TYPE);
+ primitives.put(CtClass.doubleType.getName(), Double.TYPE);
+ primitives.put(CtClass.floatType.getName(), Float.TYPE);
+ primitives.put(CtClass.intType.getName(), Integer.TYPE);
+ primitives.put(CtClass.longType.getName(), Long.TYPE);
+ primitives.put(CtClass.shortType.getName(), Short.TYPE);
+ primitives.put(CtClass.voidType.getName(), Void.TYPE);
+ }
+
+ public static Test suite()
+ {
+ return suite(JavassistUtilTestCase.class);
+ }
+
+ /**
+ * Create a new JavassistUtilTestCase.
+ *
+ * @param name
+ */
+ public JavassistUtilTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testCtClassToClass()
+ {
+ Class<?> clazz = loadClass("int");
+ assertEquals("int", clazz.getName());
+ clazz = loadClass("byte[][][]");
+ assertEquals("[[[B", clazz.getName());
+ clazz = loadClass("java.lang.String[][]");
+ assertEquals("[[Ljava.lang.String;", clazz.getName());
+ clazz = loadClass("java.lang.String[][][]");
+ assertEquals("[[[Ljava.lang.String;", clazz.getName());
+ }
+
+ public void testGeneratedCtClassToClass()
+ {
+ CtClass clazz = ClassPool.getDefault().makeClass("TestClass");
+ try
+ {
+ CtMethod foo = CtNewMethod.make("public void foo() { }", clazz);
+ clazz.addMethod(foo);
+ Class<?> theClass = JavassistUtil.ctClassToClass(clazz);
+ assertEquals("TestClass", theClass.getName());
+ }
+ catch (CannotCompileException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testSignature()
+ {
+ try
+ {
+ CtClass pojo = ClassPool.getDefault().get("org.jboss.test.plugins.javassist.Pojo");
+
+ CtMethod[] methods = pojo.getDeclaredMethods();
+ for(CtMethod m : methods)
+ {
+ System.out.println("Method "+m.getName()+", description: "+m.getSignature()+", get longname: "+m.getLongName());
+ }
+ CtField[] fields = pojo.getDeclaredFields();
+ for(CtField f : fields)
+ System.out.println("Field "+f.getName()+", description: "+f.getSignature());
+
+ CtConstructor[] constructors = pojo.getConstructors();
+ for(CtConstructor c : constructors)
+ System.out.println("Constructor "+c.getName()+", description: "+c.getSignature()+", longname: "+c.getLongName());
+ }
+ catch (NotFoundException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void testChangedCtClassToClass()
+ {
+ try
+ {
+ CtClass clazz = ClassPool.getDefault().get("org.jboss.test.plugins.javassist.Pojo");
+ CtMethod foo = CtNewMethod.make("public void test1() { }", clazz);
+ clazz.addMethod(foo);
+
+
+ Class<?> theClass = JavassistUtil.ctClassToClass(clazz);
+ assertEquals(4, theClass.getDeclaredMethods().length);
+ }
+ catch (CannotCompileException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (NotFoundException e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ private Class<?> loadClass(String name)
+ {
+ if (primitives.containsKey(name))
+ {
+ return primitives.get(name);
+ }
+
+ try
+ {
+ return JavassistUtil.ctClassToClass(ClassPool.getDefault().get(name));
+ }
+ catch (NotFoundException e)
+ {
+ return null;
+ }
+ }
+
+}
Copied: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/ModifierInfoTestCase.java (from rev 102421, projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/ModifierInfoTestCase.java)
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/ModifierInfoTestCase.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/plugins/javassist/test/ModifierInfoTestCase.java 2010-03-16 11:40:25 UTC (rev 102450)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.plugins.javassist.test;
+
+import javassist.Modifier;
+import junit.framework.Test;
+
+import org.jboss.reflect.spi.ModifierInfo;
+import org.jboss.test.ContainerTest;
+
+/**
+ * ModifierInfoTestCase.
+ *
+ * @author Stale Pedersen
+ * @author Flavia Rainone
+ * @version $Revision: 1.1 $
+ */
+public class ModifierInfoTestCase extends ContainerTest
+{
+
+ public ModifierInfoTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(ModifierInfoTestCase.class);
+ }
+
+ public void testModifiers()
+ {
+ assertEquals(ModifierInfo.PUBLIC, Modifier.PUBLIC);
+ assertEquals(ModifierInfo.PRIVATE, Modifier.PRIVATE);
+ assertEquals(ModifierInfo.PROTECTED, Modifier.PROTECTED);
+ assertEquals(ModifierInfo.STATIC, Modifier.STATIC);
+ assertEquals(ModifierInfo.PUBLIC_STATIC, Modifier.PUBLIC + Modifier.STATIC);
+
+ }
+
+ public void testNewModifiers()
+ {
+ assertEquals(Modifier.PRIVATE, ModifierInfo.PRIVATE);
+ }
+
+ public void testIsPublic()
+ {
+ assertTrue(Modifier.isPublic(ModifierInfo.PUBLIC));
+ assertFalse(Modifier.isPublic(ModifierInfo.STATIC));
+ }
+
+ public void testIsStatic()
+ {
+ assertTrue(Modifier.isStatic(ModifierInfo.STATIC));
+ assertTrue(Modifier.isStatic(ModifierInfo.PUBLIC_STATIC));
+ assertFalse(Modifier.isStatic(ModifierInfo.PACKAGE_ABSTRACT));
+ }
+
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list