[jboss-cvs] JBossAS SVN: r107654 - in branches/weld-snapshot/weld-int/deployer/src: test/java/org/jboss/test/deployers/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 17 19:42:02 EDT 2010
Author: flavia.rainone at jboss.com
Date: 2010-08-17 19:42:02 -0400 (Tue, 17 Aug 2010)
New Revision: 107654
Modified:
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java
branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentTestCase.java
branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java
Log:
[JBAS-8349] Update the new Weld-int Deployment (non-flat) implementation so it now implements the Weld 1.1.0 API.
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -27,6 +27,7 @@
import java.util.Map;
import java.util.WeakHashMap;
+import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.ejb.spi.EjbDescriptor;
@@ -220,14 +221,15 @@
* Creates the BeanDeploymentArchive that corresponds to this archive. This method
* never returns duplicates.
*
+ * @param bootstrap the Weld boostrap
* @return the BeanDeploymentArchive representing this archive. If this bda has not
* been created, it is created and returned
*/
- public BeanDeploymentArchive createBeanDeploymentArchive(ServiceRegistry services)
+ public BeanDeploymentArchive createBeanDeploymentArchive(Bootstrap bootstrap, ServiceRegistry services)
{
if (bda == null)
{
- bda = new BeanDeploymentArchiveImpl(classLoader.toString(), services, this);
+ bda = new BeanDeploymentArchiveImpl(classLoader.toString(), bootstrap, services, this);
for (ArchiveLifecycleListener listener: lifecycleListeners)
{
// notifies the listener that this archive became visible as a BDA
@@ -236,6 +238,19 @@
}
return bda;
}
+
+ /**
+ * Creates the BeanDeploymentArchive that corresponds to this archive. This method
+ * never returns duplicates.
+ * Use this method if you are sure that this Archive has no beans.xml file.
+ *
+ * @return the BeanDeploymentArchive representing this archive. If this bda has not
+ * been created, it is created and returned
+ */
+ public BeanDeploymentArchive createBeanDeploymentArchive(ServiceRegistry services)
+ {
+ return createBeanDeploymentArchive(null, services);
+ }
/**
* Adds an ArchiveLifecycleListener. When called prior to BDA creation, this listener
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -21,8 +21,10 @@
*/
package org.jboss.weld.integration.deployer.env.bda;
+import java.net.URL;
import java.util.Collection;
+import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.BeansXml;
@@ -42,22 +44,28 @@
// the Archive that this BDA represents
private final Archive archive;
+ // the WeldBootstrap
+ private final Bootstrap bootstrap;
+
// the services provided by this BDA
private final ServiceRegistry services;
/**
* Constructor.
*
- * @param id the identifier name of this BeanDeploymentArchive
- * @param archive the archive that this BeanDeploymentArchive represents
+ * @param id the identifier name of this BeanDeploymentArchive
+ * @param bootstrap the Weld bootstrap. Can be null only if {@code archive} has no
+ * beans.xml file
+ * @param archive the archive that this BeanDeploymentArchive represents
*/
- public BeanDeploymentArchiveImpl(String id, ServiceRegistry services, Archive archive)
+ public BeanDeploymentArchiveImpl(String id, Bootstrap bootstrap, ServiceRegistry services, Archive archive)
{
this.id = id;
+ this.bootstrap = bootstrap;
this.services = services;
this.archive = archive;
}
-
+
public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
{
return archive.getClasspath().getBDAs(this);
@@ -70,9 +78,12 @@
public BeansXml getBeansXml()
{
- //return archive.getXmlURLs();
- // TODO Fix this (sorry Flavia)
- return null;
+ Collection<URL> urls = archive.getXmlURLs();
+ if (urls.isEmpty())
+ {
+ return BeansXml.EMPTY_BEANS_XML;
+ }
+ return bootstrap.parse(urls);
}
public Collection<EjbDescriptor<?>> getEjbs()
Modified: branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.Map;
+import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
@@ -77,11 +78,17 @@
this.ejbs = ejbs;
for (ArchiveInfo archiveInfo: archiveInfos)
{
- Archive archive = ArchiveFactory.createArchive(archiveInfo, ejbs);
- archives.add(archive);
+ archives.add(ArchiveFactory.createArchive(archiveInfo, ejbs));
+ }
+ }
+
+ public void initialize(Bootstrap bootstrap)
+ {
+ for (Archive archive: archives)
+ {
if (archive.hasXml())
{
- archive.createBeanDeploymentArchive(bdaServices);
+ archive.createBeanDeploymentArchive(bootstrap, bdaServices);
}
}
}
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -78,7 +78,8 @@
Object bean = getBean(Deployment.class);
Deployment deployment = assertInstanceOf(bean, Deployment.class, false);
-
+ initializeDeployment(deployment);
+
List<BeanDeploymentArchive> archives = new ArrayList<BeanDeploymentArchive>();
getArchives(archives, deployment.getBeanDeploymentArchives());
assertEquals(getExpectedArchives(), archives.size());
@@ -145,6 +146,8 @@
}
protected abstract void assertNewBeanDeploymentArchive(List<BeanDeploymentArchive> archives, BeanDeploymentArchive newBDA);
+
+ protected abstract void initializeDeployment(Deployment deployment);
private static void addExpectedResource(Set<String> expected, String unit)
{
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -21,10 +21,8 @@
*/
package org.jboss.test.deployers.test;
-import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -54,16 +52,6 @@
super(name);
}
- private static void addExpectedResource(Set<String> expected, String unit)
- {
- addExpectedResource(expected, unit, "/META-INF/beans.xml");
- }
-
- private static void addExpectedResource(Set<String> expected, String unit, String suffix)
- {
- expected.add(unit + suffix);
- }
-
private static void addExpectedClass(Set<String> expected, Class<?> clazz)
{
expected.add(clazz.getName());
@@ -91,52 +79,6 @@
assertExpectedClasses(environment, expected);
}
- private void assertExpectedResources(E environment, Set<String> expected)
- {
- Collection<URL> weldXml = getResources(environment);
- assertNotNull(weldXml);
- assertTrue("Unexpected empty weld XML collection", expected.isEmpty() || !weldXml.isEmpty());
- for (URL url : weldXml)
- {
- boolean found = false;
- Iterator<String> iter = expected.iterator();
- while (iter.hasNext())
- {
- String expectedURL = iter.next();
- if (url.toExternalForm().endsWith(expectedURL))
- {
- iter.remove();
- found = true;
- break;
- }
- }
- assertTrue("Unexpected wb url: " + url, found);
- }
- assertEmpty("Should be emtpy, missing " + expected, expected);
- }
-
- protected void assertExpectedResources(E environment, String... units)
- {
- Set<String> expected = new HashSet<String>();
- for (String unit: units)
- {
- addExpectedResource(expected, unit);
- }
- assertExpectedResources(environment, expected);
- }
-
- protected void assertExpectedWarResources(E environment, String warUnit, boolean warResourceExpected, String... units)
- {
- Set<String> expected = new HashSet<String>();
- if (warResourceExpected)
- addExpectedResource(expected, warUnit, "/WEB-INF/beans.xml");
- for (String unit: units)
- {
- addExpectedResource(expected, warUnit, "/WEB-INF/lib/" + unit + "/META-INF/beans.xml");
- }
- assertExpectedResources(environment, expected);
- }
-
protected JavaArchive createEjbJar(boolean jarCDI)
{
return createEjbJar(EJB_JAR_NAME, jarCDI, PlainJavaBean.class);
@@ -205,13 +147,4 @@
* @return the list of classes that have been found in the environment
*/
protected abstract Collection<Class<?>> getClasses(E environment);
-
- /**
- * Returns the Weld XML resources recorded in the environment.
- *
- * @param environment the environment
- * @return the list of URLs pointing to the Weld XML files that have been found in the
- * environment
- */
- protected abstract Collection<URL> getResources(E environment);
}
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -21,6 +21,12 @@
*/
package org.jboss.test.deployers.test;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
@@ -414,6 +420,71 @@
assertBasicEarWithoutXml();
}
+ private void addExpectedResource(Set<String> expected, String unit)
+ {
+ addExpectedResource(expected, unit, "/META-INF/beans.xml");
+ }
+
+ private void addExpectedResource(Set<String> expected, String unit, String suffix)
+ {
+ expected.add(unit + suffix);
+ }
+
+ private void assertExpectedResources(E environment, Set<String> expected)
+ {
+ Collection<URL> weldXml = getResources(environment);
+ assertNotNull(weldXml);
+ assertTrue("Unexpected empty weld XML collection", expected.isEmpty() || !weldXml.isEmpty());
+ for (URL url : weldXml)
+ {
+ boolean found = false;
+ Iterator<String> iter = expected.iterator();
+ while (iter.hasNext())
+ {
+ String expectedURL = iter.next();
+ if (url.toExternalForm().endsWith(expectedURL))
+ {
+ iter.remove();
+ found = true;
+ break;
+ }
+ }
+ assertTrue("Unexpected wb url: " + url, found);
+ }
+ assertEmpty("Should be emtpy, missing " + expected, expected);
+ }
+
+ protected void assertExpectedResources(E environment, String... units)
+ {
+ Set<String> expected = new HashSet<String>();
+ for (String unit: units)
+ {
+ addExpectedResource(expected, unit);
+ }
+ assertExpectedResources(environment, expected);
+ }
+
+ protected void assertExpectedWarResources(E environment, String warUnit, boolean warResourceExpected, String... units)
+ {
+ Set<String> expected = new HashSet<String>();
+ if (warResourceExpected)
+ addExpectedResource(expected, warUnit, "/WEB-INF/beans.xml");
+ for (String unit: units)
+ {
+ addExpectedResource(expected, warUnit, "/WEB-INF/lib/" + unit + "/META-INF/beans.xml");
+ }
+ assertExpectedResources(environment, expected);
+ }
+
+ /**
+ * Returns the Weld XML resources recorded in the environment.
+ *
+ * @param environment the environment
+ * @return the list of URLs pointing to the Weld XML files that have been found in the
+ * environment
+ */
+ protected abstract Collection<URL> getResources(E environment);
+
protected abstract void assertBasicEarWithoutXml();
/**
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -25,7 +25,10 @@
import junit.framework.Test;
+import org.jboss.test.deployers.support.MockWeldBootstrap;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.integration.deployer.env.bda.DeploymentImpl;
/**
* JBoss Deployment test case.
@@ -44,11 +47,19 @@
return suite(BasicEarJBossDeploymentTestCase.class);
}
+ @Override
protected int getExpectedArchives()
{
return 3;
}
+ @Override
+ protected void initializeDeployment(Deployment deployment)
+ {
+ ((DeploymentImpl) deployment).initialize(new MockWeldBootstrap());
+ }
+
+ @Override
protected void assertNewBeanDeploymentArchive(List<BeanDeploymentArchive> archives, BeanDeploymentArchive newBDA)
{
assertSame(newBDA, archives.iterator().next());
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentTestCase.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentTestCase.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentTestCase.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -26,6 +26,7 @@
import junit.framework.Test;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
/**
* Flat Deployment test case.
@@ -52,6 +53,12 @@
}
@Override
+ protected void initializeDeployment(Deployment deployment)
+ {
+ // do nothing
+ }
+
+ @Override
protected void assertNewBeanDeploymentArchive(List<BeanDeploymentArchive> archives, BeanDeploymentArchive newBDA)
{
assertSame(newBDA, archives.iterator().next());
Modified: branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java
===================================================================
--- branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java 2010-08-17 22:33:43 UTC (rev 107653)
+++ branches/weld-snapshot/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java 2010-08-17 23:42:02 UTC (rev 107654)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.deployers.test;
-import java.net.URL;
import java.util.Collection;
import java.util.Iterator;
@@ -50,9 +49,12 @@
import org.jboss.test.deployers.support.web.ServletWebBean;
import org.jboss.test.deployers.vfs.classloader.support.a.A;
import org.jboss.test.deployers.vfs.classloader.support.b.B;
+import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.BeansXml;
import org.jboss.weld.bootstrap.spi.Deployment;
import org.jboss.weld.integration.deployer.DeployersUtils;
+import org.jboss.weld.integration.deployer.env.bda.DeploymentImpl;
/**
* Deployment.loadBeanDeploymentArchive test case.
@@ -61,6 +63,8 @@
*/
public class LoadBeanDeploymentArchiveTestCase extends AbstractEnvironmentTest<BeanDeploymentArchive>
{
+ private Bootstrap bootstrap = new MockWeldBootstrap();
+
public LoadBeanDeploymentArchiveTestCase(String name)
{
super(name);
@@ -91,13 +95,14 @@
JavaArchive ejbJar1 = createEjbJar("ejb1.jar", true, PlainJavaBean.class);
DeploymentUnit unit = assertDeploy(ejbJar1);
Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
- Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment1 = initializeDeploymentBean(unit);
+
// ejb2.jar
JavaArchive ejbJar2 = createEjbJar("ejb2.jar", true, MySLSBean.class, BusinessInterface.class);
unit = assertDeploy(ejbJar2);
Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
Class<?> businessInterface = getClass(BusinessInterface.class, unit);
- Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment2 = initializeDeploymentBean(unit);
assertNotSame(deployment1, deployment2);
@@ -120,43 +125,43 @@
assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
}
-// public void testMixedEjbJars() throws Exception
-// {
-// // ejb1.jar
-// JavaArchive ejbJar1 = createEjbJar("ejb1.jar", true, PlainJavaBean.class);
-// DeploymentUnit unit = assertDeploy(ejbJar1);
-// Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
-// Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
-// // ejb2.jar
-// JavaArchive ejbJar2 = createEjbJar("ejb2.jar", false, MySLSBean.class, BusinessInterface.class);
-// unit = assertDeploy(ejbJar2);
-// ClassLoader classLoader2 = unit.getClassLoader();
-// Class<?> mySLSBeanClass = classLoader2.loadClass(MySLSBean.class.getName());
-// Class<?> businessInterface = classLoader2.loadClass(BusinessInterface.class.getName());
-//
-// BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
-// assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
-// // creation of bda2 on demand
-// BeanDeploymentArchive bda2 = deployment1.loadBeanDeploymentArchive(mySLSBeanClass);
-// assertBDAId(bda2, "ejb2.jar");
-// assertExpectedClasses(bda2, MySLSBean.class);
-// assertExpectedResources(bda2);
-// // double invocation
-// assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
-// assertBDAId(bda2, "ejb2.jar");
-// assertExpectedClasses(bda2, MySLSBean.class);
-// assertExpectedResources(bda2);
-// // inclusion of BusinessInterface
-// assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
-// assertBDAId(bda2, "ejb2.jar");
-// assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
-// assertExpectedResources(bda2);
-// // double invocation
-// assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
-// assertBDAId(bda2, "ejb2.jar");
-// assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
-// assertExpectedResources(bda2);
-// }
+ public void testMixedEjbJars() throws Exception
+ {
+ // ejb1.jar
+ JavaArchive ejbJar1 = createEjbJar("ejb1.jar", true, PlainJavaBean.class);
+ DeploymentUnit unit = assertDeploy(ejbJar1);
+ Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+ Deployment deployment1 = initializeDeploymentBean(unit);
+ // ejb2.jar
+ JavaArchive ejbJar2 = createEjbJar("ejb2.jar", false, MySLSBean.class, BusinessInterface.class);
+ unit = assertDeploy(ejbJar2);
+ ClassLoader classLoader2 = unit.getClassLoader();
+ Class<?> mySLSBeanClass = classLoader2.loadClass(MySLSBean.class.getName());
+ Class<?> businessInterface = classLoader2.loadClass(BusinessInterface.class.getName());
+
+ BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
+ assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
+ // creation of bda2 on demand
+ BeanDeploymentArchive bda2 = deployment1.loadBeanDeploymentArchive(mySLSBeanClass);
+ assertBDAId(bda2, "ejb2.jar");
+ assertExpectedClasses(bda2, MySLSBean.class);
+ assertNoBeansXml(bda2);
+ // double invocation
+ assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
+ assertBDAId(bda2, "ejb2.jar");
+ assertExpectedClasses(bda2, MySLSBean.class);
+ assertNoBeansXml(bda2);
+ // inclusion of BusinessInterface
+ assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
+ assertBDAId(bda2, "ejb2.jar");
+ assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
+ assertNoBeansXml(bda2);
+ // double invocation
+ assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
+ assertBDAId(bda2, "ejb2.jar");
+ assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
+ assertNoBeansXml(bda2);
+ }
public void testEjbJarsInEar() throws Exception
{
@@ -171,7 +176,7 @@
Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
Class<?> businessInterface = getClass(BusinessInterface.class, unit);
- Deployment deployment = (Deployment) getBean(Deployment.class);
+ Deployment deployment = initializeDeploymentBean();
BeanDeploymentArchive bda = deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
assertBDAId(bda, EAR_NAME);
assertExpectedClasses(bda, PlainJavaBean.class, MySLSBean.class, BusinessInterface.class);
@@ -193,7 +198,7 @@
Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
Class<?> businessInterface = getClass(BusinessInterface.class, unit);
- Deployment deployment = (Deployment) getBean(Deployment.class);
+ Deployment deployment = initializeDeploymentBean();
BeanDeploymentArchive bda = deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
assertBDAId(bda, EAR_NAME);
assertExpectedClasses(bda, PlainJavaBean.class);
@@ -219,7 +224,7 @@
MockArchiveManifest.addManifest(ear1);
DeploymentUnit unit = assertDeploy(ear1);
Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
- Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment1 = initializeDeploymentBean(unit);
// simple2.ear
EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "simple2.ear");
JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
@@ -228,7 +233,7 @@
unit = assertDeploy(ear2);
Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
Class<?> businessInterface = getClass(BusinessInterface.class, unit);
- Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment2 = initializeDeploymentBean(unit);
BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
BeanDeploymentArchive bda2 = deployment2.getBeanDeploymentArchives().iterator().next();
@@ -250,60 +255,60 @@
}
-// public void testMixedEjbJarsInEars() throws Exception
-// {
-// // simple1.ear
-// EnterpriseArchive ear1 = ShrinkWrap.create(EnterpriseArchive.class, "simple1.ear");
-// JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", false, PlainJavaBean.class);
-// ear1.addModule(ejbJar1);
-// MockArchiveManifest.addManifest(ear1);
-// DeploymentUnit unit = assertDeploy(ear1);
-// Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
-//
-// // simple2.ear
-// EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "simple2.ear");
-// JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
-// ear2.addModule(ejbJar2);
-// MockArchiveManifest.addManifest(ear2);
-// unit = assertDeploy(ear2);
-// Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
-// Class<?> businessInterface = getClass(BusinessInterface.class, unit);
-// Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
-//
-// BeanDeploymentArchive bda2 = deployment2.getBeanDeploymentArchives().iterator().next();
-// // contents of BDA2
-// assertBDAId(bda2, "simple2.ear");
-// assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
-// // call loadBDA
-// assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
-// assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
-// // make sure that loadBDA did not change the contents of BDA2
-// assertBDAId(bda2, "simple2.ear");
-// assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
-//
-// // creation of bda1 on demand
-// BeanDeploymentArchive bda1 = deployment2.loadBeanDeploymentArchive(plainJavaBeanClass);
-// assertBDAId(bda1, "simple1.ear");
-// assertExpectedClasses(bda1, PlainJavaBean.class);
-// assertExpectedResources(bda1);
-// // double invocation
-// assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
-// assertBDAId(bda1, "simple1.ear");
-// assertExpectedClasses(bda1, PlainJavaBean.class);
-// assertExpectedResources(bda1);
-// }
+ public void testMixedEjbJarsInEars() throws Exception
+ {
+ // simple1.ear
+ EnterpriseArchive ear1 = ShrinkWrap.create(EnterpriseArchive.class, "simple1.ear");
+ JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", false, PlainJavaBean.class);
+ ear1.addModule(ejbJar1);
+ MockArchiveManifest.addManifest(ear1);
+ DeploymentUnit unit = assertDeploy(ear1);
+ Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+
+ // simple2.ear
+ EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "simple2.ear");
+ JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
+ ear2.addModule(ejbJar2);
+ MockArchiveManifest.addManifest(ear2);
+ unit = assertDeploy(ear2);
+ Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
+ Class<?> businessInterface = getClass(BusinessInterface.class, unit);
+ Deployment deployment2 = initializeDeploymentBean(unit);
+
+ BeanDeploymentArchive bda2 = deployment2.getBeanDeploymentArchives().iterator().next();
+ // contents of BDA2
+ assertBDAId(bda2, "simple2.ear");
+ assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
+ // call loadBDA
+ assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
+ assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
+ // make sure that loadBDA did not change the contents of BDA2
+ assertBDAId(bda2, "simple2.ear");
+ assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
+
+ // creation of bda1 on demand
+ BeanDeploymentArchive bda1 = deployment2.loadBeanDeploymentArchive(plainJavaBeanClass);
+ assertBDAId(bda1, "simple1.ear");
+ assertExpectedClasses(bda1, PlainJavaBean.class);
+ assertNoBeansXml(bda1);
+ // double invocation
+ assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+ assertBDAId(bda1, "simple1.ear");
+ assertExpectedClasses(bda1, PlainJavaBean.class);
+ assertNoBeansXml(bda1);
+ }
public void testWars() throws Exception
{
WebArchive war1 = createWar("simple1.war", true, ServletWebBean.class);
DeploymentUnit unit = assertDeploy(war1);
Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
- Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment1 = initializeDeploymentBean(unit);
WebArchive war2 = createWar("simple2.war", true, NotWBJsfBean.class);
unit = assertDeploy(war2);
Class<?> notWBJsfBeanClass = getClass(NotWBJsfBean.class, unit);
- Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment2 = initializeDeploymentBean(unit);
// assertion deleted as loadBDA implementation does not check for unreachable classes anymore
//assertCannotLoadBDA(deployment1, notWBJsfBeanClass);
@@ -330,7 +335,7 @@
{
WebArchive war1 = createWar("simple1.war", true, ServletWebBean.class);
/*DeploymentUnit unit = */assertDeploy(war1);
- //Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ //Deployment deployment1 = initializeDeploymentBean(unit));
WebArchive war2 = createWar("simple2.war", false, NotWBJsfBean.class);
/*unit = */assertDeploy(war2);
@@ -346,7 +351,7 @@
DeploymentUnit unit = assertDeploy(war);
Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
Class<?> uiWebBeanClass = getClass(UIWebBean.class, unit);
- Deployment deployment = (Deployment) getBean(Deployment.class);
+ Deployment deployment = initializeDeploymentBean();
BeanDeploymentArchive bda = deployment.getBeanDeploymentArchives().iterator().next();
assertBDAId(bda, WAR_NAME);
@@ -364,7 +369,7 @@
DeploymentUnit unit = assertDeploy(war);
Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
Class<?> uiWebBeanClass = getClass(UIWebBean.class, unit);
- Deployment deployment = (Deployment) getBean(Deployment.class);
+ Deployment deployment = initializeDeploymentBean();
BeanDeploymentArchive bda = deployment.getBeanDeploymentArchives().iterator().next();
assertBDAId(bda, WAR_NAME);
@@ -387,7 +392,7 @@
DeploymentUnit unit = assertDeploy(war);
Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
Class<?> uiWebBeanClass = getClass(UIWebBean.class, unit);
- Deployment deployment = (Deployment) getBean(Deployment.class);
+ Deployment deployment = initializeDeploymentBean();
BeanDeploymentArchive bda = deployment.getBeanDeploymentArchives().iterator().next();
assertBDAId(bda, WAR_NAME);
@@ -411,7 +416,7 @@
Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
Class<?> uiWebBeanClass = getClass(UIWebBean.class, unit);
Class<?> crmWebBeanClass = getClass(CrmWebBean.class, unit);
- Deployment deployment = (Deployment) getBean(Deployment.class);
+ Deployment deployment = initializeDeploymentBean();
BeanDeploymentArchive bda = deployment.getBeanDeploymentArchives().iterator().next();
assertBDAId(bda, WAR_NAME);
@@ -440,7 +445,7 @@
MockArchiveManifest.addManifest(ear1);
/*DeploymentUnit unit = */assertDeploy(ear1);
//Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit.getChildren().iterator().next());
- //Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ //Deployment deployment1 = initializeDeploymentBean(unit));
EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "warinear2.ear");
WebArchive war2 = createWar(WAR_NAME, true, NotWBJsfBean.class);
@@ -450,7 +455,7 @@
// assertion deleted as loadBDA implementation does not check for unreachable classes anymore
// Class<?> notWBJsfBeanClass = getClass(NotWBJsfBean.class, unit.getChildren().iterator().next());
- // Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ // Deployment deployment2 = initializeDeploymentBean(unit));
//assertCannotLoadBDA(deployment1, notWBJsfBeanClass);
//assertCannotLoadBDA(deployment2, servletWebBeanClass);
}
@@ -475,7 +480,7 @@
}
Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit1);
Class<?> notWBJsfBeanClass = getClass(NotWBJsfBean.class, unit2);
- Deployment deployment = (Deployment) getBean(Deployment.class);
+ Deployment deployment = initializeDeploymentBean();
BeanDeploymentArchive bda1 = deployment.loadBeanDeploymentArchive(servletWebBeanClass);
assertBDAId(bda1, "warinear.ear/simple1.war");
@@ -492,12 +497,12 @@
JavaArchive ejbJar = createEjbJar(true);
DeploymentUnit unit = assertDeploy(ejbJar);
Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
- Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment1 = initializeDeploymentBean(unit);
// simple.war
WebArchive war = createWar(true);
unit = assertDeploy(war);
- Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment2 = initializeDeploymentBean(unit);
// assertion deleted as loadBDA implementation does not check for unreachable classes anymore
//Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
@@ -532,7 +537,7 @@
} while (!warUnit.getName().contains(WAR_NAME));
Class<?> servletWebBeanClass = getClass(ServletWebBean.class, warUnit);
- Deployment deployment = (Deployment) getBean(Deployment.class);
+ Deployment deployment = initializeDeploymentBean();
BeanDeploymentArchive bda = deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
@@ -553,12 +558,12 @@
MockArchiveManifest.addManifest(ear);
DeploymentUnit unit = assertDeploy(ear);
Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
- Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment1 = initializeDeploymentBean(unit);
// simple.war
WebArchive war = createWar(true);
unit = assertDeploy(war);
- Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment2 = initializeDeploymentBean(unit);
// assertion deleted as loadBDA implementation does not check for unreachable classes anymore
// Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
@@ -583,7 +588,7 @@
MockArchiveManifest.addManifest(ejbEar);
DeploymentUnit unit = assertDeploy(ejbEar);
Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
- Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment1 = initializeDeploymentBean(unit);
// war.ear
EnterpriseArchive warEar = ShrinkWrap.create(EnterpriseArchive.class, "war.ear");
WebArchive war = createWarWithLib(true, false);
@@ -593,7 +598,7 @@
DeploymentUnit warUnit = unit.getChildren().iterator().next();
Class<?> servletWebBeanClass = getClass(ServletWebBean.class, warUnit);
Class<?> uiWebBeanClass = getClass(UIWebBean.class, warUnit);
- Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ Deployment deployment2 = initializeDeploymentBean(unit);
// assertion deleted as loadBDA implementation does not check for unreachable classes anymore
//assertCannotLoadBDA(deployment1, servletWebBeanClass);
@@ -621,7 +626,7 @@
{
WebArchive war1 = createWar("web1.war", true, ServletWebBean.class);
DeploymentUnit war1Unit = assertDeploy(war1);
- Deployment war1Deployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(war1Unit));
+ Deployment war1Deployment = initializeDeploymentBean(war1Unit);
BeanDeploymentArchive war1BDA = war1Deployment.getBeanDeploymentArchives().iterator().next();
assertBDAId(war1BDA, "web1.war");
assertExpectedClasses(war1BDA, ServletWebBean.class);
@@ -630,7 +635,7 @@
WebArchive war2 = createWar("web2.war", true, NotWBJsfBean.class);
createLib(war2, "crm.jar", false, CrmWebBean.class);
DeploymentUnit war2Unit = assertDeploy(war2);
- Deployment war2Deployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(war2Unit));
+ Deployment war2Deployment = initializeDeploymentBean(war2Unit);
BeanDeploymentArchive war2BDA = war2Deployment.getBeanDeploymentArchives().iterator().next();
assertBDAId(war2BDA, "web2.war");
assertExpectedClasses(war2BDA, NotWBJsfBean.class);
@@ -639,7 +644,7 @@
JavaArchive ejbJar = createEjbJar("ejb.jar", true, BusinessInterface.class);
DeploymentUnit ejbJarUnit = assertDeploy(ejbJar);
- Deployment ejbJarDeployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(ejbJarUnit));
+ Deployment ejbJarDeployment = initializeDeploymentBean(ejbJarUnit);
BeanDeploymentArchive ejbJarBDA = ejbJarDeployment.getBeanDeploymentArchives().iterator().next();
assertBDAId(ejbJarBDA, "ejb.jar");
assertExpectedClasses(ejbJarBDA, BusinessInterface.class);
@@ -656,7 +661,7 @@
createLib(ear1, "lib3.jar", false, B.class);
MockArchiveManifest.addManifest(ear1);
DeploymentUnit ear1Unit = assertDeploy(ear1);
- Deployment ear1Deployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(ear1Unit));
+ Deployment ear1Deployment = initializeDeploymentBean(ear1Unit);
BeanDeploymentArchive ear1BDA = null, ear1War1BDA = null, ear1War2BDA = null;
for (BeanDeploymentArchive bda: ear1Deployment.getBeanDeploymentArchives())
{
@@ -707,7 +712,7 @@
createLib(ear2, "lib2.jar", true, CrmWebBean.class);
MockArchiveManifest.addManifest(ear2);
DeploymentUnit ear2Unit = assertDeploy(ear2);
- Deployment ear2Deployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(ear2Unit));
+ Deployment ear2Deployment = initializeDeploymentBean(ear2Unit);
BeanDeploymentArchive ear2BDA = ear2Deployment.getBeanDeploymentArchives().iterator().next();
assertBDAId(ear2BDA, "ejbWLibs.ear");
assertExpectedClasses(ear2BDA, PlainJavaBean.class, CrmWebBean.class);
@@ -886,14 +891,25 @@
return bda.getBeanClasses();
}
- @Override
- protected Collection<URL> getResources(BeanDeploymentArchive bda)
+ private Deployment initializeDeploymentBean(DeploymentUnit unit)
{
- // TODO Fix this
- return null;
- //return bda.getBeansXml();
+ DeploymentImpl deployment = (DeploymentImpl) getBean(DeployersUtils.getDeploymentBeanName(unit));
+ deployment.initialize(bootstrap);
+ return deployment;
}
+ private Deployment initializeDeploymentBean()
+ {
+ DeploymentImpl deployment = (DeploymentImpl) getBean(Deployment.class);
+ deployment.initialize(bootstrap);
+ return deployment;
+ }
+
+ private void assertNoBeansXml (BeanDeploymentArchive bda)
+ {
+ assertSame(BeansXml.EMPTY_BEANS_XML, bda.getBeansXml());
+ }
+
private void assertBDAId(BeanDeploymentArchive bda, String name)
{
assertTrue("BDA id \"" + bda.getId() + "\" expected to end with suffix \"" + name + "/}\"",
More information about the jboss-cvs-commits
mailing list