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/02/10 21:58:01 UTC

svn commit: r620325 [2/2] - in /felix/sandbox/clement/ipojo: arch/src/main/java/org/apache/felix/ipojo/arch/ core/src/main/java/org/apache/felix/ipojo/ core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ core/src/main/java/org/apache/feli...

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,294 @@
+/* 
+ * 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.impl;
+
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiJunitRunner;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Detect test suite from installed bundles.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class JunitExtender implements OSGiJunitRunner {
+
+    public static final String SUITE_METHODNAME = "suite";
+
+    private Map<Bundle, List<Class>> m_suites = new HashMap<Bundle, List<Class>>();
+
+    private ResultPrinter m_printer = new ResultPrinter(System.out);
+
+    void onBundleArrival(Bundle bundle, String header) {
+        String[] tss = header.split(",");
+        for (int i = 0; i < tss.length; i++) {
+            try {
+                if (tss[i].length() != 0) {
+                    System.out.println("Loading " + tss[i]);
+                    Class<? extends Test> clazz = bundle.loadClass(tss[i].trim());
+                    addTestSuite(bundle, clazz);
+                }
+            } catch (ClassNotFoundException e) {
+                System.err.println("The test suite " + tss[i] + " is not in the bundle " + bundle.getBundleId() + " : " + e.getMessage());
+            }
+        }
+    }
+
+    private void addTestSuite(Bundle bundle, Class<? extends Test> test) {
+        List<Class> list = m_suites.get(bundle);
+        if (list == null) {
+            list = new ArrayList<Class>();
+            list.add(test);
+            m_suites.put(bundle, list);
+        } else {
+            list.add(test);
+        }
+    }
+
+    private void removeTestSuites(Bundle bundle) {
+        m_suites.remove(bundle);
+    }
+
+    void onBundleDeparture(Bundle bundle) {
+        removeTestSuites(bundle);
+    }
+
+    public void setResultPrinter(PrintStream pw) {
+        m_printer = new ResultPrinter(pw);
+    }
+
+    public List<TestResult> run() {
+        List<TestResult> results = new ArrayList<TestResult>(m_suites.size());
+        Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
+        while (it.hasNext()) {
+            Entry<Bundle, List<Class>> entry = it.next();
+            Bundle bundle = entry.getKey();
+            List<Class> list = m_suites.get(bundle);
+            for (int i = 0; i < list.size(); i++) {
+                Test test = createTestFromClass(list.get(i), bundle);
+                TestResult tr = doRun(test);
+                results.add(tr);
+            }
+        }
+        return results;
+    }
+
+    private TestResult doRun(Test test) {
+        TestResult result = new TestResult();
+        result.addListener(m_printer);
+        long startTime = System.currentTimeMillis();
+
+        test.run(result);
+
+        long endTime = System.currentTimeMillis();
+        long runTime = endTime - startTime;
+        m_printer.print(result, runTime);
+
+        return result;
+    }
+
+    private Test createTestFromClass(Class<?> clazz, Bundle bundle) {
+        Method suiteMethod = null;
+        boolean bc = false;
+        try {
+            suiteMethod = clazz.getMethod(SUITE_METHODNAME, new Class[0]);
+        } catch (Exception e) {
+            // try to use a suite method receiving a bundle context
+            try {
+                suiteMethod = clazz.getMethod(SUITE_METHODNAME, new Class[] { BundleContext.class });
+                bc = true;
+            } catch (Exception e2) {
+                // try to extract a test suite automatically
+                if (OSGiTestSuite.class.isAssignableFrom(clazz)) {
+                    OSGiTestSuite ts = new OSGiTestSuite(clazz, getBundleContext(bundle));
+                    return ts;
+                } else if (OSGiTestCase.class.isAssignableFrom(clazz)) {
+                    OSGiTestSuite ts = new OSGiTestSuite(clazz, getBundleContext(bundle));
+                    return ts;
+                } else {
+                    return new TestSuite(clazz);
+                }
+            }
+        }
+
+        if (!Modifier.isStatic(suiteMethod.getModifiers())) {
+            System.err.println("Suite() method must be static");
+            return null;
+        }
+        Test test = null;
+        try {
+            if (bc) {
+                test = (Test) suiteMethod.invoke(null, new Object[] { getBundleContext(bundle) }); // static method injection the bundle context
+            } else {
+                test = (Test) suiteMethod.invoke(null, (Object[]) new Class[0]); // static method
+            }
+        } catch (InvocationTargetException e) {
+            System.err.println("Failed to invoke suite():" + e.getTargetException().toString());
+            return null;
+        } catch (IllegalAccessException e) {
+            System.err.println("Failed to invoke suite():" + e.toString());
+            return null;
+        }
+
+        return test;
+    }
+
+    public List<Test> getTests() {
+        List<Test> results = new ArrayList<Test>();
+        Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
+        while (it.hasNext()) {
+            Entry<Bundle, List<Class>> entry = it.next();
+            Bundle bundle = entry.getKey();
+            List<Class> list = m_suites.get(bundle);
+            for (int i = 0; i < list.size(); i++) {
+                Test test = createTestFromClass(list.get(i), bundle);
+                results.add(test);
+            }
+        }
+        return results;
+    }
+
+    public TestResult run(Test test) {
+        return doRun(test);
+    }
+
+    public List<Test> getTests(long bundleId) {
+        Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
+        while (it.hasNext()) {
+            Entry<Bundle, List<Class>> entry = it.next();
+            Bundle bundle = entry.getKey();
+            if (bundle.getBundleId() == bundleId) {
+                List<Test> results = new ArrayList<Test>();
+                List<Class> list = m_suites.get(bundle);
+                for (int i = 0; i < list.size(); i++) {
+                    Test test = createTestFromClass(list.get(i), bundle);
+                    results.add(test);
+                }
+                return results;
+            }
+        }
+        return null;
+    }
+
+    public List<TestResult> run(long bundleId) {
+        Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
+        while (it.hasNext()) {
+            Entry<Bundle, List<Class>> entry = it.next();
+            Bundle bundle = entry.getKey();
+            if (bundle.getBundleId() == bundleId) {
+                List<TestResult> results = new ArrayList<TestResult>();
+                List<Class> list = m_suites.get(bundle);
+                for (int i = 0; i < list.size(); i++) {
+                    Test test = createTestFromClass(list.get(i), bundle);
+                    TestResult tr = doRun(test);
+                    results.add(tr);
+                }
+                return results;
+            }
+        }
+        return null;
+    }
+
+    public void stopping() {
+        System.out.println("Cleaning test suites ...");
+        m_suites = null;
+    }
+
+    private BundleContext getBundleContext(Bundle bundle) {
+        if (bundle == null) { return null; }
+
+        // getBundleContext (OSGi 4.1)
+        Method meth = null;
+        try {
+            meth = bundle.getClass().getMethod("getBundleContext", new Class[0]);
+        } catch (SecurityException e) {
+            // Nothing do to, will try the Equinox method
+        } catch (NoSuchMethodException e) {
+            // Nothing do to, will try the Equinox method
+        }
+
+        // try Equinox getContext if not found.
+        if (meth == null) {
+            try {
+                meth = bundle.getClass().getMethod("getContext", new Class[0]);
+            } catch (SecurityException e) {
+                // Nothing do to, will try field inspection
+            } catch (NoSuchMethodException e) {
+                // Nothing do to, will try field inspection
+            }
+        }
+
+        if (meth != null) {
+            meth.setAccessible(true);
+            try {
+                return (BundleContext) meth.invoke(bundle, new Object[0]);
+            } catch (IllegalArgumentException e) {
+                err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                return null;
+            } catch (IllegalAccessException e) {
+                err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                return null;
+            } catch (InvocationTargetException e) {
+                err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                return null;
+            }
+        }
+
+        // Else : Field inspection (KF and Prosyst)        
+        Field[] fields = bundle.getClass().getDeclaredFields();
+        for (int i = 0; i < fields.length; i++) {
+            if (BundleContext.class.isAssignableFrom(fields[i].getType())) {
+                fields[i].setAccessible(true);
+                try {
+                    return (BundleContext) fields[i].get(bundle);
+                } catch (IllegalArgumentException e) {
+                    err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                    return null;
+                } catch (IllegalAccessException e) {
+                    err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                    return null;
+                }
+            }
+        }
+        err("Cannot find the BundleContext for " + bundle.getSymbolicName(), null);
+        return null;
+    }
+
+    private void err(String s, Throwable e) {
+        System.err.println(s + " : " + e.getMessage());
+    }
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,162 @@
+/* 
+ * 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.impl;
+
+import java.io.PrintStream;
+import java.text.NumberFormat;
+import java.util.Enumeration;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestFailure;
+import junit.framework.TestListener;
+import junit.framework.TestResult;
+import junit.runner.BaseTestRunner;
+
+/**
+ * Result Printer.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ResultPrinter implements TestListener {
+    PrintStream fWriter;
+
+    int fColumn = 0;
+
+    public ResultPrinter(PrintStream writer) {
+        fWriter = writer;
+    }
+
+    /*
+     * API for use by textui.TestRunner
+     */
+
+    synchronized void print(TestResult result, long runTime) {
+        printHeader(runTime);
+        printErrors(result);
+        printFailures(result);
+        printFooter(result);
+    }
+
+    void printWaitPrompt() {
+        getWriter().println();
+        getWriter().println("<RETURN> to continue");
+    }
+
+    /*
+     * Internal methods
+     */
+
+    protected void printHeader(long runTime) {
+        getWriter().println();
+        getWriter().println("Time: " + elapsedTimeAsString(runTime));
+    }
+
+    protected void printErrors(TestResult result) {
+        printDefects(result.errors(), result.errorCount(), "error");
+    }
+
+    protected void printFailures(TestResult result) {
+        printDefects(result.failures(), result.failureCount(), "failure");
+    }
+
+    protected void printDefects(Enumeration<TestFailure> booBoos, int count, String type) {
+        if (count == 0)
+            return;
+        if (count == 1)
+            getWriter().println("There was " + count + " " + type + ":");
+        else
+            getWriter().println("There were " + count + " " + type + "s:");
+        for (int i = 1; booBoos.hasMoreElements(); i++) {
+            printDefect(booBoos.nextElement(), i);
+        }
+    }
+
+    public void printDefect(TestFailure booBoo, int count) { // only public for testing purposes
+        printDefectHeader(booBoo, count);
+        printDefectTrace(booBoo);
+    }
+
+    protected void printDefectHeader(TestFailure booBoo, int count) {
+        // I feel like making this a println, then adding a line giving the throwable a chance to print something
+        // before we get to the stack trace.
+        getWriter().print(count + ") " + booBoo.failedTest());
+    }
+
+    protected void printDefectTrace(TestFailure booBoo) {
+        getWriter().print(BaseTestRunner.getFilteredTrace(booBoo.trace()));
+    }
+
+    protected void printFooter(TestResult result) {
+        if (result.wasSuccessful()) {
+            getWriter().println();
+            getWriter().print("OK");
+            getWriter().println(" (" + result.runCount() + " test" + (result.runCount() == 1 ? "" : "s") + ")");
+
+        } else {
+            getWriter().println();
+            getWriter().println("FAILURES!!!");
+            getWriter().println("Tests run: " + result.runCount() + ",  Failures: " + result.failureCount() + ",  Errors: " + result.errorCount());
+        }
+        getWriter().println();
+    }
+
+    /**
+     * Returns the formatted string of the elapsed time. Duplicated from BaseTestRunner. Fix it.
+     */
+    protected String elapsedTimeAsString(long runTime) {
+        return NumberFormat.getInstance().format((double) runTime / 1000);
+    }
+
+    public PrintStream getWriter() {
+        return fWriter;
+    }
+
+    /**
+     * @see junit.framework.TestListener#addError(Test, Throwable)
+     */
+    public void addError(Test test, Throwable t) {
+        getWriter().print("E");
+    }
+
+    /**
+     * @see junit.framework.TestListener#addFailure(Test, AssertionFailedError)
+     */
+    public void addFailure(Test test, AssertionFailedError t) {
+        getWriter().print("F");
+    }
+
+    /**
+     * @see junit.framework.TestListener#endTest(Test)
+     */
+    public void endTest(Test test) {
+    }
+
+    /**
+     * @see junit.framework.TestListener#startTest(Test)
+     */
+    public void startTest(Test test) {
+        getWriter().print(".");
+        if (fColumn++ >= 40) {
+            getWriter().println();
+            fColumn = 0;
+        }
+    }
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestCase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestCase.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestCase.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestCase.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,34 @@
+/* 
+ * 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.test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+
+/**
+ * Simple OSGi Test Case.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class TestOSGiTestCase extends OSGiTestCase {
+    
+    public void test1() {
+        System.out.println("Test BC");
+        assertNotNull("Test bundle context", context);
+    }
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestSuite.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestSuite.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestSuite.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestSuite.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,43 @@
+/* 
+ * 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.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Simple OSGi Test suite.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class TestOSGiTestSuite extends TestSuite {
+    
+    public static Test suite(BundleContext bc) {
+        TestSuite ts = new TestSuite();
+        ts.setName("Test OSGi suite() method");
+        ts.addTestSuite(TestTestCase.class);
+        OSGiTestSuite ots = new OSGiTestSuite(TestOSGiTestCase.class, bc);
+        ots.setBundleContext(bc);
+        ts.addTest(ots);
+        return ts;
+    }
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestCase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestCase.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestCase.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestCase.java Sun Feb 10 12:57:57 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.junit4osgi.test;
+
+import junit.framework.TestCase;
+
+/**
+ * Simple Test Case.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class TestTestCase extends TestCase {
+    
+    public void test1() { }
+    
+    public void test2() { }
+    
+    public void test3() { }
+    
+    public void test4() { }
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestSuite.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestSuite.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestSuite.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestSuite.java Sun Feb 10 12:57:57 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.junit4osgi.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Simple OSGi Test Suite.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class TestTestSuite extends TestSuite {
+    
+    public static Test suite() {
+        TestSuite ts = new TestSuite();
+        ts.setName("Test suite() method");
+        ts.addTestSuite(TestTestCase.class);
+        return ts;
+    }
+
+}

Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml Sun Feb 10 12:57:57 2008
@@ -6,71 +6,32 @@
     <relativePath>../pom.xml</relativePath>
   </parent>
   <modelVersion>4.0.0</modelVersion>
-  <packaging>bundle</packaging>
-  <name>Junit4Osgi</name>
-  <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.felix</groupId>
-      <artifactId>org.apache.felix.ipojo</artifactId>
-      <version>${pom.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.felix</groupId>
-      <artifactId>org.apache.felix.ipojo.metadata</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.2.0</version>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-          	<Bundle-Name>iPOJO OSGi Junit Runner</Bundle-Name>
-            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
-            <Private-Package>org.apache.felix.ipojo.junit4osgi.impl, org.apache.felix.ipojo.junit4osgi.command, org.apache.felix.ipojo.junit4osgi.test</Private-Package>
-            <Export-Package>org.apache.felix.ipojo.junit4osgi, junit.*</Export-Package>
-            <Test-Suite>org.apache.felix.ipojo.junit4osgi.test.TestTestCase, org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestCase, org.apache.felix.ipojo.junit4osgi.test.TestTestSuite, org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestSuite</Test-Suite>
-          </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>
+  <artifactId>Junit4Osgi</artifactId>
+  <name>Apache Felix iPOJO Junit4OSGi</name>
+  <packaging>pom</packaging>
+
+  <profiles>
+	<profile>
+		<id>java5</id>
+		<activation>
+			<jdk>1.5</jdk>
+		</activation>
+		<modules>
+			<module>junit4osgi</module>
+			<module>felix-command</module>
+			<module>swing-runner</module>
+		</modules>
+	</profile>
+	<profile>
+		<id>java6</id>
+		<activation>
+			<jdk>1.6</jdk>
+		</activation>
+		<modules>
+			<module>junit4osgi</module>
+			<module>felix-command</module>
+			<module>swing-runner</module>
+		</modules>
+	</profile>
+  </profiles>
+</project>
\ No newline at end of file

Propchange: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Feb 10 12:57:57 2008
@@ -0,0 +1,6 @@
+.checkstyle
+.classpath
+.project
+bin
+nbproject
+target

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml Sun Feb 10 12:57:57 2008
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<iPOJO>	
+	<component classname="org.apache.felix.ipojo.junit4osgi.command.SwingRunner">
+            <requires field="m_runner"/>
+            <callback method="stop" transition="invalidate"/>
+            <callback method="start" transition="validate"/>
+        </component>
+        <instance component="org.apache.felix.ipojo.junit4osgi.command.SwingRunner"/>
+</iPOJO>
\ No newline at end of file

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml Sun Feb 10 12:57:57 2008
@@ -0,0 +1,77 @@
+<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-Swing-GUI</name>
+	<artifactId>
+		org.apache.felix.ipojo.junit4osgi.swing-gui
+	</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.2.0</version>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Bundle-Name>
+							iPOJO OSGi Junit Runner - Swing Gui
+						</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>

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/NewJFrame.form
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/NewJFrame.form?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/NewJFrame.form (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/NewJFrame.form Sun Feb 10 12:57:57 2008
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="3"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="15" max="32767" attributes="0"/>
+              <Component id="jScrollPane1" min="-2" pref="375" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane1" min="-2" pref="86" max="-2" attributes="0"/>
+              <EmptySpace pref="203" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTable" name="jTable1">
+          <Properties>
+            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
+              <Table columnCount="4" rowCount="4">
+                <Column editable="true" title="Title 1" type="java.lang.Object"/>
+                <Column editable="true" title="Title 2" type="java.lang.Object"/>
+                <Column editable="true" title="Title 3" type="java.lang.Object"/>
+                <Column editable="true" title="Title 4" type="java.lang.Object"/>
+              </Table>
+            </Property>
+          </Properties>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,137 @@
+/* 
+ * 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.util.ArrayList;
+import java.util.List;
+import javax.swing.table.AbstractTableModel;
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+
+/**
+ * Result Table Model.
+ * Store the results of executed tests.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ResultTableModel extends AbstractTableModel{
+    
+    private static final long serialVersionUID = 1L;
+    private List<TestRecord> results = new ArrayList<TestRecord>();
+
+    public int getRowCount() {
+        return results.size();
+    }
+
+    public int getColumnCount() {
+        return 2;
+    }
+    
+    public void addTest(Test t, AssertionFailedError e) {
+        TestRecord rec = new TestRecord(t, e);
+        results.add(rec);
+        fireTableDataChanged();
+    }
+    
+    public void addTest(Test t, Throwable e) {
+        TestRecord rec = new TestRecord(t, e);
+        results.add(rec);
+        fireTableDataChanged();
+    }
+    
+    public void addTest(Test t) {
+        TestRecord rec = new TestRecord(t);
+        results.add(rec);
+        fireTableDataChanged();
+    }
+    
+    public void clear() {
+        results.clear();
+        fireTableDataChanged();
+    }
+
+    public Object getValueAt(int rowIndex, int columnIndex) {
+        if (columnIndex == 0) {
+            return results.get(rowIndex).m_test;
+        }
+        if (columnIndex == 1) {
+            TestRecord tr = results.get(rowIndex);
+            if (tr.m_wasSucessFull) { return "sucess"; }
+            if (tr.m_failure != null) { return "failure"; }
+            if (tr.m_error != null) { return "error"; }
+        }
+        return null;
+    }
+    
+    
+    
+    public String getColumnName(int column) {
+        if (column == 0) {
+            return "Test";
+        }
+        
+        if (column == 1) {
+            return "Status";
+        }
+        
+        return null;
+    }
+    
+    
+    public String getMessage(int row, int column) {
+        if (row == -1) {
+            return null;
+        }
+        TestRecord rec = results.get(row);
+        if (rec.m_wasSucessFull) {
+            return "The test " + rec.m_test + " was executed sucessfully.";
+        }
+        if (rec.m_failure != null) {
+            return "The test " + rec.m_test + " has failed : \n" + rec.m_failure.getMessage();
+        }
+        if (rec.m_error != null) {
+            return "The test " + rec.m_test + " has thrown an error : \n" + rec.m_error.getMessage();
+        }
+        return "";
+    }
+    
+    private class TestRecord {
+        private boolean m_wasSucessFull;
+        private Test m_test;
+        private AssertionFailedError m_failure;
+        private Throwable m_error;
+        
+        public TestRecord(Test t, AssertionFailedError e) {
+            m_test = t;
+            m_wasSucessFull = false;
+            m_failure = e;
+        }
+        
+        public TestRecord(Test t, Throwable e) {
+            m_test = t;
+            m_wasSucessFull = false;
+            m_error = e;
+        }
+        
+        public TestRecord(Test t) {
+            m_test = t;
+            m_wasSucessFull = true;
+        }
+    }
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form Sun Feb 10 12:57:57 2008
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <NonVisualComponents>
+    <Container class="javax.swing.JDialog" name="m_resultDialog">
+      <Properties>
+        <Property name="defaultCloseOperation" type="int" value="0"/>
+        <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[320, 250]"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="onDialogClosed"/>
+        <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="onDialogClosed"/>
+      </Events>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JButton" name="m_ok">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Ok"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[120, 23]"/>
+            </Property>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_okActionPerformed"/>
+          </Events>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="1" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+        </Component>
+        <Container class="javax.swing.JScrollPane" name="m_message">
+          <Properties>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[300, 202]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[300, 202]"/>
+            </Property>
+          </Properties>
+          <AuxValues>
+            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+          </AuxValues>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+          <SubComponents>
+            <Component class="javax.swing.JTextArea" name="m_messageArea">
+              <Properties>
+                <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                  <Color blue="f0" green="f0" id="Panel.background" palette="3" red="f0" type="palette"/>
+                </Property>
+                <Property name="columns" type="int" value="20"/>
+                <Property name="editable" type="boolean" value="false"/>
+                <Property name="lineWrap" type="boolean" value="true"/>
+                <Property name="rows" type="int" value="5"/>
+                <Property name="wrapStyleWord" type="boolean" value="true"/>
+                <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[250, 200]"/>
+                </Property>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[250, 200]"/>
+                </Property>
+              </Properties>
+            </Component>
+          </SubComponents>
+        </Container>
+      </SubComponents>
+    </Container>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="title" type="java.lang.String" value="Junit Runner"/>
+    <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+      <Dimension value="[580, 580]"/>
+    </Property>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,84,0,0,2,98"/>
+  </AuxValues>
+
+  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="m_panel">
+      <Properties>
+        <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[580, 560]"/>
+        </Property>
+        <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[580, 566]"/>
+        </Property>
+      </Properties>
+      <Constraints>
+        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+          <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="0.0" weightY="0.0"/>
+        </Constraint>
+      </Constraints>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+      <SubComponents>
+        <Container class="javax.swing.JScrollPane" name="m_suiteScroll">
+          <Properties>
+            <Property name="autoscrolls" type="boolean" value="true"/>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[400, 147]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[400, 147]"/>
+            </Property>
+          </Properties>
+          <AuxValues>
+            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+          </AuxValues>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="0" gridY="0" gridWidth="4" gridHeight="2" fill="1" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+          <SubComponents>
+            <Component class="javax.swing.JList" name="m_suiteList">
+              <Properties>
+                <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                  <Connection code="new TestListModel()" type="code"/>
+                </Property>
+                <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[250, 147]"/>
+                </Property>
+                <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[250, 147]"/>
+                </Property>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[250, 147]"/>
+                </Property>
+              </Properties>
+            </Component>
+          </SubComponents>
+        </Container>
+        <Component class="javax.swing.JButton" name="m_allButton">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Select All"/>
+            <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[90, 23]"/>
+            </Property>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[90, 23]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[90, 23]"/>
+            </Property>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_allButtonActionPerformed"/>
+          </Events>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+        </Component>
+        <Component class="javax.swing.JButton" name="m_executeButton">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Execute"/>
+            <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[90, 23]"/>
+            </Property>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[90, 23]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[90, 23]"/>
+            </Property>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_executeButtonActionPerformed"/>
+          </Events>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="4" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+        </Component>
+        <Container class="javax.swing.JScrollPane" name="m_resultScroll">
+          <Properties>
+            <Property name="verticalScrollBarPolicy" type="int" value="22"/>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[452, 402]"/>
+            </Property>
+          </Properties>
+          <AuxValues>
+            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+          </AuxValues>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="0" gridY="2" gridWidth="5" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+          <SubComponents>
+            <Component class="javax.swing.JTable" name="m_resultTable">
+              <Properties>
+                <Property name="autoCreateRowSorter" type="boolean" value="true"/>
+                <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                  <Font name="Tahoma" size="10" style="0"/>
+                </Property>
+                <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                  <Connection code="new ResultTableModel()" type="code"/>
+                </Property>
+                <Property name="autoResizeMode" type="int" value="4"/>
+                <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[300, 400]"/>
+                </Property>
+                <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[300, 400]"/>
+                </Property>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="null"/>
+                </Property>
+              </Properties>
+              <Events>
+                <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="m_resultTableMouseClicked"/>
+              </Events>
+            </Component>
+          </SubComponents>
+        </Container>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,481 @@
+/* 
+ * 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.awt.Cursor;
+import java.awt.Point;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JScrollBar;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestResult;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiJunitRunner;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+
+/**
+ * Swing Runner for Junit4Osgi.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class SwingRunner extends javax.swing.JFrame implements BundleListener {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Bundle context (to register the bundle listener).
+     */
+    private BundleContext m_context;
+    
+    /**
+     * OSGi Junit Runner Service. 
+     */
+    private OSGiJunitRunner m_runner;
+    
+    /**
+     * State variable describing if we are executing tests.
+     */
+    private boolean m_running = false;
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    
+    /**
+     * Select all button.
+     */
+    private javax.swing.JButton m_allButton;
+
+    /**
+     * Execute button.
+     */
+    private javax.swing.JButton m_executeButton;
+
+    /**
+     * Message scroll pane.
+     */
+    private javax.swing.JScrollPane m_message;
+
+    /**
+     * Message Text Area.
+     */
+    private javax.swing.JTextArea m_messageArea;
+
+    /**
+     * Ok button (test dialog).
+     */
+    private javax.swing.JButton m_ok;
+
+    /**
+     * Main panel. 
+     */
+    private javax.swing.JPanel m_panel;
+
+    /**
+     * Result dialog. 
+     */
+    private javax.swing.JDialog m_resultDialog;
+
+    /**
+     * Result scroll pane.
+     */
+    private javax.swing.JScrollPane m_resultScroll;
+
+    /**
+     * Result table. 
+     */
+    private javax.swing.JTable m_resultTable;
+
+    /**
+     * Available Suite List.  
+     */
+    private javax.swing.JList m_suiteList;
+
+    /**
+     * Test Suite scroll pane.
+     */
+    private javax.swing.JScrollPane m_suiteScroll;
+
+    // End of variables declaration//GEN-END:variables
+
+    /**
+     * Constructor.
+     * @param bc : bundle context.
+     */
+    public SwingRunner(BundleContext bc) {
+        m_context = bc;
+    }
+
+    /**
+     * Start method.
+     */
+    public void start() {
+        initComponents();
+        setVisible(true);
+        m_resultDialog.setVisible(false);
+        refreshSuites();
+        m_context.addBundleListener(this);
+    }
+
+    /**
+     * Stop method.
+     */
+    public void stop() {
+        m_context.removeBundleListener(this);
+        dispose();
+    }
+
+    /**
+     * Refresh the list of available test suites.
+     */
+    private void refreshSuites() {
+        List<Test> list = m_runner.getTests();
+        TestListModel lm = (TestListModel) m_suiteList.getModel();
+        lm.clear();
+        for (Test t : list) {
+            lm.addTest(t);
+        }
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+        java.awt.GridBagConstraints gridBagConstraints;
+
+        m_resultDialog = new javax.swing.JDialog();
+        m_ok = new javax.swing.JButton();
+        m_message = new javax.swing.JScrollPane();
+        m_messageArea = new javax.swing.JTextArea();
+        m_panel = new javax.swing.JPanel();
+        m_suiteScroll = new javax.swing.JScrollPane();
+        m_suiteList = new javax.swing.JList();
+        m_allButton = new javax.swing.JButton();
+        m_executeButton = new javax.swing.JButton();
+        m_resultScroll = new javax.swing.JScrollPane();
+        m_resultTable = new javax.swing.JTable();
+
+        m_resultDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+        m_resultDialog.setMinimumSize(new java.awt.Dimension(320, 250));
+        m_resultDialog.addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosed(java.awt.event.WindowEvent evt) {
+                onDialogClosed(evt);
+            }
+
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                onDialogClosed(evt);
+            }
+        });
+        m_resultDialog.getContentPane().setLayout(new java.awt.GridBagLayout());
+
+        m_ok.setText("Ok");
+        m_ok.setPreferredSize(new java.awt.Dimension(120, 23));
+        m_ok.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okActionPerformed(evt);
+            }
+        });
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 1;
+        gridBagConstraints.insets = new java.awt.Insets(1, 3, 3, 3);
+        m_resultDialog.getContentPane().add(m_ok, gridBagConstraints);
+
+        m_message.setMinimumSize(new java.awt.Dimension(300, 202));
+        m_message.setPreferredSize(new java.awt.Dimension(300, 202));
+
+        m_messageArea.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
+        m_messageArea.setColumns(20);
+        m_messageArea.setEditable(false);
+        m_messageArea.setLineWrap(true);
+        m_messageArea.setRows(5);
+        m_messageArea.setWrapStyleWord(true);
+        m_messageArea.setMinimumSize(new java.awt.Dimension(250, 200));
+        m_messageArea.setPreferredSize(new java.awt.Dimension(250, 200));
+        m_message.setViewportView(m_messageArea);
+
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+        m_resultDialog.getContentPane().add(m_message, gridBagConstraints);
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setTitle("Junit Runner");
+        setMinimumSize(new java.awt.Dimension(580, 580));
+        getContentPane().setLayout(new java.awt.GridBagLayout());
+
+        m_panel.setMinimumSize(new java.awt.Dimension(580, 560));
+        m_panel.setPreferredSize(new java.awt.Dimension(580, 566));
+        m_panel.setLayout(new java.awt.GridBagLayout());
+
+        m_suiteScroll.setAutoscrolls(true);
+        m_suiteScroll.setMinimumSize(new java.awt.Dimension(400, 147));
+        m_suiteScroll.setPreferredSize(new java.awt.Dimension(400, 147));
+
+        m_suiteList.setModel(new TestListModel());
+        m_suiteList.setMaximumSize(new java.awt.Dimension(250, 147));
+        m_suiteList.setMinimumSize(new java.awt.Dimension(250, 147));
+        m_suiteList.setPreferredSize(new java.awt.Dimension(250, 147));
+        m_suiteScroll.setViewportView(m_suiteList);
+
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.gridwidth = 4;
+        gridBagConstraints.gridheight = 2;
+        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
+        m_panel.add(m_suiteScroll, gridBagConstraints);
+
+        m_allButton.setText("Select All");
+        m_allButton.setMaximumSize(new java.awt.Dimension(90, 23));
+        m_allButton.setMinimumSize(new java.awt.Dimension(90, 23));
+        m_allButton.setPreferredSize(new java.awt.Dimension(90, 23));
+        m_allButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                allButtonActionPerformed(evt);
+            }
+        });
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 4;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+        gridBagConstraints.insets = new java.awt.Insets(3, 0, 0, 0);
+        m_panel.add(m_allButton, gridBagConstraints);
+
+        m_executeButton.setText("Execute");
+        m_executeButton.setMaximumSize(new java.awt.Dimension(90, 23));
+        m_executeButton.setMinimumSize(new java.awt.Dimension(90, 23));
+        m_executeButton.setPreferredSize(new java.awt.Dimension(90, 23));
+        m_executeButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                executeButtonActionPerformed(evt);
+            }
+        });
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 4;
+        gridBagConstraints.gridy = 1;
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
+        gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
+        m_panel.add(m_executeButton, gridBagConstraints);
+
+        m_resultScroll.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+        m_resultScroll.setMinimumSize(new java.awt.Dimension(452, 402));
+
+        //m_resultTable.setAutoCreateRowSorter(true);
+        m_resultTable.setFont(new java.awt.Font("Tahoma", 0, 10));
+        m_resultTable.setModel(new ResultTableModel());
+        m_resultTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
+        m_resultTable.setMaximumSize(new java.awt.Dimension(300, 400));
+        m_resultTable.setMinimumSize(new java.awt.Dimension(300, 400));
+        m_resultTable.setPreferredSize(null);
+        m_resultTable.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                resultTableMouseClicked(evt);
+            }
+        });
+        m_resultScroll.setViewportView(m_resultTable);
+
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 2;
+        gridBagConstraints.gridwidth = 5;
+        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+        gridBagConstraints.insets = new java.awt.Insets(2, 3, 3, 3);
+        m_panel.add(m_resultScroll, gridBagConstraints);
+
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = 0;
+        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
+        getContentPane().add(m_panel, gridBagConstraints);
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    /**
+     * Execute button action.
+     * @param evt : event.
+     */
+    private void executeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_executeButtonActionPerformed
+        if (m_running) { return; }
+        // Collect selected test.
+        int[] indices = m_suiteList.getSelectedIndices();
+        List<Test> list = new ArrayList<Test>(indices.length);
+        TestListModel model = (TestListModel) m_suiteList.getModel();
+        for (int i = 0; i < indices.length; i++) {
+            list.add(model.getTestElementAt(indices[i]));
+        }
+        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+        executeTest(list);
+    } //GEN-LAST:event_m_executeButtonActionPerformed
+
+    /**
+     * All button action.
+     * @param evt : event.
+     */
+    private void allButtonActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_m_allButtonActionPerformed
+        int max = m_suiteList.getModel().getSize();
+        int[] indices = new int[max];
+        for (int i = 0; i < max; i++) {
+            indices[i] = i;
+        }
+        m_suiteList.setSelectedIndices(indices);
+    } //GEN-LAST:event_m_allButtonActionPerformed
+
+    /**
+     * Listener on table click.
+     * @param evt : event.
+     */
+    private void resultTableMouseClicked(java.awt.event.MouseEvent evt) { //GEN-FIRST:event_m_resultTableMouseClicked
+        Point p = evt.getPoint();
+        int row = m_resultTable.rowAtPoint(p);
+        int col = m_resultTable.columnAtPoint(p);
+        ResultTableModel model = (ResultTableModel) m_resultTable.getModel();
+        String message = model.getMessage(row, col);
+        if (message != null) {
+            setEnabled(false);
+            m_resultDialog.setTitle("Test Report");
+            m_messageArea.setText(message);
+            m_resultDialog.setVisible(true);
+        }
+    } //GEN-LAST:event_m_resultTableMouseClicked
+
+    /**
+     * Ok button action.
+     * @param evt : event.
+     */
+    private void okActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_m_okActionPerformed
+        m_resultDialog.setVisible(false);
+        setEnabled(true);
+    } //GEN-LAST:event_m_okActionPerformed
+
+    /**
+     * Listener when the test report is closed.
+     * @param evt : event.
+     */
+    private void onDialogClosed(java.awt.event.WindowEvent evt) { //GEN-FIRST:event_onDialogClosed
+        m_resultDialog.setVisible(false);
+        setEnabled(true);
+    } //GEN-LAST:event_onDialogClosed
+
+    /**
+     * Execute method.
+     * @param list : list of test to execute.
+     */
+    private void executeTest(final List<Test> list) {
+        Runnable thread = new Runnable() {
+            public void run() {
+                ResultTableModel model = (ResultTableModel) m_resultTable.getModel();
+                m_running = true;
+                m_executeButton.setText("Running...");
+                model.clear();
+                for (int i = 0; i < list.size(); i++) {
+                    TestResult tr = new TestResult();
+                    tr.addListener(new MyTestListener());
+                    list.get(i).run(tr);
+                }
+                m_running = false;
+                m_executeButton.setText("Execute");
+                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+            }
+        };
+        new Thread(thread).start();
+    }
+
+    /**
+     * @author clement
+     *
+     */
+    private class MyTestListener implements junit.framework.TestListener {
+        /**
+         * Table model.
+         */
+        ResultTableModel m_model = (ResultTableModel) m_resultTable.getModel();
+
+        /**
+         * Add an error.
+         * @param arg0 : test which throws an error.
+         * @param arg1 : thrown exception.
+         * @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
+         */
+        public void addError(Test arg0, Throwable arg1) {
+            m_model.addTest(arg0, arg1);
+            adjustScroll();
+        }
+
+        /**
+         * Add a failure.
+         * @param arg0 : failing test.
+         * @param arg1 : thrown failure.
+         * @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
+         */
+        public void addFailure(Test arg0, AssertionFailedError arg1) {
+            m_model.addTest(arg0, arg1);
+            adjustScroll();
+        }
+
+        /**
+         * End of a test.
+         * @param arg0 : test.
+         * @see junit.framework.TestListener#endTest(junit.framework.Test)
+         */
+        public void endTest(Test arg0) {
+            m_model.addTest(arg0);
+            adjustScroll();
+        }
+
+        /**
+         * Start of a test.
+         * @param arg0 : test.
+         * @see junit.framework.TestListener#startTest(junit.framework.Test)
+         */
+        public void startTest(Test arg0) {
+            // Nothing to do here.
+        }
+
+        /**
+         * Adjust the scrolling bar of the result table.
+         */
+        private void adjustScroll() {
+            JScrollBar bar = m_resultScroll.getVerticalScrollBar();
+            if ((bar != null) && (bar.isVisible())) {
+                bar.setValue(Integer.MAX_VALUE);
+            }
+        }
+
+    }
+
+    /**
+     * Bundle Changed callback method.
+     * @param arg0 : bundle event.
+     * @see org.osgi.framework.BundleListener#bundleChanged(org.osgi.framework.BundleEvent)
+     */
+    public void bundleChanged(BundleEvent arg0) {
+        refreshSuites();
+    }
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,77 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.junit4osgi.command;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.AbstractListModel;
+import junit.framework.Test;
+
+/**
+ * Test Suite list model.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class TestListModel extends AbstractListModel {
+
+    private static final long serialVersionUID = 1L;
+
+    private List<TestRecord> list = new ArrayList<TestRecord>();
+
+    public Object getElementAt(int index) {
+        return list.get(index).name;
+    }
+
+    public Test getTestElementAt(int index) {
+        return list.get(index).test;
+    }
+
+    public void addTest(Test test) {
+        TestRecord tr = new TestRecord();
+        tr.test = test;
+        tr.name = test.toString();
+        list.add(tr);
+        fireContentsChanged(this, list.size() - 1, list.size() - 1);
+    }
+
+    public void removeTest(Test test) {
+        for (TestRecord t : list) {
+            if (t.test.equals(test)) {
+                int index = list.indexOf(t);
+                list.remove(t);
+                fireContentsChanged(this, index, index);
+                return;
+            }
+        }
+    }
+
+    public void clear() {
+        list.clear();
+    }
+
+    private class TestRecord {
+        public Test test;
+
+        public String name;
+    }
+
+    public int getSize() {
+        return list.size();
+    }
+
+}

Modified: felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client.annotation/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client.annotation/pom.xml?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client.annotation/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client.annotation/pom.xml Sun Feb 10 12:57:57 2008
@@ -1,14 +1,14 @@
 <project>
   <modelVersion>4.0.0</modelVersion>
   <packaging>bundle</packaging>
-  <groupId>ipojo.example</groupId>
+  <groupId>ipojo.examples</groupId>
   <artifactId>hello.client.annotation</artifactId>
    <version>0.7.6-SNAPSHOT</version>
   <name>Hello Service Client using Annotations</name>
   
   <dependencies>
     <dependency>
-      <groupId>ipojo.example</groupId>
+      <groupId>ipojo.examples</groupId>
       <artifactId>hello.service</artifactId>
       <version>${pom.version}</version>
     </dependency>

Modified: felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client/pom.xml?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client/pom.xml Sun Feb 10 12:57:57 2008
@@ -1,13 +1,13 @@
 <project>
   <modelVersion>4.0.0</modelVersion>
   <packaging>bundle</packaging><!-- Use the BND Maven plug-in -->
-  <groupId>ipojo.example</groupId>
+  <groupId>ipojo.examples</groupId>
   <artifactId>hello.client</artifactId>
    <version>0.7.6-SNAPSHOT</version>
   <name>Hello Service Client</name>
   <dependencies>
     <dependency>
-      <groupId>ipojo.example</groupId>
+      <groupId>ipojo.examples</groupId>
       <artifactId>hello.service</artifactId>
       <version>${pom.version}</version>
     </dependency>

Modified: felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl.annotation/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl.annotation/pom.xml?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl.annotation/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl.annotation/pom.xml Sun Feb 10 12:57:57 2008
@@ -1,7 +1,7 @@
 <project>
   <modelVersion>4.0.0</modelVersion>
   <packaging>bundle</packaging>
-  <groupId>ipojo.example</groupId>
+  <groupId>ipojo.examples</groupId>
   <artifactId>hello.impl.annotation</artifactId>
   <version>0.7.6-SNAPSHOT</version>
   <name>Hello Service Provider using Annotations</name>
@@ -16,7 +16,7 @@
   
   <dependencies>
    <dependency>
-      <groupId>ipojo.example</groupId>
+      <groupId>ipojo.examples</groupId>
       <artifactId>hello.service</artifactId>
       <version>${pom.version}</version>
     </dependency>

Modified: felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl/pom.xml?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl/pom.xml Sun Feb 10 12:57:57 2008
@@ -1,7 +1,7 @@
 <project>
   <modelVersion>4.0.0</modelVersion>
   <packaging>bundle</packaging>
-  <groupId>ipojo.example</groupId>
+  <groupId>ipojo.examples</groupId>
   <artifactId>hello.impl</artifactId>
   <version>0.7.6-SNAPSHOT</version>
   <name>Hello Service Provider</name>
@@ -24,7 +24,7 @@
   
   <dependencies>
   	<dependency>
-  		<groupId>ipojo.example</groupId>
+  		<groupId>ipojo.examples</groupId>
   		<artifactId>hello.service</artifactId>
   		<version>${pom.version}</version>
   	</dependency>

Modified: felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.service/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.service/pom.xml?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.service/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.service/pom.xml Sun Feb 10 12:57:57 2008
@@ -1,7 +1,7 @@
 <project>
   <modelVersion>4.0.0</modelVersion>
   <packaging>bundle</packaging>
-  <groupId>ipojo.example</groupId>
+  <groupId>ipojo.examples</groupId>
   <artifactId>hello.service</artifactId>
   <version>0.7.6-SNAPSHOT</version>
   <name>Hello Service</name>

Modified: felix/sandbox/clement/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java (original)
+++ felix/sandbox/clement/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java Sun Feb 10 12:57:57 2008
@@ -237,7 +237,7 @@
      * @return the resulting element array (null if the search failed)
      */
     public Element[] getElements(String name, String ns) {
-        if (ns == null || ns.equals("")) {
+        if (ns == null || ns.length() == 0) {
             return getElements(name);
         }
         name = ns + ":" + name;
@@ -260,7 +260,7 @@
      * @return true if the element contains an element of the type "name"
      */
     public boolean containsElement(String name, String ns) {
-        if (ns != null && !ns.equals("")) {
+        if (ns != null && ns.length() != 0) {
             name = ns + ":" + name;
         }
         return containsElement(name);

Modified: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/IPOJOTestSuite.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/IPOJOTestSuite.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/IPOJOTestSuite.java (original)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/IPOJOTestSuite.java Sun Feb 10 12:57:57 2008
@@ -19,7 +19,7 @@
 public class IPOJOTestSuite {
     
     public static Test suite(BundleContext bc) {
-        OSGiTestSuite ots = new OSGiTestSuite(bc);
+        OSGiTestSuite ots = new OSGiTestSuite("IPojo Core Test Suite", bc);
         ots.addTest(ManipulationTestSuite.suite(bc));
         ots.addTest(CoreTestSuite.suite(bc));
         ots.addTest(FactoryTestSuite.suite(bc));