[weld-commits] Weld SVN: r5372 - core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Dec 30 09:11:03 EST 2009


Author: dallen6
Date: 2009-12-30 09:11:02 -0500 (Wed, 30 Dec 2009)
New Revision: 5372

Added:
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Bar.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarConsumer.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarProducer.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/DisposalMethodInjectionPointTest.java
Log:
Added unit test for WELD-358

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Bar.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Bar.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Bar.java	2009-12-30 14:11:02 UTC (rev 5372)
@@ -0,0 +1,10 @@
+package org.jboss.weld.tests.producer.method;
+
+public class Bar
+{
+
+   public Bar(String blah)
+   {
+      
+   }
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Bar.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarConsumer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarConsumer.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarConsumer.java	2009-12-30 14:11:02 UTC (rev 5372)
@@ -0,0 +1,16 @@
+package org.jboss.weld.tests.producer.method;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+
+ at RequestScoped
+public class BarConsumer
+{
+   @Inject
+   private Bar bar;
+
+   public Bar getBar()
+   {
+      return bar;
+   }
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarConsumer.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarProducer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarProducer.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarProducer.java	2009-12-30 14:11:02 UTC (rev 5372)
@@ -0,0 +1,58 @@
+package org.jboss.weld.tests.producer.method;
+
+import java.lang.reflect.Member;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+/**
+ * Class with a producer method and disposal method both containing InjectionPoint
+ * parameters.
+ * 
+ * @author David Allen
+ *
+ */
+public class BarProducer
+{
+   private static Bar disposedBar;
+   private static Member disposedInjection;
+   private static Member producedInjection;
+   
+   @Produces
+   public Bar getBar(InjectionPoint injectionPoint)
+   {
+      producedInjection = injectionPoint.getMember();
+      return new Bar("blah");
+   }
+   
+   public void dispose(@Disposes @Any Bar bar, InjectionPoint injectionPoint)
+   {
+      disposedBar = bar;
+      disposedInjection = injectionPoint.getMember();
+   }
+
+   public static Bar getDisposedBar()
+   {
+      return disposedBar;
+   }
+
+   public static Member getDisposedInjection()
+   {
+      return disposedInjection;
+   }
+
+   public static Member getProducedInjection()
+   {
+      return producedInjection;
+   }
+   
+   public static void reset()
+   {
+      disposedBar = null;
+      disposedInjection = null;
+      producedInjection = null;
+   }
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/BarProducer.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/DisposalMethodInjectionPointTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/DisposalMethodInjectionPointTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/DisposalMethodInjectionPointTest.java	2009-12-30 14:11:02 UTC (rev 5372)
@@ -0,0 +1,27 @@
+package org.jboss.weld.tests.producer.method;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+ at Artifact
+public class DisposalMethodInjectionPointTest extends AbstractWeldTest
+{
+   @Test(groups = { "broken" })
+   // WELD-358
+   public void test()
+   {
+      BarProducer.reset();
+      Bean<BarConsumer> barConsumerBean = getBean(BarConsumer.class);
+      CreationalContext<BarConsumer> ctx = getCurrentManager().createCreationalContext(barConsumerBean);
+      BarConsumer barConsumer = barConsumerBean.create(ctx);
+      assert BarProducer.getProducedInjection().getName().equals("bar");
+      Bar bar = barConsumer.getBar();
+      barConsumerBean.destroy(barConsumer, ctx);
+      assert BarProducer.getDisposedBar() == bar;
+      assert BarProducer.getDisposedInjection().getName().equals("bar");
+   }
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/DisposalMethodInjectionPointTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the weld-commits mailing list