[jboss-cvs] JBossAS SVN: r105094 - in projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers: classloading/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 21 10:14:53 EDT 2010
Author: alesj
Date: 2010-05-21 10:14:52 -0400 (Fri, 21 May 2010)
New Revision: 105094
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/AbstractDeployerTest.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java
Log:
Add GC module test.
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/AbstractDeployerTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/AbstractDeployerTest.java 2010-05-21 14:14:12 UTC (rev 105093)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/AbstractDeployerTest.java 2010-05-21 14:14:52 UTC (rev 105094)
@@ -55,6 +55,7 @@
* AbstractDeployerTest.
*
* @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public abstract class AbstractDeployerTest extends BaseTestCase
@@ -207,6 +208,16 @@
main.undeploy(deployment);
}
+ protected void assertChange(DeployerClient main, Deployment deployment, DeploymentStage stage) throws Exception
+ {
+ main.change(deployment.getName(), stage);
+ DeploymentUnit unit = assertDeploymentUnit(main, deployment.getName());
+ ControllerContext context = unit.getTopLevel().getAttachment(ControllerContext.class);
+ assertNotNull(context);
+ ControllerState state = context.getState();
+ assertEquals(ControllerState.getInstance(stage.getName()), state);
+ }
+
protected Deployment createSimpleDeployment(String name)
{
AbstractDeployment unit = createAbstractDeployment(name);
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java 2010-05-21 14:14:12 UTC (rev 105093)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java 2010-05-21 14:14:52 UTC (rev 105094)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.deployers.classloading.test;
+import org.jboss.classloader.spi.ShutdownPolicy;
+import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.deployers.client.spi.DeployerClient;
import org.jboss.deployers.client.spi.Deployment;
@@ -277,7 +279,7 @@
assertLoadClass(clB, B.class);
}
- public void testWildcard() throws Exception
+ public void testWildcardWithCascade() throws Exception
{
DeployerClient deployer = getMainDeployer();
@@ -322,4 +324,55 @@
assertEquals(BA, deployer2.deployed);
assertEquals(AB, deployer2.undeployed);
}
+
+ public void testWildcardWithGC() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deploymentB = createSimpleDeployment(NameB);
+ ClassLoadingMetaData clmd = addClassLoadingMetaData(deploymentB, deploymentB.getName(), null, B.class);
+ clmd.setShutdownPolicy(ShutdownPolicy.GARBAGE_COLLECTION);
+ DeploymentUnit unitB = assertDeploy(deployer, deploymentB);
+
+ ClassLoader clB = unitB.getClassLoader();
+ assertLoadClass(clB, B.class);
+
+ assertEquals(B, deployer2.deployed);
+ assertEquals(NONE, deployer2.undeployed);
+
+ Deployment deploymentA = createSimpleDeployment(NameA);
+ ClassLoadingMetaData classLoadingMetaData = addClassLoadingMetaData(deploymentA, deploymentA.getName(), null, A.class);
+ addRequireWildcard(classLoadingMetaData, B.class, null);
+ DeploymentUnit unitA = assertDeploy(deployer, deploymentA);
+
+ ClassLoader clA = unitA.getClassLoader();
+ assertLoadClass(clA, B.class, clB);
+
+ assertEquals(BA, deployer2.deployed);
+ assertEquals(NONE, deployer2.undeployed);
+
+ assertUndeploy(deployer, deploymentB); //, DeploymentStages.NOT_INSTALLED);
+ assertLoadClass(clA, B.class, clB); // we should still be able to see the B resources
+
+ assertEquals(BA, deployer2.deployed);
+ assertEquals(B, deployer2.undeployed);
+
+ Module.refreshModules(); // A should be refreshed as well
+
+ assertDeploymentStage(getDeploymentUnit(deployer, deploymentA.getName()), DeploymentStages.INSTALLED);
+ clA = unitA.getClassLoader(); // re-get classloader
+ assertLoadClassFail(clA, B.class); // no match found
+
+ Module.refreshModules(); // make sure we cleaned up
+
+ unitB = assertDeploy(deployer, deploymentB); // new B matching deployment
+ assertLoadClass(clA, B.class, unitB.getClassLoader()); // find the new one
+ assertUndeploy(deployer, deploymentB);
+
+ assertUndeploy(deployer, deploymentA);
+ assertLoadClassFail(clA, B.class);
+
+ assertEquals(BA, deployer2.deployed);
+ assertEquals(AB, deployer2.undeployed);
+ }
}
More information about the jboss-cvs-commits
mailing list