[jboss-cvs] JBossAS SVN: r82186 - in projects/aop/trunk: asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 10 06:54:03 EST 2008
Author: kabir.khan at jboss.com
Date: 2008-12-10 06:54:03 -0500 (Wed, 10 Dec 2008)
New Revision: 82186
Modified:
projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java
projects/aop/trunk/asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test/UclClassLoaderSanityTestCase.java
projects/aop/trunk/asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test/UclDelegatingClassPoolTestCase.java
projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithRepositorySanityTestCase.java
projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithRepositoryTestCase.java
Log:
[JBAOP-666] ClassLoader within domain ordering
Modified: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java 2008-12-10 10:08:58 UTC (rev 82185)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java 2008-12-10 11:54:03 UTC (rev 82186)
@@ -125,6 +125,10 @@
{
clazz = pool.createCtClass(classname, true);
}
+ if (clazz != null)
+ {
+ break;
+ }
}
}
}
Modified: projects/aop/trunk/asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test/UclClassLoaderSanityTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test/UclClassLoaderSanityTestCase.java 2008-12-10 10:08:58 UTC (rev 82185)
+++ projects/aop/trunk/asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test/UclClassLoaderSanityTestCase.java 2008-12-10 11:54:03 UTC (rev 82186)
@@ -325,4 +325,30 @@
removeClassLoaderFromRepository(globalB);
}
}
+
+ public void testUclLoaderOrdering() throws Exception
+ {
+ ClassLoader globalA = null;
+ ClassLoader globalB = null;
+ ClassLoader globalC = null;
+ try
+ {
+ globalA = createGlobalClassLoader(JAR_A_1);
+ globalB = createGlobalClassLoader(JAR_A_1);
+ globalC = createGlobalClassLoader(JAR_A_1);
+
+ Class<?> aFromA = globalA.loadClass(CLASS_A);
+ Class<?> aFromB = globalB.loadClass(CLASS_A);
+ Class<?> aFromC = globalC.loadClass(CLASS_A);
+ assertSame(aFromA, aFromB);
+ assertSame(aFromA, aFromC);
+ assertSame(globalA, aFromA.getClassLoader());
+ }
+ finally
+ {
+ removeClassLoaderFromRepository(globalA);
+ removeClassLoaderFromRepository(globalB);
+ removeClassLoaderFromRepository(globalC);
+ }
+ }
}
Modified: projects/aop/trunk/asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test/UclDelegatingClassPoolTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test/UclDelegatingClassPoolTestCase.java 2008-12-10 10:08:58 UTC (rev 82185)
+++ projects/aop/trunk/asintegration-jmx/src/tests/org/jboss/test/aop/classpool/ucl/test/UclDelegatingClassPoolTestCase.java 2008-12-10 11:54:03 UTC (rev 82186)
@@ -602,4 +602,29 @@
}
}
+ public void testUclLoaderOrdering() throws Exception
+ {
+ ClassPool globalA = null;
+ ClassPool globalB = null;
+ ClassPool globalC = null;
+ try
+ {
+ globalA = createGlobalClassPool(JAR_A_1);
+ globalB = createGlobalClassPool(JAR_A_1);
+ globalC = createGlobalClassPool(JAR_A_1);
+
+ CtClass aFromA = globalA.get(CLASS_A);
+ CtClass aFromB = globalB.get(CLASS_A);
+ CtClass aFromC = globalC.get(CLASS_A);
+ assertSame(aFromA, aFromB);
+ assertSame(aFromA, aFromC);
+ assertSame(globalA, aFromA.getClassPool());
+ }
+ finally
+ {
+ removeClassPool(globalA);
+ removeClassPool(globalB);
+ removeClassPool(globalC);
+ }
+ }
}
Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithRepositorySanityTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithRepositorySanityTestCase.java 2008-12-10 10:08:58 UTC (rev 82185)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithRepositorySanityTestCase.java 2008-12-10 11:54:03 UTC (rev 82186)
@@ -514,4 +514,31 @@
unregisterDomain(cl1B);
}
}
+
+ public void testUclLoaderOrdering() throws Exception
+ {
+ ClassLoader globalA = null;
+ ClassLoader globalB = null;
+ ClassLoader globalC = null;
+ try
+ {
+ globalA = createClassLoader("A1", true, JAR_A_1);
+ globalB = createClassLoader("A2", true, JAR_A_1);
+ globalC = createClassLoader("A3", true, JAR_A_1);
+
+ Class<?> aFromA = globalA.loadClass(CLASS_A);
+ Class<?> aFromB = globalB.loadClass(CLASS_A);
+ Class<?> aFromC = globalC.loadClass(CLASS_A);
+ assertSame(aFromA, aFromB);
+ assertSame(aFromA, aFromC);
+ assertSame(globalA, aFromA.getClassLoader());
+ }
+ finally
+ {
+ unregisterClassLoader(globalA);
+ unregisterClassLoader(globalB);
+ unregisterClassLoader(globalC);
+ }
+ }
+
}
Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithRepositoryTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithRepositoryTestCase.java 2008-12-10 10:08:58 UTC (rev 82185)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithRepositoryTestCase.java 2008-12-10 11:54:03 UTC (rev 82186)
@@ -462,6 +462,160 @@
}
}
+
+ public void testUclLoaderOrdering() throws Exception
+ {
+ ClassPool globalA = null;
+ ClassPool globalB = null;
+ ClassPool globalC = null;
+ try
+ {
+ globalA = createClassPool("A", true, JAR_A_1);
+ globalB = createClassPool("B", true, JAR_A_1);
+ globalC = createClassPool("C", true, JAR_A_1);
+
+ CtClass aFromA = globalA.get(CLASS_A);
+ CtClass aFromB = globalB.get(CLASS_A);
+ CtClass aFromC = globalC.get(CLASS_A);
+ assertSame(aFromA, aFromB);
+ assertSame(aFromA, aFromC);
+ assertSame(globalA, aFromA.getClassPool());
+ }
+ finally
+ {
+ unregisterClassPool(globalA);
+ unregisterClassPool(globalB);
+ unregisterClassPool(globalC);
+ }
+ }
+
+// public void testGeneratingClassInNonDelegatingPool() throws Exception
+// {
+// ClassPool global = null;
+// ClassPool child = null;
+// try
+// {
+// final String PARENT = "parent.Parent";
+// final String CHILD = "child.Child";
+// global = createGlobalClassPoolWithParent(JAR_A_1, parent);
+// child = createChildURLClassPool(global, JAR_C_1);
+//
+// assertCannotLoadCtClass(global, PARENT);
+// assertCannotLoadCtClass(child, PARENT);
+// assertCannotLoadCtClass(child, CHILD);
+//
+//
+// CtClass childClass = child.makeClass(CHILD);
+// childClass.setSuperclass(parentClass);
+//
+// CtClass parentFromParent = parent.get(PARENT);
+// assertSame(parent, parentFromParent.getClassPool());
+// assertSame(parentClass, parentFromParent);
+//
+// CtClass childFromChild = child.get(CHILD);
+// assertSame(child, childFromChild.getClassPool());
+// assertSame(childClass, childFromChild);
+//
+// assertCannotLoadCtClass(global, CHILD);
+//
+// CtClass parentFromChildA = childClass.getSuperclass();
+// assertSame(parentClass, parentFromChildA);
+//
+// CtClass parentFromChildB = child.get(PARENT);
+// assertSame(parentClass, parentFromChildB);
+//
+// Class<?> parentClazz = parentClass.toClass();
+// assertSame(parent.getClassLoader(), parentClazz.getClassLoader());
+//
+// Class<?> childClazz = childClass.toClass();
+// assertSame(child.getClassLoader(), childClazz.getClassLoader());
+//
+// Class<?> parentClazzFromParent = parent.getClassLoader().loadClass(PARENT);
+// assertSame(parentClazz, parentClazzFromParent);
+//
+// Class<?> parentClazzFromChild = parent.getClassLoader().loadClass(PARENT);
+// assertSame(parentClazz, parentClazzFromChild);
+//
+// Class<?> childClazzFromChild = child.getClassLoader().loadClass(CHILD);
+// assertSame(childClazz, childClazzFromChild);
+// }
+// finally
+// {
+// removeClassPool(parent);
+// removeClassPool(global);
+// removeClassPool(child);
+// }
+// }
+//
+//
+// public void testGeneratingClassInDelegatingPool() throws Exception
+// {
+// ClassPool globalA = null;
+// ClassPool globalB = null;
+// ClassPool child = null;
+// try
+// {
+// globalA = createGlobalClassPool(JAR_A_1);
+// globalB = createGlobalClassPool(JAR_B_1);
+// child = createChildURLClassPool(globalA, JAR_C_1);
+//
+// final String A_CLASS = "a.Clazz";
+// final String B_CLASS = "b.Clazz";
+//
+// assertCannotLoadCtClass(globalA, A_CLASS);
+// assertCannotLoadCtClass(globalB, A_CLASS);
+// assertCannotLoadCtClass(child, A_CLASS);
+// assertCannotLoadCtClass(globalA, B_CLASS);
+// assertCannotLoadCtClass(globalB, B_CLASS);
+// assertCannotLoadCtClass(child, B_CLASS);
+//
+// CtClass a = globalA.makeClass(A_CLASS);
+// CtClass b = globalB.makeClass(B_CLASS);
+//
+// CtClass aFromA = globalA.get(A_CLASS);
+// assertSame(a, aFromA);
+// assertSame(globalA, aFromA.getClassPool());
+// CtClass aFromB = globalB.get(A_CLASS);
+// assertSame(a, aFromB);
+// CtClass bFromA = globalA.get(B_CLASS);
+// assertSame(b, bFromA);
+// assertSame(globalB, bFromA.getClassPool());
+// CtClass bFromB = globalB.get(B_CLASS);
+// assertSame(b, bFromB);
+// CtClass aFromChild = child.get(A_CLASS);
+// assertSame(a, aFromChild);
+// CtClass bFromChild = child.get(B_CLASS);
+// assertSame(b, bFromChild);
+//
+// Class<?> clazzA = a.toClass();
+// assertSame(globalA.getClassLoader(), clazzA.getClassLoader());
+//
+// Class<?> clazzB = b.toClass();
+// assertSame(globalB.getClassLoader(), clazzB.getClassLoader());
+//
+// Class<?> clazzAFromA = globalA.getClassLoader().loadClass(A_CLASS);
+// assertSame(clazzA, clazzAFromA);
+// Class<?> clazzAFromB = globalB.getClassLoader().loadClass(A_CLASS);
+// assertSame(clazzA, clazzAFromB);
+// Class<?> clazzAFromChild = child.getClassLoader().loadClass(A_CLASS);
+// assertSame(clazzA, clazzAFromChild);
+//
+// Class<?> clazzBFromA = globalA.getClassLoader().loadClass(B_CLASS);
+// assertSame(clazzB, clazzBFromA);
+// Class<?> clazzBFromB = globalB.getClassLoader().loadClass(B_CLASS);
+// assertSame(clazzB, clazzBFromB);
+// Class<?> clazzBFromChild = child.getClassLoader().loadClass(B_CLASS);
+// assertSame(clazzB, clazzBFromChild);
+// }
+// finally
+// {
+// removeClassPool(globalA);
+// removeClassPool(globalB);
+// removeClassPool(child);
+// }
+// }
+
+
/*
The folllowing two tests are probably not very realistic http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4195022#4195022
public void testClassLoaderlWithParentClassLoader() throws Exception
More information about the jboss-cvs-commits
mailing list