[webbeans-commits] Webbeans SVN: r2856 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle: fail2 and 3 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Jun 19 00:37:45 EDT 2009


Author: dan.j.allen
Date: 2009-06-19 00:37:45 -0400 (Fri, 19 Jun 2009)
New Revision: 2856

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/AddDefinitionErrorTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/BeanDiscoveryObserver.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/AddDeploymentProblemTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/BeanDiscoveryObserver.java
Modified:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail2/AfterBeanDiscoveryFailureTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail4/AfterDeploymentValidationObserverExecutionFailureTest.java
Log:
add tests to verify definition and deployment errors added by observers are queued, then wrapped in appropriate error

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail2/AfterBeanDiscoveryFailureTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail2/AfterBeanDiscoveryFailureTest.java	2009-06-19 04:36:43 UTC (rev 2855)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail2/AfterBeanDiscoveryFailureTest.java	2009-06-19 04:37:45 UTC (rev 2856)
@@ -57,10 +57,8 @@
    @AfterClass(alwaysRun = true, groups = "scaffold")
    public void afterClass() throws Exception
    {
-      boolean initialized = BeanDiscoveryObserver.isManagerInitialized();
-      // make sure that the artifact gets undeployed
       super.afterClass();
-      assert initialized;
+      assert BeanDiscoveryObserver.isManagerInitialized();
    }
    
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail4/AfterDeploymentValidationObserverExecutionFailureTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail4/AfterDeploymentValidationObserverExecutionFailureTest.java	2009-06-19 04:36:43 UTC (rev 2855)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail4/AfterDeploymentValidationObserverExecutionFailureTest.java	2009-06-19 04:37:45 UTC (rev 2856)
@@ -25,8 +25,8 @@
 import org.testng.annotations.Test;
 
 /**
- * Tests that any failure in an observer observing the @AfterDependencyValidation
- * event results in a DeploymentException.
+ * Tests that any failure in an observer observing the AfterDeploymentValidation
+ * event results in a deployment error.
  * 
  * Spec version: 20090519
  * 

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/AddDefinitionErrorTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/AddDefinitionErrorTest.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/AddDefinitionErrorTest.java	2009-06-19 04:37:45 UTC (rev 2856)
@@ -0,0 +1,38 @@
+package org.jboss.jsr299.tck.tests.deployment.lifecycle.fail5;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.api.DefinitionError;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests that any definition error added by an observer of the AfterBeanDiscovery
+ * event results in a definition error.
+ * 
+ * Spec version: 20090519
+ * 
+ * @author David Allen
+ * @author Dan Allen
+ */
+ at Artifact
+ at ExpectedDeploymentException(DefinitionError.class)
+public class AddDefinitionErrorTest extends AbstractJSR299Test
+{
+   @Test
+   @SpecAssertion(section = "11.5.2", id = "c")
+   public void testObserverDefinitionErrorTreatedAsDefinitionError()
+   {
+      assert false;
+   }
+   
+   @Override
+   @AfterClass(alwaysRun = true, groups = "scaffold")
+   public void afterClass() throws Exception
+   {
+      super.afterClass();
+      assert BeanDiscoveryObserver.getInvocationCount() == 2 : "All AfterBeanDiscovery observer methods should have been called";
+   }
+}
\ No newline at end of file

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/BeanDiscoveryObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/BeanDiscoveryObserver.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail5/BeanDiscoveryObserver.java	2009-06-19 04:37:45 UTC (rev 2856)
@@ -0,0 +1,26 @@
+package org.jboss.jsr299.tck.tests.deployment.lifecycle.fail5;
+
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.event.Observes;
+
+class BeanDiscoveryObserver
+{
+   private static int invocationCount = 0;
+   
+   public void afterBeanDiscovery(@Observes AfterBeanDiscovery event)
+   {
+      event.addDefinitionError(new AssertionError("This error should be treated as a definition error"));
+      invocationCount++;
+   }
+   
+   public void alsoAfterBeanDiscovery(@Observes AfterBeanDiscovery event)
+   {
+      event.addDefinitionError(new AssertionError("This error should also be treated as a definition error"));
+      invocationCount++;
+   }
+   
+   public static int getInvocationCount()
+   {
+      return invocationCount;
+   }
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/AddDeploymentProblemTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/AddDeploymentProblemTest.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/AddDeploymentProblemTest.java	2009-06-19 04:37:45 UTC (rev 2856)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.deployment.lifecycle.fail6;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.api.DeploymentError;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests that a deployment error registered by an observer of the AfterDeploymentValidation
+ * event results in a deployment error, but that all observers that observe this event
+ * are still called.
+ * 
+ * Spec version: 20090519
+ * 
+ * @author David Allen
+ * @author Dan Allen
+ */
+ at Artifact
+ at ExpectedDeploymentException(DeploymentError.class)
+public class AddDeploymentProblemTest extends AbstractJSR299Test
+{
+   @Test
+   @SpecAssertion(section = "11.5.3", id = "b")
+   public void testObserverDeploymentProblemTreatedAsDeploymentError()
+   {
+      assert false;
+   }
+
+   @Override
+   @AfterClass(alwaysRun = true, groups = "scaffold")
+   public void afterClass() throws Exception
+   {
+      super.afterClass();
+      assert BeanDiscoveryObserver.getInvocationCount() == 2 : "All AfterDeploymentValidation observer methods should have been called";
+   }
+   
+}

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/BeanDiscoveryObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/BeanDiscoveryObserver.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/fail6/BeanDiscoveryObserver.java	2009-06-19 04:37:45 UTC (rev 2856)
@@ -0,0 +1,26 @@
+package org.jboss.jsr299.tck.tests.deployment.lifecycle.fail6;
+
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.event.Observes;
+
+class BeanDiscoveryObserver
+{
+   private static int invocationCount = 0;
+   
+   public void afterDeploymentValidation(@Observes AfterDeploymentValidation event)
+   {
+      event.addDeploymentProblem(new AssertionError("This error should be treated as a deployment error"));
+      invocationCount++;
+   }
+   
+   public void alsoAfterDeploymentValidation(@Observes AfterDeploymentValidation event)
+   {
+      event.addDeploymentProblem(new AssertionError("This error should also be treated as a deployment error"));
+      invocationCount++;
+   }
+   
+   public static int getInvocationCount()
+   {
+      return invocationCount;
+   }
+}




More information about the weld-commits mailing list