You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2013/02/26 14:02:40 UTC
svn commit: r1450158 [6/9] - in /felix/trunk/ipojo/runtime/composite-it: ./
src/ src/it/ src/it/ipojo-composite-import-export-test/
src/it/ipojo-composite-import-export-test/src/
src/it/ipojo-composite-import-export-test/src/main/ src/it/ipojo-composit...
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,83 @@
+/*
+ * 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.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
+
+ FooService fs;
+
+ int simpleB = 0;
+ int objectB = 0;
+ int refB = 0;
+ int bothB = 0;
+
+ public boolean check() {
+ return fs.foo();
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("voidB", new Integer(simpleB));
+ props.put("objectB", new Integer(objectB));
+ props.put("refB", new Integer(refB));
+ props.put("bothB", new Integer(bothB));
+ props.put("voidU", new Integer(simpleU));
+ props.put("objectU", new Integer(objectU));
+ props.put("refU", new Integer(refU));
+ props.put("bothU", new Integer(bothU));
+ if (fs != null) {
+ props.put("result", new Boolean(fs.foo()));
+ props.put("boolean", new Boolean(fs.getBoolean()));
+ props.put("int", new Integer(fs.getInt()));
+ props.put("long", new Long(fs.getLong()));
+ props.put("double", new Double(fs.getDouble()));
+ if(fs.getObject() != null) { props.put("object", fs.getObject()); }
+ }
+ props.put("static", CheckService.foo);
+ props.put("class", CheckService.class.getName());
+ return props;
+ }
+
+ private void voidBind() {
+ simpleB++;
+ }
+
+ protected void objectBind(FooService o) {
+ if (o == null) {
+ System.err.println("Bind receive null !!! ");
+ return;
+ }
+ if(o != null && o instanceof FooService) { objectB++; }
+ }
+
+ public void refBind(ServiceReference sr) {
+ if(sr != null) { refB++; }
+ }
+
+ public void bothBind(FooService o, ServiceReference sr) {
+ if(sr != null && o != null && o instanceof FooService) { bothB++; }
+ }
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,54 @@
+/*
+ * 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.components;
+
+import org.apache.felix.ipojo.runtime.core.services.BarService;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.Properties;
+
+public class FooBarProviderType1 implements FooService, BarService {
+
+ public boolean foo() {
+ return true;
+ }
+
+ public Properties fooProps() {
+ return new Properties();
+ }
+
+ public boolean bar() {
+ return true;
+ }
+
+ public Properties getProps() {
+ return new Properties();
+ }
+
+ 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); }
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,92 @@
+/*
+ * 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.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+public class FooProviderType1 implements FooService {
+
+ private int m_bar;
+ private String m_foo;
+
+ private BundleContext m_context;
+
+ private static FooProviderType1 singleton;
+ private static int count = 0;
+
+ public FooProviderType1(BundleContext bc) {
+ if (bc ==null) {
+ throw new RuntimeException("Injected bundle context null");
+ }
+ m_context = bc;
+ }
+
+ public boolean foo() {
+ return true;
+ }
+
+ public Properties fooProps() {
+ Properties p = new Properties();
+ p.put("bar", new Integer(m_bar));
+ if(m_foo != null) {
+ p.put("foo", m_foo);
+ }
+ p.put("context", m_context);
+
+ p.put("count", new Integer(count));
+ return p;
+ }
+
+ public void testException() throws Exception {
+ String a = "foobarbaz";
+ throw new Exception("foo"+a);
+ }
+
+ public void testTry() {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ public void testTry2(String s) {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ private void nexttry(String s) {
+ try {
+ s += "foo";
+ } catch(RuntimeException e) {
+
+ }
+ }
+
+ 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); }
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,63 @@
+/*
+ * 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.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.Properties;
+
+public class FooProviderTypeDyn implements FooService {
+
+ private int intProp;
+ private String strProp;
+ private String[] strAProp;
+ private int[] intAProp;
+ private boolean boolProp;
+
+ public boolean foo() {
+ 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};
+ 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); }
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,58 @@
+/*
+ * 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.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.Properties;
+
+public class FooProviderTypeDyn2 implements FooService {
+
+ private int intProp = 2;
+ private boolean boolProp = true;
+ private String strProp = "foo";
+ private String[] strAProp = new String[] {"foo", "bar"};
+ private int[] intAProp = new int[] {1, 2, 3};
+
+ public boolean foo() {
+ intAProp = null;
+ 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); }
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,222 @@
+/*
+ * 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.components;
+
+import org.apache.felix.ipojo.runtime.core.services.Tata;
+
+import java.util.Properties;
+
+
+public class TataProvider implements Tata {
+
+ int tata = 0;
+ int tataStr = 0;
+ int tataStrs = 0;
+ int tata_2 = 0;
+ int tata_3 = 0;
+ int tata1 = 0;
+ int tata1_1 = 0;
+ int tata5 = 0;
+ int tata5_1 = 0;
+ int tata5_2 = 0;
+ int tataBoolean = 0;
+ int tataBooleans = 0;
+ int tataByte = 0;
+ int tataBytes = 0;
+ private int add;
+ private int tataShorts;
+ private int tataShort;
+ private int tataLongs;
+ private int tataLong;
+ private int tataInts;
+ private int tataInt;
+ private int tataFloat;
+ private int tataFloats;
+ private int tataDoubles;
+ private int tataDouble;
+ private int tataChars;
+ private int tataChar;
+
+ public Properties getPropsTata() {
+ Properties props = new Properties();
+ props.put("tata", new Integer(tata));
+ props.put("tataStr", new Integer(tataStr));
+ props.put("tataStrs", new Integer(tataStrs));
+ props.put("tata_2", new Integer(tata_2));
+ props.put("tata_3", new Integer(tata_3));
+ props.put("tata1", new Integer(tata1));
+ props.put("tata1_1", new Integer(tata1_1));
+ props.put("tata5", new Integer(tata5));
+ props.put("tata5_1", new Integer(tata5_1));
+ props.put("tata5_2", new Integer(tata5_2));
+ props.put("add", new Integer(add));
+ props.put("tataBoolean", new Integer(tataBoolean));
+ props.put("tataBoolean", new Integer(tataBoolean));
+ props.put("tataByte", new Integer(tataByte));
+ props.put("tataBytes", new Integer(tataBytes));
+ props.put("tataShort", new Integer(tataShort));
+ props.put("tataShorts", new Integer(tataShorts));
+ props.put("tataLongs", new Integer(tataLongs));
+ props.put("tataLong", new Integer(tataLong));
+ props.put("tataInt", new Integer(tataInt));
+ props.put("tataInts", new Integer(tataInts));
+ props.put("tataFloat", new Integer(tataFloat));
+ props.put("tataFloats", new Integer(tataFloats));
+ props.put("tataDouble", new Integer(tataDouble));
+ props.put("tataDoubles", new Integer(tataDoubles));
+ props.put("tataChar", new Integer(tataChar));
+ props.put("tataChars", new Integer(tataChars));
+ return props;
+ }
+
+ public void tata() {
+ tata++;
+ }
+
+ public String tataStr() {
+ tataStr++;
+ return "Tata";
+ }
+
+ public String[] tataStrs() {
+ tataStrs++;
+ return new String[] {"T", "A", "T", "A"};
+ }
+
+ public void tata(int i, int j) {
+ tata_2++;
+ }
+
+ public void tata(String s) {
+ tata_3++;
+ }
+
+ public String tata1(String a) {
+ tata1++;
+ return a;
+ }
+
+ public String tata1(char[] a) {
+ tata1_1++;
+ String s = new String(a);
+ return s;
+ }
+
+ public String tata5(String a, int i) {
+ tata5++;
+ return a+i;
+ }
+
+ public String tata5(String[] a, int i) {
+ tata5_1++;
+ return ""+a.length + i;
+ }
+
+ public String tata5(String a, int[] i) {
+ tata5_2++;
+ return a + i.length;
+ }
+
+ public boolean tataBoolean(boolean b) {
+ tataBoolean++;
+ return b;
+ }
+
+ public boolean[] tataBooleans(boolean[] b) {
+ tataBooleans++;
+ return b;
+ }
+
+ public byte tataByte(byte b) {
+ tataByte++;
+ return b;
+ }
+
+ public byte[] tataBytes(byte[] b) {
+ tataBytes++;
+ return b;
+ }
+
+ public char tataChar(char c) {
+ tataChar++;
+ return c;
+ }
+
+ public char[] tataChars(char[] c) {
+ tataChars++;
+ return c;
+ }
+
+ public double tataDouble(double d) {
+ tataDouble++;
+ return d;
+ }
+
+ public double[] tataDoubles(double[] d) {
+ tataDoubles++;
+ return d;
+ }
+
+ public float tataFloat(float f) {
+ tataFloat++;
+ return f;
+ }
+
+ public float[] tataFloats(float[] f) {
+ tataFloats++;
+ return f;
+ }
+
+ public int tataInt(int i) {
+ tataInt++;
+ return i;
+ }
+
+ public int[] tataInts(int[] its) {
+ tataInts++;
+ return its;
+ }
+
+ public long tataLong(long l) {
+ tataLong++;
+ return l;
+ }
+
+ public long[] tataLongs(long[] l) {
+ tataLongs++;
+ return l;
+ }
+
+ public short tataShort(short s) {
+ tataShort++;
+ return s;
+ }
+
+ public short[] tataShorts(short[] s) {
+ tataShorts++;
+ return s;
+ }
+
+ public long add(int i, int j, int k) {
+ add++;
+ return i + j + k;
+ }
+
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,73 @@
+/*
+ * 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.components;
+
+import org.apache.felix.ipojo.runtime.core.services.Toto;
+
+import java.util.Properties;
+
+
+public class TotoProvider implements Toto {
+
+ private int i = 0;
+ public static int toto = 0;
+ public static int toto_2 = 0;
+ public static int toto_3 = 0;
+ public static int toto_4 = 0;
+ public static int toto1 = 0;
+
+ public int count() {
+ return i;
+ }
+
+ public void toto() {
+ toto++;
+ }
+
+ public void toto(int i, int j) {
+ toto_2++;
+ }
+
+ public String toto(String a) {
+ toto_3++;
+ return a;
+ }
+
+ public String toto(String[] a) {
+ toto_4++;
+ return "toto";
+ }
+
+ public void toto1(String j) {
+ i++;
+ toto1++;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("i", new Integer(i));
+ props.put("toto", new Integer(toto));
+ props.put("toto_2", new Integer(toto_2));
+ props.put("toto_3", new Integer(toto_3));
+ props.put("toto_4", new Integer(toto_4));
+ props.put("toto1", new Integer(toto1));
+ return props;
+ }
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,81 @@
+/*
+ * 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.components;
+
+import org.apache.felix.ipojo.runtime.core.services.Toto;
+
+import java.util.Properties;
+
+
+public class TotoProviderGlue implements Toto {
+
+ Toto m_toto;
+
+ private int i = 0;
+ public static int toto = 0;
+ public static int toto_2 = 0;
+ public static int toto_3 = 0;
+ public static int toto_4 = 0;
+ public static int toto1 = 0;
+
+ public int count() {
+ return i;
+ }
+
+ public void toto() {
+ toto++;
+ m_toto.toto();
+ }
+
+ public void toto(int i, int j) {
+ toto_2++;
+ m_toto.toto(i, j);
+ }
+
+ public String toto(String a) {
+ toto_3++;
+ return a;
+ }
+
+ public String toto(String[] a) {
+ toto_4++;
+ return "toto";
+ }
+
+ public void toto1(String j) {
+ i++;
+ toto1++;
+ m_toto.toto1(j);
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("i", new Integer(i));
+ props.put("gtoto", new Integer(toto));
+ props.put("gtoto_2", new Integer(toto_2));
+ props.put("gtoto_3", new Integer(toto_3));
+ props.put("gtoto_4", new Integer(toto_4));
+ props.put("gtoto1", new Integer(toto1));
+ props.put("glue", "glue");
+ Properties p2 = m_toto.getProps();
+ props.putAll(p2);
+ return props;
+ }
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,25 @@
+/*
+ * 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.services.A123;
+
+public interface CheckService2 {
+
+ public boolean check();
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.services;
+
+import java.util.Properties;
+
+public interface BarService {
+
+ public boolean bar();
+
+ public Properties getProps();
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,39 @@
+/*
+ * 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.services;
+
+import java.util.Properties;
+
+public interface BazService {
+
+ boolean foo();
+
+ Properties fooProps();
+
+ Boolean getObject();
+
+ boolean getBoolean();
+
+ int getInt();
+
+ long getLong();
+
+ double getDouble();
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.services;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,39 @@
+/*
+ * 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.services;
+
+import java.util.Properties;
+
+public interface FooService {
+
+ boolean foo();
+
+ Properties fooProps();
+
+ Boolean getObject();
+
+ boolean getBoolean();
+
+ int getInt();
+
+ long getLong();
+
+ double getDouble();
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,62 @@
+/*
+ * 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.services;
+
+import java.util.Properties;
+
+public interface Tata {
+
+ public Properties getPropsTata();
+
+ public void tata();
+
+ public int tataInt(int i);
+ public long tataLong(long l);
+ public double tataDouble(double d);
+ public char tataChar(char c);
+ public boolean tataBoolean(boolean b);
+ public short tataShort(short s);
+ public float tataFloat(float f);
+ public byte tataByte(byte b);
+
+ public int[] tataInts(int[] its);
+ public long[] tataLongs(long[] l);
+ public double[] tataDoubles(double[] d);
+ public char[] tataChars(char[] c);
+ public boolean[] tataBooleans(boolean[] b);
+ public short[] tataShorts(short[] s);
+ public float[] tataFloats(float[] f);
+ public byte[] tataBytes(byte[] b);
+
+ public String tataStr();
+ public String[] tataStrs();
+
+ public void tata(int i, int j);
+ public void tata(String s);
+
+ public String tata1(String a);
+ public String tata1(char[] a);
+
+ public String tata5(String a, int i);
+ public String tata5(String[] a, int i);
+ public String tata5(String a, int[] i);
+
+ public long add(int i, int j, int k);
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,78 @@
+/*
+ * 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.services;
+
+import java.util.Properties;
+
+public interface Tota {
+
+ public static final String specification="specification { " +
+ "requires { " +
+ "$specification=\"org.apache.felix.ipojo.test.composite.service.Toto\" " +
+ "$optional=\"true\" " +
+ "$aggregate=\"true\" " +
+ "$type=\"service\" " +
+ "} }";
+
+ public Properties getProps() throws UnsupportedOperationException;;
+ public Properties getPropsTata();
+
+ public void tata();
+
+ public int tataInt(int i);
+ public long tataLong(long l);
+ public double tataDouble(double d);
+ public char tataChar(char c);
+ public boolean tataBoolean(boolean b);
+ public short tataShort(short s);
+ public float tataFloat(float f);
+ public byte tataByte(byte b);
+
+ public int[] tataInts(int[] its);
+ public long[] tataLongs(long[] l);
+ public double[] tataDoubles(double[] d);
+ public char[] tataChars(char[] c);
+ public boolean[] tataBooleans(boolean[] b);
+ public short[] tataShorts(short[] s);
+ public float[] tataFloats(float[] f);
+ public byte[] tataBytes(byte[] b);
+
+ public String tataStr();
+ public String[] tataStrs();
+
+ public void tata(int i, int j);
+ public void tata(String s);
+
+ public String tata1(String a);
+ public String tata1(char[] a);
+
+ public String tata5(String a, int i);
+ public String tata5(String[] a, int i);
+ public String tata5(String a, int[] i);
+
+ public long add(int i, int j, int k);
+
+ public void toto() throws UnsupportedOperationException;
+ public void toto(int i, int j) throws UnsupportedOperationException;
+ public String toto(String a) throws UnsupportedOperationException;
+
+ public void toto1(String j) throws UnsupportedOperationException;
+
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,37 @@
+/*
+ * 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.services;
+
+import java.util.Properties;
+
+public interface Toto {
+
+ public Properties getProps();
+
+ public void toto();
+ public void toto(int i, int j);
+ public String toto(String a);
+ public String toto(String[] a);
+
+ public void toto1(String j);
+
+ public int count();
+
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/resources/metadata.xml?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/resources/metadata.xml (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/resources/metadata.xml Tue Feb 26 13:02:34 2013
@@ -0,0 +1,112 @@
+<ipojo
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd
+ org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"
+ xmlns="org.apache.felix.ipojo"
+ xmlns:comp="org.apache.felix.ipojo.composite">
+ <!-- Used component type -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="COMPO-FooProviderType-1" architecture="true">
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="COMPO-FooProviderType-2" architecture="true">
+ <provides>
+ <property name="int" type="int" value="2" />
+ <property name="long" type="long" value="40" />
+ <property name="string" type="java.lang.String" value="foo" />
+ <property name="strAProp" type="java.lang.String[]"
+ value="{foo, bar}" />
+ <property name="intAProp" type="int[]" value="{1,2,3}" />
+ </provides>
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn"
+ name="COMPO-FooProviderType-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>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn2"
+ name="COMPO-FooProviderType-Dyn2" architecture="true">
+ <provides>
+ <property name="int" field="intProp" value="4" />
+ <property name="boolean" field="boolProp" />
+ <property name="string" field="strProp" />
+ <property name="strAProp" field="strAProp" />
+ <property name="intAProp" field="intAProp"
+ value="{1, 2,3 }" />
+ </provides>
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.CheckServiceProvider"
+ name="COMPO-SimpleCheckServiceProvider" architecture="true">
+ <requires field="fs" />
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"
+ name="COMPO-FooBarProviderType-1" architecture="true">
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"
+ name="COMPO-FooBarProviderType-2" architecture="true">
+ <provides
+ specifications="{org.apache.felix.ipojo.test.composite.service.FooService, org.apache.felix.ipojo.test.composite.service.BarService }" />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"
+ name="COMPO-FooBarProviderType-3" architecture="true">
+ <provides
+ specifications="{org.apache.felix.ipojo.test.composite.service.FooService}">
+ <property name="baz" type="java.lang.String" value="foo" />
+ </provides>
+ <provides
+ specifications="{org.apache.felix.ipojo.test.composite.service.BarService}">
+ <property name="baz" type="java.lang.String" value="bar" />
+ </provides>
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.BazProviderType1"
+ name="BazProviderType">
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.TataProvider"
+ name="tata">
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.TotoProvider"
+ name="toto" architecture="true">
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.TotoProviderGlue"
+ name="totoglue">
+ <requires field="m_toto" scope="composite" />
+ </component>
+
+ <!-- Composite -->
+ <comp:composite name="composite.empty" architecture="true">
+ </comp:composite>
+
+ <component classname="org.apache.felix.ipojo.runtime.core.components.Baz2CheckProvider" name="Baz2CheckProvider" architecture="true">
+ <requires field="fs" scope="composite"/>
+ <provides/>
+ </component>
+
+</ipojo>
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,225 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.composite.CompositeManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+ @Inject
+ protected
+ BundleContext bc;
+
+ protected OSGiHelper osgiHelper;
+ protected IPOJOHelper ipojoHelper;
+
+ protected boolean deployTestedBundle = true;
+
+ @Configuration
+ public Option[] config() throws IOException {
+ Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+ root.setLevel(Level.INFO);
+
+ if (deployTestedBundle) {
+ return options(
+ cleanCaches(),
+ ipojoBundles(),
+ junitBundles(),
+ testedBundle(),
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+ );
+ } else {
+ return options(
+ cleanCaches(),
+ ipojoBundles(),
+ junitBundles(),
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+ );
+ }
+ }
+
+ public static Option junitAndMockitoBundles() {
+ return new DefaultCompositeOption(
+ // Repository required to load harmcrest (OSGi-fied version).
+ repository("http://repository.springsource.com/maven/bundles/external").id(
+ "com.springsource.repository.bundles.external"),
+
+ // Mockito without Hamcrest and Objenesis
+ mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+ // Hamcrest with a version matching the range expected by Mockito
+ mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+ // Objenesis with a version matching the range expected by Mockito
+ wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+ .exports("*;version=1.2"),
+
+ // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+ // 4.9 which does not match the Mockito import.
+ CoreOptions.junitBundles(),
+
+ /*
+ * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+ * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+ * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+ * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+ * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+ * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+ * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+ * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+ * proxy/Callback used in the signature
+ *
+ * So we disable the bootdelegation.
+ */
+ frameworkProperty("felix.bootdelegation.implicit").value("false")
+ );
+ }
+
+
+ @Before
+ public void commonSetUp() {
+ osgiHelper = new OSGiHelper(bc);
+ ipojoHelper = new IPOJOHelper(bc);
+
+ // Dump OSGi Framework information
+ String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+ if (vendor == null) {
+ vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+ }
+ String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+ System.out.println("OSGi Framework : " + vendor + " - " + version);
+ }
+
+ @After
+ public void commonTearDown() {
+ ipojoHelper.dispose();
+ osgiHelper.dispose();
+ }
+
+ public BundleContext getContext() {
+ return bc;
+ }
+
+ public static ServiceContext getServiceContext(ComponentInstance ci) {
+ if (ci instanceof CompositeManager) {
+ return ((CompositeManager) ci).getServiceContext();
+ } else {
+ throw new RuntimeException("Cannot get the service context from a non composite instance");
+ }
+ }
+
+ public CompositeOption ipojoBundles() {
+ return new DefaultCompositeOption(
+ mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
+ mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+ // configuration admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
+ );
+ }
+
+ public Option testedBundle() throws MalformedURLException {
+ File out = new File("target/tested/bundle.jar");
+ if (out.exists()) {
+ return bundle(out.toURI().toURL().toExternalForm());
+ }
+
+ TinyBundle tested = TinyBundles.bundle();
+
+ // We look inside target/classes to find the class and resources
+ File classes = new File("target/classes");
+ Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+ List<File> services = new ArrayList<File>();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ // By convention we export of .services and .service package
+ if (file.getName().endsWith("services") || file.getName().endsWith("service")) {
+ services.add(file);
+ }
+ } else {
+ // We need to compute the path
+ String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+ tested.add(path, file.toURI().toURL());
+ System.out.println(file.getName() + " added to " + path);
+ }
+ }
+
+ // Export the inherited package, components and strategies
+ String export = "";
+ for (File file : services) {
+ if (export.length() > 0) { export += ", "; }
+ String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+ String packageName = path.replace('/', '.');
+ export += packageName;
+ }
+
+ System.out.println("Exported packages : " + export);
+
+ InputStream inputStream = tested
+ .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+ .set(Constants.IMPORT_PACKAGE, "*")
+ .set(Constants.EXPORT_PACKAGE, export)
+ .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+ try {
+ org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+ return bundle(out.toURI().toURL().toExternalForm());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot write of the manipulated bundle");
+ }
+ }
+
+ public void assertContains(String s, String[] arrays, String object) {
+ for (String suspect : arrays) {
+ if (object.equals(suspect)) {
+ return;
+ }
+ }
+ fail("Assertion failed : " + s);
+ }
+
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/EmptyCompositeTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/EmptyCompositeTest.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/EmptyCompositeTest.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/EmptyCompositeTest.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,227 @@
+/*
+ * 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;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
+import org.apache.felix.ipojo.composite.CompositeInstanceDescription;
+import org.apache.felix.ipojo.composite.CompositeManager;
+import org.junit.Test;
+import org.osgi.framework.InvalidSyntaxException;
+
+import java.util.Properties;
+
+import static org.junit.Assert.*;
+
+public class EmptyCompositeTest extends Common {
+
+ @Test
+ public void testEmptyCompositeCreation() {
+ Factory factory = ipojoHelper.getFactory("composite.empty");
+ Properties props = new Properties();
+ props.put("instance.name", "empty");
+
+ ComponentInstance ci = null;
+ try {
+ ci = factory.createComponentInstance(props);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unacceptable configuration : " + e.getMessage());
+ }
+
+ ComponentTypeDescription cd = ci.getFactory().getComponentDescription();
+ assertEquals("Check component type name", cd.getName(), "composite.empty");
+// assertEquals("Check class name (" + cd.getClassName() + ")", cd.getClassName(), "composite");
+ assertEquals("Check offered service", cd.getprovidedServiceSpecification().length, 0);
+ assertEquals("Check configurable properties", cd.getProperties().length, 0);
+
+ CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
+ assertEquals("Check composite instance name", id.getName(), "empty");
+ assertEquals("Check composite instance state (" + id.getState() + ")", id.getState(), ComponentInstance.VALID);
+
+ assertEquals("Check contained instance", id.getContainedInstances().length, 0);
+
+ assertTrue("Check composite manager", ci instanceof CompositeManager);
+ CompositeManager cm = (CompositeManager) ci;
+ ServiceContext sc = cm.getServiceContext();
+ try {
+ assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
+ } catch (InvalidSyntaxException e) {
+ fail("Invalid filter : " + e.getMessage());
+ }
+ ci.dispose();
+ }
+
+ @Test
+ public void testInstanceCreation1() {
+ Factory factory = ipojoHelper.getFactory("composite.empty");
+ Properties props = new Properties();
+ props.put("instance.name", "empty");
+
+ ComponentInstance ci = null;
+ try {
+ ci = factory.createComponentInstance(props);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unacceptable configuration : " + e.getMessage());
+ }
+
+ assertTrue("Check composite manager", ci instanceof CompositeManager);
+ CompositeManager cm = (CompositeManager) ci;
+ ServiceContext sc = cm.getServiceContext();
+ try {
+ assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
+ } catch (InvalidSyntaxException e) {
+ fail("Invalid filter : " + e.getMessage());
+ }
+
+ Properties props2 = new Properties();
+ props2.put("instance.name", "empty2");
+ ComponentInstance ci2 = null;
+ try {
+ ci2 = factory.createComponentInstance(props2, sc);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unacceptable configuration : " + e.getMessage());
+ }
+
+ CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
+ assertEquals("Check composite instance name", id.getName(), "empty");
+ assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id.getContainedInstances().length, 1);
+ CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];
+ assertEquals("Check composite instance name", id2.getName(), "empty2");
+ assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id2.getContainedInstances().length, 0);
+
+ ci2.dispose();
+ //id = ci.getInstanceDescription();
+ assertEquals("Check composite instance name", id.getName(), "empty");
+ assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id.getContainedInstances().length, 0);
+
+ ci.dispose();
+ }
+
+ @Test
+ public void testInstanceCreation2() {
+ Factory factory = ipojoHelper.getFactory("composite.empty");
+ Properties props = new Properties();
+ props.put("instance.name", "empty");
+
+ ComponentInstance ci = null;
+ try {
+ ci = factory.createComponentInstance(props);
+ } catch (Exception e) {
+ fail("Unacceptable configuration : " + e.getMessage());
+ }
+
+ assertTrue("Check composite manager", ci instanceof CompositeManager);
+ CompositeManager cm = (CompositeManager) ci;
+ ServiceContext sc = cm.getServiceContext();
+ try {
+ assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
+ } catch (InvalidSyntaxException e) {
+ fail("Invalid filter : " + e.getMessage());
+ }
+
+ Factory factory2 = ipojoHelper.getFactory(sc, "composite.empty");
+ assertNotNull("Check factory2 not null", factory2);
+ Properties props2 = new Properties();
+ props2.put("instance.name", "empty2");
+ ComponentInstance ci2 = null;
+ try {
+ ci2 = factory2.createComponentInstance(props2);
+ } catch (Exception e) {
+ fail("Unacceptable configuration : " + e.getMessage());
+ }
+
+ CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
+ assertEquals("Check composite instance name", id.getName(), "empty");
+ assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id.getContainedInstances().length, 1);
+ CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];
+ assertEquals("Check composite instance name", id2.getName(), "empty2");
+ assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id2.getContainedInstances().length, 0);
+
+ ci2.dispose();
+ //id = ci.getInstanceDescription();
+ assertEquals("Check composite instance name", id.getName(), "empty");
+ assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id.getContainedInstances().length, 0);
+
+ ci.dispose();
+ }
+
+ @Test
+ public void testInstanceCreation3() {
+ Factory factory = ipojoHelper.getFactory("composite.empty");
+ Properties props = new Properties();
+ props.put("instance.name", "empty");
+
+ ComponentInstance ci = null;
+ try {
+ ci = factory.createComponentInstance(props);
+ } catch (Exception e) {
+ fail("Unacceptable configuration : " + e.getMessage());
+ }
+
+ assertTrue("Check composite manager", ci instanceof CompositeManager);
+ CompositeManager cm = (CompositeManager) ci;
+ ServiceContext sc = cm.getServiceContext();
+ try {
+ assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
+ } catch (InvalidSyntaxException e) {
+ fail("Invalid filter : " + e.getMessage());
+ }
+
+ Factory factory2 = ipojoHelper.getFactory(sc, "composite.empty");
+ assertNotNull("Check factory2 not null", factory2);
+ Properties props2 = new Properties();
+ props2.put("instance.name", "empty2");
+ ComponentInstance ci2 = null;
+ try {
+ ci2 = factory2.createComponentInstance(props2, sc);
+ } catch (Exception e) {
+ fail("Unacceptable configuration : " + e.getMessage());
+ }
+
+ CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
+ assertEquals("Check composite instance name", id.getName(), "empty");
+ assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id.getContainedInstances().length, 1);
+ CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];
+ assertEquals("Check composite instance name", id2.getName(), "empty2");
+ assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id2.getContainedInstances().length, 0);
+
+ ci2.dispose();
+ //id = ci.getInstanceDescription();
+ assertEquals("Check composite instance name", id.getName(), "empty");
+ assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
+ assertEquals("Check contained instance", id.getContainedInstances().length, 0);
+
+ ci.dispose();
+ }
+
+
+}
Added: felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/FactoryManagementTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/FactoryManagementTest.java?rev=1450158&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/FactoryManagementTest.java (added)
+++ felix/trunk/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/FactoryManagementTest.java Tue Feb 26 13:02:34 2013
@@ -0,0 +1,320 @@
+/*
+ * 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;
+
+import org.apache.felix.ipojo.*;
+import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Properties;
+
+import static org.junit.Assert.*;
+
+public class FactoryManagementTest extends Common {
+
+ private FakeFactory fake1 = new FakeFactory("fake");
+ private FakeFactory fake2 = new FakeFactory("fake2");
+
+ private Factory emptyFactory;
+ private ComponentInstance empty;
+
+ private class FakeFactory implements Factory {
+
+ private String m_name;
+
+ public FakeFactory(String name) {
+ m_name = name;
+ }
+
+ public ComponentInstance createComponentInstance(Dictionary arg0) throws UnacceptableConfiguration {
+ return null;
+ }
+
+ public ComponentInstance createComponentInstance(Dictionary arg0, ServiceContext arg1) throws UnacceptableConfiguration {
+ return null;
+ }
+
+ public Element getDescription() {
+ return null;
+ }
+
+ public String getName() {
+ return m_name;
+ }
+
+ public boolean isAcceptable(Dictionary arg0) {
+ return false;
+ }
+
+ public void reconfigure(Dictionary arg0) throws UnacceptableConfiguration {
+ }
+
+ public void addFactoryStateListener(FactoryStateListener arg0) {
+ }
+
+ public List getMissingHandlers() {
+ return null;
+ }
+
+ public List getRequiredHandlers() {
+ return null;
+ }
+
+ public void removeFactoryStateListener(FactoryStateListener arg0) {
+ }
+
+ public ComponentTypeDescription getComponentDescription() {
+ return null;
+ }
+
+ public String getClassName() {
+ return "";
+ }
+
+ public int getState() {
+ return Factory.VALID;
+ }
+
+ public BundleContext getBundleContext() {
+ return getContext();
+ }
+
+ public String getVersion() {
+ return null;
+ }
+
+ public Element getComponentMetadata() {
+ return null;
+ }
+
+ }
+
+ @Before
+ public void setUp() {
+ emptyFactory = ipojoHelper.getFactory("composite.empty");
+ Properties props = new Properties();
+ props.put("instance.name", "empty-1");
+ try {
+ empty = emptyFactory.createComponentInstance(props);
+ } catch (Exception e) {
+ fail("Cannot create empty instance " + e.getMessage());
+ }
+ }
+
+ @After
+ public void tearDown() {
+ empty.dispose();
+ empty = null;
+ }
+
+ @Test
+ public void testOneLevelExposition() {
+ ServiceReference[] parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);
+ ServiceContext sc = getServiceContext(empty);
+ ServiceReference[] internalFactoryReferences = ipojoHelper.getServiceReferences(sc, Factory.class.getName(), null);
+
+ assertEquals("Check the number of available factories", parentsFactoryReferences.length, internalFactoryReferences.length);
+
+ for (int i = 0; i < parentsFactoryReferences.length; i++) {
+ Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);
+ assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, internalFactoryReferences, sc));
+ }
+ }
+
+ @Test
+ public void testTwoLevelExposition() {
+ ServiceReference[] parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);
+ ServiceContext sc1 = getServiceContext(empty);
+ ServiceReference[] Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);
+
+ Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");
+ Properties p = new Properties();
+ p.put("instance.name", "empty2");
+ ComponentInstance empty2 = null;
+ try {
+ empty2 = fact.createComponentInstance(p);
+ } catch (Exception e) {
+ fail("Cannot instantiate empty2 instance : " + e.getMessage());
+ }
+
+ ServiceContext sc2 = getServiceContext(empty2);
+ ServiceReference[] Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);
+
+ assertEquals("Check the number of available factories - 1", parentsFactoryReferences.length, Level1FactoryReferences.length);
+ assertEquals("Check the number of available factories - 2", parentsFactoryReferences.length, Level2FactoryReferences.length);
+ assertEquals("Check the number of available factories - 3", Level1FactoryReferences.length, Level2FactoryReferences.length);
+
+ for (int i = 0; i < Level1FactoryReferences.length; i++) {
+ Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);
+ assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, Level2FactoryReferences, sc2));
+ }
+
+ empty2.dispose();
+ }
+
+ @Test
+ public void testDynamism() {
+ ServiceReference[] parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);
+ ServiceContext sc1 = getServiceContext(empty);
+ ServiceReference[] Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);
+
+ Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");
+ Properties p = new Properties();
+ p.put("instance.name", "empty2");
+ ComponentInstance empty2 = null;
+ try {
+ empty2 = fact.createComponentInstance(p);
+ } catch (Exception e) {
+ fail("Cannot instantiate empty2 instance : " + e.getMessage());
+ }
+
+ ServiceContext sc2 = getServiceContext(empty2);
+ ServiceReference[] Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);
+
+ assertEquals("Check the number of available factories - 1", parentsFactoryReferences.length, Level1FactoryReferences.length);
+ assertEquals("Check the number of available factories - 2", parentsFactoryReferences.length, Level2FactoryReferences.length);
+ assertEquals("Check the number of available factories - 3", Level1FactoryReferences.length, Level2FactoryReferences.length);
+
+ for (int i = 0; i < Level1FactoryReferences.length; i++) {
+ Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);
+ assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, Level2FactoryReferences, sc2));
+ }
+
+ // Publish fake1
+ ServiceRegistration reg1 = getContext().registerService(Factory.class.getName(), fake1, null);
+
+ parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);
+ sc1 = getServiceContext(empty);
+ Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);
+ sc2 = getServiceContext(empty2);
+ Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);
+
+ assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);
+ assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);
+ assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);
+
+ // Publish fake2
+ ServiceRegistration reg2 = getContext().registerService(Factory.class.getName(), fake2, null);
+
+ parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);
+ sc1 = getServiceContext(empty);
+ Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);
+ sc2 = getServiceContext(empty2);
+ Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);
+
+ assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);
+ assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);
+ assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);
+
+ reg1.unregister();
+
+ parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);
+ sc1 = getServiceContext(empty);
+ Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);
+ sc2 = getServiceContext(empty2);
+ Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);
+
+ assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);
+ assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);
+ assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);
+
+ reg2.unregister();
+
+ parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);
+ sc1 = getServiceContext(empty);
+ Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);
+ sc2 = getServiceContext(empty2);
+ Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);
+
+ assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);
+ assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);
+ assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);
+
+ empty2.dispose();
+ }
+
+ @Test
+ public void testInvocation() {
+ ServiceContext sc1 = getServiceContext(empty);
+ Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");
+ Properties p = new Properties();
+ p.put("instance.name", "empty2");
+ ComponentInstance empty2 = null;
+ try {
+ empty2 = fact.createComponentInstance(p);
+ } catch (Exception e) {
+ fail("Cannot instantiate empty2 instance : " + e.getMessage());
+ }
+
+ ServiceContext sc2 = getServiceContext(empty2);
+
+ Factory fact1 = ipojoHelper.getFactory(sc2, "COMPO-SimpleCheckServiceProvider");
+ Properties props = new Properties();
+ props.put("instance.name", "client");
+ ComponentInstance client = null;
+ try {
+ client = fact1.createComponentInstance(props);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Cannot instantiate the client : " + e.getMessage());
+ }
+
+ Factory fact2 = ipojoHelper.getFactory(sc2, "COMPO-FooProviderType-1");
+ Properties props2 = new Properties();
+ props2.put("instance.name", "provider");
+ ComponentInstance provider = null;
+ try {
+ provider = fact2.createComponentInstance(props2);
+ } catch (Exception e) {
+ fail("Cannot instantiate the provider : " + e.getMessage());
+ }
+
+ ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
+ assertNotNull("Check ref existency", ref);
+ CheckService check = (CheckService) sc2.getService(ref);
+
+ assertTrue("Check invocation", check.check());
+ client.dispose();
+ provider.dispose();
+ empty2.dispose();
+ }
+
+
+ private boolean isExposed(Factory fact, ServiceReference[] refs, ServiceContext sc) {
+ for (int i = 0; i < refs.length; i++) {
+ Factory f = (Factory) sc.getService(refs[i]);
+ if (fact.getName().equals(f.getName())) {
+ sc.ungetService(refs[i]);
+ return true;
+ }
+ sc.ungetService(refs[i]);
+ }
+ return false;
+ }
+
+}