felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1479564 - in /felix/trunk/ipojo/runtime: annotations/src/main/java/org/apache/felix/ipojo/annotations/ core-it/ core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ core-i...
Date Mon, 06 May 2013 13:25:52 GMT
Author: clement
Date: Mon May  6 13:25:52 2013
New Revision: 1479564

URL: http://svn.apache.org/r1479564
Log:
Fix FELIX-4053 
https://issues.apache.org/jira/browse/FELIX-4053

Added:
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ComponentWithProperties.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProviding.java
      - copied, changed from r1479322, felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProdiving.java
Removed:
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProdiving.java
Modified:
    felix/trunk/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java
    felix/trunk/ipojo/runtime/core-it/pom.xml

Modified: felix/trunk/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java?rev=1479564&r1=1479563&r2=1479564&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java
(original)
+++ felix/trunk/ipojo/runtime/annotations/src/main/java/org/apache/felix/ipojo/annotations/StaticServiceProperty.java
Mon May  6 13:25:52 2013
@@ -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 {
 
     /**

Modified: felix/trunk/ipojo/runtime/core-it/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/pom.xml?rev=1479564&r1=1479563&r2=1479564&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/pom.xml (original)
+++ felix/trunk/ipojo/runtime/core-it/pom.xml Mon May  6 13:25:52 2013
@@ -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>

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ComponentWithProperties.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ComponentWithProperties.java?rev=1479564&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ComponentWithProperties.java
(added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/components/ComponentWithProperties.java
Mon May  6 13:25:52 2013
@@ -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;
+    }
+}

Copied: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProviding.java
(from r1479322, felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProdiving.java)
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProviding.java?p2=felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProviding.java&p1=felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProdiving.java&r1=1479322&r2=1479564&rev=1479564&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProdiving.java
(original)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestServiceProviding.java
Mon May  6 13:25:52 2013
@@ -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 @@ public class TestServiceProdiving extend
 
     @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 @@ public class TestServiceProdiving extend
 
     @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 @@ public class TestServiceProdiving extend
 
     @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 @@ public class TestServiceProdiving extend
 
     @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 @@ public class TestServiceProdiving extend
 
     @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 @@ public class TestServiceProdiving extend
         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");



Mime
View raw message