Author: pete.muir(a)jboss.org
Date: 2009-03-07 11:26:56 -0500 (Sat, 07 Mar 2009)
New Revision: 1803
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/InactiveContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Farm.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FarmLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Fox.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRun.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRunLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Horse.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Stable.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/servlet/
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextIntegrationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MyCreationalContext.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Farm.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Fox.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/FoxRun.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/HorseStable.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/OtherSpiderProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/SpiderProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Tarantula.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
Tidy up dependentcontext tests and start on the ejb remove stuff
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-03-07
16:13:45 UTC (rev 1802)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -235,18 +235,21 @@
}
}
- /**
- * Destroys an instance of the bean
- *
- * @param instance The instance
- */
public void destroy(T instance)
{
+ if (instance == null)
+ {
+ throw new IllegalArgumentException("instance to destroy cannot be
null");
+ }
EnterpriseBeanInstance enterpiseBeanInstance = (EnterpriseBeanInstance) instance;
if (enterpiseBeanInstance.isDestroyed())
{
return;
}
+ else
+ {
+ // TODO
getManager().getEjbResolver().removeEjb(enterpiseBeanInstance.getUnproxiedInstances());
+ }
}
/**
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -16,6 +16,8 @@
*/
package org.jboss.webbeans.bean.proxy;
+import java.util.Collection;
+
/**
* Interface implemented by all enterprise bean proxies to determine if
* the enterprise bean has already had a remove method called by the application
@@ -33,4 +35,10 @@
*/
public boolean isDestroyed();
+ /**
+ * The unproxied version of this object
+ * @return
+ */
+ public Collection<Object> getUnproxiedInstances();
+
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java 2009-03-07
16:13:45 UTC (rev 1802)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBResolver.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -4,6 +4,7 @@
package org.jboss.webbeans.mock;
import java.lang.annotation.Annotation;
+import java.util.Collection;
import javax.annotation.Resource;
import javax.ejb.EJB;
@@ -44,4 +45,9 @@
{
return null;
}
+
+ public void removeEjb(Collection<Object> instance)
+ {
+ // No-op
+ }
}
\ No newline at end of file
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java 2009-03-07
16:13:45 UTC (rev 1802)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbResolver.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -10,6 +10,8 @@
* A container should implement this interface to allow the Web Beans RI to
* resolve EJBs, Resources and JPA persistence units
*
+ * TODO This probably needs renaming to EjbLifecycle
+ *
* @author Pete Muir
*
*/
@@ -21,10 +23,11 @@
/**
* Resolve the value for the given @EJB injection point
*
- * @param injectionPoint the injection point metadata
+ * @param injectionPoint
+ * the injection point metadata
* @return an instance of the EJB
* @throws IllegalArgumentException
- * if the injection point is not annotated with @EJB, or, if the
+ * if the injection point is not annotated with @EJB, or, if the
* injection point is a method that doesn't follow JavaBean
* conventions
* @throws IllegalStateException
@@ -32,16 +35,25 @@
*/
public Object resolveEjb(InjectionPoint injectionPoint, NamingContext namingContext);
+// /**
+// * Request the EJB container remove an EJB
+// *
+// * @param instances all objects retrieved from the container for this EJB
+// */
+// public void removeEjb(Collection<Object> instances);
+
/**
* Resolve the value for the given @PersistenceContext injection point
*
- * @param injectionPoint the injection point metadata
- * @param namingContext the pluggable Web Beans JNDI lookup facility
+ * @param injectionPoint
+ * the injection point metadata
+ * @param namingContext
+ * the pluggable Web Beans JNDI lookup facility
* @return an instance of the persistence unit
* @throws IllegalArgumentException
- * if the injection point is not annotated with
- * @PersistenceContext, or, if the injection point is a method
- * that doesn't follow JavaBean conventions
+ * if the injection point is not annotated with
+ * @PersistenceContext, or, if the injection point is a method that doesn't
+ * follow JavaBean conventions
* @throws IllegalStateException
* if no suitable persistence units can be resolved for injection
*/
@@ -50,12 +62,14 @@
/**
* Resolve the value for the given @Resource injection point
*
- * @param injectionPoint the injection point metadata
- * @param namingContext the pluggable Web Beans JNDI lookup facility
+ * @param injectionPoint
+ * the injection point metadata
+ * @param namingContext
+ * the pluggable Web Beans JNDI lookup facility
* @return an instance of the resource
* @throws IllegalArgumentException
- * if the injection point is not annotated with @Resource, or, if
- * the injection point is a method that doesn't follow JavaBean
+ * if the injection point is not annotated with @Resource, or, if
+ * the injection point is a method that doesn't follow JavaBean
* conventions
* @throws IllegalStateException
* if no resource can be resolved for injection
@@ -83,5 +97,4 @@
*/
public Class<? extends Annotation> getResourceAnnotation();
-
}
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbResolver.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -51,6 +51,11 @@
{
return delegate().resolveResource(injectionPoint, namingContext);
}
+//
+// public void removeEjb(Collection<Object> instance)
+// {
+// delegate().removeEjb(instance);
+// }
@Override
public boolean equals(Object obj)
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextTest.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextTest.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -55,14 +55,6 @@
}
}
- @Test(expectedExceptions = { ContextNotActiveException.class }, groups = {
"manager" })
- @SpecAssertion(section = "8.6", id = "c")
- public void testGetContextWithNoActiveContextsFails()
- {
-
getCurrentConfiguration().getContexts().setInactive(getCurrentConfiguration().getContexts().getRequestContext());
- getCurrentManager().getContext(RequestScoped.class);
- }
-
@Test(expectedExceptions = { IllegalStateException.class }, groups = {
"manager" })
@SpecAssertion(section = "8.6", id = "d")
public void testGetContextWithTooManyActiveContextsFails()
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/InactiveContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/InactiveContextTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/InactiveContextTest.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,24 @@
+package org.jboss.jsr299.tck.tests.context;
+
+import javax.context.ContextNotActiveException;
+import javax.context.RequestScoped;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class InactiveContextTest extends AbstractDeclarativeTest
+{
+
+
+ @Test(expectedExceptions = { ContextNotActiveException.class }, groups = {
"manager" })
+ @SpecAssertion(section = "8.6", id = "c")
+ public void testGetContextWithNoActiveContextsFails()
+ {
+
getCurrentConfiguration().getContexts().setInactive(getCurrentConfiguration().getContexts().getRequestContext());
+ getCurrentManager().getContext(RequestScoped.class);
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/InactiveContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextIntegrationTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextIntegrationTest.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextIntegrationTest.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, 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 org.hibernate.tck.annotations.SpecAssertion;
-import org.testng.annotations.Test;
-
-/**
- * Spec version: Public Release Draft 2
- */
-public class DependentContextIntegrationTest
-{
- @Test(groups = { "contexts", "injection", "stub",
"ejb3", "integration" })
- @SpecAssertion(section = "8.3", id = "k")
- public void testContextIsActiveDuringEJBDependencyInjection()
- {
- assert false;
- }
-
- @Test(groups = { "contexts", "postconstruct", "stub",
"ejb3", "integration" })
- @SpecAssertion(section = "8.3", id = "l")
- public void testContextIsActiveDuringEJBPostConstruct()
- {
- assert false;
- }
-
-
- @Test(groups = { "contexts", "injection", "stub",
"servlet", "integration" })
- @SpecAssertion(section = "8.3", id = "m")
- public void testContextIsActiveDuringServletDependencyInjection()
- {
- assert false;
- }
-
- @Test(groups = { "stub", "contexts", "ejb3",
"integration" })
- @SpecAssertion(section = "8.3.1", id = "a")
- public void testEjbBeanMayCreateInstanceWheneverScopeActive()
- {
- assert false;
- }
-
-
- @Test(groups = { "stub", "contexts", "servlet",
"integration" })
- @SpecAssertion(section = "8.3.1", id = "a")
- public void testServletBeanMayCreateInstanceWheneverScopeIsActive()
- {
- assert false;
- }
-
- @Test(groups = { "stub", "contexts", "ejb3",
"integration" })
- @SpecAssertion(section = "8.3.2", id = "b")
- public void testDestroyingEjbDestroysDependents()
- {
- assert false;
- }
-
- @Test(groups = { "stub", "contexts", "servlet",
"integration" })
- @SpecAssertion(section = "8.3.2", id = "b")
- public void testDestroyingServletDestroysDependents()
- {
- assert false;
- }
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -10,6 +10,7 @@
import javax.inject.manager.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractDeclarativeTest;
import org.jboss.jsr299.tck.impl.packaging.Artifact;
import org.jboss.jsr299.tck.impl.packaging.jsr299.BeansXml;
@@ -34,20 +35,10 @@
Set<Bean<FoxRun>> foxRunBeans =
getCurrentManager().resolveByType(FoxRun.class);
assert foxRunBeans.size() == 1;
Bean<FoxRun> foxRunBean = foxRunBeans.iterator().next();
- FoxRun foxRun = foxRunBean.create(new MyCreationalContext<FoxRun>());
+ FoxRun foxRun = foxRunBean.create(new MockCreationalContext<FoxRun>());
assert !foxRun.fox.equals(foxRun.anotherFox);
}
- @Test(groups = { "contexts", "stub" })
- @SpecAssertion(section = "8.3", id = "b")
- public void testDependentBeansBoundToLifecycleOfContainingBean() throws Exception
- {
- // Once injected, dependent beans will be destroyed when the
- // containing bean is destroyed. This other test should
- // satisfy this assertion.
- testDestroyingParentDestroysDependents();
- }
-
@Test(groups = { "contexts", "el" })
@SpecAssertion(section = "8.3", id = "c")
public void testInstanceUsedForElEvaluationNotShared() throws Exception
@@ -72,8 +63,8 @@
public void testInstanceUsedForProducerMethodNotShared() throws Exception
{
Bean<Tarantula> tarantulaBean =
getCurrentManager().resolveByType(Tarantula.class).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
MyCreationalContext<Tarantula>());
- Tarantula tarantula2 = tarantulaBean.create(new
MyCreationalContext<Tarantula>());
+ Tarantula tarantula = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
+ Tarantula tarantula2 = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
assert tarantula != null;
assert tarantula2 != null;
assert tarantula != tarantula2;
@@ -84,8 +75,8 @@
public void testInstanceUsedForProducerFieldNotShared() throws Exception
{
Bean<Tarantula> tarantulaBean =
getCurrentManager().resolveByType(Tarantula.class, TAME_LITERAL).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
MyCreationalContext<Tarantula>());
- Tarantula tarantula2 = tarantulaBean.create(new
MyCreationalContext<Tarantula>());
+ Tarantula tarantula = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
+ Tarantula tarantula2 = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
assert tarantula != null;
assert tarantula2 != null;
assert tarantula != tarantula2;
@@ -112,6 +103,7 @@
// }
//
// }.run();
+ assert false;
}
@Test(groups = { "contexts", "observerMethod" })
@@ -147,8 +139,8 @@
assert foxBeans.size() == 1;
Bean<Fox> foxBean = foxBeans.iterator().next();
Context context = getCurrentManager().getContext(Dependent.class);
- assert context.get(foxBean, new MyCreationalContext<Fox>()) != null;
- assert context.get(foxBean, new MyCreationalContext<Fox>()) instanceof
Fox;
+ assert context.get(foxBean, new MockCreationalContext<Fox>()) != null;
+ assert context.get(foxBean, new MockCreationalContext<Fox>())
instanceof Fox;
}
}.run();
@@ -179,7 +171,7 @@
public void testContextIsInactive()
{
// The RI test harness is broken here, it just enables the dependent context
blindly
- //getCurrentManager().getContext(Dependent.class);
+ getCurrentManager().getContext(Dependent.class);
}
@Test(groups = { "contexts", "producerMethod" })
@@ -187,22 +179,26 @@
public void testContextIsActiveWhenInvokingProducerMethod()
{
Bean<Tarantula> tarantulaBean =
getCurrentManager().resolveByType(Tarantula.class).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
MyCreationalContext<Tarantula>());
+ Tarantula tarantula = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
assert tarantula != null;
assert SpiderProducer.isDependentContextActive();
}
- @Test(groups = { "stub", "contexts", "producerField",
"underInvestigation" })
+ @Test(groups = { "contexts", "producerField"})
@SpecAssertion(section = "8.3", id = "g")
public void testContextIsActiveWhenInvokingProducerField()
{
- // TODO Rather difficult to detect anything when a producer field is
- // accessed
- assert false;
+ // Reset test class
+ Tarantula.setDependentContextActive(false);
+ getCurrentManager().getInstanceByType(Tarantula.class, TAME_LITERAL);
+ assert Tarantula.isDependentContextActive();
}
@Test(groups = { "broken", "contexts", "disposalMethod"
})
- @SpecAssertion(section = "8.3", id = "g")
+ @SpecAssertions({
+ @SpecAssertion(section = "8.3", id = "g"),
+ @SpecAssertion(section = "8.3", id = "j")
+ })
public void testContextIsActiveWhenInvokingDisposalMethod()
{
// deployBeans(SpiderProducer.class);
@@ -212,6 +208,7 @@
// SpiderProducer.setDependentContextActive(false);
// tarantulaBean.destroy(tarantula);
// assert SpiderProducer.isDependentContextActive();
+ assert false;
}
@Test(groups = { "contexts", "observerMethod" })
@@ -266,28 +263,21 @@
}.run();
}
- @Test(groups = { "broken", "contexts", "beanDestruction"
})
- @SpecAssertion(section = "8.3", id = "j")
- public void testContextIsActiveDuringBeanDestruction()
- {
- // Since the only way to check the context during bean
- // destruction is to have a disposal method, we'll use
- // that test to verify this behavior.
- this.testContextIsActiveWhenInvokingDisposalMethod();
- }
-
@Test(groups = { "contexts", "injection" })
@SpecAssertion(section = "8.3", id = "j")
public void testContextIsActiveDuringInjection()
{
Bean<FoxRun> foxRunBean =
getCurrentManager().resolveByType(FoxRun.class).iterator().next();
- FoxRun foxRun = foxRunBean.create(new MyCreationalContext<FoxRun>());
+ FoxRun foxRun = foxRunBean.create(new MockCreationalContext<FoxRun>());
assert foxRun.fox != null;
}
@Test(groups = { "contexts", "beanDestruction"})
- @SpecAssertion(section = "8.3.2", id = "a")
- public void testDestroyingParentDestroysDependents() throws Exception
+ @SpecAssertions({
+ @SpecAssertion(section = "8.3.2", id = "a"),
+ @SpecAssertion(section = "8.3", id = "b")
+ })
+ public void testDestroyingSimpleParentDestroysDependents() throws Exception
{
new RunInDependentContext()
{
@@ -307,7 +297,37 @@
}.run();
}
+
+ @Test(groups = { "contexts", "beanDestruction",
"ri-broken"})
+ @SpecAssertions({
+ @SpecAssertion(section = "8.3.2", id = "a"),
+ @SpecAssertion(section = "8.3", id = "b")
+ })
+ public void testDestroyingSimpleParentDestroysDependentsOfSameBean() throws Exception
+ {
+ // WBRI-158
+ new RunInDependentContext()
+ {
+ @Override
+ protected void execute() throws Exception
+ {
+ // Reset test class
+ Fox.setDestroyed(false);
+ Fox.setDestroyCount(0);
+
+ assert getCurrentManager().resolveByType(FoxRun.class).size() == 1;
+ Bean<FoxRun> bean =
getCurrentManager().resolveByType(FoxRun.class).iterator().next();
+ FoxRun instance = getCurrentManager().getInstanceByType(FoxRun.class);
+ assert instance.fox != instance.anotherFox;
+ bean.destroy(instance);
+ assert Fox.isDestroyed();
+ assert Fox.getDestroyCount() == 2;
+ }
+
+ }.run();
+ }
+
@Test(groups = { "contexts", "el"})
@SpecAssertion(section = "8.3.2", id = "c")
public void testDependentsDestroyedWhenElEvaluationCompletes() throws Exception
@@ -317,19 +337,19 @@
@Override
protected void execute() throws Exception
{
- Set<Bean<Fox>> foxBeans =
getCurrentManager().resolveByType(Fox.class);
- assert foxBeans.size() == 1;
- Bean<Fox> foxBean = foxBeans.iterator().next();
-
- Fox fox1 =
getCurrentConfiguration().getEl().evaluateValueExpression("#{fox}", Fox.class);
- assert fox1 != null;
- assert getCurrentManager().getContext(Dependent.class).get(foxBean) == null;
+ // Reset test class
+ Fox.setDestroyed(false);
+ FoxRun.setDestroyed(false);
+
+
getCurrentConfiguration().getEl().evaluateValueExpression("#{foxRun}",
FoxRun.class);
+ assert FoxRun.isDestroyed();
+ assert Fox.isDestroyed();
}
}.run();
}
@Test(groups = { "contexts", "producerMethod" })
- @SpecAssertion(section = "8.3.2", id = "d")
+ @SpecAssertion(section = "8.3.2", id = "da")
public void testDependentsDestroyedWhenProducerMethodCompletes() throws Exception
{
new RunInDependentContext()
@@ -338,24 +358,18 @@
@Override
protected void execute() throws Exception
{
- Bean<SpiderProducer> spiderProducer =
getCurrentManager().resolveByType(SpiderProducer.class).iterator().next();
- Context dependentContext = getCurrentManager().getContext(Dependent.class);
- SpiderProducer currentSpiderProducerInstance =
dependentContext.get(spiderProducer);
- // Should not have any instance of this bean yet
- assert currentSpiderProducerInstance == null;
+ // Reset the test class
+ SpiderProducer.setDestroyed(false);
Tarantula spiderInstance =
getCurrentManager().getInstanceByType(Tarantula.class);
assert spiderInstance != null;
- currentSpiderProducerInstance = dependentContext.get(spiderProducer);
- // Still should not have any instance of this bean (already
- // destroyed)
- assert currentSpiderProducerInstance == null;
+ assert SpiderProducer.isDestroyed();
}
}.run();
}
@Test(groups = { "contexts", "producerField" })
- @SpecAssertion(section = "8.3.2", id = "d")
+ @SpecAssertion(section = "8.3.2", id = "db")
public void testDependentsDestroyedWhenProducerFieldCompletes() throws Exception
{
new RunInDependentContext()
@@ -364,24 +378,20 @@
@Override
protected void execute() throws Exception
{
- Bean<OtherSpiderProducer> spiderProducer =
getCurrentManager().resolveByType(OtherSpiderProducer.class).iterator().next();
- Context dependentContext = getCurrentManager().getContext(Dependent.class);
- OtherSpiderProducer currentSpiderProducerInstance =
dependentContext.get(spiderProducer);
- // Should not have any instance of this bean yet
- assert currentSpiderProducerInstance == null;
+ // Reset the test class
+ OtherSpiderProducer.setDestroyed(false);
+
Tarantula spiderInstance =
getCurrentManager().getInstanceByType(Tarantula.class, TAME_LITERAL);
assert spiderInstance != null;
- currentSpiderProducerInstance = dependentContext.get(spiderProducer);
- // Still should not have any instance of this bean (already
- // destroyed)
- assert currentSpiderProducerInstance == null;
+ assert OtherSpiderProducer.isDestroyed();
+
}
}.run();
}
- @Test(groups = { "contexts", "disposalMethod" })
- @SpecAssertion(section = "8.3.2", id = "d")
+ @Test(groups = { "contexts", "disposalMethod",
"ri-broken" })
+ @SpecAssertion(section = "8.3.2", id = "dc")
public void testDependentsDestroyedWhenDisposalMethodCompletes() throws Exception
{
new RunInDependentContext()
@@ -390,20 +400,22 @@
@Override
protected void execute() throws Exception
{
- Bean<SpiderProducer> spiderProducerBean =
getCurrentManager().resolveByType(SpiderProducer.class).iterator().next();
Bean<Tarantula> tarantulaBean =
getCurrentManager().resolveByType(Tarantula.class).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
MyCreationalContext<Tarantula>());
+ Tarantula tarantula = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
assert tarantula != null;
+
+ // Reset test class state
+ SpiderProducer.setDestroyed(false);
+
tarantulaBean.destroy(tarantula);
- // No instance of this bean should exist
- assert
getCurrentManager().getContext(Dependent.class).get(spiderProducerBean) == null;
+ assert SpiderProducer.isDestroyed();
}
}.run();
}
@Test(groups = { "contexts", "observerMethod" })
- @SpecAssertion(section = "8.3.2", id = "d")
+ @SpecAssertion(section = "8.3.2", id = "dd")
public void testDependentsDestroyedWhenObserverMethodEvaluationCompletes() throws
Exception
{
new RunInDependentContext()
@@ -412,12 +424,13 @@
@Override
protected void execute() throws Exception
{
- Bean<HorseStable> horseStableBean =
getCurrentManager().resolveByType(HorseStable.class).iterator().next();
+ // Reset test class state...
+ HorseStable.setInstanceThatObservedEvent(null);
+ HorseStable.setDestroyed(false);
+
getCurrentManager().fireEvent(new HorseInStableEvent());
assert HorseStable.getInstanceThatObservedEvent() != null;
- HorseStable stableInstance =
getCurrentManager().getContext(Dependent.class).get(horseStableBean);
- // The instance used for the event should be destroyed
- assert stableInstance == null;
+ assert HorseStable.isDestroyed();
}
}.run();
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Farm.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Farm.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Farm.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -4,7 +4,7 @@
import javax.inject.Current;
@RequestScoped
-public class Farm
+class Farm
{
@Current Stable stable;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Fox.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Fox.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Fox.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -1,12 +1,44 @@
package org.jboss.jsr299.tck.tests.context.dependent;
import javax.annotation.Named;
+import javax.annotation.PreDestroy;
import javax.context.Dependent;
@Dependent @Named
class Fox
{
+ private static boolean destroyed = false;
+
+ private static int destroyCount = 0;
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ Fox.destroyed = destroyed;
+ }
+
+ public static void setDestroyCount(int destroyCount)
+ {
+ Fox.destroyCount = destroyCount;
+ }
+
+ public static int getDestroyCount()
+ {
+ return destroyCount;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ destroyCount++;
+ }
+
public String getName()
{
return "gavin";
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/FoxRun.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/FoxRun.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/FoxRun.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -1,14 +1,35 @@
package org.jboss.jsr299.tck.tests.context.dependent;
+import javax.annotation.Named;
+import javax.annotation.PreDestroy;
import javax.inject.Current;
+@Named("foxRun")
class FoxRun
{
+ private static boolean destroyed = false;
+
@Current
public Fox fox;
@Current
public Fox anotherFox;
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ FoxRun.destroyed = destroyed;
+ }
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/HorseStable.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/HorseStable.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/HorseStable.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -1,5 +1,6 @@
package org.jboss.jsr299.tck.tests.context.dependent;
+import javax.annotation.PreDestroy;
import javax.context.Dependent;
import javax.event.Observes;
import javax.inject.Current;
@@ -11,6 +12,7 @@
{
private static boolean dependentContextActive = false;
private static HorseStable instanceThatObservedEvent = null;
+ private static boolean destroyed = false;
@Initializer
public HorseStable(@Current Manager manager)
@@ -25,10 +27,16 @@
{
instanceThatObservedEvent = this;
}
+
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ }
public static boolean isDependentContextActive()
{
- return HorseStable.dependentContextActive;
+ return dependentContextActive;
}
public static void setDependentContextActive(boolean dependentContextActive)
@@ -40,4 +48,19 @@
{
return instanceThatObservedEvent;
}
+
+ public static void setInstanceThatObservedEvent(HorseStable
instanceThatObservedEvent)
+ {
+ HorseStable.instanceThatObservedEvent = instanceThatObservedEvent;
+ }
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ HorseStable.destroyed = destroyed;
+ }
}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java
(from rev 1791,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MyCreationalContext.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.context.dependent;
+
+import javax.context.CreationalContext;
+
+public class MockCreationalContext<T> implements CreationalContext<T>
+{
+
+ public void push(T incompleteInstance)
+ {
+
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MyCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MyCreationalContext.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MyCreationalContext.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -1,13 +0,0 @@
-package org.jboss.jsr299.tck.tests.context.dependent;
-
-import javax.context.CreationalContext;
-
-public class MyCreationalContext<T> implements CreationalContext<T>
-{
-
- public void push(T incompleteInstance)
- {
-
- }
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/OtherSpiderProducer.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/OtherSpiderProducer.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/OtherSpiderProducer.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -1,9 +1,29 @@
package org.jboss.jsr299.tck.tests.context.dependent;
+import javax.annotation.PreDestroy;
import javax.inject.Produces;
@AnotherDeploymentType
class OtherSpiderProducer
{
+
+ private static boolean destroyed = false;
+
@Produces @Tame public Tarantula produceTarantula = new Tarantula();
+
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ }
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ OtherSpiderProducer.destroyed = destroyed;
+ }
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/SpiderProducer.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/SpiderProducer.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/SpiderProducer.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -1,5 +1,6 @@
package org.jboss.jsr299.tck.tests.context.dependent;
+import javax.annotation.PreDestroy;
import javax.context.Dependent;
import javax.inject.Current;
import javax.inject.Disposes;
@@ -13,9 +14,10 @@
private Manager manager;
private static boolean dependentContextActive = false;
-
+ private static boolean destroyed = false;
private static SpiderProducer instanceUsedForDisposal = null;
+
@Produces public Tarantula produceTarantula()
{
if (manager.getContext(Dependent.class).isActive())
@@ -48,4 +50,20 @@
{
return instanceUsedForDisposal;
}
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ SpiderProducer.destroyed = destroyed;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ }
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Tarantula.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Tarantula.java 2009-03-07
16:13:45 UTC (rev 1802)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/Tarantula.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -1,6 +1,26 @@
package org.jboss.jsr299.tck.tests.context.dependent;
+import org.jboss.jsr299.tck.impl.ConfigurationImpl;
+
class Tarantula extends Spider implements DeadlySpider
{
+ private static boolean dependentContextActive = false;
+
+ public Tarantula()
+ {
+ dependentContextActive =
ConfigurationImpl.get().getContexts().getDependentContext().isActive();
+ }
+
+ public static boolean isDependentContextActive()
+ {
+ return dependentContextActive;
+ }
+
+ public static void setDependentContextActive(boolean dependentContextActive)
+ {
+ Tarantula.dependentContextActive = dependentContextActive;
+ }
+
+
}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java
(from rev 1791,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextIntegrationTest.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.ejb;
+
+import javax.context.CreationalContext;
+import javax.context.RequestScoped;
+import javax.inject.manager.Bean;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.jboss.jsr299.tck.impl.packaging.IntegrationTest;
+import org.jboss.jsr299.tck.impl.packaging.Packaging;
+import org.jboss.jsr299.tck.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+/**
+ * Spec version: Public Release Draft 2
+ */
+@IntegrationTest
+(a)Packaging(PackagingType.EAR)
+@Artifact
+public class DependentContextEjbTest extends AbstractDeclarativeTest
+{
+ @Test(groups = { "contexts", "injection", "ejb3",
"integration" })
+ @SpecAssertion(section = "8.3", id = "k")
+ public void testContextIsActiveDuringEJBDependencyInjection()
+ {
+ Bean<FoxRunLocal> foxRunBean =
getCurrentManager().resolveByType(FoxRunLocal.class).iterator().next();
+ FoxRunLocal foxRun = foxRunBean.create(new CreationalContext<FoxRunLocal>(){
+
+ public void push(FoxRunLocal incompleteInstance) {}
+
+ });
+ assert foxRun.getFox() != null;
+ }
+
+ @Test(groups = { "contexts", "postconstruct", "ejb3",
"integration" })
+ @SpecAssertion(section = "8.3", id = "l")
+ public void testContextIsActiveDuringEJBPostConstruct()
+ {
+ Fox.setDependentContextActiveDuringPostConstruct(false);
+ getCurrentManager().getInstanceByType(FoxLocal.class).getName();
+ assert Fox.isDependentContextActiveDuringPostConstruct();
+ }
+
+ @Test(groups = { "contexts", "ejb3", "integration",
"ri-broken" })
+ @SpecAssertion(section = "8.3.2", id = "ba")
+ public void testDestroyingEjbDestroysDependents() throws Exception
+ {
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ assert getCurrentManager().resolveByType(HouseLocal.class).size() == 1;
+ Bean<HouseLocal> bean =
getCurrentManager().resolveByType(HouseLocal.class).iterator().next();
+ HouseLocal instance =
getCurrentManager().getContext(RequestScoped.class).get(bean, new
CreationalContext<HouseLocal>(){
+
+ public void push(HouseLocal incompleteInstance) {}
+
+ });
+ Room.destroyed = false;
+ Table.destroyed = false;
+ bean.destroy(instance);
+ assert Room.destroyed;
+ assert Table.destroyed;
+ }
+
+ }.run();
+ }
+
+ @Test(groups = { "contexts", "ejb3",
"integration","ri-broken" })
+ @SpecAssertion(section = "8.3.2", id = "ba")
+ public void testDestroyingEjbDestroysDependentSimples() throws Exception
+ {
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ assert getCurrentManager().resolveByType(FarmLocal.class).size() == 1;
+ Bean<FarmLocal> farmBean =
getCurrentManager().resolveByType(FarmLocal.class).iterator().next();
+ FarmLocal farm =
getCurrentManager().getContext(RequestScoped.class).get(farmBean, new
CreationalContext<FarmLocal>(){
+
+ public void push(FarmLocal incompleteInstance) {}
+
+ });
+ Horse.destroyed = false;
+ Stable.destroyed = false;
+ farmBean.destroy(farm);
+ assert Horse.destroyed;
+ assert Stable.destroyed;
+ }
+
+ }.run();
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Farm.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Farm.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Farm.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.context.RequestScoped;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+
+
+@RequestScoped @Stateful
+public class Farm implements FarmLocal
+{
+
+ @Current Stable stable;
+
+ public void open() {};
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Farm.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FarmLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FarmLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FarmLocal.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+public interface FarmLocal
+{
+
+ public void open();
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FarmLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Fox.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Fox.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Fox.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,86 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.annotation.Named;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.context.ContextNotActiveException;
+import javax.context.Dependent;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+
+@Dependent @Named @Stateful
+public class Fox implements FoxLocal
+{
+
+ private static boolean destroyed = false;
+ private static int destroyCount = 0;
+ private static boolean dependentContextActiveDuringPostConstruct = false;
+
+ @Current
+ private Manager manager;
+
+ @PostConstruct
+ public void construct()
+ {
+ try
+ {
+ dependentContextActiveDuringPostConstruct =
manager.getContext(Dependent.class).isActive();
+ }
+ catch (ContextNotActiveException e)
+ {
+ dependentContextActiveDuringPostConstruct = false;
+ }
+ }
+
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ Fox.destroyed = destroyed;
+ }
+
+ public static void setDestroyCount(int destroyCount)
+ {
+ Fox.destroyCount = destroyCount;
+ }
+
+ public static int getDestroyCount()
+ {
+ return destroyCount;
+ }
+
+ public static boolean isDependentContextActiveDuringPostConstruct()
+ {
+ return dependentContextActiveDuringPostConstruct;
+ }
+
+ public static void setDependentContextActiveDuringPostConstruct(boolean
dependentContextActiveDuringPostConstruct)
+ {
+ Fox.dependentContextActiveDuringPostConstruct =
dependentContextActiveDuringPostConstruct;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ destroyCount++;
+ }
+
+ public String getName()
+ {
+ return "gavin";
+ }
+
+ @Remove
+ public void remove()
+ {
+
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Fox.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxLocal.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.ejb.Local;
+
+@Local
+public interface FoxLocal
+{
+
+ public String getName();
+
+}
\ No newline at end of file
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRun.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRun.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRun.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,48 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.annotation.Named;
+import javax.annotation.PreDestroy;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+
+@Named("foxRun") @Stateful
+public class FoxRun implements FoxRunLocal
+{
+
+ private static boolean destroyed = false;
+
+ @Current
+ public FoxLocal fox;
+
+ @Current
+ public FoxLocal anotherFox;
+
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ FoxRun.destroyed = destroyed;
+ }
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public FoxLocal getFox()
+ {
+ return fox;
+ }
+
+ @Remove
+ public void remove()
+ {
+
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRun.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRunLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRunLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRunLocal.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.ejb.Local;
+
+@Local
+public interface FoxRunLocal
+{
+
+ public FoxLocal getFox();
+
+}
\ No newline at end of file
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/FoxRunLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Horse.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Horse.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Horse.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import java.io.Serializable;
+
+import javax.annotation.PreDestroy;
+
+class Horse implements Serializable
+{
+
+ public static boolean destroyed;
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ destroyed = true;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Horse.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.context.RequestScoped;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+
+@RequestScoped @Stateful
+class House implements HouseLocal
+{
+
+ @Current RoomLocal room;
+
+ public void open() {};
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/House.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.ejb.Local;
+
+@Local
+public interface HouseLocal
+{
+
+ public void open();
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/HouseLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+
+@Stateful
+class Room implements RoomLocal
+{
+
+ @Current TableLocal table;
+
+ public static boolean destroyed;
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ destroyed = true;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Room.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.ejb.Local;
+
+@Local
+public interface RoomLocal
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/RoomLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Stable.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Stable.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Stable.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import java.io.Serializable;
+
+import javax.annotation.PreDestroy;
+import javax.inject.Current;
+
+class Stable implements Serializable
+{
+
+ @Current Horse horse;
+
+ public static boolean destroyed;
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ destroyed = true;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Stable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateful;
+
+@Stateful
+class Table implements TableLocal
+{
+
+ public static boolean destroyed;
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ destroyed = true;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/Table.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java 2009-03-07
16:26:56 UTC (rev 1803)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.context.dependent.ejb;
+
+import javax.ejb.Local;
+
+@Local
+public interface TableLocal
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/TableLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-07 16:13:45 UTC (rev 1802)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-03-07 16:26:56 UTC (rev 1803)
@@ -4630,8 +4630,9 @@
</section>
<section id="8.3.1" title="Dependent objects">
- <assertion id="a">
+ <assertion id="a" testable="false">
<text>A bean, EJB or servlet may obtain an instance of a bean with scope
@Dependent via dependency injection or by calling Manager.getInstance(),
Manager.getInstanceByType() or Instance.get() when the @Dependent scope is
active</text>
+ <note>A statement of intent</note>
</assertion>
<assertion id="b">
@@ -4645,18 +4646,34 @@
<text>The container must destroy all dependent objects of a contextual bean
instance when the instance is destroyed</text>
</assertion>
- <assertion id="b">
- <text>The container must destroy all dependent objects of an EJB or servlet
when the EJB or servlet is destroyed</text>
+ <assertion id="ba">
+ <text>The container must destroy all dependent objects of an EJB ~or servlet~
when the EJB ~or servlet~ is destroyed</text>
</assertion>
+ <assertion id="bb">
+ <text>The container must destroy all dependent objects of a~n EJB or~ servlet
when the ~EJB or~ servlet is destroyed</text>
+ </assertion>
+
<assertion id="c">
<text>The container must destroy all @Dependent scoped contextual instances
created during an EL expression evaluation when the evaluation completes</text>
</assertion>
- <assertion id="d">
- <text>The container must destroy any @Dependent scoped contextual instance
created to receive a producer method, producer field, disposal method or observer method
invocation when the invocation completes</text>
+ <assertion id="da">
+ <text>The container must destroy any @Dependent scoped contextual instance
created to receive a producer method~, producer field, disposal method or observer method~
invocation when the invocation completes</text>
</assertion>
+ <assertion id="db">
+ <text>The container must destroy any @Dependent scoped contextual instance
created to receive a ~producer method,~ producer field~, disposal method or observer
method~ invocation when the invocation completes</text>
+ </assertion>
+
+ <assertion id="dc">
+ <text>The container must destroy any @Dependent scoped contextual instance
created to receive a ~producer method, producer field,~ disposal method ~or observer
method~ invocation when the invocation completes</text>
+ </assertion>
+
+ <assertion id="dd">
+ <text>The container must destroy any @Dependent scoped contextual instance
created to receive a ~producer method, producer field, disposal method or~ observer method
invocation when the invocation completes</text>
+ </assertion>
+
<assertion id="e" testable="false">
<text>The container is permitted to destroy any @Dependent scoped contextual
instance at any time if the instance is no Scopes and contexts longer referenced by the
application (excluding weak, soft and phantom references)</text>
<note>In other words this is unspecified</note>