Migrate some core tests (bad configuration) to pax exam 3

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1446244 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/pom.xml b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/pom.xml
new file mode 100644
index 0000000..a1bef03
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/pom.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.ipojo.runtime.core-it</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.felix</groupId>
+    <artifactId>ipojo-core-bad-configuration-test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <name>${project.artifactId}</name>
+
+    <properties>
+        <exam.version>3.0.0</exam.version>
+        <url.version>1.5.1</url.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-native</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>${url.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>4.2.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>0.9.6</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>0.9.6</version>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.9</version>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.ipojo</artifactId>
+            <version>1.9.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
+            <version>1.9.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ow2.chameleon.testing</groupId>
+            <artifactId>osgi-helpers</artifactId>
+            <version>0.6.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ow2.chameleon.testing</groupId>
+            <artifactId>tinybundles-ipojo</artifactId>
+            <version>0.3.0</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.5.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <id>generate-config</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    
+</project>
\ No newline at end of file
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/BadConstructors.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/BadConstructors.java
new file mode 100644
index 0000000..a23588f
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/BadConstructors.java
@@ -0,0 +1,21 @@
+package org.apache.felix.ipojo.runtime.bad.components;
+
+public class BadConstructors {
+    
+    public BadConstructors() {
+        throw new Error("BAD");
+    }
+    
+    public BadConstructors(int i) {
+        // DO NOTHING
+    }
+    
+    public static BadConstructors createBad() {
+        throw new RuntimeException("BAD");
+    }
+    
+    public static BadConstructors createBad2(int o) {
+        return new BadConstructors(o);
+    }
+
+}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CallbackCheckService.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CallbackCheckService.java
new file mode 100644
index 0000000..b8cc4b6
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CallbackCheckService.java
@@ -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.runtime.bad.components;

+

+import org.apache.felix.ipojo.runtime.bad.services.CheckService;

+import org.apache.felix.ipojo.runtime.bad.services.FooService;

+

+import java.util.Properties;

+

+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;

+    }

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CheckProviderParentClass.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CheckProviderParentClass.java
new file mode 100644
index 0000000..98fd637
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CheckProviderParentClass.java
@@ -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.runtime.bad.components;

+

+import org.apache.felix.ipojo.runtime.bad.services.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++;

+    }

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CheckServiceProvider.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CheckServiceProvider.java
new file mode 100644
index 0000000..dfe1e7a
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/CheckServiceProvider.java
@@ -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.bad.components;

+

+import org.apache.felix.ipojo.runtime.bad.services.CheckService;

+import org.apache.felix.ipojo.runtime.bad.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++; }

+	}

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/LifecycleControllerTest.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/LifecycleControllerTest.java
new file mode 100644
index 0000000..0ad1c4f
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/LifecycleControllerTest.java
@@ -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.runtime.bad.components;

+

+import org.apache.felix.ipojo.runtime.bad.services.CheckService;

+

+import java.util.Properties;

+

+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;

+    }

+}

+

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/ParentClass.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/ParentClass.java
new file mode 100644
index 0000000..557c2ea
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/components/ParentClass.java
@@ -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.runtime.bad.components;

+

+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++;

+    }

+	

+	

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/BarService.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/BarService.java
new file mode 100644
index 0000000..89c4614
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/BarService.java
@@ -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.bad.services;

+

+import java.util.Properties;

+

