[weld-commits] Weld SVN: r4542 - in cdi-tck/trunk/impl/src/main: resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Mon Nov 2 08:36:31 EST 2009


Author: jharting
Date: 2009-11-02 08:36:30 -0500 (Mon, 02 Nov 2009)
New Revision: 4542

Added:
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/SecureLiteral.java
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/SimpleInterceptorWithoutAnnotations.java
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/TransactionalLiteral.java
Removed:
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/InterceptorClass.java
Modified:
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/AfterBeanDiscoveryObserver.java
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorImplementation.java
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorTest.java
   cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/beans.xml
Log:
Tests for section 9.5

Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/AfterBeanDiscoveryObserver.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/AfterBeanDiscoveryObserver.java	2009-11-02 13:28:40 UTC (rev 4541)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/AfterBeanDiscoveryObserver.java	2009-11-02 13:36:30 UTC (rev 4542)
@@ -3,12 +3,24 @@
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.Extension;
+import static javax.enterprise.inject.spi.InterceptionType.*;
 
 
 public class AfterBeanDiscoveryObserver implements Extension
 {
+   public static final CustomInterceptorImplementation POST_CONSTRUCT_INTERCEPTOR = new CustomInterceptorImplementation(POST_CONSTRUCT);
+   public static final CustomInterceptorImplementation PRE_DESTROY_INTERCEPTOR = new CustomInterceptorImplementation(PRE_DESTROY);
+   public static final CustomInterceptorImplementation POST_ACTIVATE_INTERCEPTOR = new CustomInterceptorImplementation(POST_ACTIVATE);
+   public static final CustomInterceptorImplementation PRE_PASSIVATE_INTERCEPTOR = new CustomInterceptorImplementation(PRE_PASSIVATE);
+   public static final CustomInterceptorImplementation AROUND_INVOKE_INTERCEPTOR = new CustomInterceptorImplementation(AROUND_INVOKE);
+   public static final CustomInterceptorImplementation AROUND_TIMEOUT_INTERCEPTOR = new CustomInterceptorImplementation(AROUND_TIMEOUT);
+   
    public void addInterceptors(@Observes AfterBeanDiscovery event) {
-      event.addBean(new CustomInterceptorImplementation());
+      event.addBean(POST_CONSTRUCT_INTERCEPTOR);
+      event.addBean(PRE_DESTROY_INTERCEPTOR);
+      event.addBean(POST_ACTIVATE_INTERCEPTOR);
+      event.addBean(PRE_PASSIVATE_INTERCEPTOR);
+      event.addBean(AROUND_INVOKE_INTERCEPTOR);
+      event.addBean(AROUND_TIMEOUT_INTERCEPTOR);
    }
-
 }

Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorImplementation.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorImplementation.java	2009-11-02 13:28:40 UTC (rev 4541)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorImplementation.java	2009-11-02 13:36:30 UTC (rev 4542)
@@ -14,13 +14,17 @@
 import javax.enterprise.util.AnnotationLiteral;
 import javax.interceptor.InvocationContext;
 
-class CustomInterceptorImplementation implements Interceptor<InterceptorClass>
+class CustomInterceptorImplementation implements Interceptor<SimpleInterceptorWithoutAnnotations>
 {
 
    private Set<Annotation> interceptorBindingTypes = new HashSet<Annotation>();
+   private InterceptionType type;
+   private boolean getInterceptorBindingsCalled = false;
+   private boolean interceptsCalled = false;
 
-   public CustomInterceptorImplementation()
+   public CustomInterceptorImplementation(InterceptionType type)
    {
+      this.type = type;
       interceptorBindingTypes.add(new AnnotationLiteral<Secure>()
       {
       });
@@ -29,11 +33,6 @@
       });
    }
 
-   public Set<Annotation> getInterceptorBindings()
-   {
-      return Collections.unmodifiableSet(interceptorBindingTypes);
-   }
-
    public Set<InjectionPoint> getInjectionPoints()
    {
       return Collections.emptySet();
@@ -77,7 +76,7 @@
       return false;
    }
 
