Author: jharting
Date: 2010-04-21 06:24:39 -0400 (Wed, 21 Apr 2010)
New Revision: 6133
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DomesticationKit.java
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/SpiderProducer.java
Log:
CDITCK-142
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2010-04-21
10:23:37 UTC (rev 6132)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2010-04-21
10:24:39 UTC (rev 6133)
@@ -334,16 +334,23 @@
@SpecAssertion(section = "6.4.2", id = "ddd"),
@SpecAssertion(section = "6.4.1", id="h")
})
-
public void testDependentsDestroyedWhenProducerMethodCompletes()
{
- // Reset the test class
+ // Reset the test classes
SpiderProducer.reset();
Tarantula.reset();
- Tarantula spiderInstance = getInstanceByType(Tarantula.class, PET_LITERAL);
- spiderInstance.ping();
+ DomesticationKit.reset();
+
+ Bean<Tarantula> tarantulaBean = getUniqueBean(Tarantula.class, PET_LITERAL);
+ CreationalContext<Tarantula> creationalContext =
getCurrentManager().createCreationalContext(tarantulaBean);
+ Tarantula tarantula = (Tarantula) getCurrentManager().getReference(tarantulaBean,
Tarantula.class, creationalContext);
+ tarantula.ping();
+ // contextual instance created to receive a producer method invocation
+ // is destroyed when the invocation completes
assert SpiderProducer.isDestroyed();
- assert Tarantula.isDestroyed();
+ // DomesticationKit instance is a dependent object of the Tarantula instance
+ tarantulaBean.destroy(tarantula, creationalContext);
+ assert DomesticationKit.isDestroyed();
SpiderProducer.reset();
}
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DomesticationKit.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DomesticationKit.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DomesticationKit.java 2010-04-21
10:24:39 UTC (rev 6133)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.context.dependent;
+
+import javax.annotation.PreDestroy;
+
+public class DomesticationKit
+{
+ private static boolean destroyed = false;
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ destroyed = true;
+ }
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public static void reset()
+ {
+ destroyed = false;
+ }
+}
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/SpiderProducer.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/SpiderProducer.java 2010-04-21
10:23:37 UTC (rev 6132)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/SpiderProducer.java 2010-04-21
10:24:39 UTC (rev 6133)
@@ -33,7 +33,7 @@
private static SpiderProducer instanceUsedForDisposal = null;
- @Produces @Pet public Tarantula produceTarantula(Tarantula spider)
+ @Produces @Pet public Tarantula produceTarantula(Tarantula spider, DomesticationKit
domesticationKit)
{
dependentContextActive = beanManager.getContext(Dependent.class).isActive();
return spider;