Fix FELIX-2308
Fix FELIX-2309
Update versions
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@939354 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/core/service-providing/pom.xml b/ipojo/tests/core/service-providing/pom.xml
index bdbf7e0..7a0b062 100644
--- a/ipojo/tests/core/service-providing/pom.xml
+++ b/ipojo/tests/core/service-providing/pom.xml
@@ -27,12 +27,12 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo</artifactId>
- <version>${pom.version}</version>
+ <version>1.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo.metadata</artifactId>
- <version>${pom.version}</version>
+ <version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
@@ -77,7 +77,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
- <version>${pom.version}</version>
+ <version>1.6.0</version>
<executions>
<execution>
<goals>
@@ -97,7 +97,7 @@
<target>1.4</target>
</configuration>
</plugin>
-
+
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-junit4osgi-plugin</artifactId>
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java
new file mode 100644
index 0000000..a41b2f1
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java
@@ -0,0 +1,77 @@
+/*
+ * 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.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
+
+public class FooProviderWithAnonymousClass implements FooService {
+
+ private int intProp;
+ private String strProp;
+ private String[] strAProp;
+ private int[] intAProp;
+ private boolean boolProp;
+
+ public boolean foo() {
+ Runnable runnable = new Runnable() {
+ public void run() {
+ intProp = 3;
+ boolProp = true;
+ if(strProp.equals("foo")) { strProp = "bar"; }
+ else { strProp = "foo"; }
+ strAProp = new String[] {"foo", "bar", "baz"};
+ intAProp = new int[] {3, 2, 1};
+ }
+ };
+ new Thread(runnable).start();
+
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ return true;
+ }
+
+ public Properties fooProps() {
+ Properties p = new Properties();
+ p.put("intProp", new Integer(intProp));
+ p.put("boolProp", new Boolean(boolProp));
+ p.put("strProp", strProp);
+ p.put("strAProp", strAProp);
+ p.put("intAProp", intAProp);
+ return p;
+ }
+
+ public boolean getBoolean() { return true; }
+
+ public double getDouble() { return 1.0; }
+
+ public int getInt() { return 1; }
+
+ public long getLong() { return 1; }
+
+ public Boolean getObject() { return new Boolean(true); }
+
+
+
+}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java
new file mode 100644
index 0000000..8c3111c
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java
@@ -0,0 +1,77 @@
+package org.apache.felix.ipojo.test.scenarios.ps;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public class PropertiesInAnonymousClassTest extends OSGiTestCase {
+
+ IPOJOHelper helper;
+
+ public void setUp() {
+ helper = new IPOJOHelper(this);
+ String type = "PS-FooProviderTypeAnonymous-Dyn";
+ helper.createComponentInstance(type, "FooProviderAno-1");
+
+ }
+
+ public void tearDown() {
+ helper.dispose();
+ }
+
+ public void testProperties1() {
+ ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
+ assertNotNull("Check the availability of the FS service", sr);
+
+ // Check service properties
+ Integer intProp = (Integer) sr.getProperty("int");
+ Boolean boolProp = (Boolean) sr.getProperty("boolean");
+ String strProp = (String) sr.getProperty("string");
+ String[] strAProp = (String[]) sr.getProperty("strAProp");
+ int[] intAProp = (int[]) sr.getProperty("intAProp");
+
+ assertEquals("Check intProp equality (1)", intProp, new Integer(2));
+ assertEquals("Check longProp equality (1)", boolProp, new Boolean(false));
+ assertEquals("Check strProp equality (1)", strProp, new String("foo"));
+ assertNotNull("Check strAProp not nullity (1)", strAProp);
+ String[] v = new String[] {"foo", "bar"};
+ for (int i = 0; i < strAProp.length; i++) {
+ if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (1)"); }
+ }
+ assertNotNull("Check intAProp not nullity", intAProp);
+ int[] v2 = new int[] {1, 2, 3};
+ for (int i = 0; i < intAProp.length; i++) {
+ if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (1)"); }
+ }
+
+ // Invoke
+ FooService fs = (FooService) getServiceObject(sr);
+ assertTrue("invoke fs", fs.foo());
+
+ sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
+ // Re-check the property (change)
+ intProp = (Integer) sr.getProperty("int");
+ boolProp = (Boolean) sr.getProperty("boolean");
+ strProp = (String) sr.getProperty("string");
+ strAProp = (String[]) sr.getProperty("strAProp");
+ intAProp = (int[]) sr.getProperty("intAProp");
+
+ assertEquals("Check intProp equality (2)", intProp, new Integer(3));
+ assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
+ assertEquals("Check strProp equality (2)", strProp, new String("bar"));
+ assertNotNull("Check strAProp not nullity (2)", strAProp);
+ v = new String[] {"foo", "bar", "baz"};
+ for (int i = 0; i < strAProp.length; i++) {
+ if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (2)"); }
+ }
+ assertNotNull("Check intAProp not nullity (2)", intAProp);
+ v2 = new int[] {3, 2, 1};
+ for (int i = 0; i < intAProp.length; i++) {
+ if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (2)"); }
+ }
+
+ fs = null;
+ }
+
+}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
index 5e9adc6..b054e0b 100644
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
+++ b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -40,6 +40,7 @@
ots.addTestSuite(OSGiPropertiesTest.class);
ots.addTestSuite(NullCheck.class);
ots.addTestSuite(ServiceControllerTest.class);
+ ots.addTestSuite(PropertiesInAnonymousClassTest.class);
return ots;
}
diff --git a/ipojo/tests/core/service-providing/src/main/resources/metadata.xml b/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
index 6abd991..0fbbbed 100644
--- a/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
@@ -9,14 +9,14 @@
name="PS-FooProviderType-1" architecture="true">
<provides />
</component>
-
+
<component
classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
name="PS-FooProviderType-itf" architecture="true">
<provides
specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService" />
</component>
-
+
<component
classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
name="PS-FooProviderType-3" architecture="true">
@@ -30,7 +30,7 @@
<property name="bar" field="m_bar" />
</properties>
</component>
-
+
<!-- Providers providing 2 services -->
<component
classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"
@@ -55,7 +55,7 @@
<property name="baz" type="java.lang.String" value="bar" />
</provides>
</component>
-
+
<!-- Provider with dynamic property -->
<component
@@ -70,7 +70,7 @@
<property name="intAProp" field="intAProp" value="{1,2,3}" />
</provides>
</component>
-
+
<component
classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
name="PS-FooProviderType-2" architecture="true">
@@ -83,7 +83,7 @@
<property name="intAProp" type="int[]" value="{1,2,3}" />
</provides>
</component>
-
+
<component
classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn2"
name="PS-FooProviderType-Dyn2" architecture="true">
@@ -96,7 +96,7 @@
value="{1, 2,3 }" />
</provides>
</component>
-
+
<!-- Inherited Provides -->
<component
classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"
@@ -136,7 +136,7 @@
name="PS-PI3" architecture="true">
<provides />
</component>
-
+
<!-- Concrete and abstract class -->
<component
classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"
@@ -156,10 +156,10 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation3"
name="PS-PI7" architecture="true">
- <provides specifications="[org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation,
+ <provides specifications="[org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation,
org.apache.felix.ipojo.test.scenarios.ps.service.FooService]"/>
</component>
-
+
<!-- Null Check -->
<component classname="org.apache.felix.ipojo.test.scenarios.component.NullCheckServiceProvider" immediate="true"
name="PS-Null">
@@ -168,7 +168,7 @@
<property field="prop2"/>
</provides>
</component>
-
+
<!-- Service Controller -->
<component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"
name="PS-Controller-1-default">
@@ -210,4 +210,18 @@
<controller field="controllerCS" value="true"/>
</provides>
</component>
+
+ <!-- Anonymous classes -->
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderWithAnonymousClass"
+ name="PS-FooProviderTypeAnonymous-Dyn" architecture="true">
+ <provides>
+ <property name="int" field="intProp" value="2" />
+ <property name="boolean" field="boolProp" value="false" />
+ <property name="string" field="strProp" value="foo" />
+ <property name="strAProp" field="strAProp"
+ value="{foo, bar}" />
+ <property name="intAProp" field="intAProp" value="{1,2,3}" />
+ </provides>
+ </component>
</ipojo>