-   public Object intercept(InterceptionType type, InterceptorClass instance, InvocationContext ctx)
+   public Object intercept(InterceptionType type, SimpleInterceptorWithoutAnnotations instance, InvocationContext ctx)
    {
       try {
          return instance.intercept(ctx);
@@ -88,21 +87,39 @@
 
    public boolean intercepts(InterceptionType type)
    {
-      return type.equals(InterceptionType.AROUND_INVOKE);
+      interceptsCalled = true;
+      return this.type.equals(type);
    }
 
+   public Set<Annotation> getInterceptorBindings()
+   {
+      return Collections.unmodifiableSet(interceptorBindingTypes);
+   }
+   
    public Class<?> getBeanClass()
    {
-      return InterceptorClass.class;
+      return SimpleInterceptorWithoutAnnotations.class;
    }
 
-   public InterceptorClass create(CreationalContext<InterceptorClass> creationalContext)
+   public SimpleInterceptorWithoutAnnotations create(CreationalContext<SimpleInterceptorWithoutAnnotations> creationalContext)
    {
-      return new InterceptorClass();
+      return new SimpleInterceptorWithoutAnnotations();
    }
 
-   public void destroy(InterceptorClass instance, CreationalContext<InterceptorClass> creationalContext)
+   public void destroy(SimpleInterceptorWithoutAnnotations instance, CreationalContext<SimpleInterceptorWithoutAnnotations> creationalContext)
    {
       creationalContext.release();
    }
+
+
+   public boolean isGetInterceptorBindingsCalled()
+   {
+      return getInterceptorBindingsCalled;
+   }
+
+
+   public boolean isInterceptsCalled()
+   {
+      return interceptsCalled;
+   }
 }

Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorTest.java	2009-11-02 13:28:40 UTC (rev 4541)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorTest.java	2009-11-02 13:36:30 UTC (rev 4542)
@@ -16,8 +16,7 @@
  */
 package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
 
-import javax.enterprise.inject.spi.InterceptionType;
-import javax.enterprise.util.AnnotationLiteral;
+import static javax.enterprise.inject.spi.InterceptionType.*;
 
 import org.jboss.jsr299.tck.AbstractJSR299Test;
 import org.jboss.test.audit.annotations.SpecAssertion;
@@ -36,14 +35,62 @@
 public class CustomInterceptorTest extends AbstractJSR299Test
 {
    @Test(groups = "ri-broken")
+   @SpecAssertion(section = "9.5", id = "fa")
+   // WELD-238
+   public void testCustomPostConstructInterceptor()
+   {
+      assert !getCurrentManager().resolveInterceptors(POST_CONSTRUCT, new SecureLiteral(), new TransactionalLiteral()).isEmpty();
+      assert AfterBeanDiscoveryObserver.POST_CONSTRUCT_INTERCEPTOR.isGetInterceptorBindingsCalled();
+      assert AfterBeanDiscoveryObserver.POST_CONSTRUCT_INTERCEPTOR.isInterceptsCalled();
+   }
+   
+   @Test(groups = "ri-broken")
+   @SpecAssertion(section = "9.5", id = "fb")
+   // WELD-238
+   public void testCustomPreDestroyInterceptor()
+   {
+      assert !getCurrentManager().resolveInterceptors(PRE_DESTROY, new SecureLiteral(), new TransactionalLiteral()).isEmpty();
+      assert AfterBeanDiscoveryObserver.PRE_DESTROY_INTERCEPTOR.isGetInterceptorBindingsCalled();
+      assert AfterBeanDiscoveryObserver.PRE_DESTROY_INTERCEPTOR.isInterceptsCalled();
+   }
+   
+   @Test(groups = "ri-broken")
+   @SpecAssertion(section = "9.5", id = "fc")
+   // WELD-238
+   public void testCustomPostActivateInterceptor()
+   {
+      assert !getCurrentManager().resolveInterceptors(POST_ACTIVATE, new SecureLiteral(), new TransactionalLiteral()).isEmpty();
+      assert AfterBeanDiscoveryObserver.POST_ACTIVATE_INTERCEPTOR.isGetInterceptorBindingsCalled();
+      assert AfterBeanDiscoveryObserver.POST_ACTIVATE_INTERCEPTOR.isInterceptsCalled();
+   }
+   
+   @Test(groups = "ri-broken")
+   @SpecAssertion(section = "9.5", id = "fd")
+   // WELD-238
+   public void testCustomPrePassivateInterceptor()
+   {
+      assert !getCurrentManager().resolveInterceptors(PRE_PASSIVATE, new SecureLiteral(), new TransactionalLiteral()).isEmpty();
+      assert AfterBeanDiscoveryObserver.PRE_PASSIVATE_INTERCEPTOR.isGetInterceptorBindingsCalled();
+      assert AfterBeanDiscoveryObserver.PRE_PASSIVATE_INTERCEPTOR.isInterceptsCalled();
+   }
+   
+   @Test(groups = "ri-broken")
    @SpecAssertion(section = "9.5", id = "fe")
    // WELD-238
    public void testCustomAroundInvokeInterceptor()
    {
-      assert !getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, new AnnotationLiteral<Secure>()
-      {
-      }, new AnnotationLiteral<Transactional>()
-      {
-      }).isEmpty();
+      assert !getCurrentManager().resolveInterceptors(AROUND_INVOKE, new SecureLiteral(), new TransactionalLiteral()).isEmpty();
+      assert AfterBeanDiscoveryObserver.AROUND_INVOKE_INTERCEPTOR.isGetInterceptorBindingsCalled();
+      assert AfterBeanDiscoveryObserver.AROUND_INVOKE_INTERCEPTOR.isInterceptsCalled();
    }
+   
+   @Test(groups = "ri-broken")
+   @SpecAssertion(section = "9.5", id = "ff")
+   // WELD-238
+   public void testCustomAroundTimeoutInterceptor()
+   {
+      assert !getCurrentManager().resolveInterceptors(AROUND_TIMEOUT, new SecureLiteral(), new TransactionalLiteral()).isEmpty();
+      assert AfterBeanDiscoveryObserver.AROUND_TIMEOUT_INTERCEPTOR.isGetInterceptorBindingsCalled();
+      assert AfterBeanDiscoveryObserver.AROUND_TIMEOUT_INTERCEPTOR.isInterceptsCalled();
+   }
 }

