Author: clement
Date: Thu May 17 18:23:46 2012
New Revision: 1339772
URL: http://svn.apache.org/viewvc?rev=1339772&view=rev
Log:
Fixed FELIX-3508
Arrays containing enumerations are not supported in custom handler annotation.
Added:
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java
Modified:
felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
felix/trunk/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
Modified:
felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
URL:
http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java?rev=1339772&r1=1339771&r2=1339772&view=diff
==============================================================================
---
felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
(original)
+++
felix/trunk/ipojo/manipulator/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/CustomAnnotationVisitor.java
Thu May 17 18:23:46 2012
@@ -302,6 +302,21 @@ public class CustomAnnotationVisitor ext
}
/**
+ * 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
Modified:
felix/trunk/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
URL:
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java?rev=1339772&r1=1339771&r2=1339772&view=diff
==============================================================================
---
felix/trunk/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
(original)
+++
felix/trunk/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
Thu May 17 18:23:46 2012
@@ -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 {};
}
Modified:
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
URL:
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java?rev=1339772&r1=1339771&r2=1339772&view=diff
==============================================================================
---
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
(original)
+++
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
Thu May 17 18:23:46 2012
@@ -48,6 +48,8 @@ public class AnnotationsTestSuite extend
ots.addTestSuite(Extender.class);
ots.addTestSuite(EventAdmin.class);
+ ots.addTestSuite(CustomAnnotations.class);
+
// Instantiate
ots.addTestSuite(Instantiate.class);
Added:
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java
URL:
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java?rev=1339772&view=auto
==============================================================================
---
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java
(added)
+++
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java
Thu May 17 18:23:46 2012
@@ -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"));
+ }
+
+
+
+
+}
+
Added:
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java
URL:
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java?rev=1339772&view=auto
==============================================================================
---
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java
(added)
+++
felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java
Thu May 17 18:23:46 2012
@@ -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 {
+
+}