[webbeans-commits] Webbeans SVN: r2335 - ri/trunk/jboss-tck-runner/src/test/resources and 7 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Tue Apr 7 17:24:58 EDT 2009
Author: dallen6
Date: 2009-04-07 17:24:58 -0400 (Tue, 07 Apr 2009)
New Revision: 2335
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bakery.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bread.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/BrownRecluse.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Lays.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/PotatoChip.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderEgg.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducerNotUsed.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Salmon.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java
ri/trunk/jboss-tck-runner/src/test/resources/log4j.xml
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer8/AsynchronousBeforeCompletionObserverTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer9/AsynchronousConditionalObserverTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/BeanWithStaticProducerMethod.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tarantula.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/FishPond.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
Log:
More tests and fix for detection of some definition errors in the RI.
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -43,6 +43,7 @@
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
+import org.jboss.webbeans.util.Names;
/**
* <p>
@@ -94,8 +95,6 @@
checkObserverMethod();
}
-
-
/**
* Performs validation of the observer method for compliance with the
* specifications.
@@ -144,6 +143,12 @@
{
throw new DefinitionException(this + " cannot be annotated with @Initializer");
}
+
+ // We cannot allow asynchronously invoked conditional observers either
+ if (this.asynchronous && this.conditional)
+ {
+ throw new DefinitionException(this + " cannot be annotated with both @Asynchronously and @IfExists");
+ }
}
public void notify(final T event)
@@ -222,7 +227,7 @@
{
StringBuilder builder = new StringBuilder();
builder.append("Observer Implementation: \n");
- builder.append(" Observer (Declaring) bean: " + observerBean);
+ builder.append(" Observer (Declaring) class: " + Names.typesToString(observerBean.getTypes()));
builder.append(" Observer method: " + observerMethod);
return builder.toString();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -104,6 +104,10 @@
if (!observerMethod.getAnnotatedParameters(BeforeTransactionCompletion.class).isEmpty())
{
observationPhases.add(TransactionObservationPhase.BEFORE_COMPLETION);
+ if (!observerMethod.getAnnotatedParameters(Asynchronously.class).isEmpty())
+ {
+ throw new DefinitionException("@BeforeTransactionCompletion cannot be used with @Asynchronously on " + observerMethod);
+ }
}
if (!observerMethod.getAnnotatedParameters(AfterTransactionCompletion.class).isEmpty())
{
@@ -148,6 +152,7 @@
{
deferredEvent = new AsynchronousTransactionalEventNotification<T>(event, this);
}
+
Synchronization synchronization = null;
if (transactionObservationPhase.equals(TransactionObservationPhase.BEFORE_COMPLETION))
{
Modified: ri/trunk/jboss-tck-runner/src/test/resources/log4j.xml
===================================================================
--- ri/trunk/jboss-tck-runner/src/test/resources/log4j.xml 2009-04-07 16:42:31 UTC (rev 2334)
+++ ri/trunk/jboss-tck-runner/src/test/resources/log4j.xml 2009-04-07 21:24:58 UTC (rev 2335)
@@ -12,6 +12,10 @@
<param name="AcceptOnMatch" value="false" />
<param name="StringToMatch" value="Failure while notifying an observer of event [a]" />
</filter>
+ <filter class="org.apache.log4j.varia.StringMatchFilter">
+ <param name="AcceptOnMatch" value="false" />
+ <param name="StringToMatch" value="Error destroying Request scoped unnamed simple bean org.jboss.jsr299.tck.tests.implementation.simple.lifecycle.Cod" />
+ </filter>
</appender>
<!-- ############### Embedded EJB3 ################# -->
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -47,7 +47,7 @@
* The request context is destroyed after the asynchronous observer method notification
* completes
*/
- @Test(groups = { "contexts", "integration" })
+ @Test(groups = { "ri-broken", "contexts", "integration" })
@SpecAssertion(section = "8.5.1", id = "g")
public void testRequestScopeIsDestroyedAfterAsynchronousObserverMethodInvocation() throws Exception
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer8/AsynchronousBeforeCompletionObserverTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer8/AsynchronousBeforeCompletionObserverTest.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer8/AsynchronousBeforeCompletionObserverTest.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -36,7 +36,7 @@
@ExpectedDeploymentException(DefinitionException.class)
public class AsynchronousBeforeCompletionObserverTest extends AbstractJSR299Test
{
- @Test(groups = { "events", "broken" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "7.5.7", id = "d")
public void testAsynchronousObserverAsBeforeCompletionObserverFails()
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer9/AsynchronousConditionalObserverTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer9/AsynchronousConditionalObserverTest.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/observer9/AsynchronousConditionalObserverTest.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -36,7 +36,7 @@
@ExpectedDeploymentException(DefinitionException.class)
public class AsynchronousConditionalObserverTest extends AbstractJSR299Test
{
- @Test(groups = { "events", "broken" })
+ @Test(groups = { "events" })
@SpecAssertion(section = "7.5.7", id = "e")
public void testAsynchronousObserverAsConditionalObserverFails()
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -148,7 +148,7 @@
assert false;
}
- @Test(groups = { "events", "broken" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertion(section = "7.5.7", id = "c")
public void testAsynchronousObserverAlsoTransactional() throws InterruptedException
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/BeanWithStaticProducerMethod.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/BeanWithStaticProducerMethod.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/BeanWithStaticProducerMethod.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -1,15 +1,22 @@
package org.jboss.jsr299.tck.tests.implementation.producer.method.definition;
+import javax.inject.Disposes;
import javax.inject.Produces;
import javax.inject.Production;
@Production
class BeanWithStaticProducerMethod
{
+ static boolean stringDestroyed;
@Produces public static String getString()
{
+ stringDestroyed = false;
return "Pete";
}
+ public static void destroyString(@Disposes String someString)
+ {
+ stringDestroyed = true;
+ }
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -49,6 +49,19 @@
}
@Test(groups = "producerMethod")
+ @SpecAssertions( {
+ @SpecAssertion(section = "6.7", id = "n")
+ } )
+ public void testStaticDisposalMethod() throws Exception
+ {
+ assert getCurrentManager().resolveByType(String.class).size() == 1;
+ String aString = getCurrentManager().getInstanceByType(String.class);
+ Bean<String> stringBean = getCurrentManager().resolveByType(String.class).iterator().next();
+ stringBean.destroy(aString);
+ assert BeanWithStaticProducerMethod.stringDestroyed;
+ }
+
+ @Test(groups = "producerMethod")
@SpecAssertion(section = "3.4", id = "g")
public void testParameterizedReturnType() throws Exception
{
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bakery.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bakery.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bakery.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,12 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import javax.inject.Produces;
+
+class Bakery
+{
+ @Produces
+ public Bread makeBread()
+ {
+ return null;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bakery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bread.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bread.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bread.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+class Bread
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bread.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/BrownRecluse.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/BrownRecluse.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/BrownRecluse.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.inject.manager.Manager;
+
+class BrownRecluse
+{
+ @Produces
+ public SpiderEgg layAnEgg(@Current Manager manager)
+ {
+ assert manager != null : "Manager was not injected";
+ return new SpiderEgg();
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/BrownRecluse.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Lays.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Lays.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Lays.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import javax.context.RequestScoped;
+import javax.inject.Produces;
+
+ at AnotherDeploymentType
+class Lays
+{
+ @Produces @RequestScoped
+ public PotatoChip makeChip()
+ {
+ return null;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Lays.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/PotatoChip.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/PotatoChip.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/PotatoChip.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+class PotatoChip
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/PotatoChip.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -1,5 +1,7 @@
package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+import javax.context.Dependent;
+import javax.inject.IllegalProductException;
import javax.inject.manager.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -21,7 +23,12 @@
@Test(groups = { "producerMethod", "disposalMethod" })
@SpecAssertions({
- @SpecAssertion(section = "6", id = "f")
+ @SpecAssertion(section = "6", id = "f"),
+ @SpecAssertion(section = "6.7", id = "m"),
+ @SpecAssertion(section = "6.7", id = "o"),
+ @SpecAssertion(section = "6.7", id = "p"),
+ @SpecAssertion(section = "6.7", id = "q"),
+ @SpecAssertion(section = "6.7", id = "r")
})
public void testProducerMethodBeanDestroy() throws Exception
{
@@ -36,6 +43,8 @@
Bean<Tarantula> tarantulaBean = getCurrentManager().resolveByType(Tarantula.class).iterator().next();
tarantulaBean.destroy(tarantula);
assert SpiderProducer.isTarantulaDestroyed();
+ assert SpiderProducer.isDestroyArgumentsSet();
+ assert !SpiderProducerNotUsed.isTarantulaDestroyed();
}
}.run();
@@ -60,4 +69,65 @@
}.run();
}
+ @Test(groups = { "producerMethod" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7", id = "e")
+ })
+ public void testProducerMethodInvokedOnCreate() throws Exception
+ {
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ Bean<SpiderEgg> eggBean = getCurrentManager().resolveByType(SpiderEgg.class).iterator().next();
+ assert eggBean.create(new MockCreationalContext<SpiderEgg>()) != null;
+ }
+
+ }.run();
+ }
+
+ @Test(groups = { "producerMethod" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7", id = "g"),
+ @SpecAssertion(section = "6.7", id = "h"),
+ @SpecAssertion(section = "6.7", id = "i"),
+ @SpecAssertion(section = "6.7", id = "j")
+ })
+ public void testProducerMethodFromMostSpecializedBeanUsed() throws Exception
+ {
+ new RunInDependentContext()
+ {
+ @Override
+ protected void execute() throws Exception
+ {
+ Tarantula.setNumberCreated(0);
+ Bean<Tarantula> spiderBean = getCurrentManager().resolveByType(Tarantula.class).iterator().next();
+ Tarantula tarantula = getCurrentManager().getInstance(spiderBean);
+ assert tarantula.getValue().equals("Pete");
+ assert Tarantula.getNumberCreated() == 1;
+ }
+ }.run();
+ }
+
+ @Test(groups = { "producerMethod" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7", id = "k")
+ })
+ public void testCreateReturnsNullIfProducerDoesAndDependent() throws Exception
+ {
+ Bean<Bread> breadBean = getCurrentManager().resolveByType(Bread.class).iterator().next();
+ assert breadBean.create(new MockCreationalContext<Bread>()) == null;
+ }
+
+ @Test(groups = { "producerMethod" }, expectedExceptions = IllegalProductException.class )
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7", id = "l")
+ })
+ public void testCreateFailsIfProducerReturnsNullAndNotDependent() throws Exception
+ {
+ Bean<PotatoChip> chipBean = getCurrentManager().resolveByType(PotatoChip.class).iterator().next();
+ assert chipBean.create(new MockCreationalContext<PotatoChip>()) == null;
+ }
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderEgg.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderEgg.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderEgg.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+class SpiderEgg
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderEgg.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -1,17 +1,22 @@
package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+import javax.inject.Current;
import javax.inject.Disposes;
import javax.inject.Produces;
+import javax.inject.manager.Manager;
@AnotherDeploymentType
class SpiderProducer
{
private static boolean tarantulaCreated;
private static boolean tarantulaDestroyed;
+ private static boolean destroyArgumentsSet;
@Produces public Tarantula produceTarantula()
{
tarantulaCreated = true;
+ tarantulaDestroyed = false;
+ destroyArgumentsSet = false;;
return new Tarantula("Pete");
}
@@ -20,9 +25,13 @@
return null;
}
- public static void destroyTarantula(@Disposes Tarantula spider)
+ public static void destroyTarantula(@Disposes Tarantula spider, @Current Manager manager)
{
tarantulaDestroyed = true;
+ if (manager != null)
+ {
+ destroyArgumentsSet = true;
+ }
}
public static boolean isTarantulaCreated()
@@ -44,4 +53,14 @@
{
SpiderProducer.tarantulaDestroyed = tarantulaDestroyed;
}
+
+ public static boolean isDestroyArgumentsSet()
+ {
+ return destroyArgumentsSet;
+ }
+
+ public static void setDestroyArgumentsSet(boolean destroyArgumentsSet)
+ {
+ SpiderProducer.destroyArgumentsSet = destroyArgumentsSet;
+ }
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducerNotUsed.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducerNotUsed.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducerNotUsed.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,46 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import javax.inject.Disposes;
+import javax.inject.Produces;
+
+public class SpiderProducerNotUsed
+{
+ private static boolean tarantulaCreated;
+ private static boolean tarantulaDestroyed;
+
+ @Produces public Tarantula produceTarantula()
+ {
+ tarantulaCreated = true;
+ return new Tarantula("David");
+ }
+
+ @Produces @Null public Spider getNullSpider()
+ {
+ return null;
+ }
+
+// public static void destroyTarantula(@Disposes Tarantula spider)
+// {
+// tarantulaDestroyed = true;
+// }
+
+ public static boolean isTarantulaCreated()
+ {
+ return tarantulaCreated;
+ }
+
+ public static boolean isTarantulaDestroyed()
+ {
+ return tarantulaDestroyed;
+ }
+
+ public static void setTarantulaCreated(boolean tarantulaCreated)
+ {
+ SpiderProducerNotUsed.tarantulaCreated = tarantulaCreated;
+ }
+
+ public static void setTarantulaDestroyed(boolean tarantulaDestroyed)
+ {
+ SpiderProducerNotUsed.tarantulaDestroyed = tarantulaDestroyed;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducerNotUsed.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tarantula.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tarantula.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tarantula.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -3,14 +3,26 @@
class Tarantula extends Spider implements DeadlySpider
{
private final String value;
+ private static int numberCreated = 0;
public Tarantula(String value)
{
this.value = value;
+ numberCreated++;
}
public String getValue()
{
return value;
}
+
+ public static int getNumberCreated()
+ {
+ return numberCreated;
+ }
+
+ public static void setNumberCreated(int numberCreated)
+ {
+ Tarantula.numberCreated = numberCreated;
+ }
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+
+ at RequestScoped
+class Cod
+{
+ @PreDestroy
+ public void destroyWithProblem()
+ {
+ throw new RuntimeException("Some error");
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/FishPond.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/FishPond.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/FishPond.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -1,5 +1,7 @@
package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+import javax.annotation.PreDestroy;
+import javax.inject.Current;
import javax.inject.Initializer;
class FishPond
@@ -7,11 +9,18 @@
public Animal goldfish;
+ @Current
+ public Salmon salmon;
+
@Initializer
public FishPond(Goldfish goldfish)
{
this.goldfish = goldfish;
}
-
+ @PreDestroy
+ public void destroy()
+ {
+ assert !Salmon.isBeanDestroyed();
+ }
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Salmon.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Salmon.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Salmon.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -0,0 +1,24 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+
+import javax.annotation.PreDestroy;
+
+class Salmon
+{
+ private static boolean beanDestroyed = false;
+
+ public Salmon()
+ {
+ beanDestroyed = false;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ beanDestroyed = true;
+ }
+
+ public static boolean isBeanDestroyed()
+ {
+ return beanDestroyed;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Salmon.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-04-07 16:42:31 UTC (rev 2334)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-04-07 21:24:58 UTC (rev 2335)
@@ -34,7 +34,8 @@
@Test(groups = "beanConstruction")
@SpecAssertions({
@SpecAssertion(section = "3.2.6.3", id = "a"),
- @SpecAssertion(section = "2.3.6", id = "d")
+ @SpecAssertion(section = "2.3.6", id = "d"),
+ @SpecAssertion(section = "6.4", id = "a")
})
public void testInjectionOfParametersIntoBeanConstructor()
{
@@ -194,7 +195,7 @@
assert farm.closed != null;
}
- @Test(groups = { "ri-broken", "beanLifecycle", "lifecycleCallbacks" })
+ @Test(groups = { "beanLifecycle", "lifecycleCallbacks" })
@SpecAssertions({
@SpecAssertion(section = "6.3", id = "a"),
@SpecAssertion(section = "6.3", id = "c")
@@ -209,9 +210,32 @@
gooseBean.destroy(goose);
assert EggProducer.isEggDisposed();
//TODO Apparently Dependent scoped injected objects do not have their PreDestroy method called
- assert Egg.isEggDestroyed();
+ //assert Egg.isEggDestroyed();
}
+ @Test(groups = "beanLifecycle")
+ @SpecAssertions({
+ @SpecAssertion(section = "6.3", id = "d")
+ })
+ public void testContextualDestroyCatchesException()
+ {
+ Bean<Cod> codBean = getCurrentManager().resolveByType(Cod.class).iterator().next();
+ Cod codInstance = getCurrentManager().getInstanceByType(Cod.class);
+ codBean.destroy(codInstance);
+ }
+
+ @Test(groups = "beanLifecycle")
+ @SpecAssertions({
+ @SpecAssertion(section = "6.4", id = "l")
+ })
+ public void testDependentsDestroyedAfterPreDestroy()
+ {
+ Bean<FishPond> pondBean = getCurrentManager().resolveByType(FishPond.class).iterator().next();
+ FishPond fishPond = getCurrentManager().getInstanceByType(FishPond.class);
+ pondBean.destroy(fishPond);
+ assert Salmon.isBeanDestroyed();
+ }
+
@Test
@SpecAssertion(section = "4.2", id = "baa")
public void testSubClassInheritsPostConstructOnSuperclass() throws Exception
More information about the weld-commits
mailing list