[weld-commits] Weld SVN: r4583 - in core/trunk/tests: src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Mon Nov 2 19:13:42 EST 2009


Author: pete.muir at jboss.org
Date: 2009-11-02 19:13:42 -0500 (Mon, 02 Nov 2009)
New Revision: 4583

Added:
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java
Removed:
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/NonTransitiveResolutionTest.java
Modified:
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/Bar.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/Foo.java
   core/trunk/tests/unit-tests.xml
Log:
Improve test and cause it to run

Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/Bar.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/Bar.java	2009-11-03 00:12:53 UTC (rev 4582)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/Bar.java	2009-11-03 00:13:42 UTC (rev 4583)
@@ -1,15 +1,28 @@
 package org.jboss.weld.test.unit.deployment.structure.nonTransitiveResolution;
 
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.inject.Inject;
 
 public class Bar
 {
    
-   @Inject Foo foo;
+   @Inject private Foo foo;
    
+   // Inject the bean manager to make sure the bean is intranstive
+   @Inject private BeanManager beanManager;
+   
+   // Inject the @New bean to make sure the bean is intranstive   
+   @Inject @New String str;
+   
    public Foo getFoo()
    {
       return foo;
    }
+   
+   public BeanManager getBeanManager()
+   {
+      return beanManager;
+   }
 
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/Foo.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/Foo.java	2009-11-03 00:12:53 UTC (rev 4582)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/Foo.java	2009-11-03 00:13:42 UTC (rev 4583)
@@ -1,6 +1,21 @@
 package org.jboss.weld.test.unit.deployment.structure.nonTransitiveResolution;
 
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
 public class Foo
 {
-
+   
+   // Inject the bean manager to make sure the bean is intranstive  
+   @Inject private BeanManager beanManager;
+   
+   // Inject the @New bean to make sure the bean is intranstive
+   @Inject @New String str;
+   
+   public BeanManager getBeanManager()
+   {
+      return beanManager;
+   }
+   
 }

Deleted: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/NonTransitiveResolutionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/NonTransitiveResolutionTest.java	2009-11-03 00:12:53 UTC (rev 4582)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/NonTransitiveResolutionTest.java	2009-11-03 00:13:42 UTC (rev 4583)
@@ -1,48 +0,0 @@
-package org.jboss.weld.test.unit.deployment.structure.nonTransitiveResolution;
-
-import org.jboss.weld.BeanManagerImpl;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
-import org.jboss.weld.mock.AbstractMockDeployment;
-import org.jboss.weld.mock.MockBeanDeploymentArchive;
-import org.jboss.weld.mock.MockServletLifecycle;
-import org.jboss.weld.mock.TestContainer;
-import org.testng.annotations.Test;
-
-public class NonTransitiveResolutionTest
-{
-   
-   @Test(description="WELD-236")
-   public void test()
-   { 
-      
-      // 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)
-      Deployment deployment = new AbstractMockDeployment(war, ejbJar)
-      {
-
-         public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
-         {
-            return ejbJar;
-         }
-         
-      };
-      
-      
-      TestContainer container = new TestContainer(new MockServletLifecycle(deployment, war));
-      container.startContainer();
-      container.ensureRequestActive();
-      
-      // Get the bean manager for bda1 and bda2
-      BeanManagerImpl beanManager1 = container.getBeanManager();
-   }
-   
-}

Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java (from rev 4532, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/NonTransitiveResolutionTest.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java	2009-11-03 00:13:42 UTC (rev 4583)
@@ -0,0 +1,59 @@
+package org.jboss.weld.test.unit.deployment.structure.nonTransitiveResolution;
+
+import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.mock.AbstractMockDeployment;
+import org.jboss.weld.mock.MockBeanDeploymentArchive;
+import org.jboss.weld.mock.MockServletLifecycle;
+import org.jboss.weld.mock.TestContainer;
+import org.testng.annotations.Test;
+
+public class TransitiveResolutionTest
+{
+   
+   @Test(description="WELD-236")
+   public void testTypicalEarStructure()
+   { 
+      
+      // 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)
+      Deployment deployment = new AbstractMockDeployment(war, ejbJar)
+      {
+
+         public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+         {
+            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;
+      assert ejbJarBeanManager.getBeans(Bar.class).size() == 0;
+      Bar bar = warBeanManager.getInstanceByType(Bar.class);
+      assert bar.getFoo() != null;
+      assert bar.getBeanManager() != null;
+      assert bar.getBeanManager().equals(warBeanManager);
+      assert bar.getFoo().getBeanManager().equals(ejbJarBeanManager);
+   }
+   
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/nonTransitiveResolution/TransitiveResolutionTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/tests/unit-tests.xml
===================================================================
--- core/trunk/tests/unit-tests.xml	2009-11-03 00:12:53 UTC (rev 4582)
+++ core/trunk/tests/unit-tests.xml	2009-11-03 00:13:42 UTC (rev 4583)
@@ -38,6 +38,7 @@
          <package name="org.jboss.weld.test.unit.definition" />
          <package name="org.jboss.weld.test.unit.deployment.structure.extensions" />
          <package name="org.jboss.weld.test.unit.deployment.structure.resolution" />
+         <package name="org.jboss.weld.test.unit.deployment.structure.nonTransitiveResolution" />
          <package name="org.jboss.weld.test.unit.environments.servlet" />
          <package name="org.jboss.weld.test.unit.extensions" />
          <package name="org.jboss.weld.test.unit.implementation" />



More information about the weld-commits mailing list