[webbeans-commits] Webbeans SVN: r1397 - in tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit: definition/deployment and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Feb 3 17:14:04 EST 2009


Author: dallen6
Date: 2009-02-03 17:14:04 -0500 (Tue, 03 Feb 2009)
New Revision: 1397

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/definition/deployment/DeploymentTypeDefinitionTest.java
Log:
Verified tests are at PRD2 version.

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-03 15:47:47 UTC (rev 1396)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/NormalContextTest.java	2009-02-03 22:14:04 UTC (rev 1397)
@@ -6,6 +6,7 @@
 import javax.context.Contextual;
 import javax.context.CreationalContext;
 import javax.context.SessionScoped;
+import javax.inject.manager.Bean;
 
 import org.jboss.webbeans.tck.AbstractTest;
 import org.jboss.webbeans.tck.impl.SpecAssertion;
@@ -43,11 +44,13 @@
    public void testGetReturnsExistingInstance()
    {
       deployBeans(MySessionBean.class);
-      MySessionBean beanInstance = manager.getInstanceByType(MySessionBean.class);
 
       Contextual<MySessionBean> mySessionBean = manager.resolveByType(MySessionBean.class).iterator().next();
+      MyCreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+      MySessionBean beanInstance = manager.getContext(SessionScoped.class).get(mySessionBean, myCreationalContext);
+      assert beanInstance != null;
       MySessionBean beanInstanceFromGet = manager.getContext(SessionScoped.class).get(mySessionBean);
-      assert beanInstanceFromGet.equals(beanInstance);
+      assert beanInstanceFromGet == beanInstance;
    }
 
    /**
@@ -150,12 +153,28 @@
     * A destroyed instance must not subsequently be returned by the get()
     * method.
     */
-   @Test(groups = { "contexts", "stub", "underInvestigation" })
+   @Test(groups = { "contexts", "broken" })
    @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;
