[jboss-cvs] JBossAS SVN: r82483 - projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 22 13:32:59 EST 2008
Author: kabir.khan at jboss.com
Date: 2008-12-22 13:32:59 -0500 (Mon, 22 Dec 2008)
New Revision: 82483
Modified:
projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithReExportModuleSanityTestCase.java
projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithReExportPackageSanityTestCase.java
projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithUsesPackageSanityTestCase.java
projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java
Log:
[JBAOP-666] Make sure classes returned by loader are the same
Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithReExportModuleSanityTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithReExportModuleSanityTestCase.java 2008-12-22 17:14:51 UTC (rev 82482)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithReExportModuleSanityTestCase.java 2008-12-22 18:32:59 UTC (rev 82483)
@@ -55,7 +55,7 @@
createModule("a").
createPackage(PACKAGE_A);
clA = createClassLoader("A", builderA, JAR_A_1);
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA = assertLoadClass(CLASS_A, clA);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
@@ -67,11 +67,12 @@
createPackage(PACKAGE_B).
createReExportModule("a");
clB = createClassLoader("B", builderB, JAR_B_1);
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ Class<?> classB = assertLoadClass(CLASS_B, clB);
assertCannotLoadClass(clB, CLASS_C);
ClassLoader clC = null;
@@ -81,32 +82,41 @@
createRequireModule("b");
clC = createClassLoader("C", builderC, JAR_C_1);
- assertLoadClass(CLASS_A, clA);
+ classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
- assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ classA1 = assertLoadClass(CLASS_A, clB, clA);
+ assertSame(classA, classA1);
+ Class<?> classB1 = assertLoadClass(CLASS_B, clB);
+ assertSame(classB, classB1);
assertCannotLoadClass(clB, CLASS_C);
- assertLoadClass(CLASS_A, clC, clA);
- assertLoadClass(CLASS_B, clC, clB);
+ classA1 = assertLoadClass(CLASS_A, clC, clA);
+ assertSame(classA, classA1);
+ classB1 = assertLoadClass(CLASS_B, clC, clB);
+ assertSame(classB, classB1);
assertLoadClass(CLASS_C, clC);
}
finally
{
unregisterClassLoader(clC);
}
- assertLoadClass(CLASS_A, clA);
+ classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
- assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ classA1 = assertLoadClass(CLASS_A, clB, clA);
+ assertSame(classA, classA1);
+ Class<?> classB1 = assertLoadClass(CLASS_B, clB);
+ assertSame(classB, classB1);
assertCannotLoadClass(clB, CLASS_C);
}
finally
{
unregisterClassLoader(clB);
}
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
}
@@ -125,7 +135,7 @@
createModule("a").
createPackage(PACKAGE_A);
clA = createClassLoader("A", builderA, JAR_A_1);
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA = assertLoadClass(CLASS_A, clA);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
@@ -137,11 +147,13 @@
createPackage(PACKAGE_B).
createReExportModule("a");
clB = createClassLoader("B", builderB, JAR_B_1);
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
- assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ classA1 = assertLoadClass(CLASS_A, clB, clA);
+ assertSame(classA, classA1);
+ Class<?> classB = assertLoadClass(CLASS_B, clB);
assertCannotLoadClass(clB, CLASS_C);
ClassLoader clC = null;
@@ -151,32 +163,40 @@
createRequirePackage(PACKAGE_B);
clC = createClassLoader("C", builderC, JAR_C_1);
- assertLoadClass(CLASS_A, clA);
+ classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
- assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ classA1 = assertLoadClass(CLASS_A, clB, clA);
+ assertSame(classA, classA1);
+ Class<?> classB1 = assertLoadClass(CLASS_B, clB);
+ assertSame(classB, classB1);
assertCannotLoadClass(clB, CLASS_C);
assertCannotLoadClass(clC, CLASS_A);
- assertLoadClass(CLASS_B, clC, clB);
+ classB1 = assertLoadClass(CLASS_B, clC, clB);
+ assertSame(classB, classB1);
assertLoadClass(CLASS_C, clC);
}
finally
{
unregisterClassLoader(clC);
}
- assertLoadClass(CLASS_A, clA);
+ classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
- assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ classA1 = assertLoadClass(CLASS_A, clB, clA);
+ assertSame(classA, classA1);
+ Class<?> classB1 = assertLoadClass(CLASS_B, clB);
+ assertSame(classB, classB1);
assertCannotLoadClass(clB, CLASS_C);
}
finally
{
unregisterClassLoader(clB);
}
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
}
Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithReExportPackageSanityTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithReExportPackageSanityTestCase.java 2008-12-22 17:14:51 UTC (rev 82482)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithReExportPackageSanityTestCase.java 2008-12-22 18:32:59 UTC (rev 82483)
@@ -55,7 +55,7 @@
createModule("a").
createPackage(PACKAGE_A);
clA = createClassLoader("A", builderA, JAR_A_1);
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA = assertLoadClass(CLASS_A, clA);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
@@ -68,11 +68,13 @@
createReExportPackage(PACKAGE_A);
clB = createClassLoader("B", builderB, JAR_B_1);
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
- assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ classA1 = assertLoadClass(CLASS_A, clB, clA);
+ assertSame(classA, classA1);
+ Class<?> classB = assertLoadClass(CLASS_B, clB);
assertCannotLoadClass(clB, CLASS_C);
ClassLoader clC = null;
@@ -82,32 +84,41 @@
createRequireModule("b");
clC = createClassLoader("C", builderC, JAR_C_1);
- assertLoadClass(CLASS_A, clA);
+ classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
- assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ classA1 = assertLoadClass(CLASS_A, clB, clA);
+ assertSame(classA, classA1);
+ Class<?> classB1 = assertLoadClass(CLASS_B, clB);
+ assertSame(classB, classB1);
assertCannotLoadClass(clB, CLASS_C);
- assertLoadClass(CLASS_A, clC, clA);
- assertLoadClass(CLASS_B, clC, clB);
+ classA1 = assertLoadClass(CLASS_A, clC, clA);
+ assertSame(classA, classA1);
+ classB1 = assertLoadClass(CLASS_B, clC, clB);
+ assertSame(classB, classB1);
assertLoadClass(CLASS_C, clC);
}
finally
{
unregisterClassLoader(clC);
}
- assertLoadClass(CLASS_A, clA);
+ classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
- assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ classA1 = assertLoadClass(CLASS_A, clB, clA);
+ assertSame(classA, classA1);
+ Class<?> classB1 = assertLoadClass(CLASS_B, clB);
+ assertSame(classB, classB1);
assertCannotLoadClass(clB, CLASS_C);
}
finally
{
unregisterClassLoader(clB);
}
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
}
@@ -126,7 +137,7 @@
createModule("a").
createPackage(PACKAGE_A);
clA = createClassLoader("A", builderA, JAR_A_1);
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA = assertLoadClass(CLASS_A, clA);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
@@ -138,11 +149,13 @@
createPackage(PACKAGE_B).
createReExportModule("a");
clB = createClassLoader("B", builderB, JAR_B_1);
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ assertSame(classA, classA1);
+ Class<?> classB = assertLoadClass(CLASS_B, clB);
assertCannotLoadClass(clB, CLASS_C);
ClassLoader clC = null;
@@ -153,13 +166,17 @@
clC = createClassLoader("C", builderC, JAR_C_1);
assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ assertSame(classA, classA1);
+ Class<?> classB1 = assertLoadClass(CLASS_B, clB);
+ assertSame(classB, classB1);
assertCannotLoadClass(clB, CLASS_C);
assertCannotLoadClass(clC, CLASS_A);
- assertLoadClass(CLASS_B, clC, clB);
+ classB1 = assertLoadClass(CLASS_B, clC, clB);
+ assertSame(classB, classB1);
assertLoadClass(CLASS_C, clC);
}
finally
@@ -167,17 +184,21 @@
unregisterClassLoader(clC);
}
assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
assertLoadClass(CLASS_A, clB, clA);
- assertLoadClass(CLASS_B, clB);
+ assertSame(classA, classA1);
+ Class<?> classB1 = assertLoadClass(CLASS_B, clB);
+ assertSame(classB, classB1);
assertCannotLoadClass(clB, CLASS_C);
}
finally
{
unregisterClassLoader(clB);
}
- assertLoadClass(CLASS_A, clA);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA);
+ assertSame(classA, classA1);
assertCannotLoadClass(clA, CLASS_B);
assertCannotLoadClass(clA, CLASS_C);
}
Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithUsesPackageSanityTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithUsesPackageSanityTestCase.java 2008-12-22 17:14:51 UTC (rev 82482)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithUsesPackageSanityTestCase.java 2008-12-22 18:32:59 UTC (rev 82483)
@@ -56,7 +56,7 @@
createModule("a1").
createPackage(PACKAGE_A);
clA1 = createClassLoader("A1", builderA1, JAR_A_1);
- assertLoadClass(CLASS_A, clA1);
+ Class<?> classA = assertLoadClass(CLASS_A, clA1);
ClassLoader clA2 = null;
try
@@ -66,8 +66,10 @@
createUsesPackage(PACKAGE_A);
clA2 = createClassLoader("A2", builderA2, JAR_A_1);
- assertLoadClass(CLASS_A, clA1);
- assertLoadClass(CLASS_A, clA2, clA1);
+ Class<?> classA1 = assertLoadClass(CLASS_A, clA1);
+ assertSame(classA, classA1);
+ classA1 = assertLoadClass(CLASS_A, clA2, clA1);
+ assertSame(classA, classA1);
}
finally
{
Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java 2008-12-22 17:14:51 UTC (rev 82482)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java 2008-12-22 18:32:59 UTC (rev 82483)
@@ -32,6 +32,7 @@
import java.util.WeakHashMap;
import javassist.ClassPool;
+import javassist.CtClass;
import junit.framework.Test;
import org.jboss.aop.AspectManager;
@@ -352,6 +353,12 @@
return AspectManager.instance().registerClassLoader(loader);
}
+ protected ClassPool createClassPool(String name, BundleInfoBuilder builder, URL... urls) throws Exception
+ {
+ ClassLoader loader = createClassLoader(name, builder, urls);
+ return AspectManager.instance().registerClassLoader(loader);
+ }
+
protected ClassPool createChildDomainParentFirstClassPool(String name, String domainName, boolean importAll, URL... urls) throws Exception
{
ClassLoader loader = createChildDomainParentFirstClassLoader(name, domainName, importAll, urls);
@@ -534,6 +541,21 @@
return clazz;
}
+ protected CtClass assertLoadCtClass(String name, ClassPool initiating) throws Exception
+ {
+ return assertLoadCtClass(name, initiating, initiating);
+ }
+
+ protected CtClass assertLoadCtClass(String name, ClassPool initiating, ClassPool expected) throws Exception
+ {
+ CtClass clazz = initiating.get(name);
+ if (expected != null)
+ {
+ assertSame(expected, clazz.getClassPool());
+ }
+ return clazz;
+ }
+
protected Module assertModule(String contextName)
{
return assertBean(contextName + "$MODULE", Module.class);
More information about the jboss-cvs-commits
mailing list