deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antoin...@apache.org
Subject deltaspike git commit: DELTASPIKE-781 : fixing the issue by avoiding method addition if the class wa are creating an AnnotatedType for is an annotaion Adding test to validate the change
Date Mon, 17 Nov 2014 10:13:28 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 6e62f8eb3 -> b4dd2ba9c


DELTASPIKE-781 : fixing the issue by avoiding method addition if the class wa are creating
an AnnotatedType for is an annotaion
Adding test to validate the change


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/b4dd2ba9
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/b4dd2ba9
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/b4dd2ba9

Branch: refs/heads/master
Commit: b4dd2ba9c18de97a70bda142d4dcb1adee3792fc
Parents: 6e62f8e
Author: Antoine Sabot-Durand <antoine@sabot-durand.net>
Authored: Sat Nov 15 23:14:52 2014 +0100
Committer: Antoine Sabot-Durand <antoine@sabot-durand.net>
Committed: Mon Nov 17 10:51:31 2014 +0100

----------------------------------------------------------------------
 .../metadata/builder/AnnotatedTypeImpl.java     |  3 +-
 .../api/metadata/AnnotatedTypeBuilderTest.java  | 12 +++++++
 .../deltaspike/test/api/metadata/Small.java     | 34 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b4dd2ba9/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/builder/AnnotatedTypeImpl.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/builder/AnnotatedTypeImpl.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/builder/AnnotatedTypeImpl.java
index f029eee..4f5da7e 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/builder/AnnotatedTypeImpl.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/metadata/builder/AnnotatedTypeImpl.java
@@ -23,6 +23,7 @@ import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -89,7 +90,7 @@ class AnnotatedTypeImpl<X> extends AnnotatedImpl implements AnnotatedType<X>
         methods = new HashSet<AnnotatedMethod<? super X>>();
         for (Method m : clazz.getMethods())
         {
-            if (!m.getDeclaringClass().equals(Object.class))
+            if (!m.getDeclaringClass().equals(Object.class) && !m.getDeclaringClass().equals(Annotation.class))
             {
                 AnnotatedMethodImpl<X> met = new AnnotatedMethodImpl<X>(this,
m, methodAnnotations.get(m),
                         methodParameterAnnotations.get(m), methodParameterTypes.get(m));

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b4dd2ba9/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java
b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java
index 66deb57..2398dff 100644
--- a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java
+++ b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/AnnotatedTypeBuilderTest.java
@@ -148,4 +148,16 @@ public class AnnotatedTypeBuilderTest
             }
         }
     }
+
+    @Test
+    public void buildValidAnnotationAnnotatedType()
+    {
+        final AnnotatedTypeBuilder<Small> builder = new AnnotatedTypeBuilder<Small>();
+        builder.readFromType(Small.class);
+        final AnnotatedType<Small> smallAnnotatedType = builder.create();
+
+        assertThat(smallAnnotatedType.getMethods().size(), is(1));
+        assertThat(smallAnnotatedType.getConstructors().size(), is(0));
+        assertThat(smallAnnotatedType.getFields().size(), is(0));
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b4dd2ba9/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/Small.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/Small.java
b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/Small.java
new file mode 100644
index 0000000..eace316
--- /dev/null
+++ b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/metadata/Small.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.test.api.metadata;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+
+@Qualifier
+@Documented
+@Retention(value = RetentionPolicy.RUNTIME)
+public @interface Small
+{
+    String value() default "";
+}


Mime
View raw message