Author: jharting
Date: 2009-10-30 10:25:03 -0400 (Fri, 30 Oct 2009)
New Revision: 4446
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/AnimalCountInterceptorBinding.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/DecreasingInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/Farm.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/IncreasingInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/InterceptorBindingTypeWithMemberTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/VehicleCountInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/VehicleCountInterceptorBinding.java
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/member/
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/member/beans.xml
Modified:
cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
Tests for section 9.5.2
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/AnimalCountInterceptorBinding.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/AnimalCountInterceptorBinding.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/AnimalCountInterceptorBinding.java 2009-10-30
14:25:03 UTC (rev 4446)
@@ -0,0 +1,24 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.member;
+
+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 AnimalCountInterceptorBinding
+{
+ Operation value();
+
+ enum Operation {
+ INCREASE, DECREASE
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/DecreasingInterceptor.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/DecreasingInterceptor.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/DecreasingInterceptor.java 2009-10-30
14:25:03 UTC (rev 4446)
@@ -0,0 +1,26 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.member;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+import
org.jboss.jsr299.tck.tests.interceptors.definition.member.AnimalCountInterceptorBinding.Operation;
+
+@Interceptor
+(a)AnimalCountInterceptorBinding(Operation.DECREASE)
+class DecreasingInterceptor
+{
+ private static boolean intercepted = false;
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ intercepted = true;
+ return ((Integer) ctx.proceed()) - 10;
+ }
+
+ public static boolean isIntercepted()
+ {
+ return intercepted;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/Farm.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/Farm.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/Farm.java 2009-10-30
14:25:03 UTC (rev 4446)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.member;
+
+import
org.jboss.jsr299.tck.tests.interceptors.definition.member.AnimalCountInterceptorBinding.Operation;
+
+class Farm
+{
+ @AnimalCountInterceptorBinding(Operation.INCREASE)
+ public int getAnimalCount() {
+ return 10;
+ }
+
+ @VehicleCountInterceptorBinding(comment = "foo")
+ public int getVehicleCount() {
+ return 10;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/IncreasingInterceptor.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/IncreasingInterceptor.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/IncreasingInterceptor.java 2009-10-30
14:25:03 UTC (rev 4446)
@@ -0,0 +1,26 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.member;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+import
org.jboss.jsr299.tck.tests.interceptors.definition.member.AnimalCountInterceptorBinding.Operation;
+
+@Interceptor
+(a)AnimalCountInterceptorBinding(Operation.INCREASE)
+class IncreasingInterceptor
+{
+ private static boolean intercepted = false;
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ intercepted = true;
+ return ((Integer) ctx.proceed()) + 10;
+ }
+
+ public static boolean isIntercepted()
+ {
+ return intercepted;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/InterceptorBindingTypeWithMemberTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/InterceptorBindingTypeWithMemberTest.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/InterceptorBindingTypeWithMemberTest.java 2009-10-30
14:25:03 UTC (rev 4446)
@@ -0,0 +1,52 @@
+/*
+ * 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.member;
+
+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.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for interceptor bindings types with members.
+ * @author Jozef Hartinger
+ *
+ */
+@Artifact
+@SpecVersion(spec="cdi", version="20091018")
+(a)BeansXml("beans.xml")
+public class InterceptorBindingTypeWithMemberTest extends AbstractJSR299Test
+{
+ @Test
+ @SpecAssertion(section = "9.5.2", id = "a")
+ public void testInterceptorBindingTypeWithMember() {
+ Farm farm = getInstanceByType(Farm.class);
+ assert farm.getAnimalCount() == 20;
+ assert IncreasingInterceptor.isIntercepted();
+ assert !DecreasingInterceptor.isIntercepted();
+ }
+
+ @Test
+ @SpecAssertion(section = "9.5.2", id = "b")
+ public void testInterceptorBindingTypeWithNonBindingMember() {
+ Farm farm = getInstanceByType(Farm.class);
+ assert farm.getVehicleCount() == 20;
+ assert VehicleCountInterceptor.isIntercepted();
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/VehicleCountInterceptor.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/VehicleCountInterceptor.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/VehicleCountInterceptor.java 2009-10-30
14:25:03 UTC (rev 4446)
@@ -0,0 +1,24 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.member;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@VehicleCountInterceptorBinding(comment = "bar")
+class VehicleCountInterceptor
+{
+ private static boolean intercepted = false;
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ intercepted = true;
+ return ((Integer) ctx.proceed()) + 10;
+ }
+
+ public static boolean isIntercepted()
+ {
+ return intercepted;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/VehicleCountInterceptorBinding.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/VehicleCountInterceptorBinding.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/member/VehicleCountInterceptorBinding.java 2009-10-30
14:25:03 UTC (rev 4446)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.member;
+
+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.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@InterceptorBinding
+@interface VehicleCountInterceptorBinding
+{
+ @Nonbinding
+ String comment();
+}
Added:
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/member/beans.xml
===================================================================
---
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/member/beans.xml
(rev 0)
+++
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/member/beans.xml 2009-10-30
14:25:03 UTC (rev 4446)
@@ -0,0 +1,7 @@
+<beans>
+ <interceptors>
+
<class>org.jboss.jsr299.tck.tests.interceptors.definition.member.IncreasingInterceptor</class>
+
<class>org.jboss.jsr299.tck.tests.interceptors.definition.member.DecreasingInterceptor</class>
+
<class>org.jboss.jsr299.tck.tests.interceptors.definition.member.VehicleCountInterceptor</class>
+ </interceptors>
+</beans>
Modified: cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-10-30 13:46:54 UTC (rev
4445)
+++ cdi-tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-10-30 14:25:03 UTC (rev
4446)
@@ -4469,7 +4469,7 @@
<text>An annotation member may be excluded from consideration using the
@Nonbinding annotation.</text>
</assertion>
- <assertion id="ca">
+ <assertion id="ca" testable="false">
<text>Array-valued or annotation-valued members of an interceptor binding
type should be annotated |@Nonbinding| in a portable application. If an array-valued or
annotation-valued member of an interceptor binding type is not annotated |@Nonbinding|,
non-portable behavior results.</text>
</assertion>