[webbeans-commits] Webbeans SVN: r1381 - tck/trunk/impl/src/main/java/org/jboss/webbeans/tck and 8 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Feb 2 07:17:11 EST 2009


Author: dallen6
Date: 2009-02-02 07:17:11 -0500 (Mon, 02 Feb 2009)
New Revision: 1381

Added:
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyContext.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyScoped.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyApplicationBean.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyContextual.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyCreationalContext.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MySessionBean.java
Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/AbstractBeanMapContext.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/AbstractTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/application/ApplicationContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/request/RequestContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/session/SessionContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/manager/ManagerTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/non/contextual/NonContextualInjectionTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/ContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/NormalContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/DisposalMethodDefinitionTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/SimpleBeanDefinitionTest.java
Log:
Additional test changes including new impls for normal context tests.

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/AbstractBeanMapContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/AbstractBeanMapContext.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/AbstractBeanMapContext.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -73,7 +73,10 @@
       else if (creationalContext != null)
       {
          instance = contextual.create(creationalContext);
-         getBeanMap().put(contextual, instance);
+         if (instance != null)
+         {
+            getBeanMap().put(contextual, instance);
+         }
          return instance;
       }
       else
@@ -81,7 +84,7 @@
          return null;
       }
    }
-   
+
    public <T> T get(Contextual<T> contextual)
    {
       return get(contextual, null);

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/AbstractTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/AbstractTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/AbstractTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -15,6 +15,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import javax.context.Context;
 import javax.context.CreationalContext;
 import javax.inject.Production;
 import javax.inject.Standard;
@@ -161,7 +162,22 @@
    {
       configuration().getContexts().setInactive(configuration().getContexts().getDependentContext());
    }
-   
+
+   protected static void setContextActive(Context context)
+   {
+      configuration().getContexts().setActive(context);
+   }
+
+   protected static void setContextInactive(Context context)
+   {
+      configuration().getContexts().setInactive(context);
+   }
+
+   protected static void destroyContext(Context context)
+   {
+      configuration().getContexts().destroyContext(context);
+   }
+
    @Deprecated
    public static final <T> CreationalContext<T> mockCreationalContext(Class<T> expectedType)
    {

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/application/ApplicationContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/application/ApplicationContextTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/application/ApplicationContextTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -15,7 +15,7 @@
     * The application scope is active during the service() method of any servlet
     * in the web application.
     */
-   @Test(groups = { "stub", "contexts", "servlet" })
+   @Test(groups = { "stub", "contexts", "servlet", "integration" })
    @SpecAssertion(section = "8.5.3", id = "unknown")
    public void testApplicationScopeActiveDuringServiceMethod()
    {
@@ -25,7 +25,7 @@
    /**
     * The application scope is active during any Java EE web service invocation.
     */
-   @Test(groups = { "stub", "contexts", "webservice" })
+   @Test(groups = { "stub", "contexts", "webservice", "integration" })
    @SpecAssertion(section = "8.5.3", id = "unknown")
    public void testApplicationScopeActiveDuringWebSericeInvocation()
    {
@@ -37,7 +37,7 @@
     * 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" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.3", id = "unknown")
    public void testApplicationScopeActiveDuringRemoteMethodInvocationOfEjb()
    {
@@ -49,7 +49,7 @@
     * 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" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.3", id = "unknown")
    public void testApplicationScopeActiveDuringCallToEjbTimeoutMethod()
    {
@@ -61,7 +61,7 @@
     * 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" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.3", id = "unknown")
    public void testApplicationScopeActiveDuringEjbMessageDelivery()
    {
@@ -74,7 +74,7 @@
     * message deliveries to message driven beans that execute within the same
     * application
     */
-   @Test(groups = { "stub", "contexts" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.3", id = "unknown")
    public void testApplicationContextSharedBetweenInvokationsInApplication()
    {
@@ -84,7 +84,7 @@
    /**
     * The application context is destroyed when the application is undeployed.
     */
-   @Test(groups = { "stub", "contexts" })
+   @Test(groups = { "stub", "contexts", "integration" })
    @SpecAssertion(section = "8.5.3", id = "unknown")
    public void testApplicationScopeDestroyedWhenApplicationIsUndeployed()
    {

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/request/RequestContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/request/RequestContextTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/request/RequestContextTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -15,7 +15,7 @@
     * The request scope is active during the service() method of any Servlet in
     * the web application.
     */
-   @Test(groups = { "stub", "contexts", "servlet" })
+   @Test(groups = { "stub", "contexts", "servlet", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeActiveDuringServiceMethod()
    {
@@ -26,7 +26,7 @@
     * The request context is destroyed at the end of the servlet request, after
     * the Servlet service() method returns.
     */
-   @Test(groups = { "stub", "contexts", "servlet" })
+   @Test(groups = { "stub", "contexts", "servlet", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeIsDestroyedAfterServiceMethod()
    {
@@ -36,7 +36,7 @@
    /**
     * The request scope is active during any Java EE web service invocation.
     */
-   @Test(groups = { "stub", "contexts", "webservice" })
+   @Test(groups = { "stub", "contexts", "webservice", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeActiveDuringWebSericeInvocation()
    {
@@ -47,7 +47,7 @@
     * The request context is destroyed after the web service invocation
     * completes
     */
-   @Test(groups = { "stub", "contexts", "webservice" })
+   @Test(groups = { "stub", "contexts", "webservice", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeIsDestroyedAfterWebServiceInvocation()
    {
@@ -59,7 +59,7 @@
     * bean, during any call to an EJB timeout method and during message delivery
     * to any EJB message driven bean.
     */
-   @Test(groups = { "stub", "contexts", "ejb3" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeActiveDuringRemoteMethodInvocationOfEjb()
    {
@@ -71,7 +71,7 @@
     * bean, during any call to an EJB timeout method and during message delivery
     * to any EJB message driven bean.
     */
-   @Test(groups = { "stub", "contexts", "ejb3" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeActiveDuringCallToEjbTimeoutMethod()
    {
@@ -83,7 +83,7 @@
     * bean, during any call to an EJB timeout method and during message delivery
     * to any EJB message driven bean.
     */
-   @Test(groups = { "stub", "contexts", "ejb3" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeActiveDuringEjbMessageDelivery()
    {
@@ -94,7 +94,7 @@
     * The request context is destroyed after the remote method invocation,
     * timeout or message delivery completes.
     */
-   @Test(groups = { "stub", "contexts", "ejb3" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeDestroyedAfterRemoteMethodInvocationOfEjb()
    {
@@ -105,7 +105,7 @@
     * The request context is destroyed after the remote method invocation,
     * timeout or message delivery completes.
     */
-   @Test(groups = { "stub", "contexts", "ejb3" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeDestroyedAfterCallToEjbTimeoutMethod()
    {
@@ -116,7 +116,7 @@
     * The request context is destroyed after the remote method invocation,
     * timeout or message delivery completes.
     */
-   @Test(groups = { "stub", "contexts", "ejb3" })
+   @Test(groups = { "stub", "contexts", "ejb3", "integration" })
    @SpecAssertion(section = "8.5.1", id = "unknown")
    public void testRequestScopeDestroyedAfterEjbMessageDelivery()
    {

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/session/SessionContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/session/SessionContextTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/context/session/SessionContextTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -15,7 +15,7 @@
     * The session scope is active during the service() method of any servlet in
     * the web application
     */
-   @Test(groups = { "stub", "contexts", "servlet" })
+   @Test(groups = { "stub", "contexts", "servlet", "integration" })
    @SpecAssertion(section = "8.5.2", id = "unknown")
    public void testSessionScopeActiveDuringServiceMethod()
    {
@@ -26,7 +26,7 @@
     * The session context is shared between all servlet requests that occur in
     * the same HTTP servlet session
     */
-   @Test(groups = { "stub", "contexts", "servlet" })
+   @Test(groups = { "stub", "contexts", "servlet", "integration" })
    @SpecAssertion(section = "8.5.2", id = "unknown")
    public void testSessionContextSharedBetweenServletRequestsInSameHttpSession()
    {
@@ -37,7 +37,7 @@
     * The session context is destroyed when the HTTPSession is invalidated or
     * times out.
     */
-   @Test(groups = { "stub", "contexts" })
+   @Test(groups = { "stub", "contexts", "integration" })
    @SpecAssertion(section = "8.5.2", id = "unknown")
    public void testSessionContextDestroyedWhenHttpSessionInvalidatedOrTimesOut()
    {

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/manager/ManagerTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/manager/ManagerTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/manager/ManagerTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -6,7 +6,8 @@
 
 public class ManagerTest extends AbstractTest
 {
-   @Test(groups={"stub", "manager", "ejb3"}) @SpecAssertion(section="5.8", id = "unknown")
+   @Test(groups = { "stub", "manager", "ejb3", "integration" })
+   @SpecAssertion(section = "5.8", id = "unknown")
    public void testManagerLookupInJndi()
    {
       assert false;

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/non/contextual/NonContextualInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/non/contextual/NonContextualInjectionTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/integration/lookup/non/contextual/NonContextualInjectionTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -1,44 +1,86 @@
 package org.jboss.webbeans.tck.integration.lookup.non.contextual;
 
 import org.jboss.webbeans.tck.AbstractTest;
+import org.jboss.webbeans.tck.impl.SpecAssertion;
 import org.testng.annotations.Test;
 
 /**
  * 
  * Spec version: PRD2
- *
+ * 
  */
 public class NonContextualInjectionTest extends AbstractTest
 {
-   
-   @Test(groups="stub")
+
+   /**
+    * For the purposes of dependency injection and interceptor/decorator stack
+    * creation, the container must treat non-contextual instances of session
+    * beans as instances of the most specialized bean that specializes the bean
+    * with binding @New and de- ployment type @Standard defined in Section
+    * 3.3.6, “Session beans with the @New binding”.
+    */
+   @Test(groups = { "stub", "integration" })
+   @SpecAssertion(section = "5.12.1", id = "unknown")
    public void testNonContextualSessionBeanSpecializesNewBeanForInjection()
    {
-      
+      assert false;
    }
-   
-   @Test(groups="stub")
+
+   /**
+    * Session bean instances obtained directly from JNDI, injected using @EJB or
+    * @Resource, or created by the container to re- ceive remote method calls or
+    * timeouts are not contextual instances. However, the container is still
+    * required to perform de- pendency injection and create interceptor and
+    * decorator stacks for these instances.
+    */
+   @Test(groups = { "stub", "integration" })
+   @SpecAssertion(section = "5.12.1", id = "unknown")
    public void testNonContextualSessionBeanSpecializesNewBeanForInterceptorStack()
    {
-      
+      assert false;
    }
-   
-   @Test(groups="stub")
+
+   /**
+    * Session bean instances obtained directly from JNDI, injected using @EJB or
+    * @Resource, or created by the container to re- ceive remote method calls or
+    * timeouts are not contextual instances. However, the container is still
+    * required to perform de- pendency injection and create interceptor and
+    * decorator stacks for these instances.
+    */
+   @Test(groups = { "stub", "integration" })
+   @SpecAssertion(section = "5.12.1", id = "unknown")
    public void testNonContextualSessionBeanSpecializesNewBeanForDecoratorStack()
    {
-      
+      assert false;
    }
-   
-   @Test(groups="stub")
+
+   /**
+    * Message-driven beans do not have contextual instances. However, the
+    * container is still required to perform dependency in- jection and create
+    * interceptor and decorator stacks.
+    * 
+    * The container performs dependency injection and creates interceptor and
+    * decorator stacks for message-driven bean in- stances according to the bean
+    * class annotations.
+    */
+   @Test(groups = { "stub", "integration" })
+   @SpecAssertion(section = "5.12.2", id = "unknown")
    public void testInjectionIntoMessageDrivenBean()
    {
-      
+      assert false;
    }
-   
-   @Test(groups="stub")
+
+   /**
+    * Servlets do not have contextual instances. However, the container is still
+    * required to perform dependency injection. The container performs
+    * dependency injection for servlets according to the servlet class
+    * annotations.
+    */
+   @Test(groups = { "stub", "integration" })
+   @SpecAssertion(section = "5.12.3", id = "unknown")
    public void testInjectionIntoServlet()
    {
-      
+      assert false;
    }
-   
+
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/ContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/ContextTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/ContextTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -92,7 +92,7 @@
     * For each of the built-in normal scopes, contexts propagate across any Java
     * method call, including invocation of EJB local business methods.
     */
-   @Test(groups = { "stub", "contexts" })
+   @Test(groups = { "stub", "contexts", "underInvestigation" })
    @SpecAssertion(section = "8.5", id = "unknown")
    public void testBuiltInNormalScopedContextsPropagateAcrossAnyJavaMethodCall()
    {
@@ -104,7 +104,7 @@
     * to asynchronous processes such as JMS message listeners or EJB timer
     * service timeouts
     */
-   @Test(groups = { "stub", "contexts" })
+   @Test(groups = { "stub", "contexts", "integration" })
    @SpecAssertion(section = "8.5", id = "unknown")
    public void testBuiltInNormalScopedContextsDoNotPropagateAcrossRemoteMethodInvocations()
    {
@@ -116,7 +116,7 @@
     * to asynchronous processes such as JMS message listeners or EJB timer
     * service timeouts
     */
-   @Test(groups = { "stub", "contexts" })
+   @Test(groups = { "stub", "contexts", "integration" })
    @SpecAssertion(section = "8.5", id = "unknown")
    public void testBuiltInNormalScopedContextsDoNotPropagateAcrossAsynchronousMethodInvocations()
    {

Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyContext.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyContext.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyContext.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -0,0 +1,30 @@
+package org.jboss.webbeans.tck.unit.context;
+
+import java.lang.annotation.Annotation;
+
+import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+
+class DummyContext implements Context
+{
+   public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   public <T> T get(Contextual<T> contextual)
+   {
+      return get(contextual, null);
+   }
+
+   public Class<? extends Annotation> getScopeType()
+   {
+      return DummyScoped.class;
+   }
+
+   public boolean isActive()
+   {
+      return true;
+   }
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyContext.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyScoped.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyScoped.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyScoped.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.tck.unit.context;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import javax.context.ScopeType;
+
+ at ScopeType
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface DummyScoped
+{
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/DummyScoped.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyApplicationBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyApplicationBean.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyApplicationBean.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.tck.unit.context;
+
+import java.io.Serializable;
+
+import javax.context.ApplicationScoped;
+
+ at ApplicationScoped
+class MyApplicationBean implements Serializable
+{
+
+   /**
+    * 
+    */
+   private static final long serialVersionUID = 1L;
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyApplicationBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyContextual.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyContextual.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyContextual.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -0,0 +1,109 @@
+package org.jboss.webbeans.tck.unit.context;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.CreationalContext;
+import javax.context.SessionScoped;
+import javax.inject.Standard;
+import javax.inject.manager.Bean;
+import javax.inject.manager.InjectionPoint;
+import javax.inject.manager.Manager;
+
+class MyContextual extends Bean<MySessionBean>
+{
+   private boolean createCalled = false;
+   private boolean destroyCalled = false;
+   private boolean shouldReturnNullInstances = false;
+
+   protected MyContextual(Manager manager)
+   {
+      super(manager);
+   }
+
+   @Override
+   public Set<Annotation> getBindings()
+   {
+      return Collections.emptySet();
+   }
+
+   @Override
+   public Class<? extends Annotation> getDeploymentType()
+   {
+      return Standard.class;
+   }
+
+   @Override
+   public Set<? extends InjectionPoint> getInjectionPoints()
+   {
+      return Collections.emptySet();
+   }
+
+   @Override
+   public String getName()
+   {
+      return "my-session-bean";
+   }
+
+   @Override
+   public Class<? extends Annotation> getScopeType()
+   {
+      return SessionScoped.class;
+   }
+
+   @SuppressWarnings("unchecked")
+   @Override
+   public Set<Type> getTypes()
+   {
+      return new HashSet<Type>(Arrays.asList(Object.class, MySessionBean.class, Serializable.class));
+   }
+
+   @Override
+   public boolean isNullable()
+   {
+      return false;
+   }
+
+   @Override
+   public boolean isSerializable()
+   {
+      return true;
+   }
+
+   @Override
+   public MySessionBean create(CreationalContext<MySessionBean> creationalContext)
+   {
+      createCalled = true;
+      if (shouldReturnNullInstances)
+         return null;
+      else
+         return new MySessionBean();
+   }
+
+   @Override
+   public void destroy(MySessionBean instance)
+   {
+      destroyCalled = true;
+   }
+
+   public boolean isCreateCalled()
+   {
+      return createCalled;
+   }
+
+   public boolean isDestroyCalled()
+   {
+      return destroyCalled;
+   }
+
+   public void setShouldReturnNullInstances(boolean shouldReturnNullInstances)
+   {
+      this.shouldReturnNullInstances = shouldReturnNullInstances;
+   }
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyContextual.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyCreationalContext.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyCreationalContext.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyCreationalContext.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.tck.unit.context;
+
+import javax.context.CreationalContext;
+
+class MyCreationalContext<T> implements CreationalContext<T>
+{
+
+   @Override
+   public void push(T incompleteInstance)
+   {
+   }
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MyCreationalContext.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MySessionBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MySessionBean.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MySessionBean.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.tck.unit.context;
+
+import java.io.Serializable;
+
+ at DummyScoped
+class MySessionBean implements Serializable
+{
+
+   /**
+    * 
+    */
+   private static final long serialVersionUID = 1L;
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/MySessionBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/NormalContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/NormalContextTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/NormalContextTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -1,13 +1,11 @@
 package org.jboss.webbeans.tck.unit.context;
 
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
+import javax.context.ApplicationScoped;
 import javax.context.Context;
+import javax.context.ContextNotActiveException;
 import javax.context.Contextual;
 import javax.context.CreationalContext;
-import javax.context.ScopeType;
+import javax.context.SessionScoped;
 
 import org.jboss.webbeans.tck.AbstractTest;
 import org.jboss.webbeans.tck.impl.SpecAssertion;
@@ -18,104 +16,112 @@
  * 
  * @author Nicklas Karlsson
  * @author Pete Muir
+ * @author David Allen
  * 
  *         This class tests a basic context against section 8 of the
  *         specification
  * 
- * Spec version: PRD2
+ *         Spec version: PRD2
  */
 public class NormalContextTest extends AbstractTest
 {
-   
-   @ScopeType
-   @Retention(RetentionPolicy.RUNTIME)
-   private @interface Dummy {}
-   
-   private static class DummyContext implements Context
-   {
 
-      public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext)
-      {
-         throw new UnsupportedOperationException();
-      }
-      
-      public <T> T get(Contextual<T> contextual)
-      {
-         return get(contextual, null);
-      }
-
-      public Class<? extends Annotation> getScopeType()
-      {
-         return Dummy.class;
-      }
-
-      public boolean isActive()
-      {
-         return true;
-      }
-      
-   }
-   
    Context context;
 
    @BeforeMethod
    public void initContext()
    {
       context = new DummyContext();
+      manager.addContext(context);
    }
 
    /**
     * return an existing instance of the given contextual type, or
     */
-   @Test(groups = { "contexts", "stub" })
+   @Test(groups = { "contexts", "broken" })
    @SpecAssertion(section = "8.1", id = "unknown")
-   public void testGetReturnsExistingInstace()
+   public void testGetReturnsExistingInstance()
    {
-      assert false;
+      deployBeans(MySessionBean.class);
+      MySessionBean beanInstance = manager.getInstanceByType(MySessionBean.class);
+
+      Contextual<MySessionBean> mySessionBean = manager.resolveByType(MySessionBean.class).iterator().next();
+      MySessionBean beanInstanceFromGet = manager.getContext(SessionScoped.class).get(mySessionBean);
+      assert beanInstanceFromGet.equals(beanInstance);
    }
 
    /**
-    * if the value of the create parameter is false, return a null value, or
+    * if no CreationalContext is given, return a null value, or
     */
-   @Test(groups = { "contexts", "stub" })
+   @Test(groups = { "contexts" })
    @SpecAssertion(section = "8.1", id = "unknown")
-   public void testGetWithCreateFalseReturnsNull()
+   public void testGetWithoutCreationalContextReturnsNull()
    {
-      assert false;
+      deployBeans(MySessionBean.class);
+
+      Contextual<MySessionBean> mySessionBean = manager.resolveByType(MySessionBean.class).iterator().next();
+      assert manager.getContext(SessionScoped.class).get(mySessionBean) == null;
    }
 
    /**
-    * if the value of the create parameter is true, create a new instance of the
-    * given contextual type by calling Bean.create() and return the new
+    * if a CreationalContext is given, create a new instance of the given
+    * contextual type by calling Contextual.create() and return the new
     * instance.
     */
-   @Test(groups = { "contexts", "stub" })
+   @Test(groups = { "contexts" })
    @SpecAssertion(section = "8.1", id = "unknown")
-   public void testGetWithCreateTrueReturnsNewInstance()
+   public void testGetWithCreationalContextReturnsNewInstance()
    {
-      assert false;
+      MyContextual bean = new MyContextual(manager);
+      bean.setShouldReturnNullInstances(false);
+      manager.addBean(bean);
+
+      CreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+      assert manager.getContext(SessionScoped.class).get(bean, myCreationalContext) != null;
+      assert bean.isCreateCalled();
    }
 
    /**
-    * The get() method may not return a null value unless the create parameter
-    * is false or Contextual.create() returns a null value
+    * The get() method may not return a null value unless no CreationalContext
+    * is given, or Contextual.create() returns a null value.
     */
-   @Test(groups = { "contexts", "stub" })
+   @Test(groups = { "contexts" })
    @SpecAssertion(section = "8.1", id = "unknown")
-   public void testGetMayNotReturnNullUnlessCreateIsFalseOrContextualCreateReturnsNull()
+   public void testGetMayNotReturnNullUnlessNoCreationalContextOrContextualCreateReturnsNull()
    {
-      assert false;
+      // The case of no creational context is already tested where a null is
+      // returned. Here we just test that the contextual create can return null.
+      MyContextual bean = new MyContextual(manager);
+      bean.setShouldReturnNullInstances(true);
+      manager.addBean(bean);
+
+      CreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+      assert manager.getContext(SessionScoped.class).get(bean, myCreationalContext) == null;
+      assert bean.isCreateCalled();
    }
 
    /**
     * The get() method may not create a new instance of the given contextual
-    * type unless the create parameter is true
+    * type unless a CreationalContext is given.
     */
-   @Test(groups = { "contexts", "stub" })
+   @Test(groups = { "contexts" })
    @SpecAssertion(section = "8.1", id = "unknown")
-   public void testGetMayNotCreateNewInstanceUnlessCreateIsTrue()
+   public void testGetMayNotCreateNewInstanceUnlessCreationalContextGiven()
    {
-      assert false;
+      deployBeans(MySessionBean.class, MyApplicationBean.class);
+
+      Contextual<MySessionBean> mySessionBean = manager.resolveByType(MySessionBean.class).iterator().next();
+      assert manager.getContext(SessionScoped.class).get(mySessionBean) == null;
+
+      Contextual<MyApplicationBean> myApplicationBean = manager.resolveByType(MyApplicationBean.class).iterator().next();
+      assert manager.getContext(ApplicationScoped.class).get(myApplicationBean) == null;
+
+      // Now try same operation with a CreationalContext
+      CreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+      assert manager.getContext(SessionScoped.class).get(mySessionBean, myCreationalContext) != null;
+
+      CreationalContext<MyApplicationBean> myOtherCreationalContext = new MyCreationalContext<MyApplicationBean>();
+      assert manager.getContext(ApplicationScoped.class).get(myApplicationBean, myOtherCreationalContext) != null;
    }
 
    /**
@@ -123,19 +129,32 @@
     * instance it creates by passing the instance to the destroy() method of the
     * Contextual object representing the contextual type.
     */
+   @Test(groups = { "contexts" })
+   @SpecAssertion(section = "8.1", id = "unknown")
    public void testContextDestroysBeansWhenDestroyed()
    {
-      assert false;
+      MyContextual bean = new MyContextual(manager);
+      bean.setShouldReturnNullInstances(false);
+      manager.addBean(bean);
+
+      CreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+      Context sessionContext = manager.getContext(SessionScoped.class);
+      assert sessionContext.get(bean, myCreationalContext) != null;
+      assert bean.isCreateCalled();
+      
+      destroyContext(sessionContext);
+      assert bean.isDestroyCalled();
    }
 
    /**
     * A destroyed instance must not subsequently be returned by the get()
     * method.
     */
-   @Test(groups = { "contexts", "stub" })
+   @Test(groups = { "contexts", "stub", "underInvestigation" })
    @SpecAssertion(section = "8.1", id = "unknown")
    public void testDestroyedInstanceMustNotBeReturnedByGet()
    {
+      //TODO How is an instance destroyed such that the context is not and could later return the same instance
       assert false;
    }
 
@@ -144,20 +163,26 @@
     * thread upon the Context object for that scope results in a
     * ContextNotActiveException.
     */
-   @Test(groups = { "contexts", "stub" })
+   @Test(groups = { "contexts" }, expectedExceptions = { ContextNotActiveException.class })
    @SpecAssertion(section = "8.1", id = "unknown")
    public void testInvokingGetOnInactiveContextFails()
    {
-      assert false;
+      deployBeans(MySessionBean.class);
+      Context sessionContext = manager.getContext(SessionScoped.class);
+      assert sessionContext.isActive();
+      setContextInactive(sessionContext);
+
+      Contextual<MySessionBean> mySessionBean = manager.resolveByType(MySessionBean.class).iterator().next();
+      sessionContext.get(mySessionBean);
    }
 
    /**
     * There may be no more than one mapped instance per contextual type per
     * thread
     */
-   @Test(groups = { "contexts", "stub" })
+   @Test(groups = { "contexts", "stub", "underInvestigation" })
    @SpecAssertion(section = "8.1", id = "unknown")
-   public void testOnlyMappedInstancePerContextualTypePerThread()
+   public void testOnlyOneMappedInstancePerContextualTypePerThread()
    {
       assert false;
    }

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/DisposalMethodDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/DisposalMethodDefinitionTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/producer/method/DisposalMethodDefinitionTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -14,7 +14,7 @@
    @Test(groups="stub") @SpecAssertion(section="4.2", id = "unknown")
    public void testNonStaticDisposalMethodNotInherited()
    {
-      
+      assert false;
    }
    
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/SimpleBeanDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/SimpleBeanDefinitionTest.java	2009-02-02 11:18:04 UTC (rev 1380)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/implementation/simple/SimpleBeanDefinitionTest.java	2009-02-02 12:17:11 UTC (rev 1381)
@@ -101,7 +101,7 @@
    @Test(groups="stub")
    public void testEjbsNotDiscoveredAsSimpleBean()
    {
-      
+      assert false;
    }
    
    @Test(groups={"stub", "producerMethod", "webbeansxml"}) 




More information about the weld-commits mailing list