[jboss-cvs] JBossAS SVN: r82116 - in projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl: test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 8 12:47:45 EST 2008
Author: kabir.khan at jboss.com
Date: 2008-12-08 12:47:45 -0500 (Mon, 08 Dec 2008)
New Revision: 82116
Modified:
projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/MockModuleFactory.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/JBossClClassPoolTest.java
Log:
[JBAOP-666] Fix test framework for parent classloaders
Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/MockModuleFactory.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/MockModuleFactory.java 2008-12-08 16:03:07 UTC (rev 82115)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/MockModuleFactory.java 2008-12-08 17:47:45 UTC (rev 82116)
@@ -43,7 +43,7 @@
public static ClassLoaderPolicyModule createModule(String name, boolean importAll, String domainName, boolean parentFirst, URL... urls) throws Exception
{
- return createModule(name, importAll, domainName, null, false, urls);
+ return createModule(name, importAll, domainName, null, parentFirst, urls);
}
public static ClassLoaderPolicyModule createModule(String name, boolean importAll, String domainName, String parentDomainName, boolean parentFirst, URL... urls) throws Exception
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-08 16:03:07 UTC (rev 82115)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithRepositorySanityTestCase.java 2008-12-08 17:47:45 UTC (rev 82116)
@@ -369,12 +369,15 @@
Class<?> aFromGlobal = globalA.loadClass(CLASS_A);
assertSame(globalA, aFromGlobal.getClassLoader());
- globalB = createChildDomainParentFirstClassLoader("B", domain, true, parent, JAR_B_1);
+ globalB = createChildDomainParentFirstClassLoader("B", domain, true, parent, JAR_B_2);
Class<?> bFromGlobalA = globalA.loadClass(CLASS_B);
- assertSame(globalB, bFromGlobalA.getClassLoader());
+ assertSame(parent, bFromGlobalA.getClassLoader());
Class<?> bFromParent = parent.loadClass(CLASS_B);
assertSame(parent, bFromParent.getClassLoader());
- assertNotSame(bFromGlobalA, bFromParent);
+ assertSame(bFromGlobalA, bFromParent);
+
+ Class<?> bFromGlobalB = globalB.loadClass(CLASS_B);
+ assertSame(bFromGlobalB, bFromParent);
}
finally
{
@@ -385,5 +388,132 @@
}
}
-
+// public void testSeveralLevelsOfDomain() throws Exception
+// {
+// ClassLoader parent = null;
+// ClassLoader cl1B = null;
+// ClassLoader cl1C = null;
+// ClassLoader cl2B = null;
+// ClassLoader cl2C = null;
+// ClassLoader cl11A = null;
+// ClassLoader cl11B = null;
+// ClassLoader cl11C = null;
+// ClassLoader cl12A = null;
+// ClassLoader cl12B = null;
+// ClassLoader cl12C = null;
+//// ClassLoader cl21A = null;
+//// ClassLoader cl21B = null;
+//// ClassLoader cl21C = null;
+//// ClassLoader cl22A = null;
+//// ClassLoader cl22B = null;
+//// ClassLoader cl22C = null;
+//
+// try
+// {
+// parent = createClassLoader("A", true, JAR_A_1);
+// Class<?> aFromParent = parent.loadClass(CLASS_A);
+// assertSame(parent, aFromParent.getClassLoader());
+//
+// final String domain1 = "1";
+// cl1B = createChildDomainParentFirstClassLoader("1B", domain1, true, JAR_B_1);
+// cl1C = createChildDomainParentFirstClassLoader("1C", domain1, true, JAR_C_1);
+// Class<?> aFrom1B = cl1B.loadClass(CLASS_A);
+// Class<?> bFrom1B = cl1B.loadClass(CLASS_B);
+// Class<?> cFrom1B = cl1B.loadClass(CLASS_C);
+// Class<?> aFrom1C = cl1C.loadClass(CLASS_A);
+// Class<?> bFrom1C = cl1C.loadClass(CLASS_B);
+// Class<?> cFrom1C = cl1C.loadClass(CLASS_C);
+// assertSame(aFromParent, aFrom1B);
+// assertSame(aFromParent, aFrom1C);
+// assertSame(bFrom1B, bFrom1C);
+// assertSame(cFrom1B, cFrom1C);
+// assertSame(cl1B, bFrom1B.getClassLoader());
+// assertSame(cl1C, cFrom1B.getClassLoader());
+//
+//
+// final String domain2 = "2";
+// cl2B = createChildDomainParentFirstClassLoader("2B", domain2, true, JAR_B_1);
+// cl2C = createChildDomainParentFirstClassLoader("2C", domain2, true, JAR_C_1);
+// Class<?> aFrom2B = cl2B.loadClass(CLASS_A);
+// Class<?> bFrom2B = cl2B.loadClass(CLASS_B);
+// Class<?> cFrom2B = cl2B.loadClass(CLASS_C);
+// Class<?> aFrom2C = cl2C.loadClass(CLASS_A);
+// Class<?> bFrom2C = cl2C.loadClass(CLASS_B);
+// Class<?> cFrom2C = cl2C.loadClass(CLASS_C);
+// assertSame(aFromParent, aFrom2B);
+// assertSame(aFromParent, aFrom2C);
+// assertSame(bFrom2B, bFrom2C);
+// assertSame(cFrom2B, cFrom2C);
+// assertSame(cl2B, bFrom2B.getClassLoader());
+// assertSame(cl2C, cFrom2B.getClassLoader());
+// assertNotSame(bFrom1B, bFrom2B);
+// assertNotSame(bFrom2C, bFrom1C);
+// assertNotSame(cFrom2C, cFrom1C);
+//
+// final String domain11 = "11";
+// cl11A = createChildDomainParentFirstClassLoader("11A", domain11, domain1, true, JAR_A_2);
+// cl11B = createChildDomainParentFirstClassLoader("11B", domain11, domain1, true, JAR_B_2);
+// cl11C = createChildDomainParentFirstClassLoader("11C", domain11, domain1, true, JAR_C_2);
+// final String domain12 = "12";
+// cl12A = createChildDomainParentLastClassLoader("11A", domain12, domain1, true, JAR_A_2);
+// cl12B = createChildDomainParentLastClassLoader("11B", domain12, domain1, true, JAR_B_2);
+// cl12C = createChildDomainParentLastClassLoader("11C", domain12, domain1, true, JAR_C_2);
+// Class<?> aFrom11A = cl11A.loadClass(CLASS_A);
+// Class<?> aFrom11B = cl11B.loadClass(CLASS_A);
+// Class<?> aFrom11C = cl11C.loadClass(CLASS_A);
+// assertSame(aFromParent, aFrom11A);
+// assertSame(aFromParent, aFrom11B);
+// assertSame(aFromParent, aFrom11C);
+// Class<?> aFrom12A = cl12A.loadClass(CLASS_A);
+// Class<?> aFrom12B = cl12B.loadClass(CLASS_A);
+// Class<?> aFrom12C = cl12C.loadClass(CLASS_A);
+// assertNotSame(aFromParent, aFrom12A);
+// assertSame(aFrom12A, aFrom12B);
+// assertSame(aFrom12A, aFrom12C);
+// assertSame(cl12A, aFrom12A.getClassLoader());
+//
+// Class<?> bFrom11A = cl11A.loadClass(CLASS_B);
+// Class<?> bFrom11B = cl11B.loadClass(CLASS_B);
+// Class<?> bFrom11C = cl11C.loadClass(CLASS_B);
+// Class<?> cFrom11A = cl11A.loadClass(CLASS_C);
+// Class<?> cFrom11B = cl11B.loadClass(CLASS_C);
+// Class<?> cFrom11C = cl11C.loadClass(CLASS_C);
+// assertSame(bFrom11A, bFrom11B);
+// assertSame(bFrom11A, bFrom11C);
+// assertSame(cl12B, bFrom11B.getClassLoader());
+// assertSame(cFrom11A, cFrom11B);
+// assertSame(cFrom11A, cFrom11C);
+// assertSame(cl12C, bFrom11C.getClassLoader());
+//
+// Class<?> bFrom12A = cl12A.loadClass(CLASS_B);
+// Class<?> bFrom12B = cl12B.loadClass(CLASS_B);
+// Class<?> bFrom12C = cl12C.loadClass(CLASS_B);
+// Class<?> cFrom12A = cl12A.loadClass(CLASS_C);
+// Class<?> cFrom12B = cl12B.loadClass(CLASS_C);
+// Class<?> cFrom12C = cl12C.loadClass(CLASS_C);
+//
+//
+//
+//// final String domain21 = "21";
+// }
+// finally
+// {
+// unregisterClassLoader(parent);
+// unregisterClassLoader(cl1B);
+// unregisterClassLoader(cl1C);
+// unregisterClassLoader(cl2B);
+// unregisterClassLoader(cl2C);
+// unregisterClassLoader(cl11A);
+// unregisterClassLoader(cl11B);
+// unregisterClassLoader(cl11C);
+// unregisterClassLoader(cl12A);
+// unregisterClassLoader(cl12B);
+// unregisterClassLoader(cl12C);
+//
+// unregisterDomain(cl12A);
+// unregisterDomain(cl11A);
+// unregisterDomain(cl2B);
+// unregisterDomain(cl1B);
+// }
+// }
}
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-08 16:03:07 UTC (rev 82115)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java 2008-12-08 17:47:45 UTC (rev 82116)
@@ -204,9 +204,14 @@
protected ClassLoader createChildDomainParentFirstClassLoader(String name, String domainName, boolean importAll, ClassLoader parent, URL... urls) throws Exception
{
- return createChildDomainClassLoader(name, domainName, true, importAll, parent, urls);
+ return createChildDomainClassLoader(name, domainName, null, true, importAll, parent, urls);
}
+ protected ClassLoader createChildDomainParentFirstClassLoader(String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+ {
+ return createChildDomainClassLoader(name, domainName, parentDomainName, true, importAll, null, urls);
+ }
+
protected ClassLoader createChildDomainParentLastClassLoader(String name, String domainName, boolean importAll, URL... urls) throws Exception
{
return createChildDomainParentLastClassLoader(name, domainName, importAll, null, urls);
@@ -214,12 +219,17 @@
protected ClassLoader createChildDomainParentLastClassLoader(String name, String domainName, boolean importAll, ClassLoader parent, URL... urls) throws Exception
{
- return createChildDomainClassLoader(name, domainName, false, importAll, parent, urls);
+ return createChildDomainClassLoader(name, domainName, null, false, importAll, parent, urls);
}
- protected ClassLoader createChildDomainClassLoader(String name, String domainName, boolean parentFirst, boolean importAll, ClassLoader parent, URL... urls) throws Exception
+ protected ClassLoader createChildDomainParentLastClassLoader(String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
{
- ClassLoaderPolicyModule module = MockModuleFactory.createModule(name, importAll, domainName, parentFirst, urls);
+ return createChildDomainClassLoader(name, domainName, parentDomainName, false, importAll, null, urls);
+ }
+
+ protected ClassLoader createChildDomainClassLoader(String name, String domainName, String parentDomainName, boolean parentFirst, boolean importAll, ClassLoader parent, URL... urls) throws Exception
+ {
+ ClassLoaderPolicyModule module = MockModuleFactory.createModule(name, importAll, domainName, parentDomainName, parentFirst, urls);
ClassLoader classLoader = createClassLoader(module, parent);
More information about the jboss-cvs-commits
mailing list