[webbeans-commits] Webbeans SVN: r3516 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals and 1 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Sun Aug 16 05:57:59 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-08-16 05:57:59 -0400 (Sun, 16 Aug 2009)
New Revision: 3516
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/RetentionLiteral.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/TargetLiteral.java
Modified:
ri/trunk/api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Transactional.java
Log:
WBRI-364, and fix annotation literal to support array member values
Modified: ri/trunk/api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java
===================================================================
--- ri/trunk/api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java 2009-08-16 09:54:45 UTC (rev 3515)
+++ ri/trunk/api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java 2009-08-16 09:57:59 UTC (rev 3516)
@@ -22,6 +22,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.util.Arrays;
/**
@@ -124,8 +125,15 @@
{
Object thisValue = invoke(member, this);
Object thatValue = invoke(member, that);
- if (!thisValue.equals(thatValue))
+ if (thisValue.getClass().isArray() && thatValue.getClass().isArray())
{
+ if (!Arrays.equals(Object[].class.cast(thisValue), Object[].class.cast(thatValue)))
+ {
+ return false;
+ }
+ }
+ else if (!thisValue.equals(thatValue))
+ {
return false;
}
}
@@ -142,7 +150,8 @@
for (Method member : members)
{
int memberNameHashCode = 127 * member.getName().hashCode();
- int memberValueHashCode = invoke(member, this).hashCode();
+ Object value = invoke(member, this);
+ int memberValueHashCode = value.getClass().isArray() ? Arrays.hashCode(Object[].class.cast(value)) : value.hashCode();
hashCode += memberNameHashCode ^ memberValueHashCode;
}
return hashCode;
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/RetentionLiteral.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/RetentionLiteral.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/RetentionLiteral.java 2009-08-16 09:57:59 UTC (rev 3516)
@@ -0,0 +1,30 @@
+/*
+ * 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.literals;
+
+import java.lang.annotation.Retention;
+
+import javax.enterprise.inject.AnnotationLiteral;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class RetentionLiteral extends AnnotationLiteral<Retention> implements Retention
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/RetentionLiteral.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/TargetLiteral.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/TargetLiteral.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/TargetLiteral.java 2009-08-16 09:57:59 UTC (rev 3516)
@@ -0,0 +1,30 @@
+/*
+ * 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.literals;
+
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.AnnotationLiteral;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class TargetLiteral extends AnnotationLiteral<Target> implements Target
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/TargetLiteral.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java 2009-08-16 09:54:45 UTC (rev 3515)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java 2009-08-16 09:57:59 UTC (rev 3516)
@@ -17,10 +17,16 @@
package org.jboss.jsr299.tck.tests.extensions.beanManager;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+
import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.HashSet;
import java.util.Set;
@@ -28,6 +34,7 @@
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.ScopeType;
+import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.AmbiguousResolutionException;
import javax.enterprise.inject.AnnotationLiteral;
import javax.enterprise.inject.BindingType;
@@ -40,6 +47,8 @@
import javax.enterprise.inject.stereotype.Stereotype;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.RetentionLiteral;
+import org.jboss.jsr299.tck.literals.TargetLiteral;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
@@ -101,52 +110,86 @@
getCurrentManager().validate(injectionPoint);
}
- @Test
+ @Test(groups="rewrite")
@SpecAssertion(section = "11.3.14", id = "aa")
+ // Should also check a custom bindingtype
public void testDetermineBindingType()
{
assert getCurrentManager().isBindingType(Tame.class);
+ assert !getCurrentManager().isBindingType(AnimalStereotype.class);
+ assert !getCurrentManager().isBindingType(ApplicationScoped.class);
+ assert !getCurrentManager().isBindingType(Transactional.class);
}
- @Test()
+ @Test(groups="rewrite")
+ // Should also check a custom scope
@SpecAssertion(section = "11.3.14", id = "ab")
public void testDetermineScopeType()
{
assert getCurrentManager().isScopeType(ApplicationScoped.class);
+ assert !getCurrentManager().isScopeType(Tame.class);
+ assert !getCurrentManager().isScopeType(AnimalStereotype.class);
+ assert !getCurrentManager().isScopeType(Transactional.class);
}
- @Test
+ @Test(groups="rewrite")
@SpecAssertion(section = "11.3.14", id = "ac")
+ // Should also check a custom stereotype
public void testDetermineStereotype()
{
assert getCurrentManager().isStereotype(AnimalStereotype.class);
+ assert !getCurrentManager().isStereotype(Tame.class);
+ assert !getCurrentManager().isStereotype(ApplicationScoped.class);
+ assert !getCurrentManager().isStereotype(Transactional.class);
}
- @Test(groups = "ri-broken")
- // WBRI-363
+ @Test(groups = {"ri-broken", "rewrite"})
+ // WBRI-59
+ // Should also check a custom interceptor binding type
@SpecAssertion(section = "11.3.14", id = "ad")
public void testDetermineInterceptorBindingType()
{
assert getCurrentManager().isInterceptorBindingType(Transactional.class);
+ assert !getCurrentManager().isInterceptorBindingType(Tame.class);
+ assert !getCurrentManager().isInterceptorBindingType(AnimalStereotype.class);
+ assert !getCurrentManager().isInterceptorBindingType(ApplicationScoped.class);
}
- @Test(groups = "ri-broken")
+ @Test(groups = { "rewrite"})
@SpecAssertion(section = "11.3.14", id = "ae")
- // WBRI-364
+ // Should also check a custom sterotype
public void testGetMetaAnnotationsForStereotype()
{
Set<Annotation> stereotypeAnnotations = getCurrentManager().getStereotypeDefinition(AnimalStereotype.class);
assert stereotypeAnnotations.size() == 5;
assert stereotypeAnnotations.contains(new AnnotationLiteral<Stereotype>() {});
- assert stereotypeAnnotations.contains(new AnnotationLiteral<Target>() {});
- assert stereotypeAnnotations.contains(new AnnotationLiteral<Retention>() {});
assert stereotypeAnnotations.contains(new AnnotationLiteral<RequestScoped>() {});
assert stereotypeAnnotations.contains(new AnnotationLiteral<Inherited>() {});
+ assert stereotypeAnnotations.contains(new RetentionLiteral()
+ {
+
+ public RetentionPolicy value()
+ {
+ return RetentionPolicy.RUNTIME;
+ }
+
+ });
+ assert stereotypeAnnotations.contains(new TargetLiteral()
+ {
+
+ public ElementType[] value()
+ {
+ ElementType[] value = {TYPE, METHOD, FIELD};
+ return value;
+ }
+
+ });
}
- @Test(groups = "ri-broken")
+ @Test(groups = {"ri-broken", "rewrite"})
@SpecAssertion(section = "11.3.14", id = "af")
- // WBRI-364
+ // WBRI-59
+ // Should also check a custom defined interceptor binding
public void testGetMetaAnnotationsForInterceptorBindingType()
{
Set<Annotation> metaAnnotations = getCurrentManager().getInterceptorBindingTypeDefinition(Transactional.class);
@@ -157,14 +200,18 @@
assert metaAnnotations.contains(new AnnotationLiteral<BindingType>() {});
}
- @Test(groups = "ri-broken")
+ @Test(groups = {"rewrite"})
@SpecAssertion(section = "11.3.14", id = "ag")
- // WBRI-364
+ // Should also check a custom defined scope
public void testGetScopeType()
{
- ScopeType scopeType = getCurrentManager().getScopeDefinition(RequestScoped.class);
- assert scopeType.normal();
- assert scopeType.passivating();
+ ScopeType requestScopeType = getCurrentManager().getScopeDefinition(RequestScoped.class);
+ assert requestScopeType.normal();
+ assert !requestScopeType.passivating();
+
+ ScopeType sessionScopeType = getCurrentManager().getScopeDefinition(SessionScoped.class);
+ assert sessionScopeType.normal();
+ assert sessionScopeType.passivating();
}
@Test
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Transactional.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Transactional.java 2009-08-16 09:54:45 UTC (rev 3515)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Transactional.java 2009-08-16 09:57:59 UTC (rev 3516)
@@ -10,12 +10,12 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.enterprise.inject.BindingType;
+import javax.interceptor.InterceptorBindingType;
@Target( { TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
- at BindingType
+ at InterceptorBindingType
@interface Transactional
{
More information about the weld-commits
mailing list