+      deployBeans(MySessionBean.class, MyApplicationBean.class);
+      Bean<MySessionBean> mySessionBean = manager.resolveByType(MySessionBean.class).iterator().next();
+      MyCreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+      MySessionBean beanInstance = manager.getContext(SessionScoped.class).get(mySessionBean, myCreationalContext);
+      assert beanInstance != null;
+      mySessionBean.destroy(beanInstance);
+      MySessionBean beanInstanceFromGet = manager.getContext(SessionScoped.class).get(mySessionBean);
+      assert beanInstanceFromGet != beanInstance;
+      
+      Bean<MyApplicationBean> myApplicationBean = manager.resolveByType(MyApplicationBean.class).iterator().next();
+      MyCreationalContext<MyApplicationBean> myCreationalContextForApplication = new MyCreationalContext<MyApplicationBean>();
+      MyApplicationBean myApplicationBeanInstance = manager.getContext(ApplicationScoped.class).get(myApplicationBean, myCreationalContextForApplication);
+      assert myApplicationBeanInstance != null;
+      myApplicationBean.destroy(myApplicationBeanInstance);
+      
+      MyApplicationBean mySecondApplicationBeanInstance = manager.getContext(ApplicationScoped.class).get(myApplicationBean);
+      assert mySecondApplicationBeanInstance != null;
+      assert myApplicationBeanInstance != mySecondApplicationBeanInstance;
    }
 
    /**

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/definition/deployment/DeploymentTypeDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/definition/deployment/DeploymentTypeDefinitionTest.java	2009-02-03 15:47:47 UTC (rev 1396)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/definition/deployment/DeploymentTypeDefinitionTest.java	2009-02-03 22:14:04 UTC (rev 1397)
@@ -1,7 +1,6 @@
 package org.jboss.webbeans.tck.unit.definition.deployment;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
 import java.util.List;
 
 import javax.inject.DefinitionException;
@@ -17,12 +16,12 @@
 
 /**
  * 
- * Spec version: PRD2
- *
+ * Spec version: Public Release Draft 2
+ * 
  */
 public class DeploymentTypeDefinitionTest extends AbstractTest
 {
-   
+
    @Override
    protected List<Class<? extends Annotation>> getEnabledDeploymentTypes()
    {
@@ -30,151 +29,240 @@
       deploymentTypes.add(AnotherDeploymentType.class);
       deploymentTypes.add(HornedAnimalDeploymentType.class);
       deploymentTypes.add(NotInheritedDeploymentType.class);
+      deploymentTypes.add(InheritedDeploymentType.class);
       return deploymentTypes;
    }
-   
-   @Test(expectedExceptions=DefinitionException.class) 
-   @SpecAssertion(section="2.5.1", id = "unknown")
+
+   /**
+    * No bean may be declared with the (@Standard-bean) deployment type unless
+    * explicitly required by this specification.
+    */
+   @Test(groups = { "deploymentType" }, expectedExceptions = DefinitionException.class)
+   @SpecAssertion(section = "2.5.1", id = "unknown")
    public void testNonBuiltInComponentUsesStandard()
    {
-      createSimpleBean(Gazelle_Broken.class);
+      deployBeans(Gazelle_Broken.class);
    }
-   
-   @Test(groups={"stub", "annotationDefinition"}) 
-   @SpecAssertion(section="2.5.2", id = "unknown")
+
+   /**
+    * A deployment type is a Java annotation defined as @Target({TYPE, METHOD,
+    * FIELD}) and @Retention(RUNTIME).
+    * 
+    * TODO This text is not really a testable assertion
+    */
+   @Test(groups = { "stub", "annotationDefinition", "deploymentType" })
+   @SpecAssertion(section = "2.5.2", id = "unknown")
    public void testDeploymentTypeHasCorrectTarget()
    {
       assert false;
    }
 
-   @Test(groups={"stub", "annotationDefinition"}) 
-   @SpecAssertion(section="2.5.2", id = "unknown")
+   /**
+    * A deployment type is a Java annotation defined as @Target({TYPE, METHOD,
+    * FIELD}) and @Retention(RUNTIME).
+    * 
+    * TODO This text is not really a testable assertion
+    */
+   @Test(groups = { "stub", "annotationDefinition", "deploymentType" })
+   @SpecAssertion(section = "2.5.2", id = "unknown")
    public void testDeploymentTypeHasCorrectRetention()
    {
       assert false;
    }
 
-   @Test(groups={"stub", "annotationDefinition"}) 
-   @SpecAssertion(section="2.5.2", id = "unknown")
-   public void testDeploymentTypeDeclaresScopeTypeAnnotation()
+   /**
+    * All de- ployment types must also specify the @javax.inject.DeploymentType
+    * meta-annotation.
+    * 
+    * TODO This text is not really a testable assertion
+    */
+   @Test(groups = { "stub", "annotationDefinition", "deploymentType" })
+   @SpecAssertion(section = "2.5.2", id = "unknown")
+   public void testDeploymentTypeDeclaresDeploymentTypeAnnotation()
    {
       assert false;
    }
-   
-   @Test(expectedExceptions=DefinitionException.class) 
-   @SpecAssertion(section="2.5.3", id = "unknown")
+
+   /**
+    * An bean class or producer method or field may specify at most one
+    * deployment type. If multiple deployment type annotations are specified, a
+    * DefinitionException is thrown by the container at deployment time.
+    */
+   @Test(groups = { "deploymentType" }, expectedExceptions = DefinitionException.class)
+   @SpecAssertion(section = "2.5.3", id = "unknown")
    public void testTooManyDeploymentTypes()
    {
-      createSimpleBean(BeanWithTooManyDeploymentTypes_Broken.class);
+      deployBeans(BeanWithTooManyDeploymentTypes_Broken.class);
    }
-   
-   @SuppressWarnings("unchecked")
-   @Test @SpecAssertion(section="2.5.3", id = "unknown")
+
+   /**
+    * By default, if no deployment type annotation is explicitly specified, a
+    * producer method or field inherits the deployment type of the bean in which
+    * it is defined.
+    * 
+    * @throws Exception
+    */
+   @Test(groups = { "deploymentType" })
+   @SpecAssertion(section = "2.5.3", id = "unknown")
    public void testDeploymentTypeInhertitedFromDeclaringBean() throws Exception
    {
-      Bean<SpiderProducer> bean = createSimpleBean(SpiderProducer.class);
-      manager.addBean(bean);
-      Method method = SpiderProducer.class.getMethod("produceBlackWidow");
-      Bean<BlackWidow> blackWidowSpiderModel = createProducerMethodBean(method, bean);
+      deployBeans(SpiderProducer.class);
+      Bean<BlackWidow> blackWidowSpiderModel = manager.resolveByType(BlackWidow.class).iterator().next();
       assert blackWidowSpiderModel.getDeploymentType().equals(AnotherDeploymentType.class);
    }
-   
-   @Test(groups={"stub", "webbeansxml"}) 
-   @SpecAssertion(section="2.5.4", id = "unknown")
-   public void testXmlDeploymentTypeOverridesJava()
+
+   /**
+    * When a bean is declared in beans.xml, the deployment type may be specified
+    * using a tag with the annotation type name:
+    * 
+    * TODO Section 2.5.4 does not claim that XML overrides Java for deployment
+    * types
+    */
+   @Test(groups = { "stub", "webbeansxml", "deploymentType" })
+   @SpecAssertion(section = "2.5.4", id = "unknown")
+   public void testXmlDeploymentTypeElement()
    {
-      //Map<Class<? extends Annotation>, Annotation> xmlDefinedDeploymentTypeAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
-      //xmlDefinedDeploymentTypeAnnotations.put(AnotherDeploymentType.class, new AnotherDeploymentTypeAnnotationLiteral());
-      //AnnotatedClass<BeanWithTooManyDeploymentTypes> xmlDefinedDeploymentTypeAnnotatedItem = new SimpleAnnotatedClass<BeanWithTooManyDeploymentTypes>(BeanWithTooManyDeploymentTypes.class, xmlDefinedDeploymentTypeAnnotations);
-      
-      //SimpleBean<BeanWithTooManyDeploymentTypes> model = createSimpleBean(BeanWithTooManyDeploymentTypes.class, xmlDefinedDeploymentTypeAnnotatedItem, manager);
-      //assert model.getDeploymentType().equals(AnotherDeploymentType.class);
+      // Map<Class<? extends Annotation>, Annotation>
+      // xmlDefinedDeploymentTypeAnnotations = new HashMap<Class<? extends
+      // Annotation>, Annotation>();
+      // xmlDefinedDeploymentTypeAnnotations.put(AnotherDeploymentType.class,
+      // new AnotherDeploymentTypeAnnotationLiteral());
+      // AnnotatedClass<BeanWithTooManyDeploymentTypes>
+      // xmlDefinedDeploymentTypeAnnotatedItem = new
+      // SimpleAnnotatedClass<BeanWithTooManyDeploymentTypes>(BeanWithTooManyDeploymentTypes.class,
+      // xmlDefinedDeploymentTypeAnnotations);
+
+      // SimpleBean<BeanWithTooManyDeploymentTypes> model =
+      // createSimpleBean(BeanWithTooManyDeploymentTypes.class,
+      // xmlDefinedDeploymentTypeAnnotatedItem, manager);
+      // assert model.getDeploymentType().equals(AnotherDeploymentType.class);
       assert false;
    }
-   
 
-   
-   @Test(groups={"stub", "webbeansxml"}) 
-   @SpecAssertion(section="2.5.4", id = "unknown")
-   public void testXmlRespectsJavaDeploymentType()
+   /**
+    * The default deployment type for a bean which does not explicitly declare a
+    * deployment type depends upon its declared stereotypes:
+    * 
+    * • If a bean does not declare any stereotype with a declared default
+    * deployment type, then the default deployment type is (@Production-bean).
+    * 
+    */
+   @Test(groups = { "webbeansxml", "deploymentType" })
+   @SpecAssertion(section = "2.5.5", id = "unknown")
+   public void testDefaultDeploymentType()
    {
-      //AnnotatedClass<Tuna> annotatedItem = new SimpleAnnotatedClass<Tuna>(Tuna.class, new HashMap<Class<? extends Annotation>, Annotation>());
-      //SimpleBean<Tuna> tuna = createSimpleBean(Tuna.class, annotatedItem, manager);
-      //assert tuna.getDeploymentType().equals(AnotherDeploymentType.class);
-      assert false;
+      deployBeans(BlackWidow.class);
+      Bean<BlackWidow> bean = manager.resolveByType(BlackWidow.class).iterator().next();
+      assert bean.getDeploymentType().equals(Production.class);
    }
-   
-   @Test(groups={"stub", "webbeansxml"}) 
-   @SpecAssertion(section="2.5.5", id = "unknown")
-   public void testXmlDefaultDeploymentType()
-   {
-      //AnnotatedClass<Antelope> antelopeAnnotatedItem = new SimpleAnnotatedClass<Antelope>(Antelope.class, new HashMap<Class<? extends Annotation>, Annotation>());
-      //SimpleBean<Antelope> antelope = createSimpleBean(Antelope.class, antelopeAnnotatedItem, manager);
-      // assert antelope.getDeploymentType().equals(Production.class);
-      assert false;
-   }
-   
-   @Test @SpecAssertion(section="2.5.5", id = "unknown")
+
+   /**
+    * • Otherwise, the default deployment type for the bean is the
+    * highest-precedence default deployment type declared by any stereotype
+    * declared by the bean.
+    */
+   @Test(groups = { "deploymentType" })
+   @SpecAssertion(section = "2.5.5", id = "unknown")
    public void testHighestPrecedenceDeploymentTypeFromStereotype()
    {
-      Bean<?> bean = createSimpleBean(Rhinoceros.class);
+      deployBeans(Rhinoceros.class);
+      Bean<?> bean = manager.resolveByType(Rhinoceros.class).iterator().next();
       assert bean.getDeploymentType().equals(HornedAnimalDeploymentType.class);
    }
-   
-   @SuppressWarnings("unchecked")
-   @Test(groups="beanLifecycle", expectedExceptions=UnsatisfiedDependencyException.class) 
-   @SpecAssertion(section="2.5.6", id = "unknown")
+
+   /**
+    * If the deployment type is enabled, an instance of the bean may be obtained
+    * by lookup, injection or EL resolution. Otherwise, the bean is never
+    * instantiated by the container.
+    */
+   @Test(groups = { "beanLifecycle", "deploymentType" }, expectedExceptions = UnsatisfiedDependencyException.class)
+   @SpecAssertion(section = "2.5.6", id = "unknown")
    public void testBeanWithDisabledDeploymentTypeNotInstantiated()
-   {    
-      Bean<RedSnapper> bean = createSimpleBean(RedSnapper.class);
-      manager.addBean(bean);
+   {
+      deployBeans(RedSnapper.class);
       manager.getInstanceByType(RedSnapper.class);
    }
 
-
-   
-
-   @Test(groups={"stub", "webbeansxml"}, expectedExceptions=DeploymentException.class) 
-   @SpecAssertion(section="2.5.6", id = "unknown")
+   /**
+    * If more than one deployment type is specified in XML, a
+    * DefinitionException is thrown by the container at deployment time.
+    */
+   @Test(groups = { "stub", "webbeansxml", "deploymentType" }, expectedExceptions = DeploymentException.class)
+   @SpecAssertion(section = "2.5.4", id = "unknown")
    public void testMultipleDeployElementsCannotBeDefined()
    {
-      
+
    }
-   
-   @Test 
-   @SpecAssertions({
-      @SpecAssertion(section= "2.5.5", id = "unknown"),
-      @SpecAssertion(section = "2.7.2", id = "unknown"),
-      @SpecAssertion(section = "4.1", id = "unknown")
-   })
+
+   /**
+    * If a bean explicitly declares a deployment type, any default deployment
+    * type declared by stereotypes are ignored.
+    */
+   @Test(groups = { "deploymentType" })
+   @SpecAssertions( { @SpecAssertion(section = "2.5.5", id = "unknown"), @SpecAssertion(section = "2.7.2", id = "unknown"), @SpecAssertion(section = "4.1", id = "unknown") })
    public void testWebBeanDeploymentTypeOverridesStereotype()
    {
-      Bean<Reindeer> bean = createSimpleBean(Reindeer.class);
+      deployBeans(Reindeer.class);
+      Bean<Reindeer> bean = manager.resolveByType(Reindeer.class).iterator().next();
       assert bean.getDeploymentType().equals(Production.class);
    }
-   
-   @Test @SpecAssertion(section="4.1", id = "unknown")
+
+   /**
+    * If X is annotated with a deployment type Z then Y inherits the annotation
+    * if and only if Z declares the @Inherited meta-annotation and neither Y nor
+    * any intermediate class that is a subclass of X and a superclass of Y
+    * declares a deployment type.
+    * 
+    * @throws Exception
+    */
+   @Test(groups = { "deploymentType" })
+   @SpecAssertion(section = "4.1", id = "unknown")
    public void testDeploymentTypeDeclaredInheritedIsInherited() throws Exception
    {
-      assert createSimpleBean(BorderCollie.class).getDeploymentType().equals(AnotherDeploymentType.class);
+      deployBeans(BorderCollie.class);
+      assert manager.resolveByType(BorderCollie.class).iterator().next().getDeploymentType().equals(AnotherDeploymentType.class);
    }
-   
-   @Test @SpecAssertion(section="4.1", id = "unknown")
+
+   /**
+    * If X is annotated with a deployment type Z then Y inherits the annotation
+    * if and only if Z declares the @Inherited meta-annotation and neither Y nor
+    * any intermediate class that is a subclass of X and a superclass of Y
+    * declares a deployment type.
+    */
+   @Test(groups = { "deploymentType" })
+   @SpecAssertion(section = "4.1", id = "unknown")
    public void testDeploymentTypeNotDeclaredInheritedIsNotInherited()
    {
-      assert createSimpleBean(ShetlandPony.class).getDeploymentType().equals(Production.class);
+      deployBeans(ShetlandPony.class);
+      assert manager.resolveByType(ShetlandPony.class).iterator().next().getDeploymentType().equals(Production.class);
    }
-   
-   @Test @SpecAssertion(section="4.1", id = "unknown")
+
+   /**
+    * If X is annotated with a deployment type Z then Y inherits the annotation
+    * if and only if Z declares the @Inherited meta-annotation and neither Y nor
+    * any intermediate class that is a subclass of X and a superclass of Y
+    * declares a deployment type.
+    */
+   @Test(groups = { "deploymentType" })
+   @SpecAssertion(section = "4.1", id = "unknown")
    public void testDeploymentTypeDeclaredInheritedIsBlockedByIntermediateDeploymentTypeNotMarkedInherited()
    {
-      assert createSimpleBean(GoldenRetriever.class).getDeploymentType().equals(Production.class);
+      deployBeans(GoldenRetriever.class);
+      assert manager.resolveByType(GoldenRetriever.class).iterator().next().getDeploymentType().equals(Production.class);
    }
-   
-   @Test @SpecAssertion(section="4.1", id = "unknown")
+
+   /**
+    * If X is annotated with a deployment type Z then Y inherits the annotation
+    * if and only if Z declares the @Inherited meta-annotation and neither Y nor
+    * any intermediate class that is a subclass of X and a superclass of Y
+    * declares a deployment type.
+    */
+   @Test(groups = { "deploymentType" })
+   @SpecAssertion(section = "4.1", id = "unknown")
    public void testDeploymentTypeDeclaredInheritedIsBlockedByIntermediateDeploymentTypeMarkedInherited()
    {
-      assert createSimpleBean(GoldenLabrador.class).getDeploymentType().equals(InheritedDeploymentType.class);
+      deployBeans(GoldenLabrador.class);
+      assert manager.resolveByType(GoldenLabrador.class).iterator().next().getDeploymentType().equals(InheritedDeploymentType.class);
    }
-   
+
 }




More information about the weld-commits mailing list