Fix FELIX-4053 
https://issues.apache.org/jira/browse/FELIX-4053

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1479564 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java b/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java
index f9ac981..c3adae1 100644
--- a/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java
+++ b/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java
@@ -19,10 +19,13 @@
 package org.apache.felix.ipojo.annotations;

 

 

+import java.lang.annotation.Target;

+

 /**

  * This annotation declares a static service property.

  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>

  */

+@Target({})

 public @interface StaticServiceProperty {

 

     /**

diff --git a/ipojo/runtime/core-it/pom.xml b/ipojo/runtime/core-it/pom.xml
index dbaa19e..03b9a42 100644
--- a/ipojo/runtime/core-it/pom.xml
+++ b/ipojo/runtime/core-it/pom.xml
@@ -183,6 +183,12 @@
 
         <dependency>
             <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.ipojo.annotations</artifactId>
+            <version>1.9.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.configadmin</artifactId>
             <version>1.6.0</version>
             <scope>test</scope>
@@ -359,6 +365,35 @@
         </profile>
 
         <profile>
+            <!--
+                avoid using the invoker and use a regular reactor instead.
+                it must be coupled with another profile to select the right OSGi framework implementation
+             -->
+            <id>reactor</id>
+
+            <modules>
+                <module>src/it/ipojo-core-annotations-test</module>
+                <module>src/it/ipojo-core-bad-configuration-test</module>
+                <module>src/it/ipojo-core-configuration-admin-test</module>
+                <module>src/it/ipojo-core-configuration-processor-test</module>
+                <module>src/it/ipojo-core-configuration-test</module>
+                <module>src/it/ipojo-core-external-handlers-test</module>
+                <module>src/it/ipojo-core-factory-test</module>
+                <module>src/it/ipojo-core-factory-version-test</module>
+                <module>src/it/ipojo-core-handler-test</module>
+                <module>src/it/ipojo-core-lifecycle-callback-test</module>
+                <module>src/it/ipojo-core-lifecycle-controller-test</module>
+                <module>src/it/ipojo-core-logger-test</module>
+                <module>src/it/ipojo-core-service-dependency-optional-test</module>
+                <module>src/it/ipojo-core-service-dependency-policies</module>
+                <module>src/it/ipojo-core-service-dependency-proxies</module>
+                <module>src/it/ipojo-core-service-dependency-test</module>
+                <module>src/it/ipojo-core-service-providing-test</module>
+            </modules>
+
+        </profile>
+
+        <profile>
             <id>test</id>
             <activation>
                 <activeByDefault>true</activeByDefault>
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ComponentWithProperties.java b/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ComponentWithProperties.java
new file mode 100644
index 0000000..247809b
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ComponentWithProperties.java
@@ -0,0 +1,79 @@
+/*
+ * 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.ipojo.runtime.core.test.components.components;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Instantiate;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.annotations.StaticServiceProperty;
+import org.apache.felix.ipojo.runtime.core.test.services.FooService;
+
+import java.util.Properties;
+
+/**
+ * A component publishing a service with a static service property.
+ */
+@Component
+@Provides(properties = {
+    @StaticServiceProperty(name="property", value="value", type = "java.lang.String")
+})
+@Instantiate(name="instanceWithProperties")
+// We must avoid having such static properties:
+// Fixed in https://issues.apache.org/jira/browse/FELIX-4053
+//@StaticServiceProperty(name="property", value="value", type = "java.lang.String")
+public class ComponentWithProperties implements FooService{
+
+    // The implementation is meaningless.
+
+    @Override
+    public boolean foo() {
+        return false;
+    }
+
+    @Override
+    public Properties fooProps() {
+        return null;
+    }
+
+    @Override
+    public Boolean getObject() {
+        return null;
+    }
+
+    @Override
+    public boolean getBoolean() {
+        return false;
+    }
+
+    @Override
+    public int getInt() {
+        return 0;
+    }
+
+    @Override
+    public long getLong() {
+        return 0;
+    }
+
+    @Override
+    public double getDouble() {
+        return 0;
+    }
+}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProdiving.java b/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProviding.java
similarity index 77%
rename from ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProdiving.java
rename to ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProviding.java
index 14d2f4f..c923939 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProdiving.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProviding.java
@@ -19,35 +19,38 @@
 

 package org.apache.felix.ipojo.runtime.core.test.annotations;

 

+import org.apache.felix.ipojo.architecture.Architecture;

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

 import org.apache.felix.ipojo.parser.ParseUtils;

 import org.apache.felix.ipojo.runtime.core.test.services.CheckService;

 import org.apache.felix.ipojo.runtime.core.test.services.FooService;

 import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+import org.ow2.chameleon.testing.helpers.IPOJOHelper;

 

 import java.util.List;

 

 import static junit.framework.Assert.*;

 

-public class TestServiceProdiving extends Common {

+public class TestServiceProviding extends Common {

 

     @Test

     public void testProvidesSimple() {

-        Element meta = ipojoHelper.getMetadata(getTestBundle(),  "org.apache.felix.ipojo.runtime.core.test.components.ProvidesSimple");

+        Element meta = IPOJOHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.ProvidesSimple");

         Element[] provs = meta.getElements("provides");

         assertNotNull("Provides exists ", provs);

     }

 

     @Test

     public void testProvidesDouble() {

-        Element meta = ipojoHelper.getMetadata(getTestBundle(),  "org.apache.felix.ipojo.runtime.core.test.components.ProvidesDouble");

+        Element meta = IPOJOHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.ProvidesDouble");

         Element[] provs = meta.getElements("provides");

         assertNotNull("Provides exists ", provs);

     }

 

     @Test

     public void testProvidesTriple() {

-        Element meta = ipojoHelper.getMetadata(getTestBundle(),  "org.apache.felix.ipojo.runtime.core.test.components.ProvidesTriple");

+        Element meta = IPOJOHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.ProvidesTriple");

         Element[] provs = meta.getElements("provides");

         assertNotNull("Provides exists ", provs);

         Element prov = provs[0];

@@ -58,7 +61,7 @@
 

     @Test

     public void testProvidesQuatro() {

-        Element meta = ipojoHelper.getMetadata(getTestBundle(),  "org.apache.felix.ipojo.runtime.core.test.components.ProvidesQuatro");

+        Element meta = IPOJOHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.ProvidesQuatro");

         Element[] provs = meta.getElements("provides");

         assertNotNull("Provides exists ", provs);

         Element prov = provs[0];

@@ -70,7 +73,7 @@
 

     @Test

     public void testProperties() {

-        Element meta = ipojoHelper.getMetadata(getTestBundle(),  "org.apache.felix.ipojo.runtime.core.test.components.ProvidesProperties");

+        Element meta = IPOJOHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.ProvidesProperties");

         Element[] provs = meta.getElements("provides");

         assertNotNull("Provides exists ", provs);

         Element prov = provs[0];

@@ -101,7 +104,7 @@
 

     @Test

     public void testStaticProperties() {

-        Element meta = ipojoHelper.getMetadata(getTestBundle(),  "org.apache.felix.ipojo.runtime.core.test.components.ProvidesStaticProperties");

+        Element meta = IPOJOHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.ProvidesStaticProperties");

         Element[] provs = meta.getElements("provides");

         assertNotNull("Provides exists ", provs);

         Element prov = provs[0];

@@ -149,7 +152,7 @@
 

     @Test

     public void testServiceController() {

-        Element meta = ipojoHelper.getMetadata(getTestBundle(),  "org.apache.felix.ipojo.runtime.core.test.components.PSServiceController");

+        Element meta = IPOJOHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.PSServiceController");

         Element[] provs = meta.getElements("provides");

         assertNotNull("Provides exists ", provs);

         System.out.println(provs[0].toString());

@@ -160,7 +163,7 @@
 

     @Test

     public void testServiceControllerWithSpecification() {

-        Element meta = ipojoHelper.getMetadata(getTestBundle(),  "org.apache.felix.ipojo.runtime.core.test.components.PSServiceControllerSpec");

+        Element meta = IPOJOHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.PSServiceControllerSpec");

         Element[] provs = meta.getElements("provides");

         assertNotNull("Provides exists ", provs);

         System.out.println(provs[0].toString());

@@ -170,15 +173,27 @@
         assertEquals(FooService.class.getName(), provs[0].getElements("controller")[0].getAttribute("specification"));

     }

 

+    /**

+     * Checks that declared static properties.

+     * It used 'org.apache.felix.ipojo.runtime.core.test.components.components.ComponentWithProperties'

+     * This test is related to : https://issues.apache.org/jira/browse/FELIX-4053

+     */

+    @Test

+    public void testPublishedStaticProperties() {

+        ServiceReference reference = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(),

+                "instanceWithProperties");

+        assertNotNull(reference);

+    }

+

     private Element getPropertyByName(Element[] props, String name) {

-        for (int i = 0; i < props.length; i++) {

-            String na = props[i].getAttribute("name");

-            String field = props[i].getAttribute("field");

+        for (Element prop : props) {

+            String na = prop.getAttribute("name");

+            String field = prop.getAttribute("field");

             if (na != null && na.equalsIgnoreCase(name)) {

-                return props[i];

+                return prop;

             }

             if (field != null && field.equalsIgnoreCase(name)) {

-                return props[i];

+                return prop;

             }

         }

         fail("Property  " + name + " not found");