Author: dallen6
Date: 2009-04-01 10:07:15 -0400 (Wed, 01 Apr 2009)
New Revision: 2291
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java
Log:
A couple more contexts tests to push the total over 75%.
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java 2009-04-01
11:57:18 UTC (rev 2290)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java 2009-04-01
14:07:15 UTC (rev 2291)
@@ -114,18 +114,6 @@
* to any EJB message driven bean.
*/
@Test(groups = { "stub", "contexts", "ejb3",
"integration" })
- @SpecAssertion(section = "8.5.1", id = "i")
- public void testRequestScopeActiveDuringCallToEjbTimeoutMethod()
- {
- assert false;
- }
-
- /**
- * The request scope is active during any remote method invocation of any EJB
- * bean, during any call to an EJB timeout method and during message delivery
- * to any EJB message driven bean.
- */
- @Test(groups = { "stub", "contexts", "ejb3",
"integration" })
@SpecAssertion(section = "8.5.1", id = "j")
public void testRequestScopeActiveDuringEjbMessageDelivery()
{
@@ -148,17 +136,6 @@
* timeout or message delivery completes.
*/
@Test(groups = { "stub", "contexts", "ejb3",
"integration" })
- @SpecAssertion(section = "8.5.1", id = "l")
- public void testRequestScopeDestroyedAfterCallToEjbTimeoutMethod()
- {
- assert false;
- }
-
- /**
- * The request context is destroyed after the remote method invocation,
- * timeout or message delivery completes.
- */
- @Test(groups = { "stub", "contexts", "ejb3",
"integration" })
@SpecAssertion(section = "8.5.1", id = "m")
public void testRequestScopeDestroyedAfterEjbMessageDelivery()
{
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java 2009-04-01
14:07:15 UTC (rev 2291)
@@ -0,0 +1,54 @@
+package org.jboss.jsr299.tck.tests.context.request.ejb;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+/**
+ * EJB and related tests with the built-in request context.
+ *
+ * @author David Allen
+ *
+ * Spec version: PRD2
+ */
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.EAR)
+public class EJBRequestContextTest extends AbstractJSR299Test
+{
+ /**
+ * The request scope is active during any remote method invocation of any EJB
+ * bean, during any call to an EJB timeout method and during message delivery
+ * to any EJB message driven bean.
+ */
+ @Test(groups = { "ri-broken", "contexts", "ejb3",
"integration" })
+ @SpecAssertion(section = "8.5.1", id = "i")
+ public void testRequestScopeActiveDuringCallToEjbTimeoutMethod() throws Exception
+ {
+ FMS flightManagementSystem = getCurrentManager().getInstanceByType(FMS.class);
+ flightManagementSystem.climb();
+ Thread.sleep(250);
+ assert flightManagementSystem.isRequestScopeActive();
+ }
+
+ /**
+ * The request context is destroyed after the remote method invocation,
+ * timeout or message delivery completes.
+ */
+ @Test(groups = { "ri-broken", "contexts", "ejb3",
"integration" })
+ @SpecAssertion(section = "8.5.1", id = "l")
+ public void testRequestScopeDestroyedAfterCallToEjbTimeoutMethod() throws Exception
+ {
+ FMS flightManagementSystem = getCurrentManager().getInstanceByType(FMS.class);
+ flightManagementSystem.climb();
+ flightManagementSystem.descend();
+ Thread.sleep(250);
+ assert !flightManagementSystem.isSameBean();
+ assert SimpleRequestBean.isBeanDestroyed();
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java (from
rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMS.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java 2009-04-01
14:07:15 UTC (rev 2291)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.context.request.ejb;
+
+import javax.ejb.Local;
+
+@Local
+public interface FMS
+{
+ public void turnLeft();
+
+ public void turnRight();
+
+ public void climb();
+
+ public void descend();
+
+ public boolean isRequestScopeActive();
+
+ public void setRequestScopeActive(boolean requestScopeActive);
+
+ public boolean isSameBean();
+}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java 2009-04-01
14:07:15 UTC (rev 2291)
@@ -0,0 +1,82 @@
+package org.jboss.jsr299.tck.tests.context.request.ejb;
+
+import javax.annotation.Resource;
+import javax.context.RequestScoped;
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+
+@Stateless
+public class FMSModelIII implements FMS
+{
+ private static final long serialVersionUID = 1L;
+
+ @Resource
+ private TimerService timerService;
+
+ @Current
+ private Manager manager;
+
+ private static boolean requestScopeActive = false;
+ private static double beanId = 0.0d;
+ private static boolean sameBean = false;
+
+ public void climb()
+ {
+ timerService.createTimer(200, "Climb command timeout");
+ }
+
+ public void descend()
+ {
+ timerService.createTimer(100, "Descend command timeout");
+ beanId = 0.0d;
+ sameBean = false;
+ }
+
+ public void turnLeft()
+ {
+ }
+
+ public void turnRight()
+ {
+ }
+
+ @Timeout
+ public void timeout(Timer timer)
+ {
+ if (manager.getContext(RequestScoped.class).isActive())
+ {
+ requestScopeActive = true;
+ if (beanId > 0.0)
+ {
+ if (beanId == manager.getInstanceByType(SimpleRequestBean.class).getId())
+ {
+ sameBean = true;
+ }
+ }
+ else
+ {
+ beanId = manager.getInstanceByType(SimpleRequestBean.class).getId();
+ }
+ }
+ }
+
+ public boolean isRequestScopeActive()
+ {
+ return requestScopeActive;
+ }
+
+ public void setRequestScopeActive(boolean requestScopeActive)
+ {
+ FMSModelIII.requestScopeActive = requestScopeActive;
+ }
+
+ public boolean isSameBean()
+ {
+ return sameBean;
+ }
+
+}
Copied:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java
(from rev 2289,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/SimpleApplicationBean.java)
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java 2009-04-01
14:07:15 UTC (rev 2291)
@@ -0,0 +1,32 @@
+package org.jboss.jsr299.tck.tests.context.request.ejb;
+
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+
+@RequestScoped
+class SimpleRequestBean
+{
+ private double id = Math.random();
+ private static boolean beanDestroyed = false;
+
+ public double getId()
+ {
+ return id;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ beanDestroyed = true;
+ }
+
+ public static boolean isBeanDestroyed()
+ {
+ return beanDestroyed;
+ }
+
+ public static void setBeanDestroyed(boolean beanDestroyed)
+ {
+ SimpleRequestBean.beanDestroyed = beanDestroyed;
+ }
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain