FELIX-4607 test nested anno config

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1721870 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/helper/Annotations.java b/scr/src/main/java/org/apache/felix/scr/impl/helper/Annotations.java
index eedb195..836fa09 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/helper/Annotations.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/helper/Annotations.java
@@ -24,6 +24,7 @@
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -85,6 +86,10 @@
                 for (Map.Entry<String, Method> entry: complexFields.entrySet())
                 {
                     List<Map<String, Object>> proplist = nested.get(entry.getKey());
+                    if (proplist == null)
+                    {
+                    	proplist = Collections.emptyList();
+                    }
                     Method method = entry.getValue();
                     Class<?> returnType  = method.getReturnType();
                     if (returnType.isArray())
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java b/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java
index 2b034e4..e316802 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java
@@ -20,7 +20,6 @@
 
 import java.lang.reflect.Array;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -31,6 +30,10 @@
 import org.apache.felix.scr.integration.components.annoconfig.AnnoComponent.A1;
 import org.apache.felix.scr.integration.components.annoconfig.AnnoComponent.A1Arrays;
 import org.apache.felix.scr.integration.components.annoconfig.AnnoComponent.E1;
+import org.apache.felix.scr.integration.components.annoconfig.NestedAnnoComponent;
+import org.apache.felix.scr.integration.components.annoconfig.NestedAnnoComponent.A2;
+import org.apache.felix.scr.integration.components.annoconfig.NestedAnnoComponent.B2;
+import org.apache.felix.scr.integration.components.annoconfig.NestedAnnoComponent.E2;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
@@ -253,4 +256,59 @@
         TestCase.assertEquals(null, a.shor());
         TestCase.assertEquals(null, a.string());
     }
+    
+    @Test
+    public void testNestedAnnoConfig() throws Exception
+    {
+        String name = "org.apache.felix.scr.integration.components.nestedannoconfig";
+        ComponentConfigurationDTO dto = findComponentConfigurationByName(name, ComponentConfigurationDTO.SATISFIED);
+        NestedAnnoComponent ac = getServiceFromConfiguration(dto, NestedAnnoComponent.class);
+        checkA2NoValues(ac.m_a2_activate);
+        
+        Configuration c = configure(name, null, allNestedValues());
+        delay();
+        
+        checkA2(ac.m_a2_modified);
+
+        ungetServiceFromConfiguration(dto, NestedAnnoComponent.class);
+        checkA2(ac.m_a2_deactivate);
+        ac = getServiceFromConfiguration(dto, NestedAnnoComponent.class);
+        checkA2(ac.m_a2_activate);
+        
+
+    }
+    private Hashtable<String, Object> allNestedValues()
+    {
+        Hashtable<String, Object> values = new Hashtable<String, Object>();
+        values.put("b2.0.bool", "true");
+        values.put("b2.0.e2", E2.a.toString());
+        values.put("b2s.0.bool", "true");
+        values.put("b2s.0.e2", E2.a.toString());
+        values.put("b2s.1.bool", "true");
+        values.put("b2s.1.e2", E2.b.toString());
+        values.put("b2s.2.bool", "true");
+        values.put("b2s.2.e2", E2.c.toString());
+        return values;
+    }
+
+    private void checkA2NoValues(A2 a)
+    {
+        TestCase.assertEquals(0, a.b2s().length);
+    }
+    private void checkA2(A2 a)
+    {
+        checkB2(a.b2(), E2.a);
+        TestCase.assertNull(a.b2null());
+
+        TestCase.assertEquals(3, a.b2s().length);
+        checkB2(a.b2s()[0], E2.a);
+        checkB2(a.b2s()[1], E2.b);
+        checkB2(a.b2s()[2], E2.c);
+    }
+
+	private void checkB2(B2 b, E2 e2) {
+		TestCase.assertEquals(true, b.bool());
+		TestCase.assertEquals(e2, b.e2());
+	}
+
 }
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/annoconfig/AnnoComponent.java b/scr/src/test/java/org/apache/felix/scr/integration/components/annoconfig/AnnoComponent.java
index db5770b..9125a24 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/components/annoconfig/AnnoComponent.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/annoconfig/AnnoComponent.java
@@ -19,15 +19,8 @@
 package org.apache.felix.scr.integration.components.annoconfig;
 
 
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 
-import org.apache.felix.scr.impl.helper.AnnotationTest.E1;
-import org.osgi.service.component.ComponentConstants;
 import org.osgi.service.component.ComponentContext;
 
 
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/annoconfig/NestedAnnoComponent.java b/scr/src/test/java/org/apache/felix/scr/integration/components/annoconfig/NestedAnnoComponent.java
new file mode 100644
index 0000000..84ed7d4
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/annoconfig/NestedAnnoComponent.java
@@ -0,0 +1,67 @@
+/*
+ * 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.felix.scr.integration.components.annoconfig;
+
+
+
+
+public class NestedAnnoComponent
+{
+
+    public enum E2 {a, b, c}
+    
+    public @interface A2 {
+        B2 b2();
+        B2 b2null();
+        B2[] b2s();
+    }
+    
+    public @interface B2 {
+        boolean bool();
+        E2 e2();
+    }
+    
+    
+    public A2 m_a2_activate;
+    public A2 m_a2_modified;
+    public A2 m_a2_deactivate;
+    
+
+    @SuppressWarnings("unused")
+    private void activate( A2 a1 )
+    {
+        m_a2_activate = a1;
+    }
+
+
+
+    @SuppressWarnings("unused")
+    private void modified( A2 a1)
+    {
+        m_a2_modified = a1;
+    }
+    
+    @SuppressWarnings("unused")
+    private void deactivate( A2 a1 )
+    {
+        m_a2_deactivate = a1;
+    }
+
+
+}
diff --git a/scr/src/test/resources/integration_test_annoconfig.xml b/scr/src/test/resources/integration_test_annoconfig.xml
index 6511e2d..0834107 100644
--- a/scr/src/test/resources/integration_test_annoconfig.xml
+++ b/scr/src/test/resources/integration_test_annoconfig.xml
@@ -9,7 +9,7 @@
 	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. -->
-<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0">
+<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" xmlns:ext="http://felix.apache.org/xmlns/scr/extensions/v1.0.0">
 	<scr:component
 		name='org.apache.felix.scr.integration.components.annoconfig'
 		pid='org.apache.felix.scr.integration.components.annoconfig'
@@ -22,5 +22,17 @@
 		</service>
 	</scr:component>
 
+	<scr:component ext:configureWithInterfaces="true"
+		name='org.apache.felix.scr.integration.components.nestedannoconfig'
+		pid='org.apache.felix.scr.integration.components.nestedannoconfig'
+		modified='modified'
+		>
+		<implementation
+			class='org.apache.felix.scr.integration.components.annoconfig.NestedAnnoComponent' />
+		<service>
+			<provide interface='org.apache.felix.scr.integration.components.annoconfig.NestedAnnoComponent' />
+		</service>
+	</scr:component>
+
 
 </components>