Author: pete.muir(a)jboss.org
Date: 2010-02-20 15:34:37 -0500 (Sat, 20 Feb 2010)
New Revision: 5904
Removed:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMS.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java
Log:
port CDITCK-108 to trunk
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java 2010-02-20
20:33:10 UTC (rev 5903)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java 2010-02-20
20:34:37 UTC (rev 5904)
@@ -38,7 +38,6 @@
{
@Test(groups = { "contexts", "ejb3", "integration",
"rewrite" })
- // TODO Needs to test *all* uses of app context are shared, not each type
individually
@SpecAssertion(section = "6.7.3", id = "e")
public void testApplicationContextShared() throws Exception
{
@@ -48,5 +47,15 @@
Thread.sleep(350);
assert flightManagementSystem.isSameBean();
}
+
+ @Test(groups = { "contexts", "ejb3", "integration" })
+ @SpecAssertion(section = "6.7.3", id = "dc")
+ public void testApplicationScopeActiveDuringCallToEjbTimeoutMethod() throws Exception
+ {
+ FMS flightManagementSystem = getInstanceByType(FMS.class);
+ flightManagementSystem.climb();
+ Thread.sleep(250);
+ assert flightManagementSystem.isApplicationScopeActive();
+ }
}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java 2010-02-20
20:33:10 UTC (rev 5903)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java 2010-02-20
20:34:37 UTC (rev 5904)
@@ -1,49 +0,0 @@
-/*
- * 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.application.ejb;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecVersion;
-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 application context.
- *
- * @author David Allen
- */
-@Artifact
-@IntegrationTest
-(a)Packaging(PackagingType.EAR)
-@SpecVersion(spec="cdi", version="20091101")
-public class EJBApplicationContextTest extends AbstractJSR299Test
-{
- @Test(groups = { "contexts", "ejb3", "integration" })
- @SpecAssertion(section = "6.7.3", id = "dc")
- public void testApplicationScopeActiveDuringCallToEjbTimeoutMethod() throws Exception
- {
- FMS flightManagementSystem = getInstanceByType(FMS.class);
- flightManagementSystem.climb();
- Thread.sleep(250);
- assert flightManagementSystem.isApplicationScopeActive();
- }
-
-}
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMS.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMS.java 2010-02-20
20:33:10 UTC (rev 5903)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMS.java 2010-02-20
20:34:37 UTC (rev 5904)
@@ -21,17 +21,13 @@
@Local
public interface FMS
{
- public void turnLeft();
- public void turnRight();
+ public void climb() throws Exception;
- public void climb();
+ public void descend() throws Exception;
- public void descend();
+ public boolean isSameBean();
public boolean isApplicationScopeActive();
-
- public void setApplicationScopeActive(boolean applicationScopeActive);
- public boolean isSameBean();
}
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java 2010-02-20
20:33:10 UTC (rev 5903)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java 2010-02-20
20:34:37 UTC (rev 5904)
@@ -40,30 +40,47 @@
@Inject
private Instance<SimpleApplicationBean> simpleApplicationBeanInstance;
- private static boolean applicationScopeActive = false;
- private static double beanId = 0.0d;
- private static boolean sameBean = false;
+ private static volatile boolean applicationScopeActive = false;
+ private static volatile double beanId = 0.0d;
+ private static volatile boolean sameBean = false;
+
+ private static volatile int climbState;
+ private static volatile int descendState;
- public void climb()
+ public void climb() throws Exception
{
+ climbState = 0;
timerService.createTimer(200, "Climb command timeout");
+ long timestamp = System.currentTimeMillis();
+ // Wait for the timer
+ while (climbState == 0)
+ {
+ // but don't wait more than 10s so we don't just hang!
+ if (System.currentTimeMillis() > timestamp + 10000)
+ {
+ return;
+ }
+ Thread.sleep(1);
+ }
}
- public void descend()
+ public void descend() throws Exception
{
+ descendState = 0;
timerService.createTimer(100, "Descend command timeout");
- beanId = 0.0d;
- sameBean = false;
+ long timestamp = System.currentTimeMillis();
+ // Wait for the timer
+ while (descendState == 0)
+ {
+ // but don't wait more than 10s so we don't just hang!
+ if (System.currentTimeMillis() > timestamp + 10000)
+ {
+ return;
+ }
+ Thread.sleep(1);
+ }
}
- public void turnLeft()
- {
- }
-
- public void turnRight()
- {
- }
-
@Timeout
public void timeout(Timer timer)
{
@@ -82,6 +99,8 @@
beanId = simpleApplicationBeanInstance.get().getId();
}
}
+ climbState = 1;
+ descendState = 1;
}
public boolean isApplicationScopeActive()
@@ -89,11 +108,6 @@
return applicationScopeActive;
}
- public void setApplicationScopeActive(boolean applicationScopeActive)
- {
- FMSModelIII.applicationScopeActive = applicationScopeActive;
- }
-
public boolean isSameBean()
{
return sameBean;