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 2008/04/25 18:50:22 UTC
svn commit: r651646 [3/22] - in /felix/trunk/ipojo/tests: ./
tests.composite/ tests.composite/src/ tests.composite/src/main/
tests.composite/src/main/java/ tests.composite/src/main/java/org/
tests.composite/src/main/java/org/apache/ tests.composite/src...
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCController.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCController.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCController.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCController.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,103 @@
+/*
+ * 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.bad;
+
+import org.apache.felix.ipojo.ComponentFactory;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.ManifestMetadataParser;
+import org.apache.felix.ipojo.parser.ParseException;
+
+public class BadLFCController extends OSGiTestCase {
+
+ private String clazz = "org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest";
+
+ private Element getNoFieldController() {
+ Element elem = new Element("component", "");
+ elem.addAttribute(new Attribute("classname", clazz));
+
+ Element controller = new Element("controller", "");
+ elem.addElement(controller);
+ return elem;
+ }
+
+ private Element getBadFieldController() {
+ Element elem = new Element("component", "");
+ elem.addAttribute(new Attribute("classname", clazz));
+
+ Element controller = new Element("controller", "");
+ controller.addAttribute(new Attribute("field", "controller")); // Missing field
+ elem.addElement(controller);
+ elem.addElement(getManipulationForComponent("BAD-lcTest"));
+ return elem;
+ }
+
+ private Element getManipulationForComponent(String comp_name) {
+ String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parseHeaderMetadata(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+ Element manip = getManipulationForComponent(elem, comp_name);
+ assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
+ return manip;
+ }
+
+ private Element getManipulationForComponent(Element metadata, String comp_name) {
+ Element[] comps = metadata.getElements("component");
+ for(int i = 0; i < comps.length; i++) {
+ if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
+ return comps[i].getElements("manipulation")[0];
+ }
+ if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
+ return comps[i].getElements("manipulation")[0];
+ }
+ }
+ return null;
+ }
+
+ public void testNoField() {
+ try {
+ ComponentFactory cf = new ComponentFactory(context, getNoFieldController());
+ cf.start();
+ cf.stop();
+ fail("A lifecycle controller with a missing field must be rejected " + cf);
+ } catch (Exception e) {
+ // OK
+ }
+ }
+
+ public void testBadField() {
+ try {
+ ComponentFactory cf = new ComponentFactory(context, getBadFieldController());
+ cf.start();
+ cf.stop();
+ fail("A lifecycle controller with a bad field must be rejected " + cf);
+ } catch (Exception e) {
+ // OK
+ }
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadServiceDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadServiceDependencies.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadServiceDependencies.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadServiceDependencies.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,231 @@
+/*
+ * 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.bad;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentFactory;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.MissingHandlerException;
+import org.apache.felix.ipojo.UnacceptableConfiguration;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.ManifestMetadataParser;
+import org.apache.felix.ipojo.parser.ParseException;
+import org.apache.felix.ipojo.test.scenarios.bad.service.BarService;
+
+public class BadServiceDependencies extends OSGiTestCase {
+
+ private String clazz = "org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider";
+ private String type = "BAD-BothCheckServiceProvider";
+ private Element manipulation;
+ private Properties props;
+
+ public void setUp() {
+ manipulation = getManipulationForComponent();
+ props = new Properties();
+ props.put("name", "BAD");
+ }
+
+
+ private Element getNothing() {
+ Element elem = new Element("component", "");
+ elem.addAttribute(new Attribute("classname", clazz));
+
+ Element callback = new Element("requires", "");
+ elem.addElement(callback);
+ elem.addElement(manipulation);
+ return elem;
+ }
+
+ private Element getNoField() {
+ Element elem = new Element("component", "");
+ elem.addAttribute(new Attribute("classname", clazz));
+
+ Element callback = new Element("requires", "");
+ callback.addAttribute(new Attribute("filter", "(foo=bar)"));
+ elem.addElement(callback);
+ elem.addElement(manipulation);
+ return elem;
+ }
+
+ private Element getBadField() {
+ Element elem = new Element("component", "");
+ elem.addAttribute(new Attribute("classname", clazz));
+
+ Element callback = new Element("requires", "");
+ callback.addAttribute(new Attribute("field", "BAD_FIELD")); // missing field.
+ elem.addElement(callback);
+ elem.addElement(manipulation);
+ return elem;
+ }
+
+ private Element getBadFilter() {
+ Element elem = new Element("component", "");
+ elem.addAttribute(new Attribute("classname", clazz));
+
+ Element callback = new Element("requires", "");
+ callback.addAttribute(new Attribute("field", "fs"));
+ callback.addAttribute(new Attribute("filter", "(foo=bar)&(bar=foo)")); // Incorrect filter
+ elem.addElement(callback);
+ elem.addElement(manipulation);
+ return elem;
+ }
+
+ private Element getBadType() {
+ Element elem = new Element("component", "");
+ elem.addAttribute(new Attribute("classname", clazz));
+
+ Element callback = new Element("requires", "");
+ callback.addAttribute(new Attribute("field", "fs"));
+ callback.addAttribute(new Attribute("interface", BarService.class.getName()));
+ elem.addElement(callback);
+ elem.addElement(manipulation);
+ return elem;
+ }
+
+ private Element getBadAggregate() {
+ Element elem = new Element("component", "");
+ elem.addAttribute(new Attribute("classname", clazz));
+
+ Element callback = new Element("requires", "");
+ callback.addAttribute(new Attribute("field", "fs"));
+ callback.addAttribute(new Attribute("aggregate", "true"));
+ elem.addElement(callback);
+ elem.addElement(manipulation);
+ return elem;
+ }
+
+
+ private Element getManipulationForComponent() {
+ String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parse(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+ Element manip = getManipulationForComponent(elem, type);
+ assertNotNull("Check manipulation metadata not null for " + type, manip);
+ return manip;
+ }
+
+ private Element getManipulationForComponent(Element metadata, String comp_name) {
+ Element[] comps = metadata.getElements("component");
+ for(int i = 0; i < comps.length; i++) {
+ if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
+ return comps[i].getElements("manipulation")[0];
+ }
+ if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
+ return comps[i].getElements("manipulation")[0];
+ }
+ }
+ return null;
+ }
+
+ public void testNothing() {
+ try {
+ ComponentFactory cf = new ComponentFactory(context, getNothing());
+ cf.start();
+ ComponentInstance ci = cf.createComponentInstance(props);
+ ci.dispose();
+ cf.stop();
+ fail("A service requirement with neither field and method must be rejected " + cf);
+ } catch (ConfigurationException e) {
+ // OK
+ } catch (UnacceptableConfiguration e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ } catch (MissingHandlerException e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ }
+ }
+
+ public void testNoField() {
+ try {
+ ComponentFactory cf = new ComponentFactory(context, getNoField());
+ cf.start();
+ ComponentInstance ci = cf.createComponentInstance(props);
+ ci.dispose();
+ cf.stop();
+ fail("A service requirement with neither field and method must be rejected " + cf);
+ } catch (ConfigurationException e) {
+ // OK
+ } catch (UnacceptableConfiguration e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ } catch (MissingHandlerException e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ }
+ }
+
+ public void testBadField() {
+ try {
+ ComponentFactory cf = new ComponentFactory(context, getBadField());
+ cf.start();
+ ComponentInstance ci = cf.createComponentInstance(props);
+ ci.dispose();
+ cf.stop();
+ fail("A service requirement with a bad field must be rejected " + cf);
+ }catch (ConfigurationException e) {
+ // OK
+ } catch (UnacceptableConfiguration e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ } catch (MissingHandlerException e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ }
+ }
+
+ public void testBadFilter() {
+ try {
+ ComponentFactory cf = new ComponentFactory(context, getBadFilter());
+ cf.start();
+ ComponentInstance ci = cf.createComponentInstance(props);
+ ci.dispose();
+ cf.stop();
+ fail("A service requirement with a bad filter must be rejected " + cf);
+ }catch (ConfigurationException e) {
+ //OK
+ } catch (UnacceptableConfiguration e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ } catch (MissingHandlerException e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ }
+ }
+
+ public void testBadType() {
+ try {
+ ComponentFactory cf = new ComponentFactory(context, getBadType());
+ cf.start();
+ ComponentInstance ci = cf.createComponentInstance(props);
+ ci.dispose();
+ cf.stop();
+ fail("A service requirement with a bad type must be rejected " + cf);
+ }catch (ConfigurationException e) {
+ // OK
+ } catch (UnacceptableConfiguration e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ } catch (MissingHandlerException e) {
+ fail("Unexpected exception when creating an instance : " + e.getMessage());
+ }
+ }
+ }
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadTestSuite.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadTestSuite.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadTestSuite.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.bad;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class BadTestSuite {
+
+ public static Test suite(BundleContext bc) {
+ OSGiTestSuite ots = new OSGiTestSuite("Bad configuration test suite", bc);
+ ots.addTestSuite(BadFactories.class);
+ ots.addTestSuite(BadLFCController.class);
+ ots.addTestSuite(BadLFCCallback.class);
+ ots.addTestSuite(BadServiceDependencies.class);
+ return ots;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/BarService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/BarService.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/BarService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/BarService.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.bad.service;
+
+import java.util.Properties;
+
+public interface BarService {
+
+ public boolean bar();
+
+ public Properties getProps();
+
+}
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/CheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/CheckService.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/CheckService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/CheckService.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.bad.service;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/FooService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/FooService.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/FooService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/FooService.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.bad.service;
+
+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/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.bad.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.bad.service.FooService;
+
+public class CallbackCheckService extends ParentClass implements CheckService {
+
+ int i = 0;
+
+ FooService fs;
+
+ public static CallbackCheckService singleton;
+
+ public static int count = 0;
+
+ private static CallbackCheckService singleton() {
+ if (singleton == null) {
+ count++;
+ singleton = new CallbackCheckService();
+ }
+ return singleton;
+ }
+
+ public static CallbackCheckService several() {
+ count++;
+ return new CallbackCheckService();
+ }
+
+ private void start() {
+ i++;
+ }
+
+ protected void stop() {
+ i++;
+ }
+
+ public boolean check() {
+ return fs.foo();
+ }
+
+ public Properties getProps() {
+ Properties p = new Properties();
+ p.put("int", new Integer(i));
+ p.put("count", new Integer(count));
+ return p;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.felix.ipojo.test.scenarios.bad.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public abstract class CheckProviderParentClass {
+
+ int simpleU = 0;
+ int objectU = 0;
+ int refU = 0;
+ int bothU = 0;
+
+
+ public void bothUnbind(FooService o, ServiceReference sr) {
+ if(sr != null && o != null && o instanceof FooService) { bothU++; }
+ }
+
+ public void refUnbind(ServiceReference sr) {
+ if(sr != null) { refU++; }
+ }
+
+ public void objectUnbind(FooService o) {
+ if(o != null && o instanceof FooService) { objectU++; }
+ else {
+ System.err.println("Unbind null : " + o);
+ }
+ }
+
+ public void voidUnbind() {
+ simpleU++;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.bad.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.bad.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+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/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,49 @@
+/*
+ * 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.bad.service.CheckService;
+
+public class LifecycleControllerTest implements CheckService {
+
+ private boolean m_state = true;
+ private String m_conf;
+
+ public void setConf(String newConf) {
+ if (newConf.equals("foo")) {
+ m_state = true;
+ } else {
+ m_state = false;
+ }
+ }
+
+ public boolean check() {
+ return m_state;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("conf", m_conf);
+ props.put("state", new Boolean(m_state));
+ return props;
+ }
+}
+
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+public class ParentClass {
+
+ public void parentStart() {
+
+ }
+
+ public void parentStop() {
+
+ }
+
+ protected String[] strings;
+
+ protected String string;
+
+ protected int upStrings;
+
+ protected int upString;
+
+ public void updateStrings(String[] bb) {
+ strings = bb;
+ upStrings++;
+ }
+
+ public void updateString(String bb) {
+ string = bb;
+ upString++;
+ }
+
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,326 @@
+/*
+ * 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.util;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import junit.framework.Assert;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.HandlerFactory;
+import org.apache.felix.ipojo.ServiceContext;
+//import org.apache.felix.ipojo.composite.CompositeManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ManagedServiceFactory;
+
+public class Utils {
+
+ public static Factory getFactoryByName(BundleContext bc, String factoryName) {
+ ServiceReference[] refs;
+ try {
+ refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
+ if (refs == null) {
+ System.err.println("Cannot get the factory " + factoryName);
+ return null;
+ }
+ return ((Factory) bc.getService(refs[0]));
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+ return null;
+ }
+ }
+
+ public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
+ ServiceReference[] refs;
+ try {
+ refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
+ if (refs == null) {
+ System.err.println("Cannot get the factory " + factoryName);
+ return null;
+ }
+ return (HandlerFactory) bc.getService(refs[0]);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+ return null;
+ }
+ }
+
+ public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
+ Factory fact = getFactoryByName(bc, factoryName);
+
+ if (fact == null) {
+ System.err.println("Factory " + factoryName + " not found");
+ return null;
+ }
+
+ // if(fact.isAcceptable(configuration)) {
+ try {
+ return fact.createComponentInstance(configuration);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
+ return null;
+ }
+ // }
+ // else {
+ // System.err.println("Configuration not accepted by : " + factoryName);
+ // return null;
+ // }
+ }
+
+ public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
+ Factory fact = getFactoryByName(bc, factoryName);
+
+ if (fact == null) {
+ System.err.println("Factory " + factoryName + " not found");
+ return null;
+ }
+
+ try {
+ Properties props = new Properties();
+ props.put("name", name);
+ return fact.createComponentInstance(props);
+ } catch (Exception e) {
+ System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
+ ServiceReference[] refs = null;
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return new ServiceReference[0];
+ } else {
+ return refs;
+ }
+ }
+
+ public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
+ ServiceReference[] refs = null;
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else {
+ return refs[0];
+ }
+ }
+
+ public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
+ ServiceReference[] refs = null;
+ String filter = null;
+ if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
+ filter = "(" + "factory.name" + "=" + name + ")";
+ } else {
+ filter = "(" + "instance.name" + "=" + name + ")";
+ }
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else {
+ return refs[0];
+ }
+ }
+
+ public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
+ ServiceReference[] refs = null;
+ String filter = "(" + "service.pid" + "=" + pid + ")";
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else if (refs.length == 1) {
+ return refs[0];
+ } else {
+ Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
+ return null;
+ }
+ }
+
+ public static Object getServiceObject(BundleContext bc, String itf, String filter) {
+ ServiceReference ref = getServiceReference(bc, itf, filter);
+ if (ref != null) {
+ return bc.getService(ref);
+ } else {
+ return null;
+ }
+ }
+
+ public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
+ ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+ if (refs != null) {
+ Object[] list = new Object[refs.length];
+ for (int i = 0; i < refs.length; i++) {
+ list[i] = bc.getService(refs[i]);
+ }
+ return list;
+ } else {
+ return new Object[0];
+ }
+ }
+
+// public static ServiceContext getServiceContext(ComponentInstance ci) {
+// if (ci instanceof CompositeManager) {
+// return ((CompositeManager) ci).getServiceContext();
+// } else {
+// throw new RuntimeException("Cannot get the service context form an non composite instance");
+// }
+// }
+
+ public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
+ ServiceReference[] refs;
+ try {
+ refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
+ if (refs == null) { return null; }
+ return ((Factory) bc.getService(refs[0]));
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+ return null;
+ }
+ }
+
+ public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
+ Factory fact = getFactoryByName(bc, factoryName);
+
+ if (fact == null) { return null; }
+
+ if (fact.isAcceptable(configuration)) {
+ try {
+ return fact.createComponentInstance(configuration);
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ return null;
+ }
+ } else {
+ System.err.println("Configuration not accepted by : " + factoryName);
+ return null;
+ }
+ }
+
+ public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
+ ServiceReference[] refs = null;
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return new ServiceReference[0];
+ } else {
+ return refs;
+ }
+ }
+
+ public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
+ ServiceReference[] refs = null;
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else {
+ return refs[0];
+ }
+ }
+
+ public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
+ ServiceReference[] refs = null;
+ String filter = null;
+ if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
+ filter = "(" + "factory.name" + "=" + name + ")";
+ } else {
+ filter = "(" + "instance.name" + "=" + name + ")";
+ }
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else {
+ return refs[0];
+ }
+ }
+
+ public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
+ ServiceReference ref = getServiceReference(bc, itf, filter);
+ if (ref != null) {
+ return bc.getService(ref);
+ } else {
+ return null;
+ }
+ }
+
+ public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
+ ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+ if (refs != null) {
+ Object[] list = new Object[refs.length];
+ for (int i = 0; i < refs.length; i++) {
+ list[i] = bc.getService(refs[i]);
+ }
+ return list;
+ } else {
+ return new Object[0];
+ }
+ }
+
+ public static boolean contains(String string, String[] array) {
+ for (int i = 0; array != null && i < array.length; i++) {
+ if (array[i] != null && array[i].equals(string)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean contains(int value, int[] array) {
+ for (int i = 0; array != null && i < array.length; i++) {
+ if (array[i] == value) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/resources/metadata.xml?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/resources/metadata.xml (added)
+++ felix/trunk/ipojo/tests/tests.core.bad.configurations/src/main/resources/metadata.xml Fri Apr 25 09:49:43 2008
@@ -0,0 +1,31 @@
+<ipojo>
+ <component
+ className="org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"
+ factory="BAD-CallbackCheckService" architecture="true">
+ <requires field="fs" />
+ <provides />
+ <callback transition="validate" method="start" />
+ <callback transition="invalidate" method="stop" />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"
+ name="BAD-lcTest">
+ <provides />
+ <controller field="m_state" />
+ <properties>
+ <property name="conf" field="m_conf" method="setConf" />
+ </properties>
+ </component>
+
+ <component
+ className="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ factory="BAD-BothCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="bothBind" />
+ <callback type="unbind" method="bothUnbind" />
+ </requires>
+ <provides />
+ </component>
+
+</ipojo>
Propchange: felix/trunk/ipojo/tests/tests.core.configuration/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 25 09:49:43 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+
Added: felix/trunk/ipojo/tests/tests.core.configuration/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/pom.xml?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/pom.xml (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/pom.xml Fri Apr 25 09:49:43 2008
@@ -0,0 +1,102 @@
+<!--
+ 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>iPOJO Configuration Management Test Suite</name>
+ <artifactId>tests.core.configuration</artifactId>
+ <groupId>ipojo.tests</groupId>
+ <version>0.7.6-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.metadata</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>ipojo.examples</groupId>
+ <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.felix.ipojo.test.scenarios.configuration.service
+ </Export-Package>
+ <Bundle-SymbolicName>
+ ${pom.artifactId}
+ </Bundle-SymbolicName>
+ <Private-Package>
+ org.apache.felix.ipojo.test*
+ </Private-Package>
+ <Test-Suite>
+ org.apache.felix.ipojo.test.scenarios.configuration.ConfigurationTestSuite
+ </Test-Suite>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-ipojo-plugin</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ <configuration>
+ <ignoreAnnotations>true</ignoreAnnotations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public abstract class CheckProviderParentClass {
+
+ int simpleU = 0;
+ int objectU = 0;
+ int refU = 0;
+ int bothU = 0;
+
+
+ public void bothUnbind(FooService o, ServiceReference sr) {
+ if(sr != null && o != null && o instanceof FooService) { bothU++; }
+ }
+
+ public void refUnbind(ServiceReference sr) {
+ if(sr != null) { refU++; }
+ }
+
+ public void objectUnbind(FooService o) {
+ if(o != null && o instanceof FooService) { objectU++; }
+ else {
+ System.err.println("Unbind null : " + o);
+ }
+ }
+
+ public void voidUnbind() {
+ simpleU++;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+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/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,202 @@
+/*
+ * 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.configuration.service.CheckService;
+
+public class ConfigurableCheckServiceProvider implements CheckService {
+
+ // Integer types
+ byte b;
+ short s;
+ int i;
+ long l;
+
+ // Floatting types
+ double d;
+ float f;
+
+ // Character
+ char c;
+
+ // Boolean
+ boolean bool;
+
+ // Integer arrays
+ byte[] bs;
+ short[] ss;
+ int[] is;
+ long[] ls;
+
+ double[] ds;
+ float[] fs;
+
+ char[] cs;
+
+ boolean[] bools;
+
+ String string;
+ String[] strings;
+
+ int upB, upS, upI, upL, upD, upF, upC, upBool, upBs, upSs, upIs, upLs, upDs, upFs, upCs, upBools, upString, upStrings;
+
+
+ public boolean check() {
+ return true;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("b", new Byte(b));
+ props.put("s", new Short(s));
+ props.put("i", new Integer(i));
+ props.put("l", new Long(l));
+ props.put("d", new Double(d));
+ props.put("f", new Float(f));
+ props.put("c", new Character(c));
+ props.put("bool", new Boolean(bool));
+
+ props.put("bs", bs);
+ props.put("ss", ss);
+ props.put("is", is);
+ props.put("ls", ls);
+ props.put("ds", ds);
+ props.put("fs", fs);
+ props.put("cs", cs);
+ props.put("bools", bools);
+
+ props.put("upb", new Integer(upB));
+ props.put("ups", new Integer(upS));
+ props.put("upi", new Integer(upI));
+ props.put("upl", new Integer(upL));
+ props.put("upd", new Integer(upD));
+ props.put("upf", new Integer(upF));
+ props.put("upc", new Integer(upC));
+ props.put("upbool", new Integer(upBool));
+
+ props.put("upbs", new Integer(upBs));
+ props.put("upss", new Integer(upSs));
+ props.put("upis", new Integer(upIs));
+ props.put("upls", new Integer(upLs));
+ props.put("upds", new Integer(upDs));
+ props.put("upfs", new Integer(upFs));
+ props.put("upcs", new Integer(upCs));
+ props.put("upbools", new Integer(upBools));
+
+ props.put("string", string);
+ props.put("strings", strings);
+ props.put("upstring", new Integer(upString));
+ props.put("upstrings", new Integer(upStrings));
+
+ return props;
+ }
+
+ public void updateB(byte bb) {
+ b = bb;
+ upB++;
+ }
+
+ public void updateS(short bb) {
+ s = bb;
+ upS++;
+ }
+
+ public void updateI(int bb) {
+ i = bb;
+ upI++;
+ }
+
+ public void updateL(long bb) {
+ l = bb;
+ upL++;
+ }
+
+ public void updateD(double bb) {
+ d = bb;
+ upD++;
+ }
+
+ public void updateF(float bb) {
+ f = bb;
+ upF++;
+ }
+
+ public void updateC(char bb) {
+ c = bb;
+ upC++;
+ }
+
+ public void updateBool(boolean bb) {
+ bool = bb;
+ upBool++;
+ }
+
+ public void updateBs(byte[] bb) {
+ bs = bb;
+ upBs++;
+ }
+
+ public void updateSs(short[] bb) {
+ ss = bb;
+ upSs++;
+ }
+
+ public void updateIs(int[] bb) {
+ is = bb;
+ upIs++;
+ }
+
+ public void updateLs(long[] bb) {
+ ls = bb;
+ upLs++;
+ }
+
+ public void updateDs(double[] bb) {
+ ds = bb;
+ upDs++;
+ }
+
+ public void updateFs(float[] bb) {
+ fs = bb;
+ upFs++;
+ }
+
+ public void updateCs(char[] bb) {
+ cs = bb;
+ upCs++;
+ }
+
+ public void updateBools(boolean[] bb) {
+ bools = bb;
+ upBools++;
+ }
+
+ public void updateStrings(String[] bb) {
+ strings = bb;
+ upStrings++;
+ }
+
+ public void updateString(String bb) {
+ string = bb;
+ upString++;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,117 @@
+/*
+ * 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.configuration.service.FooService;
+import org.osgi.framework.BundleContext;
+
+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;
+
+ private static FooProviderType1 singleton(BundleContext bc) {
+ if (singleton == null) {
+ count++;
+ singleton = new FooProviderType1(bc);
+ }
+ return singleton;
+ }
+
+ public static FooProviderType1 several(BundleContext bc) {
+ count++;
+ return new FooProviderType1(bc);
+ }
+
+ 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); }
+
+ /**
+ * Custom constructor.
+ * @param bar
+ * @param foo
+ * @param bc
+ */
+ public FooProviderType1(int bar, String foo, BundleContext bc) {
+ m_bar = bar;
+ m_foo = foo;
+ m_context = bc;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+
+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/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+public class ParentClass {
+
+ public void parentStart() {
+
+ }
+
+ public void parentStop() {
+
+ }
+
+ protected String[] strings;
+
+ protected String string;
+
+ protected int upStrings;
+
+ protected int upString;
+
+ public void updateStrings(String[] bb) {
+ strings = bb;
+ upStrings++;
+ }
+
+ public void updateString(String bb) {
+ string = bb;
+ upString++;
+ }
+
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,194 @@
+/*
+ * 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.configuration.service.CheckService;
+
+public class ParentConfigurableCheckServiceProvider extends ParentClass implements CheckService {
+
+ // Integer types
+ byte b;
+ short s;
+ int i;
+ long l;
+
+ // Floatting types
+ double d;
+ float f;
+
+ // Character
+ char c;
+
+ // Boolean
+ boolean bool;
+
+ // Integer arrays
+ byte[] bs;
+ short[] ss;
+ int[] is;
+ long[] ls;
+
+ double[] ds;
+ float[] fs;
+
+ char[] cs;
+
+ boolean[] bools;
+
+ //String string;
+ //String[] strings;
+
+ int upB, upS, upI, upL, upD, upF, upC, upBool, upBs, upSs, upIs, upLs, upDs, upFs, upCs, upBools/*, upString, upStrings*/;
+
+
+ public boolean check() {
+ return true;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("b", new Byte(b));
+ props.put("s", new Short(s));
+ props.put("i", new Integer(i));
+ props.put("l", new Long(l));
+ props.put("d", new Double(d));
+ props.put("f", new Float(f));
+ props.put("c", new Character(c));
+ props.put("bool", new Boolean(bool));
+
+ props.put("bs", bs);
+ props.put("ss", ss);
+ props.put("is", is);
+ props.put("ls", ls);
+ props.put("ds", ds);
+ props.put("fs", fs);
+ props.put("cs", cs);
+ props.put("bools", bools);
+
+ props.put("upb", new Integer(upB));
+ props.put("ups", new Integer(upS));
+ props.put("upi", new Integer(upI));
+ props.put("upl", new Integer(upL));
+ props.put("upd", new Integer(upD));
+ props.put("upf", new Integer(upF));
+ props.put("upc", new Integer(upC));
+ props.put("upbool", new Integer(upBool));
+
+ props.put("upbs", new Integer(upBs));
+ props.put("upss", new Integer(upSs));
+ props.put("upis", new Integer(upIs));
+ props.put("upls", new Integer(upLs));
+ props.put("upds", new Integer(upDs));
+ props.put("upfs", new Integer(upFs));
+ props.put("upcs", new Integer(upCs));
+ props.put("upbools", new Integer(upBools));
+
+ props.put("string", string);
+ props.put("strings", strings);
+ props.put("upstring", new Integer(upString));
+ props.put("upstrings", new Integer(upStrings));
+
+ return props;
+ }
+
+ public void updateB(byte bb) {
+ b = bb;
+ upB++;
+ }
+
+ public void updateS(short bb) {
+ s = bb;
+ upS++;
+ }
+
+ public void updateI(int bb) {
+ i = bb;
+ upI++;
+ }
+
+ public void updateL(long bb) {
+ l = bb;
+ upL++;
+ }
+
+ public void updateD(double bb) {
+ d = bb;
+ upD++;
+ }
+
+ public void updateF(float bb) {
+ f = bb;
+ upF++;
+ }
+
+ public void updateC(char bb) {
+ c = bb;
+ upC++;
+ }
+
+ public void updateBool(boolean bb) {
+ bool = bb;
+ upBool++;
+ }
+
+ public void updateBs(byte[] bb) {
+ bs = bb;
+ upBs++;
+ }
+
+ public void updateSs(short[] bb) {
+ ss = bb;
+ upSs++;
+ }
+
+ public void updateIs(int[] bb) {
+ is = bb;
+ upIs++;
+ }
+
+ public void updateLs(long[] bb) {
+ ls = bb;
+ upLs++;
+ }
+
+ public void updateDs(double[] bb) {
+ ds = bb;
+ upDs++;
+ }
+
+ public void updateFs(float[] bb) {
+ fs = bb;
+ upFs++;
+ }
+
+ public void updateCs(char[] bb) {
+ cs = bb;
+ upCs++;
+ }
+
+ public void updateBools(boolean[] bb) {
+ bools = bb;
+ upBools++;
+ }
+
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java (added)
+++ felix/trunk/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.configuration;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class ConfigurationTestSuite {
+
+ public static Test suite(BundleContext bc) {
+ OSGiTestSuite ots = new OSGiTestSuite("Configuration Test Suite", bc);
+ ots.addTestSuite(SimpleProperties.class);
+ ots.addTestSuite(DynamicallyConfigurableProperties.class);
+ ots.addTestSuite(TestFieldProperties.class);
+ ots.addTestSuite(TestMethodProperties.class);
+ ots.addTestSuite(TestBothProperties.class);
+ ots.addTestSuite(TestSuperMethodProperties.class);
+ ots.addTestSuite(ManagedServiceConfigurableProperties.class);
+
+ return ots;
+ }
+
+}