[jboss-cvs] JBossAS SVN: r105052 - projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 20 08:13:55 EDT 2010
Author: alesj
Date: 2010-05-20 08:13:55 -0400 (Thu, 20 May 2010)
New Revision: 105052
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java
Log:
Test wildcard.
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java 2010-05-20 11:52:44 UTC (rev 105051)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java 2010-05-20 12:13:55 UTC (rev 105052)
@@ -31,12 +31,7 @@
import org.jboss.classloader.spi.ParentPolicy;
import org.jboss.classloading.spi.dependency.ClassLoading;
import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
-import org.jboss.classloading.spi.metadata.Capability;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
-import org.jboss.classloading.spi.metadata.Requirement;
-import org.jboss.classloading.spi.metadata.RequirementsMetaData;
+import org.jboss.classloading.spi.metadata.*;
import org.jboss.classloading.spi.version.Version;
import org.jboss.classloading.spi.version.VersionRange;
import org.jboss.deployers.client.spi.DeployerClient;
@@ -52,6 +47,7 @@
* ClassLoaderDependenciesTest.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public abstract class ClassLoaderDependenciesTest extends AbstractDeployerTest
@@ -192,14 +188,24 @@
requirements.addRequirement(requirement);
}
- protected static void addRequirePackage(ClassLoadingMetaData classLoadingMetaData, Class<?> pck, VersionRange versionRange)
+ protected static void addRequirePackage(ClassLoadingMetaData classLoadingMetaData, Requirement requirement)
{
RequirementsMetaData requirements = classLoadingMetaData.getRequirements();
+ requirements.addRequirement(requirement);
+ }
+ protected static void addRequirePackage(ClassLoadingMetaData classLoadingMetaData, Class<?> pck, VersionRange versionRange)
+ {
Requirement requirement = classLoadingMetaDataFactory.createRequirePackage(pck.getPackage().getName(), versionRange);
- requirements.addRequirement(requirement);
+ addRequirePackage(classLoadingMetaData, requirement);
}
+ protected static void addRequireWildcard(ClassLoadingMetaData classLoadingMetaData, Class<?> pck, VersionRange versionRange)
+ {
+ Requirement requirement = classLoadingMetaDataFactory.createWildcardPackage(pck.getPackage().getName(), versionRange);
+ addRequirePackage(classLoadingMetaData, requirement);
+ }
+
protected static void addMetaData(PredeterminedManagedObjectAttachments attachments, ClassLoadingMetaData md)
{
addMetaData(attachments, md, ClassLoadingMetaData.class);
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-20 11:52:44 UTC (rev 105051)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java 2010-05-20 12:13:55 UTC (rev 105052)
@@ -21,20 +21,22 @@
*/
package org.jboss.test.deployers.classloading.test;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.deployers.client.spi.DeployerClient;
import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.test.deployers.classloading.support.a.A;
import org.jboss.test.deployers.classloading.support.b.B;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
/**
* MockClassLoaderDependenciesUnitTestCase.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
public class MockClassLoaderDependenciesUnitTestCase extends ClassLoaderDependenciesTest
@@ -275,4 +277,49 @@
assertLoadClass(clB, B.class);
}
+ public void testWildcard() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deploymentB = createSimpleDeployment(NameB);
+ addClassLoadingMetaData(deploymentB, deploymentB.getName(), null, B.class);
+ 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);
+ assertLoadClassIllegal(clA, B.class);
+
+ assertEquals(BA, deployer2.deployed);
+ assertEquals(BA, deployer2.undeployed); // we bounced
+ assertDeploymentStage(getDeploymentUnit(deployer, deploymentA.getName()), DeploymentStages.INSTALLED);
+ clA = unitA.getClassLoader(); // re-get classloader
+
+ assertLoadClassFail(clA, B.class); // no match found
+
+ 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