Author: nickarls
Date: 2009-12-10 07:25:20 -0500 (Thu, 10 Dec 2009)
New Revision: 5266
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/Alt.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/beans.xml
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java
Log:
Tests for WELD-319, part II (isolation)
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/Alt.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/Alt.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/Alt.java 2009-12-10
12:25:20 UTC (rev 5266)
@@ -0,0 +1,9 @@
+package org.jboss.weld.tests.unit.deployment.structure.nonTransitiveResolution;
+
+import javax.enterprise.inject.Alternative;
+
+@Alternative
+public class Alt
+{
+
+}
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java 2009-12-10
11:44:51 UTC (rev 5265)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java 2009-12-10
12:25:20 UTC (rev 5266)
@@ -5,27 +5,95 @@
import org.jboss.weld.bootstrap.spi.Deployment;
import org.jboss.weld.mock.AbstractMockDeployment;
import org.jboss.weld.mock.MockBeanDeploymentArchive;
+import org.jboss.weld.mock.MockDeployment;
import org.jboss.weld.mock.MockServletLifecycle;
import org.jboss.weld.mock.TestContainer;
import org.testng.annotations.Test;
public class TransitiveResolutionTest
{
+
+ @Test(description = "WELD-319")
+ public void testBeansXmlIsolation()
+ {
+ MockBeanDeploymentArchive jar1 = new
MockBeanDeploymentArchive("first-jar", Alt.class);
+ MockBeanDeploymentArchive jar2 = new
MockBeanDeploymentArchive("second-jar", Alt.class);
+ jar1.getBeansXml().add(getClass().getResource("beans.xml"));
+ MockBeanDeploymentArchive war = new MockBeanDeploymentArchive("war");
+ war.getBeanDeploymentArchives().add(jar1);
+ war.getBeanDeploymentArchives().add(jar2);
+
+ Deployment deployment = new MockDeployment(war);
+
+ TestContainer container = null;
+ try
+ {
+ container = new TestContainer(new MockServletLifecycle(deployment,
war)).startContainer().ensureRequestActive();
+ BeanManagerImpl warBeanManager = container.getBeanManager();
+ BeanManagerImpl jar1BeanManager =
container.getLifecycle().getBootstrap().getManager(jar1);
+ BeanManagerImpl jar2BeanManager =
container.getLifecycle().getBootstrap().getManager(jar2);
+ assert warBeanManager.getEnabledAlternativeClasses().isEmpty();
+ assert !jar1BeanManager.getEnabledAlternativeClasses().isEmpty();
+ assert jar2BeanManager.getEnabledAlternativeClasses().isEmpty();
+ }
+ finally
+ {
+ if (container != null)
+ {
+ container.stopContainer();
+ }
+ }
+ }
- @Test(description="WELD-236")
+ @Test(description = "WELD-319")
+ public void testBeansXmlMultipleEnabling()
+ {
+ MockBeanDeploymentArchive jar1 = new
MockBeanDeploymentArchive("first-jar", Alt.class);
+ MockBeanDeploymentArchive jar2 = new
MockBeanDeploymentArchive("second-jar", Alt.class);
+ jar1.getBeansXml().add(getClass().getResource("beans.xml"));
+ jar2.getBeansXml().add(getClass().getResource("beans.xml"));
+ MockBeanDeploymentArchive war = new MockBeanDeploymentArchive("war");
+ war.getBeanDeploymentArchives().add(jar1);
+ war.getBeanDeploymentArchives().add(jar2);
+
+ Deployment deployment = new MockDeployment(war);
+
+ TestContainer container = null;
+ try
+ {
+ container = new TestContainer(new MockServletLifecycle(deployment,
war)).startContainer().ensureRequestActive();
+ BeanManagerImpl warBeanManager = container.getBeanManager();
+ BeanManagerImpl jar1BeanManager =
container.getLifecycle().getBootstrap().getManager(jar1);
+ BeanManagerImpl jar2BeanManager =
container.getLifecycle().getBootstrap().getManager(jar2);
+ assert warBeanManager.getEnabledAlternativeClasses().isEmpty();
+ assert !jar1BeanManager.getEnabledAlternativeClasses().isEmpty();
+ assert !jar2BeanManager.getEnabledAlternativeClasses().isEmpty();
+ }
+ finally
+ {
+ if (container != null)
+ {
+ container.stopContainer();
+ }
+ }
+ }
+
+ @Test(description = "WELD-236")
public void testTypicalEarStructure()
- {
-
- // Create the BDA in which we will deploy Foo. This is equivalent to a ejb jar
+ {
+
+ // Create the BDA in which we will deploy Foo. This is equivalent to a ejb
+ // jar
final MockBeanDeploymentArchive ejbJar = new
MockBeanDeploymentArchive("ejb-jar", Foo.class);
-
+
// Create the BDA in which we will deploy Bar. This is equivalent to a war
MockBeanDeploymentArchive war = new MockBeanDeploymentArchive("war",
Bar.class);
-
+
// The war can access the ejb jar
war.getBeanDeploymentArchives().add(ejbJar);
-
- // Create a deployment, any other classes are put into the ejb-jar (not relevant to
test)
+
+ // Create a deployment, any other classes are put into the ejb-jar (not
+ // relevant to test)
Deployment deployment = new AbstractMockDeployment(war, ejbJar)
{
@@ -33,18 +101,17 @@
{
return ejbJar;
}
-
+
};
-
-
+
TestContainer container = new TestContainer(new MockServletLifecycle(deployment,
war));
container.startContainer();
container.ensureRequestActive();
-
+
// Get the bean manager for war and ejb jar
BeanManagerImpl warBeanManager = container.getBeanManager();
BeanManagerImpl ejbJarBeanManager =
container.getLifecycle().getBootstrap().getManager(ejbJar);
-
+
assert warBeanManager.getBeans(Bar.class).size() == 1;
assert warBeanManager.getBeans(Foo.class).size() == 1;
assert ejbJarBeanManager.getBeans(Foo.class).size() == 1;
@@ -55,5 +122,5 @@
assert bar.getBeanManager().equals(warBeanManager);
assert bar.getFoo().getBeanManager().equals(ejbJarBeanManager);
}
-
+
}
Added:
core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/beans.xml
===================================================================
---
core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/beans.xml
(rev 0)
+++
core/trunk/tests/src/test/resources/org/jboss/weld/tests/unit/deployment/structure/nonTransitiveResolution/beans.xml 2009-12-10
12:25:20 UTC (rev 5266)
@@ -0,0 +1,5 @@
+<beans>
+ <alternatives>
+ <class>org.jboss.weld.tests.unit.deployment.structure.nonTransitiveResolution.Alt</class>
+ </alternatives>
+</beans>
\ No newline at end of file
Show replies by date