+public interface BarService {

+	

+	public boolean bar();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/CheckService.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/CheckService.java
new file mode 100644
index 0000000..df9aedf
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/CheckService.java
@@ -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.bad.services;

+

+import java.util.Properties;

+

+public interface CheckService {

+    

+    public static final String foo = "foo";

+	

+	public boolean check();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/FooService.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/FooService.java
new file mode 100644
index 0000000..84ba216
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/java/org/apache/felix/ipojo/runtime/bad/services/FooService.java
@@ -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.bad.services;

+

+import java.util.Properties;

+

+public interface FooService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/resources/metadata.xml b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/resources/metadata.xml
new file mode 100644
index 0000000..ca770fc
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/main/resources/metadata.xml
@@ -0,0 +1,52 @@
+<ipojo>

+	<!-- No XSD as this file violates the format -->

+	<component

+		className="org.apache.felix.ipojo.runtime.bad.components.CallbackCheckService"

+		name="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.runtime.bad.components.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.runtime.bad.components.CheckServiceProvider"

+		name="BAD-BothCheckServiceProvider" architecture="true">

+		<requires field="fs">

+			<callback type="bind" method="bothBind" />

+			<callback type="unbind" method="bothUnbind" />

+		</requires>

+		<provides />

+	</component>

+	

+	<!-- Bad constructors -->

+	<component 

+		className="org.apache.felix.ipojo.runtime.bad.components.BadConstructors"

+		name="BAD-BadConstructor"

+		immediate="true"

+	/>

+	

+	<component

+		className="org.apache.felix.ipojo.runtime.bad.components.BadConstructors"

+		factory-method="createBad"

+		name="BAD-BadFactory"

+		immediate="true"

+	/>

+	

+	<component

+		className="org.apache.felix.ipojo.runtime.bad.components.BadConstructors"

+		factory-method="createBad2"

+		name="BAD-BadFactory2"

+		immediate="true"

+	/>

+</ipojo>

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/Common.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/Common.java
new file mode 100644
index 0000000..63eec74
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/Common.java
@@ -0,0 +1,146 @@
+package org.apache.felix.ipojo.runtime.bad.test;
+
+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.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+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.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
+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 org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class Common {
+
+    @Inject
+    BundleContext bc;
+
+    OSGiHelper osgiHelper;
+    IPOJOHelper ipojoHelper;
+
+    Bundle testedBundle;
+
+    @Configuration
+    public Option[] config() throws MalformedURLException {
+        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+        root.setLevel(Level.INFO);
+
+        return options(
+                ipojoBundles(),
+                junitBundles(),
+                testedBundle(),
+                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+        );
+    }
+
+    @Before
+    public void commonSetUp() {
+        osgiHelper = new OSGiHelper(bc);
+        ipojoHelper = new IPOJOHelper(bc);
+
+        testedBundle = osgiHelper.getBundle("test.bundle");
+
+        // 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 CompositeOption ipojoBundles() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject());
+    }
+
+    public Option testedBundle() throws MalformedURLException {
+        File out = new File("target/tested/bundle.jar");
+
+        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);
+            }
+        }
+
+        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 {
+            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");
+        }
+    }
+
+
+}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadFactories.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadFactories.java
new file mode 100644
index 0000000..fb88fa9
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadFactories.java
@@ -0,0 +1,140 @@
+/* 

+ * 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.bad.test;

+

+import org.apache.felix.ipojo.*;

+import org.apache.felix.ipojo.metadata.Attribute;

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

+import org.junit.Test;

+

+import static org.junit.Assert.fail;

+

+public class TestBadFactories extends Common {

+

+    private Element getElementFactoryWithNoClassName() {

+        Element elem = new Element("component", "");

+        elem.addAttribute(new Attribute("name", "noclassname"));

+        return elem;

+    }

+

+    private Element getElementHandlerFactoryWithNoClassName() {

+        Element elem = new Element("handler", "");

+        elem.addAttribute(new Attribute("name", "noclassname"));

+        return elem;

+    }

+

+    private Element getElementHandlerFactoryWithNoName() {

+        Element elem = new Element("handler", "");

+        elem.addAttribute(new Attribute("className", "noclassname"));

+        return elem;

+    }

+

+    @Test

+    public void testBadFactory() {

+        try {

+            new ComponentFactory(osgiHelper.getContext(), getElementFactoryWithNoClassName());

+            fail("A factory with no class name must be rejected");

+        } catch (ConfigurationException e) {

+            // OK.

+        }

+    }

+

+    @Test

+    public void testBadHandlerFactory1() {

+        try {

+            new HandlerManagerFactory(osgiHelper.getContext(), getElementHandlerFactoryWithNoClassName());

+            fail("An handler factory with no class name must be rejected");

+        } catch (ConfigurationException e) {

+            // OK.

+        }

+    }

+

+    @Test

+    public void testBadHandlerFactory2() {

+        try {

+            new HandlerManagerFactory(osgiHelper.getContext(), getElementHandlerFactoryWithNoName());

+            fail("An handler factory with no name must be rejected");

+        } catch (ConfigurationException e) {

+            // OK.

+        }

+    }

+

+    @Test

+    public void testCreationOnBadConstructor() {

+        Factory factory = ipojoHelper.getFactory("BAD-BadConstructor");

+        ComponentInstance ci;

+        try {

+            // Change in Felix-966, now throws a runtime exception

+            ci = factory.createComponentInstance(null);

+            //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

+            ci.dispose();

+            fail("Exception expected");

+        } catch (Throwable e) {

+            //fail("Exception unexpected : " + e.getMessage());

+            // OK

+        }

+    }

+

+    @Test

+    public void testCreationOnBadFactory() {

+        Factory factory = ipojoHelper.getFactory("BAD-BadFactory");

+        ComponentInstance ci;

+        try {

+            // Change in Felix-966, now throw a runtime exception

+            ci = factory.createComponentInstance(null);

+            //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

+            ci.dispose();

+            fail("Exception expected");

+        } catch (Throwable e) {

+            //fail("Exception unexpected : " + e.getMessage());

+            //OK

+        }

+    }

+

+    @Test

+    public void testCreationOnBadFactory2() {

+        Factory factory = ipojoHelper.getFactory("BAD-BadFactory2");

+        ComponentInstance ci;

+        try {

+            // Change in Felix-966, now throw a runtime exception

+            ci = factory.createComponentInstance(null);

+            //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());

+            ci.dispose();

+            fail("Exception expected");

+        } catch (Throwable e) {

+            //fail("Exception unexpected : " + e.getMessage());

+            //Ok

+        }

+    }

+

+    @Test

+    public void testNoManipulationMetadata() {

+        Element elem = new Element("component", "");

+        elem.addAttribute(new Attribute("classname", "org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"));

+        try {

+            ComponentFactory fact = new ComponentFactory(osgiHelper.getContext(), elem);

+            fact.stop();

+            fail("A factory with no manipulation metadata must be rejected");

+        } catch (ConfigurationException e) {

+            // OK.

+        }

+    }

+

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadLFCCallback.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadLFCCallback.java
new file mode 100644
index 0000000..edf5548
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadLFCCallback.java
@@ -0,0 +1,261 @@
+/* 

+ * 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.bad.test;

+

+import org.apache.felix.ipojo.*;

+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.junit.Before;

+import org.junit.Test;

+

+import java.util.Properties;

+

+import static org.junit.Assert.assertNotNull;

+import static org.junit.Assert.fail;

+

+public class TestBadLFCCallback extends Common {

+

+    private String clazz = "org.apache.felix.ipojo.runtime.bad.components.CallbackCheckService";

+    private String type = "BAD-CallbackCheckService";

+    private Element manipulation;

+    private Properties props;

+

+    @Before

+    public void setUp() {

+        manipulation = getManipulationForComponent();

+        props = new Properties();

+        props.put("instance.name", "BAD");

+    }

+

+

+    private Element getNothing() {

+        Element elem = new Element("component", "");

+        elem.addAttribute(new Attribute("classname", clazz));

+

+        Element callback = new Element("callback", "");

+        elem.addElement(callback);

+        elem.addElement(manipulation);

+        return elem;

+    }

+

+    private Element getNoTransition() {

+        Element elem = new Element("component", "");

+        elem.addAttribute(new Attribute("classname", clazz));

+

+        Element callback = new Element("callback", "");

+        callback.addAttribute(new Attribute("method", "start"));

+        elem.addElement(callback);

+        elem.addElement(manipulation);

+        return elem;

+    }

+

+    private Element getNoMethod() {

+        Element elem = new Element("component", "");

+        elem.addAttribute(new Attribute("classname", clazz));

+

+        Element callback = new Element("callback", "");

+        callback.addAttribute(new Attribute("transition", "validate"));

+        elem.addElement(callback);

+        elem.addElement(manipulation);

+        return elem;

+    }

+

+    private Element getBadMethod() {

+        Element elem = new Element("component", "");

+        elem.addAttribute(new Attribute("classname", clazz));

+

+        Element callback = new Element("callback", "");

+        callback.addAttribute(new Attribute("transition", "validate"));

+        callback.addAttribute(new Attribute("method", "start_")); // Missing method.

+        elem.addElement(callback);

+        elem.addElement(manipulation);

+        return elem;

+    }

+

+    private Element getBadMethod2() {

+        Element elem = new Element("component", "");

+        elem.addAttribute(new Attribute("classname", clazz));

+

+        Element callback = new Element("callback", "");

+        callback.addAttribute(new Attribute("transition", "invalidate"));

+        callback.addAttribute(new Attribute("method", "stop_")); // Missing method.

+        elem.addElement(callback);

+        elem.addElement(manipulation);

+        return elem;

+    }

+

+    private Element getBadTransition() {

+        Element elem = new Element("component", "");

+        elem.addAttribute(new Attribute("classname", clazz));

+

+        Element callback = new Element("callback", "");

+        callback.addAttribute(new Attribute("method", "start"));

+        callback.addAttribute(new Attribute("transition", "validate_"));

+        elem.addElement(callback);

+        elem.addElement(manipulation);

+        return elem;

+    }

+

+    private Element getManipulationForComponent() {

+        String header = testedBundle.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, 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;

+    }

+

+    @Test

+    public void testNothing() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), getNothing());

+            cf.start();

+            ComponentInstance ci = cf.createComponentInstance(props);

+            ci.dispose();

+            cf.stop();

+            fail("A lifecycle callback with a missing method and transition 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());

+        }

+    }

+

+    @Test

+    public void testNoTransition() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), getNoTransition());

+            cf.start();

+            ComponentInstance ci = cf.createComponentInstance(props);

+            ci.dispose();

+            cf.stop();

+            fail("A lifecycle callback with a missing transition 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());

+        }

+    }

+

+    @Test

+    public void testNoMethod() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), getNoMethod());

+            cf.start();

+            ComponentInstance ci = cf.createComponentInstance(props);

+            ci.dispose();

+            cf.stop();

+            fail("A lifecycle callback with a missing 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());

+        }

+    }

+

+    @Test

+    public void testBadMethod() {

+        try {

+            ComponentFactory cf = new ComponentFactory(testedBundle.getBundleContext(), getBadMethod());

+            cf.start();

+            ComponentInstance ci = cf.createComponentInstance(props);

+            if (ci.isStarted()) {

+                fail("A lifecycle callback with a bad method must be rejected (instance stills valid)" + cf);

+            }

+            ci.dispose();

+            cf.stop();

+        } catch (ConfigurationException e) {

+            //The check does not happen in the configure method.

+            fail("Unexpected exception when creating an instance : " + e.getMessage());

+        } catch (UnacceptableConfiguration e) {

+            fail("Unexpected exception when creating an instance : " + e.getMessage());

+        } catch (MissingHandlerException e) {

+            fail("Unexpected exception when creating an instance : " + e.getMessage());

+        }

+    }

+

+    @Test

+    public void testBadMethod2() {

+        try {

+            ComponentFactory cf = new ComponentFactory(testedBundle.getBundleContext(), getBadMethod2());

+            cf.start();

+            ComponentInstance ci = cf.createComponentInstance(props);

+            ci.stop();

+            if (ci.isStarted()) {

+                fail("A lifecycle callback with a bad method must be rejected (instance stills valid)" + cf);

+            }

+            ci.dispose();

+            cf.stop();

+        } catch (ConfigurationException e) {

+            //The check does not happen in the configure method.

+            fail("Unexpected exception when creating an instance : " + e.getMessage());

+        } catch (UnacceptableConfiguration e) {

+            fail("Unexpected exception when creating an instance : " + e.getMessage());

+        } catch (MissingHandlerException e) {

+            fail("Unexpected exception when creating an instance : " + e.getMessage());

+        }

+    }

+

+    @Test

+    public void testBadTransition() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), getBadTransition());

+            cf.start();

+            ComponentInstance ci = cf.createComponentInstance(props);

+            ci.dispose();

+            cf.stop();

+            fail("A lifecycle callback with a bad transition 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());

+        }

+    }

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadLFCController.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadLFCController.java
new file mode 100644
index 0000000..8206d2b
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadLFCController.java
@@ -0,0 +1,105 @@
+/* 

+ * 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.bad.test;

+

+import org.apache.felix.ipojo.ComponentFactory;

+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.junit.Test;

+

+import static org.junit.Assert.assertNotNull;

+import static org.junit.Assert.fail;

+

+public class TestBadLFCController extends Common {

+

+    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 = testedBundle.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 (Element comp : comps) {

+            if (comp.containsAttribute("name") && comp.getAttribute("name").equals(comp_name)) {

+                return comp.getElements("manipulation")[0];

+            }

+        }

+        return null;

+    }

+

+    @Test

+    public void testNoField() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), getNoFieldController());

+            cf.start();

+            cf.stop();

+            fail("A lifecycle controller with a missing field must be rejected " + cf);

+        } catch (Exception e) {

+            // OK

+        }

+    }

+

+    @Test

+    public void testBadField() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), getBadFieldController());

+            cf.start();

+            cf.stop();

+            fail("A lifecycle controller with a bad field must be rejected " + cf);

+        } catch (Exception e) {

+            // OK

+        }

+    }

+

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadServiceDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadServiceDependencies.java
new file mode 100644
index 0000000..85a70c3
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/bad/test/TestBadServiceDependencies.java
@@ -0,0 +1,254 @@
+/* 

+ * 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.bad.test;

+

+import org.apache.felix.ipojo.*;

+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.runtime.bad.services.BarService;

+import org.junit.Before;

+import org.junit.Test;

+

+import java.util.Properties;

+

+import static org.junit.Assert.assertNotNull;

+import static org.junit.Assert.fail;

+

+public class TestBadServiceDependencies extends Common {

+

+    private String clazz = "org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider";

+    private String type = "BAD-BothCheckServiceProvider";

+    private Element manipulation;

+    private Properties props;

+

+    @Before

+    public void setUp() {

+        manipulation = getManipulationForComponent();

+        props = new Properties();

+        props.put("instance.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 getBadFrom() {

+        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("from", "ba(d&_")); // Incorrect from

+        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 getManipulationForComponent() {

+        String header = testedBundle.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 (Element comp : comps) {

+            if (comp.containsAttribute("factory") && comp.getAttribute("factory").equals(comp_name)) {

+                return comp.getElements("manipulation")[0];

+            }

+            if (comp.containsAttribute("name") && comp.getAttribute("name").equals(comp_name)) {

+                return comp.getElements("manipulation")[0];

+            }

+        }

+        return null;

+    }

+

+    @Test

+    public void testNothing() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), 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());

+        }

+    }

+

+    @Test

+    public void testNoField() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), 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());

+        }

+    }

+

+    @Test

+    public void testBadField() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), 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());

+        }

+    }

+

+    @Test

+    public void testBadFilter() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), 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());

+        }

+    }

+

+    @Test

+    public void testBadFrom() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), getBadFrom());

+            cf.start();

+            ComponentInstance ci = cf.createComponentInstance(props);

+            ci.dispose();

+            cf.stop();

+            fail("A service requirement with a bad from 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());

+        }

+    }

+

+    @Test

+    public void testBadType() {

+        try {

+            ComponentFactory cf = new ComponentFactory(osgiHelper.getContext(), 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());

+        }

+    }

+}

diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/resources/exam.properties b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/resources/exam.properties
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-bad-configuration-test/src/test/resources/exam.properties