Author: pete.muir(a)jboss.org
Date: 2009-06-28 13:31:37 -0400 (Sun, 28 Jun 2009)
New Revision: 2916
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletLifecycleTest.java
Removed:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/servlet/
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/ActivitiesTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/current/Donkey.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Animal.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DeadlyAnimal.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DeadlySpider.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DefangedTarantula.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Hound.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/HoundLocal.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Salmon.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ScottishFish.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/SeaBass.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Sole.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Spider.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tame.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tarantula.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/TarantulaProducer.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tuna.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Whitefish.java
Log:
make tests pass i/c, slight reorg
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/ActivitiesTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/ActivitiesTest.java 2009-06-28
15:48:12 UTC (rev 2915)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/ActivitiesTest.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -23,7 +23,6 @@
import org.jboss.webbeans.bean.ForwardingBean;
import org.jboss.webbeans.literal.CurrentLiteral;
import org.jboss.webbeans.test.AbstractWebBeansTest;
-import
org.jboss.webbeans.test.unit.implementation.enterprise.lifecycle.MockCreationalContext;
import org.testng.annotations.Test;
@@ -190,7 +189,7 @@
BeanManager childActivity = getCurrentManager().createActivity();
Bean<?> dummyBean = createDummyBean(childActivity, Cow.class);
childActivity.addBean(dummyBean);
- assert
childActivity.getInjectableReference(dummyBean.getInjectionPoints().iterator().next(), new
MockCreationalContext<Cow>()) != null;
+ assert
childActivity.getInjectableReference(dummyBean.getInjectionPoints().iterator().next(),
childActivity.createCreationalContext(dummyBean)) != null;
}
@Test
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/current/Donkey.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/current/Donkey.java 2009-06-28
15:48:12 UTC (rev 2915)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/current/Donkey.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -11,7 +11,7 @@
public Donkey() throws NamingException
{
- beanManager = (BeanManager) new
InitialContext().lookup("java:app/Manager");
+ beanManager = (BeanManager) new
InitialContext().lookup("java:app/BeanManager");
}
public BeanManager getManager()
Copied: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet
(from rev 2914,
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments)
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Animal.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Animal.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Animal.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
interface Animal
{
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DeadlyAnimal.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/DeadlyAnimal.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DeadlyAnimal.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
interface DeadlyAnimal
{
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DeadlySpider.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/DeadlySpider.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DeadlySpider.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
interface DeadlySpider extends DeadlyAnimal
{
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DefangedTarantula.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/DefangedTarantula.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/DefangedTarantula.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
class DefangedTarantula extends Tarantula
{
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Hound.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Hound.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Hound.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import javax.ejb.Remove;
import javax.ejb.Stateful;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/HoundLocal.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/HoundLocal.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/HoundLocal.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import javax.ejb.Local;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Salmon.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Salmon.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Salmon.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import javax.enterprise.inject.Named;
import javax.enterprise.inject.deployment.Production;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ScottishFish.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/ScottishFish.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ScottishFish.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
interface ScottishFish extends Animal
{
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/SeaBass.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/SeaBass.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/SeaBass.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.deployment.Production;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/ServletEnvironmentTest.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import java.util.Arrays;
import java.util.HashMap;
Copied:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletLifecycleTest.java
(from rev 2914,
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/servlet/ServletLifecycleTest.java)
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletLifecycleTest.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletLifecycleTest.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -0,0 +1,80 @@
+package org.jboss.webbeans.test.unit.environments.servlet;
+
+import javax.servlet.http.HttpSession;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.webbeans.context.ContextLifecycle;
+import org.jboss.webbeans.context.RequestContext;
+import org.jboss.webbeans.context.SessionContext;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
+import org.jboss.webbeans.conversation.ConversationManager;
+import org.jboss.webbeans.mock.MockHttpSession;
+import org.jboss.webbeans.servlet.ServletLifecycle;
+import org.jboss.webbeans.test.AbstractWebBeansTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * A set of tests that validates that the contexts are properly created
+ * and destroyed from the perspective of a servlet environment.
+ *
+ * @author Dan Allen
+ */
+@Artifact
+(a)Classes(ConversationManager.class)
+public class ServletLifecycleTest extends AbstractWebBeansTest
+{
+ @Test(groups = "incontainer-broken")
+ public void testEndSessionWithActiveRequestAndSessionContexts()
+ {
+ ServletLifecycle servletLifecycle = new ServletLifecycle(new ContextLifecycle());
+ BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
+ RequestContext.instance().setBeanStore(requestBeanStore);
+ RequestContext.instance().setActive(true);
+
+ BeanStore sessionBeanStore = new ConcurrentHashMapBeanStore();
+ SessionContext.instance().setBeanStore(sessionBeanStore);
+ SessionContext.instance().setActive(true);
+
+ HttpSession session = new MockHttpSession("99");
+ servletLifecycle.endSession(session);
+ assert Boolean.FALSE.equals(SessionContext.instance().isActive()) : "Session
context should no longer be active";
+ assert Boolean.TRUE.equals(RequestContext.instance().isActive()) : "Request
context should still be active";
+ }
+
+ @Test(groups = "incontainer-broken")
+ public void testEndSessionWithActiveRequestContextOnly()
+ {
+ ServletLifecycle servletLifecycle = new ServletLifecycle(new ContextLifecycle());
+ BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
+ RequestContext.instance().setBeanStore(requestBeanStore);
+ RequestContext.instance().setActive(true);
+
+ HttpSession session = new MockHttpSession("99");
+ servletLifecycle.endSession(session);
+ assert Boolean.FALSE.equals(SessionContext.instance().isActive()) : "Session
context should no longer be active";
+ assert Boolean.TRUE.equals(RequestContext.instance().isActive()) : "Request
context should still be active";
+ }
+
+ @Test(groups = "incontainer-broken")
+ public void testEndSessionWithNoActiveRequestOrSessionContexts()
+ {
+ ServletLifecycle servletLifecycle = new ServletLifecycle(new ContextLifecycle());
+
+ HttpSession session = new MockHttpSession("99");
+ servletLifecycle.endSession(session);
+ assert Boolean.FALSE.equals(SessionContext.instance().isActive()) : "Session
context should no longer be active";
+ assert Boolean.FALSE.equals(RequestContext.instance().isActive()) : "Temporary
request context should have been deactivated";
+ }
+
+ @BeforeMethod(groups = "incontainer-broken")
+ public void beforeMethod()
+ {
+ RequestContext.instance().setBeanStore(null);
+ RequestContext.instance().setActive(false);
+ SessionContext.instance().setBeanStore(null);
+ SessionContext.instance().setActive(false);
+ }
+}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Sole.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Sole.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Sole.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import javax.ejb.EJB;
import javax.enterprise.inject.Named;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Spider.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Spider.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Spider.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
class Spider implements Animal
{
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tame.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Tame.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tame.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tarantula.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Tarantula.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tarantula.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
class Tarantula extends Spider implements DeadlySpider
{
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/TarantulaProducer.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/TarantulaProducer.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/TarantulaProducer.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import javax.enterprise.inject.Produces;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tuna.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Tuna.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Tuna.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import javax.enterprise.context.RequestScoped;
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Whitefish.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/Whitefish.java 2009-06-28
15:17:17 UTC (rev 2914)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/Whitefish.java 2009-06-28
17:31:37 UTC (rev 2916)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.test.unit.bootstrap.environments;
+package org.jboss.webbeans.test.unit.environments.servlet;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;