Fixed FELIX-3508

Arrays containing enumerations are not supported in custom handler annotation.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1339772 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java b/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
index 58399be..54e133b 100644
--- a/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
+++ b/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
@@ -302,6 +302,21 @@
         }

 

         /**

+         * Visits an enumeration attribute.

+         * @param arg0 the attribute name

+         * @param arg1 the enumeration descriptor

+         * @param arg2 the attribute value

+         */

+        public void visitEnum(String arg0, String arg1, String arg2) {

+            if (m_acc == null) {

+                m_acc = "{" + arg2;

+            } else {

+                m_acc = m_acc + "," + arg2;

+            }

+        }

+

+

+        /**

          * Visit an annotation element of the visited array.

          * @param arg0 : null

          * @param arg1 : annotation to visit

diff --git a/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java b/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
index fdf9037..553ae17 100644
--- a/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
+++ b/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
@@ -1,10 +1,16 @@
 package foo.ipojo;
 
 
+import foo.RGB;
+
 /**
  * Creates a simple annotation to create the processing of matching
  * annotations
  */
 public @interface IPOJOFoo {
     String bar();
+
+    RGB rgb() default RGB.BLUE;
+
+    RGB[] colors() default {};
 }
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
index 242a423..3d7f922 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
@@ -48,6 +48,8 @@
         ots.addTestSuite(Extender.class);

         ots.addTestSuite(EventAdmin.class);

 

+        ots.addTestSuite(CustomAnnotations.class);

+

         // Instantiate

         ots.addTestSuite(Instantiate.class);

 

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java
new file mode 100644
index 0000000..9e852cd
--- /dev/null
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java
@@ -0,0 +1,39 @@
+package org.apache.felix.ipojo.test.scenarios.annotations;

+

+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;

+import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;

+import org.apache.felix.ipojo.metadata.Element;

+

+/**

+ * Checks the support of the custom annotation handlinig.

+ */

+public class CustomAnnotations extends OSGiTestCase {

+    

+    private IPOJOHelper helper;

+    

+    public void setUp() {

+        helper = new IPOJOHelper(this);

+    }

+    

+    public void testThatCustomAnnotationAreCorrectlyAdded() {

+        Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.CustomAnnotationWithEnum");

+        Element[] ann = meta.getElements("IPOJOFoo", "foo.ipojo");

+        assertNotNull("Annotation exists ", ann);

+    }

+

+    public void testThatCustomAnnotationAreSupportingEnums() {

+        Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.CustomAnnotationWithEnum");

+        Element[] ann = meta.getElements("IPOJOFoo", "foo.ipojo");

+        assertNotNull("Annotation exists ", ann);

+        Element element = ann[0];

+        // Simple value

+        assertEquals("RED", element.getAttribute("rgb"));

+        // Array (FELIX-3508).

+        assertEquals("{BLUE,RED}", element.getAttribute("colors"));

+    }

+

+    

+    

+

+}

+

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java
new file mode 100644
index 0000000..5a10c2e
--- /dev/null
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java
@@ -0,0 +1,11 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import foo.RGB;
+import foo.ipojo.IPOJOFoo;
+import org.apache.felix.ipojo.annotations.Component;
+
+@Component
+@IPOJOFoo(bar="bar", rgb = RGB.RED, colors = {RGB.BLUE, RGB.RED})
+public class CustomAnnotationWithEnum {
+
+}