Commit the new iPOJO version (0.7.6).

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@642265 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/examples/junit4osgi/felix-command/metadata.xml b/ipojo/examples/junit4osgi/felix-command/metadata.xml
new file mode 100644
index 0000000..87f7db1
--- /dev/null
+++ b/ipojo/examples/junit4osgi/felix-command/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<iPOJO>

+	<component

+		className="org.apache.felix.ipojo.junit4osgi.command.JunitCommand"

+		factory="false">

+		<requires field="runner" />

+		<provides />

+	</component>

+	<instance

+		component="org.apache.felix.ipojo.junit4osgi.command.JunitCommand" />

+</iPOJO>
\ No newline at end of file
diff --git a/ipojo/examples/junit4osgi/felix-command/pom.xml b/ipojo/examples/junit4osgi/felix-command/pom.xml
new file mode 100644
index 0000000..f810d59
--- /dev/null
+++ b/ipojo/examples/junit4osgi/felix-command/pom.xml
@@ -0,0 +1,95 @@
+<!--

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

+	<parent>

+		<groupId>ipojo.examples</groupId>

+		<artifactId>Junit4Osgi</artifactId>

+		<version>0.7.6-SNAPSHOT</version>

+		<relativePath>../pom.xml</relativePath>

+	</parent>

+	<modelVersion>4.0.0</modelVersion>

+	<packaging>bundle</packaging>

+	<name>Junit4Osgi-Felix-Command</name>

+	<artifactId>

+		org.apache.felix.ipojo.junit4osgi.felix-command

+	</artifactId>

+	<dependencies>

+		<dependency>

+			<groupId>${pom.groupId}</groupId>

+			<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>

+			<version>${pom.version}</version>

+		</dependency>

+		<dependency>

+			<groupId>org.apache.felix</groupId>

+			<artifactId>org.apache.felix.shell</artifactId>

+			<version>1.0.0</version>

+		</dependency>

+		<dependency>

+			<groupId>junit</groupId>

+			<artifactId>junit</artifactId>

+			<version>3.8.1</version>

+		</dependency>

+	</dependencies>

+	<build>

+		<plugins>

+			<plugin>

+				<groupId>org.apache.maven.plugins</groupId>

+				<artifactId>maven-compiler-plugin</artifactId>

+				<configuration>

+					<source>1.5</source>

+					<target>1.5</target>

+				</configuration>

+			</plugin>

+			<plugin>

+				<groupId>org.apache.felix</groupId>

+				<artifactId>maven-bundle-plugin</artifactId>

+				<version>1.4.0</version>

+				<extensions>true</extensions>

+				<configuration>

+					<instructions>

+						<Bundle-Name>

+							iPOJO OSGi Junit Runner - Felix Command

+						</Bundle-Name>

+						<Bundle-SymbolicName>

+							${pom.artifactId}

+						</Bundle-SymbolicName>

+						<Private-Package>

+							org.apache.felix.ipojo.junit4osgi.command

+						</Private-Package>

+					</instructions>

+				</configuration>

+			</plugin>

+			<plugin>

+				<groupId>org.apache.felix</groupId>

+				<artifactId>maven-ipojo-plugin</artifactId>

+				<version>${pom.version}</version>

+				<executions>

+					<execution>

+						<goals>

+							<goal>ipojo-bundle</goal>

+						</goals>

+						<configuration>

+							<ignoreAnnotations>true</ignoreAnnotations>

+						</configuration>

+					</execution>

+				</executions>

+			</plugin>

+		</plugins>

+	</build>

+</project>

diff --git a/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java b/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java
new file mode 100644
index 0000000..a217a9e
--- /dev/null
+++ b/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java
@@ -0,0 +1,111 @@
+/* 

+ * 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.junit4osgi.command;

+

+import java.io.PrintStream;

+import java.util.ArrayList;

+import java.util.List;

+import java.util.ListIterator;

+

+import junit.framework.Test;

+import junit.framework.TestCase;

+import junit.framework.TestFailure;

+import junit.framework.TestResult;

+import junit.framework.TestSuite;

+

+import org.apache.felix.ipojo.junit4osgi.OSGiJunitRunner;

+import org.apache.felix.shell.Command;

+

+/**

+ * Felix shell command. Allow to run tests.

+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>

+ */

+public class JunitCommand implements Command {

+

+    private OSGiJunitRunner runner;

+

+    private List<String> getNamesFromTests(List<Test> list) {

+        List<String> names = new ArrayList<String>(list.size());

+        for (int i = 0; i < list.size(); i++) {

+            if (list.get(i) instanceof TestCase) {

+                names.add(((TestCase) list.get(i)).getName());

+            }

+            if (list.get(i) instanceof TestSuite) {

+                String name = ((TestSuite) list.get(i)).getName();

+                if (name == null) {

+                    name = ((TestSuite) list.get(i)).toString();

+                }

+                names.add(name);

+            }

+        }

+        return names;

+    }

+

+    public void execute(String line, PrintStream out, PrintStream err) {

+        line = line.substring(getName().length()).trim();

+        List<TestResult> tr = null;

+        if (line.equals("all")) {

+            if (runner.getTests() == null) {

+                err.println("No tests to execute");

+                return;

+            } else {

+                out.println("Executing " + getNamesFromTests(runner.getTests()));

+                tr = runner.run();

+            }

+        } else {

+            try {

+                Long bundleId = new Long(line);

+                if (runner.getTests(bundleId) == null) {

+                    err.println("No tests to execute");

+                    return;

+                } else {

+                    out.println("Executing " + getNamesFromTests(runner.getTests(bundleId)));

+                    tr = runner.run(bundleId);

+                }

+            } catch (NumberFormatException e) {

+                err.println("Unable to parse id " + line);

+                return;

+            }

+        }

+

+        ListIterator<TestResult> it = tr.listIterator();

+        while (it.hasNext()) {

+            TestResult result = it.next();

+            if (result.failureCount() != 0) {

+                TestFailure fail = (TestFailure) result.failures().nextElement();

+                out.println(fail.trace());

+                return;

+            }

+        }

+

+    }

+

+    public String getName() {

+        return "junit";

+    }

+

+    public String getShortDescription() {

+        return "launch junit tests";

+    }

+

+    public String getUsage() {

+        return "junit";

+    }

+

+}