Deleted: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/InterceptorClass.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/InterceptorClass.java	2009-11-02 13:28:40 UTC (rev 4541)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/InterceptorClass.java	2009-11-02 13:36:30 UTC (rev 4542)
@@ -1,10 +0,0 @@
-package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
-
-import javax.interceptor.InvocationContext;
-
-class InterceptorClass
-{
-   public Object intercept(InvocationContext ctx) throws Exception {
-      return ctx.proceed();
-   }
-}

Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/SecureLiteral.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/SecureLiteral.java	                        (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/SecureLiteral.java	2009-11-02 13:36:30 UTC (rev 4542)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+class SecureLiteral extends AnnotationLiteral<Secure> implements Secure
+{
+
+}

Copied: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/SimpleInterceptorWithoutAnnotations.java (from rev 4539, cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/InterceptorClass.java)
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/SimpleInterceptorWithoutAnnotations.java	                        (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/SimpleInterceptorWithoutAnnotations.java	2009-11-02 13:36:30 UTC (rev 4542)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
+
+import javax.interceptor.InvocationContext;
+
+class SimpleInterceptorWithoutAnnotations
+{
+   public Object intercept(InvocationContext ctx) throws Exception {
+      return ctx.proceed();
+   }
+}

Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/TransactionalLiteral.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/TransactionalLiteral.java	                        (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/TransactionalLiteral.java	2009-11-02 13:36:30 UTC (rev 4542)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+class TransactionalLiteral extends AnnotationLiteral<Transactional> implements Transactional
+{
+
+}

Modified: cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/beans.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/beans.xml	2009-11-02 13:28:40 UTC (rev 4541)
+++ cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/beans.xml	2009-11-02 13:36:30 UTC (rev 4542)
@@ -1,5 +1,5 @@
 <beans> 
   <interceptors>
-    <class>org.jboss.jsr299.tck.tests.interceptors.definition.custom.InterceptorClass</class>
+    <class>org.jboss.jsr299.tck.tests.interceptors.definition.custom.SimpleInterceptorWithoutAnnotations</class>
   </interceptors>
 </beans>



More information about the weld-commits mailing list