FELIX-4793 Components with an empty configuration are created even if configuration is required or available

This happens when the 'Obsolete Factory Component Factory' is set to true.
This commit addresses, the issue. Thanks to Carsten Ziegeler for the code fix.
A test is also included.



git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1658933 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java b/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
index 153d2e6..c8ed9c5 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
@@ -644,7 +644,8 @@
             {
                 if ( isSatisfied() )
                 {
-                    if ( m_factoryPidIndex == null || m_componentMetadata.isObsoleteFactoryComponentFactory())
+                    if ( m_factoryPidIndex == null ||
+                            (m_componentMetadata.isObsoleteFactoryComponentFactory() && !m_componentMetadata.isConfigurationRequired()))
                     {
                         m_singleComponent = createComponentManager(false);
                         cms.add( m_singleComponent );
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java b/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
index 33a528b..e002bd7 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
@@ -143,6 +143,19 @@
     }
 
     @Test
+    public void test_component_factory_require_configuration_obsolete() throws Exception
+    {
+        final String componentname = "factory.component.configuration.obsolete";
+
+        TestCase.assertNull(SimpleComponent.INSTANCE);
+
+        createFactoryConfiguration(componentname);
+        delay();
+        getConfigurationsDisabledThenEnable(componentname, 1, ComponentConfigurationDTO.ACTIVE);
+        TestCase.assertEquals(PROP_NAME, SimpleComponent.INSTANCE.getProperty(PROP_NAME));
+    }
+
+    @Test
     public void test_component_factory_optional_configuration() throws Exception
     {
         final String componentname = "factory.component.configuration.optional";
diff --git a/scr/src/test/resources/integration_test_simple_factory_components.xml b/scr/src/test/resources/integration_test_simple_factory_components.xml
index 9109745..98ce712 100644
--- a/scr/src/test/resources/integration_test_simple_factory_components.xml
+++ b/scr/src/test/resources/integration_test_simple_factory_components.xml
@@ -36,6 +36,15 @@
         <implementation class="org.apache.felix.scr.integration.components.SimpleComponent" />
     </scr:component>
     
+    <scr:component name="factory.component.configuration.obsolete"
+        enabled="false"
+        configuration-policy="require"
+        xmlns:felix="http://felix.apache.org/xmlns/scr/extensions/v1.0.0"
+        felix:obsoleteFactoryComponentFactory="true" >
+        <implementation class="org.apache.felix.scr.integration.components.SimpleComponent" />
+        <property name="foo">bar</property>
+    </scr:component>
+
     <scr:component name="factory.component.configuration.optional"
         enabled="false"
         configuration-policy="optional"