Author: jharting
Date: 2009-10-30 10:43:40 -0400 (Fri, 30 Oct 2009)
New Revision: 4451
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/
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/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/Secure.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/Transactional.java
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/
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/javax.enterprise.inject.spi.Extension
Log:
Test for custom implementation of the Interceptor interface
Added:
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
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/AfterBeanDiscoveryObserver.java 2009-10-30
14:43:40 UTC (rev 4451)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+
+public class AfterBeanDiscoveryObserver implements Extension
+{
+ public void addInterceptors(@Observes AfterBeanDiscovery event) {
+ event.addBean(new CustomInterceptorImplementation());
+ }
+
+}
Added:
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
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorImplementation.java 2009-10-30
14:43:40 UTC (rev 4451)
@@ -0,0 +1,108 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InterceptionType;
+import javax.enterprise.inject.spi.Interceptor;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.interceptor.InvocationContext;
+
+class CustomInterceptorImplementation implements Interceptor<InterceptorClass>
+{
+
+ private Set<Annotation> interceptorBindingTypes = new
HashSet<Annotation>();
+
+ public CustomInterceptorImplementation()
+ {
+ interceptorBindingTypes.add(new AnnotationLiteral<Secure>()
+ {
+ });
+ interceptorBindingTypes.add(new AnnotationLiteral<Transactional>()
+ {
+ });
+ }
+
+ public Set<Annotation> getInterceptorBindingTypes()
+ {
+ return Collections.unmodifiableSet(interceptorBindingTypes);
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ public String getName()
+ {
+ return null;
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+ return Collections.emptySet();
+ }
+
+ public Class<? extends Annotation> getScope()
+ {
+ return Dependent.class;
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+ public Set<Type> getTypes()
+ {
+ Set<Type> types = new HashSet<Type>();
+ types.add(Object.class);
+ types.add(getBeanClass());
+ return types;
+ }
+
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ public boolean isNullable()
+ {
+ return false;
+ }
+
+ public Object intercept(InterceptionType type, InterceptorClass instance,
InvocationContext ctx)
+ {
+ try {
+ return instance.intercept(ctx);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public boolean intercepts(InterceptionType type)
+ {
+ return type.equals(InterceptionType.AROUND_INVOKE);
+ }
+
+ public Class<?> getBeanClass()
+ {
+ return InterceptorClass.class;
+ }
+
+ public InterceptorClass create(CreationalContext<InterceptorClass>
creationalContext)
+ {
+ return new InterceptorClass();
+ }
+
+ public void destroy(InterceptorClass instance,
CreationalContext<InterceptorClass> creationalContext)
+ {
+ creationalContext.release();
+ }
+}
Added:
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
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/CustomInterceptorTest.java 2009-10-30
14:43:40 UTC (rev 4451)
@@ -0,0 +1,49 @@
+/*
+ * 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.interceptors.definition.custom;
+
+import javax.enterprise.inject.spi.InterceptionType;
+import javax.enterprise.util.AnnotationLiteral;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+@Artifact
+@SpecVersion(spec = "cdi", version = "20091018")
+@Resource(source = "javax.enterprise.inject.spi.Extension", destination =
"WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension")
+@IntegrationTest
+(a)BeansXml("beans.xml")
+public class CustomInterceptorTest extends AbstractJSR299Test
+{
+ @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();
+ }
+}
Added:
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
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/InterceptorClass.java 2009-10-30
14:43:40 UTC (rev 4451)
@@ -0,0 +1,10 @@
+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/Secure.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/Secure.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/Secure.java 2009-10-30
14:43:40 UTC (rev 4451)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@InterceptorBinding
+@interface Secure
+{
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/Transactional.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/Transactional.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/custom/Transactional.java 2009-10-30
14:43:40 UTC (rev 4451)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.custom;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@InterceptorBinding
+@interface Transactional
+{
+
+}
Added:
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
(rev 0)
+++
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/beans.xml 2009-10-30
14:43:40 UTC (rev 4451)
@@ -0,0 +1,5 @@
+<beans>
+ <interceptors>
+
<class>org.jboss.jsr299.tck.tests.interceptors.definition.custom.InterceptorClass</class>
+ </interceptors>
+</beans>
Added:
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/javax.enterprise.inject.spi.Extension
===================================================================
---
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/javax.enterprise.inject.spi.Extension
(rev 0)
+++
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/custom/javax.enterprise.inject.spi.Extension 2009-10-30
14:43:40 UTC (rev 4451)
@@ -0,0 +1 @@
+org.jboss.jsr299.tck.tests.interceptors.definition.custom.AfterBeanDiscoveryObserver
\ No newline at end of file