[webbeans-commits] Webbeans SVN: r3123 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck: tests/implementation/enterprise/lifecycle and 2 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Tue Jul 21 22:58:46 EDT 2009
Author: dan.j.allen
Date: 2009-07-21 22:58:45 -0400 (Tue, 21 Jul 2009)
New Revision: 3123
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Fail.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/FirstBorn.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/PreferredSpiderProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Web.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/AndalusianChicken.java
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/InfertileChicken.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/producer/method/lifecycle/Tame.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.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/LorryProducer_Broken.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/ShipProducer_Broken.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/simple/lifecycle/FarmOffice.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
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Van_Broken.java
Log:
bring assertions up to 20090625
fix some broken tests as a result of deployment type removal
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,10 +1,13 @@
package org.jboss.jsr299.tck.impl;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.enterprise.context.spi.CreationalContext;
public class MockCreationalContext<T> implements CreationalContext<T>
{
-
+ private static List<Object> beansPushed = new ArrayList<Object>();
private static Object lastBeanPushed = null;
private static boolean pushCalled = false;
private static boolean releaseCalled = false;
@@ -13,12 +16,18 @@
{
pushCalled = true;
lastBeanPushed = incompleteInstance;
+ beansPushed.add(incompleteInstance);
}
public static Object getLastBeanPushed()
{
return lastBeanPushed;
}
+
+ public static List<Object> getBeansPushed()
+ {
+ return beansPushed;
+ }
public static void setLastBeanPushed(Object lastBeanPushed)
{
@@ -40,9 +49,15 @@
return releaseCalled;
}
+ public static void setReleaseCalled(boolean releaseCalled)
+ {
+ MockCreationalContext.releaseCalled = releaseCalled;
+ }
+
public static void reset()
{
lastBeanPushed = null;
+ beansPushed.clear();
pushCalled = false;
releaseCalled = false;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,5 +1,6 @@
package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
+import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@@ -32,7 +33,6 @@
* @author David Allen
*
* Spec version: 20090625
- *
*/
@Artifact
@Packaging(PackagingType.EAR)
@@ -44,7 +44,8 @@
@SpecAssertions( {
@SpecAssertion(section = "3.2.5", id = "a"),
@SpecAssertion(section = "7.3.2", id = "aa"),
- @SpecAssertion(section = "7.3.2", id = "bb")
+ @SpecAssertion(section = "7.3.2", id = "bb"),
+ @SpecAssertion(section = "7.3.3", id = "b")
})
public void testCreateSFSB() throws Exception
{
@@ -62,11 +63,15 @@
assert frankfurt.isKleinStadtCreated();
assert anotherStadtInstance != stadtInstance : "create() should not return same bean as before";
+ stadtInstance.setName("hometown");
+ assert "hometown".equals(stadtInstance.getName());
+
// Verify that the instance returned is a proxy by checking for all local interfaces
+ assert getCurrentConfiguration().getBeans().isProxy(stadtInstance);
Set<Class> interfaces = new HashSet<Class>(Arrays.asList(stadtInstance.getClass().getInterfaces()));
assert interfaces.contains(KleinStadt.class);
assert interfaces.contains(SchoeneStadt.class);
-
+ assert interfaces.contains(Serializable.class);
}
@Test(groups = { "ri-broken", "enterpriseBeans", "clientProxy", "lifecycle", "integration" })
@@ -86,7 +91,8 @@
@Test(groups = { "enterpriseBeans", "clientProxy", "lifecycle", "integration" })
@SpecAssertions({
- @SpecAssertion(section = "7.3.2", id = "bc")
+ @SpecAssertion(section = "7.3.2", id = "bc"),
+ @SpecAssertion(section = "7.3.3", id = "c")
})
public void testDestroyRemovesSFSB() throws Exception
{
@@ -155,7 +161,7 @@
UniStadt marburg = getInstanceByType(UniStadt.class);
assert marburg != null : "Couldn't find the main SFSB";
Bean<UniStadt> uniStadtBean = getBeans(UniStadt.class).iterator().next();
- CreationalContext<UniStadt> creationalContext = getCurrentManager().createCreationalContext(uniStadtBean);
+ CreationalContext<UniStadt> creationalContext = getCurrentManager().createCreationalContext(uniStadtBean);
uniStadtBean.destroy(marburg, creationalContext);
GrossStadt frankfurt = getInstanceByType(GrossStadt.class);
assert frankfurt.isSchlossDestroyed();
@@ -167,14 +173,7 @@
{
OrderProcessor.postConstructCalled = false;
assert getBeans(DirectOrderProcessorLocal.class).size() == 1;
- new RunInDependentContext()
- {
- @Override
- protected void execute() throws Exception
- {
- getInstanceByType(DirectOrderProcessorLocal.class).order();
- }
- }.run();
+ getInstanceByType(DirectOrderProcessorLocal.class).order();
assert OrderProcessor.postConstructCalled;
}
@@ -184,14 +183,7 @@
{
OrderProcessor.postConstructCalled = false;
assert getBeans(OrderProcessorLocal.class).size() == 1;
- new RunInDependentContext()
- {
- @Override
- protected void execute() throws Exception
- {
- getInstanceByType(OrderProcessorLocal.class).order();
- }
- }.run();
+ getInstanceByType(OrderProcessorLocal.class).order();
assert OrderProcessor.postConstructCalled;
}
@@ -201,17 +193,10 @@
{
OrderProcessor.preDestroyCalled = false;
assert getBeans(DirectOrderProcessorLocal.class).size() == 1;
- new RunInDependentContext()
- {
- @Override
- protected void execute() throws Exception
- {
- Bean<DirectOrderProcessorLocal> bean = getBeans(DirectOrderProcessorLocal.class).iterator().next();
- CreationalContext<DirectOrderProcessorLocal> creationalContext = getCurrentManager().createCreationalContext(bean);
- DirectOrderProcessorLocal instance = getInstanceByType(DirectOrderProcessorLocal.class);
- bean.destroy(instance, creationalContext);
- }
- }.run();
+ Bean<DirectOrderProcessorLocal> bean = getBeans(DirectOrderProcessorLocal.class).iterator().next();
+ CreationalContext<DirectOrderProcessorLocal> creationalContext = getCurrentManager().createCreationalContext(bean);
+ DirectOrderProcessorLocal instance = getInstanceByType(DirectOrderProcessorLocal.class);
+ bean.destroy(instance, creationalContext);
assert OrderProcessor.preDestroyCalled;
}
@@ -221,17 +206,10 @@
{
OrderProcessor.preDestroyCalled = false;
assert getBeans(IndirectOrderProcessor.class).size() == 1;
- new RunInDependentContext()
- {
- @Override
- protected void execute() throws Exception
- {
- Bean<IndirectOrderProcessor> bean = getBeans(IndirectOrderProcessor.class).iterator().next();
- CreationalContext<IndirectOrderProcessor> creationalContext = getCurrentManager().createCreationalContext(bean);
- IndirectOrderProcessor instance = getInstanceByType(IndirectOrderProcessor.class);
- bean.destroy(instance, creationalContext);
- }
- }.run();
+ Bean<IndirectOrderProcessor> bean = getBeans(IndirectOrderProcessor.class).iterator().next();
+ CreationalContext<IndirectOrderProcessor> creationalContext = getCurrentManager().createCreationalContext(bean);
+ IndirectOrderProcessor instance = getInstanceByType(IndirectOrderProcessor.class);
+ bean.destroy(instance, creationalContext);
assert OrderProcessor.preDestroyCalled;
}
}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/AndalusianChicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/AndalusianChicken.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/AndalusianChicken.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,15 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-
-import javax.enterprise.inject.Specializes;
-
- at Specializes
-class AndalusianChicken extends Chicken
-{
- public static Egg egg = new Egg();
-
- @Override
- public Egg getEgg()
- {
- return egg;
- }
-}
Deleted: 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 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bakery.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,12 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-
-import javax.enterprise.inject.Produces;
-
-class Bakery
-{
- @Produces
- public Bread makeBread()
- {
- return null;
- }
-}
Deleted: 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 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Bread.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-
-class Bread
-{
-
-}
Modified: 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 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/BrownRecluse.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -6,8 +6,7 @@
class BrownRecluse
{
- @Produces
- public SpiderEgg layAnEgg(@Current BeanManager beanManager)
+ public @Produces @FirstBorn SpiderEgg layAnEgg(@Current BeanManager beanManager)
{
assert beanManager != null : "Manager was not injected";
return new SpiderEgg();
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Fail.java (from rev 3121, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Pet.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Fail.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Fail.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface Fail
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/FirstBorn.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/FirstBorn.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/FirstBorn.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface FirstBorn
+{
+
+}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/InfertileChicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/InfertileChicken.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/InfertileChicken.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-
-class InfertileChicken extends Chicken
-{
-
-}
Modified: 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 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Lays.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -5,8 +5,7 @@
class Lays
{
- @Produces @Delicious @RequestScoped
- public PotatoChip makeChip()
+ public @Produces @RequestScoped PotatoChip makeChip()
{
return null;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/LorryProducer_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/LorryProducer_Broken.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/LorryProducer_Broken.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -5,8 +5,7 @@
class LorryProducer_Broken
{
- @Produces
- public Lorry produceLorry() throws Exception
+ public @Produces @Fail Lorry produceLorry() throws Exception
{
throw new Exception();
}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/PreferredSpiderProducer.java (from rev 3118, 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/PreferredSpiderProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/PreferredSpiderProducer.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -0,0 +1,96 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Specializes;
+import javax.enterprise.inject.spi.BeanManager;
+
+ at Specializes class PreferredSpiderProducer extends SpiderProducer
+{
+ private @Current Web web;
+ private static Web injectedWeb;
+ private static Tarantula tarantulaCreated;
+ private static Tarantula tarantulaDestroyed;
+ private static boolean destroyArgumentsSet;
+
+ @Override
+ public @Produces @Pet Tarantula produceTarantula()
+ {
+ Tarantula tarantula = new Tarantula("Pete");
+ tarantulaCreated = tarantula;
+ resetTarantulaDestroyed();
+ injectedWeb = web;
+ return tarantula;
+ }
+
+ @Override
+ public @Produces @Null Spider getNullSpider()
+ {
+ return null;
+ }
+
+ public void destroyTarantula(@Disposes @Pet Tarantula spider, @Current BeanManager beanManager)
+ {
+ tarantulaDestroyed = spider;
+ injectedWeb = web;
+ if (beanManager != null)
+ {
+ destroyArgumentsSet = true;
+ }
+ }
+
+ public static boolean isTarantulaCreated()
+ {
+ return tarantulaCreated != null;
+ }
+
+ public static boolean isTarantulaDestroyed()
+ {
+ return tarantulaDestroyed != null;
+ }
+
+ public static Tarantula getTarantulaDestroyed()
+ {
+ return tarantulaDestroyed;
+ }
+
+ public static void resetTarantulaCreated()
+ {
+ PreferredSpiderProducer.tarantulaCreated = null;
+ }
+
+ public static void resetTarantulaDestroyed()
+ {
+ PreferredSpiderProducer.tarantulaDestroyed = null;
+ PreferredSpiderProducer.destroyArgumentsSet = false;
+ }
+
+ public static boolean isDestroyArgumentsSet()
+ {
+ return destroyArgumentsSet;
+ }
+
+ public static Tarantula getTarantulaCreated()
+ {
+ return tarantulaCreated;
+ }
+
+ public static Web getInjectedWeb()
+ {
+ return injectedWeb;
+ }
+
+ public static void resetInjections()
+ {
+ injectedWeb = null;
+ }
+
+ public static void reset()
+ {
+ resetTarantulaCreated();
+ resetTarantulaDestroyed();
+ resetInjections();
+ }
+
+}
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-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,9 +1,9 @@
package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-import java.lang.annotation.Annotation;
-
+import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AnnotationLiteral;
+import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.IllegalProductException;
import javax.enterprise.inject.spi.Bean;
@@ -15,86 +15,151 @@
import org.testng.annotations.Test;
/**
- *
* Spec version: 20090625
*
+ * NOTE May be able to get rid of some of the binding types if the producer method precedence question is resolved
*/
@Artifact
@BeansXml("beans.xml")
public class ProducerMethodLifecycleTest extends AbstractJSR299Test
{
-
- private static final Annotation PET_LITERAL = new AnnotationLiteral<Pet> () {};
- private static final Annotation DELICIOUS_LITERAL = new AnnotationLiteral<Delicious> () {};
-
- @Test(groups = { "producerMethod", "disposalMethod" })
- @SpecAssertion(section = "7.3.4", id = "ma")
- public void testProducerMethodBeanDestroy()
- {
- SpiderProducer.setTarantulaDestroyed(false);
- Tarantula tarantula = getInstanceByType(Tarantula.class, PET_LITERAL);
- Bean<Tarantula> tarantulaBean = getBeans(Tarantula.class, PET_LITERAL).iterator().next();
- CreationalContext<Tarantula> creationalContext = getCurrentManager().createCreationalContext(tarantulaBean);
- tarantulaBean.destroy(tarantula, creationalContext);
- assert SpiderProducer.isTarantulaDestroyed();
- assert SpiderProducer.isDestroyArgumentsSet();
- assert !SpiderProducerNotUsed.isTarantulaDestroyed();
- }
-
+ private AnnotationLiteral<Pet> PET_LITERAL = new AnnotationLiteral<Pet>() {};
+ private AnnotationLiteral<FirstBorn> FIRST_BORN_LITERAL = new AnnotationLiteral<FirstBorn>() {};
+ private AnnotationLiteral<Fail> FAIL_LITERAL = new AnnotationLiteral<Fail>() {};
+ private AnnotationLiteral<Null> NULL_LITERAL = new AnnotationLiteral<Null>() {};
+
@Test(groups = { "producerMethod" })
- @SpecAssertion(section = "7.3.4", id = "review")
+ @SpecAssertion(section = "7.3.4", id = "ea")
public void testProducerMethodBeanCreate()
{
- getInstanceByType(Tarantula.class, PET_LITERAL);
- assert SpiderProducer.isTarantulaCreated();
+ PreferredSpiderProducer.reset();
+ Bean<Tarantula> tarantulaBean = getBeans(Tarantula.class, PET_LITERAL).iterator().next();
+ CreationalContext<Tarantula> tarantulaCc = getCurrentManager().createCreationalContext(tarantulaBean);
+ Tarantula tarantula = tarantulaBean.create(tarantulaCc);
+ assert PreferredSpiderProducer.getTarantulaCreated() == tarantula;
+ assert PreferredSpiderProducer.getInjectedWeb() != null;
+ assert PreferredSpiderProducer.getInjectedWeb().isDestroyed();
}
@Test(groups = { "producerMethod" })
@SpecAssertions({
+ @SpecAssertion(section = "3.3.3", id = "b"),
+ @SpecAssertion(section = "3.3.3", id = "c"),
@SpecAssertion(section = "7.3.4", id = "ea")
})
public void testProducerMethodInvokedOnCreate()
{
- Bean<SpiderEgg> eggBean = getBeans(SpiderEgg.class).iterator().next();
- CreationalContext<SpiderEgg> creationalContext = getCurrentManager().createCreationalContext(eggBean);
- assert eggBean.create(creationalContext) != null;
+ Bean<SpiderEgg> eggBean = getBeans(SpiderEgg.class, FIRST_BORN_LITERAL).iterator().next();
+ CreationalContext<SpiderEgg> eggCc = getCurrentManager().createCreationalContext(eggBean);
+ assert eggBean.create(eggCc) != null;
}
+
+ @Test(groups = { "producerMethod" })
+ @SpecAssertion(section = "3.3", id = "j")
+ public void testWhenApplicationInvokesProducerMethodParametersAreNotInjected()
+ {
+ try
+ {
+ getInstanceByType(BrownRecluse.class).layAnEgg(null);
+ }
+ catch (AssertionError e)
+ {
+ return;
+ }
+
+ assert false : "The BeanManager should not have been injected into the producer method";
+ }
- @Test(groups = { "producerMethod", "rewrite" })
- //Test needs to user the InjectionTarget interface for these assertions
+ @Test(groups = { "producerMethod" })
@SpecAssertions({
- @SpecAssertion(section = "review", id = "review")
+ @SpecAssertion(section = "4.3.2", id = "a"),
+ @SpecAssertion(section = "5.6.6", id = "c")
})
public void testProducerMethodFromMostSpecializedBeanUsed()
{
- Tarantula.setNumberCreated(0);
+ SpiderProducer.reset();
+ PreferredSpiderProducer.reset();
Bean<Tarantula> spiderBean = getBeans(Tarantula.class, PET_LITERAL).iterator().next();
- CreationalContext<Tarantula> creationalContext = getCurrentManager().createCreationalContext(spiderBean);
- Tarantula tarantula = spiderBean.create(creationalContext);
- assert tarantula.getValue().equals("Pete");
- assert Tarantula.getNumberCreated() == 1;
+ CreationalContext<Tarantula> spiderBeanCc = getCurrentManager().createCreationalContext(spiderBean);
+ Tarantula tarantula = spiderBean.create(spiderBeanCc);
+ assert PreferredSpiderProducer.getTarantulaCreated() == tarantula;
+ assert !SpiderProducer.isTarantulaCreated();
}
@Test(groups = { "producerMethod" })
@SpecAssertions({
@SpecAssertion(section = "7.3.4", id = "k")
})
- public void testCreateReturnsNullIfProducerDoesAndDependent() throws Exception
+ public void testCreateReturnsNullIfProducerDoesAndDependent()
{
- Bean<Bread> breadBean = getBeans(Bread.class).iterator().next();
- CreationalContext<Bread> creationalContext = getCurrentManager().createCreationalContext(breadBean);
- assert breadBean.create(creationalContext) == null;
+ Bean<Spider> nullSpiderBean = getBeans(Spider.class, NULL_LITERAL).iterator().next();
+ CreationalContext<Spider> nullSpiderBeanCc = getCurrentManager().createCreationalContext(nullSpiderBean);
+ assert nullSpiderBean.create(nullSpiderBeanCc) == null;
}
- @Test(groups = { "producerMethod", "broken" }, expectedExceptions = IllegalProductException.class )
+ @Test(groups = { "producerMethod" }, expectedExceptions = IllegalProductException.class )
@SpecAssertions({
@SpecAssertion(section = "7.3.4", id = "l")
})
- // TODO I'm not quite sure what this test is currently doing!
- public void testCreateFailsIfProducerReturnsNullAndNotDependent() throws Exception
+ public void testCreateFailsIfProducerReturnsNullAndNotDependent()
{
- Bean<PotatoChip> chipBean = getBeans(PotatoChip.class, DELICIOUS_LITERAL).iterator().next();
- CreationalContext<PotatoChip> creationalContext = getCurrentManager().createCreationalContext(chipBean);
- assert chipBean.create(creationalContext) == null;
+ // QUESTION is there an easier way to get the producer method bean instead of the top-level (dependent) type?
+ Bean<PotatoChip> potatoChipBean = null;
+ for (Bean<PotatoChip> candidate : getBeans(PotatoChip.class))
+ {
+ if (candidate.getScopeType().equals(RequestScoped.class))
+ {
+ potatoChipBean = candidate;
+ break;
+ }
+ }
+
+ assert potatoChipBean != null;
+ CreationalContext<PotatoChip> chipCc = getCurrentManager().createCreationalContext(potatoChipBean);
+ potatoChipBean.create(chipCc);
+ assert false;
}
+
+ @Test(groups = { "producerMethod", "disposalMethod" })
+ @SpecAssertions({
+ @SpecAssertion(section = "7.3.4", id = "ma"),
+ @SpecAssertion(section = "7.3.4", id = "r")
+ })
+ public void testProducerMethodBeanDestroy()
+ {
+ PreferredSpiderProducer.reset();
+ Bean<Tarantula> tarantulaBean = getBeans(Tarantula.class, PET_LITERAL).iterator().next();
+ CreationalContext<Tarantula> tarantulaCc = getCurrentManager().createCreationalContext(tarantulaBean);
+ Tarantula tarantula = tarantulaBean.create(tarantulaCc);
+ PreferredSpiderProducer.resetInjections();
+ tarantulaBean.destroy(tarantula, tarantulaCc);
+ assert PreferredSpiderProducer.getTarantulaDestroyed() == tarantula;
+ assert PreferredSpiderProducer.isDestroyArgumentsSet();
+ assert PreferredSpiderProducer.getInjectedWeb() != null;
+ assert PreferredSpiderProducer.getInjectedWeb().isDestroyed();
+ }
+
+ @Test(groups = { "producerMethod" }, expectedExceptions = FooException.class)
+ @SpecAssertions({
+ @SpecAssertion(section = "6.1", id = "a0")
+ })
+ public void testCreateRethrowsUncheckedException()
+ {
+ Bean<Ship> shipBean = getBeans(Ship.class, FAIL_LITERAL).iterator().next();
+ CreationalContext<Ship> shipCc = getCurrentManager().createCreationalContext(shipBean);
+ shipBean.create(shipCc);
+ assert false;
+ }
+
+ @Test(groups = { "producerMethod" }, expectedExceptions = CreationException.class)
+ @SpecAssertions({
+ @SpecAssertion(section = "6.1", id = "a0")
+ })
+ public void testCreateWrapsCheckedExceptionAndRethrows()
+ {
+ Bean<Lorry> lorryBean = getBeans(Lorry.class, FAIL_LITERAL).iterator().next();
+ CreationalContext<Lorry> lorryCc = getCurrentManager().createCreationalContext(lorryBean);
+ lorryBean.create(lorryCc);
+ assert false;
+ }
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ShipProducer_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ShipProducer_Broken.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ShipProducer_Broken.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -5,8 +5,7 @@
class ShipProducer_Broken
{
- @Produces
- public Ship produceShip() throws FooException
+ public @Produces @Fail Ship produceShip() throws FooException
{
throw new FooException();
}
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-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,65 +1,70 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-
-import javax.enterprise.inject.Current;
-import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.BeanManager;
-
-class SpiderProducer
-{
- private static boolean tarantulaCreated;
- private static boolean tarantulaDestroyed;
- private static boolean destroyArgumentsSet;
-
- @Produces @Pet public Tarantula produceTarantula()
- {
- tarantulaCreated = true;
- tarantulaDestroyed = false;
- destroyArgumentsSet = false;;
- return new Tarantula("Pete");
- }
-
- @Produces @Null public Spider getNullSpider()
- {
- return null;
- }
-
- public static void destroyTarantula(@Disposes @Pet Tarantula spider, @Current BeanManager beanManager)
- {
- tarantulaDestroyed = true;
- if (beanManager != null)
- {
- destroyArgumentsSet = true;
- }
- }
-
- public static boolean isTarantulaCreated()
- {
- return tarantulaCreated;
- }
-
- public static boolean isTarantulaDestroyed()
- {
- return tarantulaDestroyed;
- }
-
- public static void setTarantulaCreated(boolean tarantulaCreated)
- {
- SpiderProducer.tarantulaCreated = tarantulaCreated;
- }
-
- public static void setTarantulaDestroyed(boolean tarantulaDestroyed)
- {
- SpiderProducer.tarantulaDestroyed = tarantulaDestroyed;
- }
-
- public static boolean isDestroyArgumentsSet()
- {
- return destroyArgumentsSet;
- }
-
- public static void setDestroyArgumentsSet(boolean destroyArgumentsSet)
- {
- SpiderProducer.destroyArgumentsSet = destroyArgumentsSet;
- }
-}
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import javax.enterprise.inject.Produces;
+
+class SpiderProducer
+{
+ private static Tarantula tarantulaCreated;
+ private static boolean tarantulaDestroyed;
+ private static boolean destroyArgumentsSet;
+
+ public @Produces @Pet Tarantula produceTarantula()
+ {
+ Tarantula tarantula = new Tarantula("Pete");
+ tarantulaCreated = tarantula;
+ resetTarantulaDestroyed();
+ return tarantula;
+ }
+
+ public @Produces @Null Spider getNullSpider()
+ {
+ return null;
+ }
+
+ // FIXME this should be allowed
+// public void destroyTarantula(@Disposes Tarantula spider, @Current BeanManager beanManager)
+// {
+// tarantulaDestroyed = true;
+// if (beanManager != null)
+// {
+// destroyArgumentsSet = true;
+// }
+// }
+
+ public static boolean isTarantulaCreated()
+ {
+ return tarantulaCreated != null;
+ }
+
+ public static boolean isTarantulaDestroyed()
+ {
+ return tarantulaDestroyed;
+ }
+
+ public static void resetTarantulaCreated()
+ {
+ SpiderProducer.tarantulaCreated = null;
+ }
+
+ public static void resetTarantulaDestroyed()
+ {
+ SpiderProducer.tarantulaDestroyed = false;
+ SpiderProducer.destroyArgumentsSet = false;
+ }
+
+ public static boolean isDestroyArgumentsSet()
+ {
+ return destroyArgumentsSet;
+ }
+
+ public static Tarantula getTarantulaCreated()
+ {
+ return tarantulaCreated;
+ }
+
+ public static void reset()
+ {
+ resetTarantulaCreated();
+ resetTarantulaDestroyed();
+ }
+}
Deleted: 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 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducerNotUsed.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,45 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-
-import javax.enterprise.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;
- }
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tame.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tame.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Tame.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,22 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.inject.BindingType;
-
- at Target( { TYPE, METHOD, PARAMETER, FIELD })
- at Retention(RUNTIME)
- at Documented
- at BindingType
- at interface Tame
-{
-
-}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Web.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Web.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/Web.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -0,0 +1,29 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+class Web
+{
+ private Boolean destroyed;
+
+ public boolean isSpun()
+ {
+ return destroyed != null;
+ }
+
+ public boolean isDestroyed()
+ {
+ return Boolean.TRUE.equals(destroyed);
+ }
+
+ @PostConstruct public void spin()
+ {
+ destroyed = false;
+ }
+
+ @PreDestroy public void destroy()
+ {
+ destroyed = true;
+ }
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/FarmOffice.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/FarmOffice.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/FarmOffice.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,9 +1,16 @@
package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+import javax.annotation.PreDestroy;
+
class FarmOffice
{
public int noOfStaff = 20;
+ @PreDestroy
+ public void preDestroy()
+ {
+ noOfStaff = 0;
+ }
}
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-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/FishPond.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -1,11 +1,13 @@
package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.inject.Current;
import javax.enterprise.inject.Initializer;
class FishPond
{
+ public boolean postConstructCalled;
public Animal goldfish;
@@ -21,6 +23,12 @@
this.goose = goose;
}
+ @PostConstruct
+ public void postConstruct()
+ {
+ postConstructCalled = true;
+ }
+
@PreDestroy
public void destroy()
{
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-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -9,9 +9,9 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AnnotationLiteral;
import javax.enterprise.inject.CreationException;
+import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.spi.Bean;
-import org.apache.commons.httpclient.methods.GetMethod;
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
@@ -21,9 +21,7 @@
import org.testng.annotations.Test;
/**
- *
* Spec version: 20090625
- *
*/
@Artifact
@BeansXml("beans.xml")
@@ -44,6 +42,7 @@
assert getBeans(FishPond.class).size() == 1;
FishPond fishPond = getInstanceByType(FishPond.class);
assert fishPond.goldfish != null;
+ assert fishPond.goldfish instanceof Goldfish;
assert fishPond.goose != null;
}
@@ -57,9 +56,29 @@
@Test(groups = { "specialization" })
@SpecAssertion(section = "3.1.5", id = "aa")
- public void testSpecializedBeanSpecializesAnotherBean()
+ public void testSpecializedBeanExtendsManagedBean()
{
- assert !getBeans(MountainLion.class, TAME_LITERAL).isEmpty();
+ assert MountainLion.class.getAnnotation(Specializes.class) != null;
+ Bean<Lion> bean = null;
+ Bean<Lion> specializedBean = null;
+ for (Bean<Lion> lionBean : getBeans(Lion.class, TAME_LITERAL))
+ {
+ if (lionBean.getBeanClass().equals(Lion.class))
+ {
+ bean = lionBean;
+ }
+ else if (lionBean.getBeanClass().equals(MountainLion.class))
+ {
+ specializedBean = lionBean;
+ }
+ }
+
+ assert bean != null;
+ assert specializedBean != null;
+ assert specializedBean == getCurrentManager().getMostSpecializedBean(bean);
+ assert specializedBean.getBeanClass().getSuperclass().equals(Lion.class);
+
+ //assert getInstanceByType(Lion.class, TAME_LITERAL) instanceof MountainLion;
}
@Test(groups = "beanLifecycle")
@@ -74,11 +93,29 @@
final Contextual<ShoeFactory> bean = getBeans(ShoeFactory.class).iterator().next();
MockCreationalContext.reset();
ShoeFactory instance = getCurrentManager().getContext(Dependent.class).get(bean, creationalContext);
- if (MockCreationalContext.isPushCalled())
- {
- assert instance.equals(MockCreationalContext.getLastBeanPushed());
- }
+ assert MockCreationalContext.isPushCalled();
+ assert instance == MockCreationalContext.getLastBeanPushed();
}
+
+ @Test(groups = "beanLifecycle")
+ @SpecAssertions({
+ @SpecAssertion(section = "7.3.1", id = "aa")
+ })
+ public void testBeanCreateInjectsDependenciesAndInvokesInitializerToInstantiateInstance()
+ {
+ MockCreationalContext.reset();
+ final CreationalContext<FishPond> creationalContext = new MockCreationalContext<FishPond>();
+ final Contextual<FishPond> bean = getBeans(FishPond.class).iterator().next();
+ FishPond fishPond = bean.create(creationalContext);
+ assert fishPond != null;
+ assert MockCreationalContext.isPushCalled();
+ assert MockCreationalContext.getBeansPushed().contains(fishPond);
+ assert fishPond.goldfish != null;
+ assert fishPond.goldfish instanceof Goldfish;
+ assert fishPond.goose != null;
+ assert fishPond.salmon != null;
+ assert fishPond.postConstructCalled = true; // required by Managed Bean specification
+ }
@Test(groups = "beanLifecycle")
@SpecAssertions({
@@ -120,46 +157,48 @@
@Test(groups = { "beanLifecycle", "lifecycleCallbacks" })
@SpecAssertions({
- @SpecAssertion(section = "review", id = "review"), // no longer explicit in the spec?
- @SpecAssertion(section = "review", id = "review")
+ @SpecAssertion(section = "7.3.1", id = "aa"),
+ @SpecAssertion(section = "7.3.1", id = "ba")
})
- public void testPostConstructPreDestroy() throws Exception
+ public void testPostConstructPreDestroy()
{
assert getBeans(Farm.class).size() == 1;
Bean<Farm> farmBean = getBeans(Farm.class).iterator().next();
CreationalContext<Farm> creationalContext = getCurrentManager().createCreationalContext(farmBean);
- Farm farm = getInstanceByType(Farm.class);
+ Farm farm = farmBean.create(creationalContext);
assert farm.founded != null;
assert farm.initialStaff == 20;
assert farm.closed == null;
farmBean.destroy(farm, creationalContext);
assert farm.closed != null;
+ assert farm.farmOffice.noOfStaff == 0;
}
@Test(groups = { "beanLifecycle", "lifecycleCallbacks" })
@SpecAssertions({
- @SpecAssertion(section = "review", id = "review") // removed from the spec?
+ @SpecAssertion(section = "6.5.3", id = "a0"),
+ @SpecAssertion(section = "7.3.1", id = "ba")
})
- public void testContextualDestroyDisposesWhenNecessary() throws Exception
+ public void testContextualDestroyDisposesWhenNecessary()
{
final Bean<Goose> gooseBean = getBeans(Goose.class).iterator().next();
- CreationalContext<Goose> creationalContext = getCurrentManager().createCreationalContext(gooseBean);
- final Goose goose = gooseBean.create(creationalContext);
-
+ final CreationalContext<Goose> gooseCc = getCurrentManager().createCreationalContext(gooseBean);
+ final Goose goose = gooseBean.create(gooseCc);
assert !EggProducer.isEggDisposed();
assert !Egg.isEggDestroyed();
- gooseBean.destroy(goose, creationalContext);
+ gooseBean.destroy(goose, gooseCc);
assert EggProducer.isEggDisposed();
+ assert !Egg.isEggDestroyed();
}
@Test(groups = "beanLifecycle")
@SpecAssertions({
- @SpecAssertion(section = "review", id = "review") // removed from the spec?
+ @SpecAssertion(section = "6.1", id = "a1")
})
public void testContextualDestroyCatchesException()
{
Bean<Cod> codBean = getBeans(Cod.class).iterator().next();
- CreationalContext<Cod> creationalContext = getCurrentManager().createCreationalContext(codBean);
+ CreationalContext<Cod> creationalContext = getCurrentManager().createCreationalContext(codBean);
Cod codInstance = getInstanceByType(Cod.class);
codInstance.ping();
codBean.destroy(codInstance, creationalContext);
@@ -167,7 +206,7 @@
@Test(groups = "beanLifecycle")
@SpecAssertions({
- @SpecAssertion(section = "review", id = "review") // removed from spec?
+ @SpecAssertion(section = "5.6.5", id = "a")
})
public void testDependentsDestroyedAfterPreDestroy()
{
@@ -196,7 +235,7 @@
assert getBeans(IndirectOrderProcessor.class).size() == 1;
getInstanceByType(IndirectOrderProcessor.class).order();
assert OrderProcessor.postConstructCalled;
- }
+ }
@Test
@SpecAssertion(section = "4.2", id = "bba")
@@ -205,7 +244,7 @@
OrderProcessor.preDestroyCalled = false;
assert getBeans(CdOrderProcessor.class).size() == 1;
Bean<CdOrderProcessor> bean = getBeans(CdOrderProcessor.class).iterator().next();
- CreationalContext<CdOrderProcessor> creationalContext = getCurrentManager().createCreationalContext(bean);
+ CreationalContext<CdOrderProcessor> creationalContext = getCurrentManager().createCreationalContext(bean);
CdOrderProcessor instance = getInstanceByType(CdOrderProcessor.class);
bean.destroy(instance, creationalContext);
assert OrderProcessor.preDestroyCalled;
@@ -218,11 +257,11 @@
OrderProcessor.preDestroyCalled = false;
assert getBeans(IndirectOrderProcessor.class).size() == 1;
Bean<IndirectOrderProcessor> bean = getBeans(IndirectOrderProcessor.class).iterator().next();
- CreationalContext<IndirectOrderProcessor> creationalContext = getCurrentManager().createCreationalContext(bean);
+ CreationalContext<IndirectOrderProcessor> creationalContext = getCurrentManager().createCreationalContext(bean);
IndirectOrderProcessor instance = getInstanceByType(IndirectOrderProcessor.class);
bean.destroy(instance, creationalContext);
assert OrderProcessor.preDestroyCalled;
- }
+ }
@Test
@SpecAssertion(section = "4.2", id = "baa")
@@ -241,15 +280,14 @@
OrderProcessor.preDestroyCalled = false;
assert getBeans(NovelOrderProcessor.class).size() == 1;
Bean<NovelOrderProcessor> bean = getBeans(NovelOrderProcessor.class).iterator().next();
- CreationalContext<NovelOrderProcessor> creationalContext = getCurrentManager().createCreationalContext(bean);
+ CreationalContext<NovelOrderProcessor> creationalContext = getCurrentManager().createCreationalContext(bean);
NovelOrderProcessor instance = getInstanceByType(NovelOrderProcessor.class);
bean.destroy(instance, creationalContext);
assert !OrderProcessor.preDestroyCalled;
-
}
@Test(expectedExceptions = CreationException.class)
- @SpecAssertion(section = "review", id = "review") // removed from spec?
+ @SpecAssertion(section = "6.1", id = "a0")
public void testCreationExceptionWrapsCheckedExceptionThrownFromCreate()
{
assert getBeans(Lorry_Broken.class).size() == 1;
@@ -257,7 +295,7 @@
}
@Test(expectedExceptions = FooException.class)
- @SpecAssertion(section = "review", id = "review") // removed from spec?
+ @SpecAssertion(section = "6.1", id = "a0")
public void testUncheckedExceptionThrownFromCreateNotWrapped()
{
assert getBeans(Van_Broken.class).size() == 1;
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Van_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Van_Broken.java 2009-07-22 02:27:04 UTC (rev 3122)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Van_Broken.java 2009-07-22 02:58:45 UTC (rev 3123)
@@ -3,7 +3,7 @@
class Van_Broken
{
- public Van_Broken() throws Exception
+ public Van_Broken()
{
throw new FooException();
}
More information about the weld-commits
mailing list