Remove deprecated properties
authorMathieu Baudier <mbaudier@argeo.org>
Mon, 23 May 2011 08:44:06 +0000 (08:44 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Mon, 23 May 2011 08:44:06 +0000 (08:44 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@4538 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/Launcher.java
osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBoot.java
osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBootUtils.java
osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootNoRuntimeTest.java [new file with mode: 0644]
osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootRuntimeTest.java [new file with mode: 0644]
osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/slc/osgiboot/OsgiBootNoRuntimeTest.java [deleted file]
osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/slc/osgiboot/OsgiBootRuntimeTest.java [deleted file]

index 98d7503e31b2f9f6ad0cba21244e137800bc785d..364e2a8efd93b1165fd07446fa5178cee57b5589 100644 (file)
@@ -25,13 +25,13 @@ import java.util.Vector;
 import org.eclipse.core.runtime.adaptor.EclipseStarter;
 import org.osgi.framework.BundleContext;
 
+/** Command line interface. */
 public class Launcher {
 
        public static void main(String[] args) {
                // Try to load system properties
-               String systemPropertiesFilePath = OsgiBootUtils.getPropertyCompat(
-                               OsgiBoot.PROP_ARGEO_OSGI_BOOT_SYSTEM_PROPERTIES_FILE,
-                               OsgiBoot.PROP_SLC_OSGIBOOT_SYSTEM_PROPERTIES_FILE);
+               String systemPropertiesFilePath = OsgiBootUtils
+                               .getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_SYSTEM_PROPERTIES_FILE);
                if (systemPropertiesFilePath != null) {
                        FileInputStream in;
                        try {
@@ -68,23 +68,16 @@ public class Launcher {
        }
 
        protected static void startMainClass() {
-               // Properties config = System.getProperties();
-               // String className = config.getProperty("slc.osgiboot.appclass");
-               String className = OsgiBootUtils.getPropertyCompat(
-                               OsgiBoot.PROP_ARGEO_OSGI_BOOT_APPCLASS,
-                               OsgiBoot.PROP_SLC_OSGIBOOT_APPCLASS);
+               String className = OsgiBootUtils
+                               .getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_APPCLASS);
                if (className == null)
                        return;
 
-               // should use OsgiBootUtils.getPropertyCompat(), but it does not 
-               // work for "" as default value
-               // so no warning displayed if PROP_SLC_OSGIBOOT_APPARGS is used
-               // FIXME: change OsgiBootUtils.getPropertyCompat()
-               String line = System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_APPARGS, 
-                               System.getProperty(OsgiBoot.PROP_SLC_OSGIBOOT_APPARGS, ""));            
-               
+               String line = System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_APPARGS,
+                               "");
+
                String[] uiArgs = readArgumentsFromLine(line);
-               
+
                try {
                        // Launch main method using reflection
                        Class clss = Class.forName(className);
@@ -103,9 +96,7 @@ public class Launcher {
         * arguments. (nested \" are not supported)
         */
        private static String[] readArgumentsFromLine(String lineOrig) {
-
                String line = lineOrig.trim();// remove trailing spaces
-               // System.out.println("line=" + line);
                List args = new Vector();
                StringBuffer curr = new StringBuffer("");
                boolean inQuote = false;
@@ -139,7 +130,6 @@ public class Launcher {
                String[] res = new String[args.size()];
                for (int i = 0; i < args.size(); i++) {
                        res[i] = args.get(i).toString();
-                       // System.out.println("res[i]=" + res[i]);
                }
                return res;
        }
index 7c37986974f3be30ccb0679dd642b49ab417396c..63e5d059b39cbd9b8d928aa21bd5755737e035ac 100644 (file)
@@ -43,6 +43,7 @@ import org.osgi.framework.ServiceReference;
 import org.osgi.service.packageadmin.ExportedPackage;
 import org.osgi.service.packageadmin.PackageAdmin;
 
+/** Core component, performing basic provisioning of an OSGi runtime. */
 public class OsgiBoot {
        public final static String SYMBOLIC_NAME_OSGI_BOOT = "org.argeo.osgi.boot";
        public final static String SYMBOLIC_NAME_EQUINOX = "org.eclipse.osgi";
@@ -62,36 +63,11 @@ public class OsgiBoot {
        public final static String PROP_ARGEO_OSGI_BOOT_APPCLASS = "argeo.osgi.boot.appclass";
        public final static String PROP_ARGEO_OSGI_BOOT_APPARGS = "argeo.osgi.boot.appargs";
 
-       /** @deprecated */
-       public final static String PROP_SLC_OSGI_START = "slc.osgi.start";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGI_BUNDLES = "slc.osgi.bundles";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGI_LOCATIONS = "slc.osgi.locations";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGI_BASE_URL = "slc.osgi.baseUrl";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGI_MODULES_URL = "slc.osgi.modulesUrl";
-
-       /** @deprecated */
-       public final static String PROP_SLC_OSGIBOOT_DEBUG = "slc.osgiboot.debug";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGIBOOT_DEFAULT_TIMEOUT = "slc.osgiboot.defaultTimeout";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGIBOOT_MODULES_URL_SEPARATOR = "slc.osgiboot.modulesUrlSeparator";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGIBOOT_SYSTEM_PROPERTIES_FILE = "slc.osgiboot.systemPropertiesFile";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGIBOOT_APPCLASS = "slc.osgiboot.appclass";
-       /** @deprecated */
-       public final static String PROP_SLC_OSGIBOOT_APPARGS = "slc.osgiboot.appargs";
-
        public final static String DEFAULT_BASE_URL = "reference:file:";
        public final static String EXCLUDES_SVN_PATTERN = "**/.svn/**";
 
        private boolean debug = Boolean.valueOf(
-                       System.getProperty(PROP_ARGEO_OSGI_BOOT_DEBUG,
-                                       System.getProperty(PROP_SLC_OSGIBOOT_DEBUG, "false")))
+                       System.getProperty(PROP_ARGEO_OSGI_BOOT_DEBUG, "false"))
                        .booleanValue();
        /** Default is 10s (set in constructor) */
        private long defaultTimeout;
@@ -104,12 +80,10 @@ public class OsgiBoot {
 
        public OsgiBoot(BundleContext bundleContext) {
                this.bundleContext = bundleContext;
-               defaultTimeout = Long.parseLong(OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_BOOT_DEFAULT_TIMEOUT,
-                               PROP_SLC_OSGIBOOT_DEFAULT_TIMEOUT, "10000"));
-               modulesUrlSeparator = OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_BOOT_MODULES_URL_SEPARATOR,
-                               PROP_SLC_OSGIBOOT_MODULES_URL_SEPARATOR, ",");
+               defaultTimeout = Long.parseLong(OsgiBootUtils.getProperty(
+                               PROP_ARGEO_OSGI_BOOT_DEFAULT_TIMEOUT, "10000"));
+               modulesUrlSeparator = OsgiBootUtils.getProperty(
+                               PROP_ARGEO_OSGI_BOOT_MODULES_URL_SEPARATOR, ",");
                initSystemProperties();
        }
 
@@ -262,8 +236,8 @@ public class OsgiBoot {
        }
 
        public void startBundles() {
-               String bundlesToStart = OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_START, PROP_SLC_OSGI_START);
+               String bundlesToStart = OsgiBootUtils
+                               .getProperty(PROP_ARGEO_OSGI_START);
                startBundles(bundlesToStart);
        }
 
@@ -342,6 +316,7 @@ public class OsgiBoot {
                }
        }
 
+       /** List packages exported twice. */
        public Map findPackagesExportedTwice() {
                ServiceReference paSr = bundleContext
                                .getServiceReference(PackageAdmin.class.getName());
@@ -445,23 +420,21 @@ public class OsgiBoot {
        }
 
        public List getLocationsUrls() {
-               String baseUrl = OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_BASE_URL, PROP_SLC_OSGI_BASE_URL,
+               String baseUrl = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BASE_URL,
                                DEFAULT_BASE_URL);
-               String bundleLocations = OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_LOCATIONS, PROP_SLC_OSGI_LOCATIONS);
+               String bundleLocations = OsgiBootUtils
+                               .getProperty(PROP_ARGEO_OSGI_LOCATIONS);
                return getLocationsUrls(baseUrl, bundleLocations);
        }
 
        public List getModulesUrls() {
                List urls = new ArrayList();
-               String modulesUrlStr = OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_MODULES_URL, PROP_SLC_OSGI_MODULES_URL);
+               String modulesUrlStr = OsgiBootUtils
+                               .getProperty(PROP_ARGEO_OSGI_MODULES_URL);
                if (modulesUrlStr == null)
                        return urls;
 
-               String baseUrl = OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_BASE_URL, PROP_SLC_OSGI_BASE_URL);
+               String baseUrl = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BASE_URL);
 
                Map installedBundles = getBundles();
 
@@ -586,11 +559,10 @@ public class OsgiBoot {
        }
 
        public List getBundlesUrls() {
-               String baseUrl = OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_BASE_URL, PROP_SLC_OSGI_BASE_URL,
+               String baseUrl = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BASE_URL,
                                DEFAULT_BASE_URL);
-               String bundlePatterns = OsgiBootUtils.getPropertyCompat(
-                               PROP_ARGEO_OSGI_BUNDLES, PROP_SLC_OSGI_BUNDLES);
+               String bundlePatterns = OsgiBootUtils
+                               .getProperty(PROP_ARGEO_OSGI_BUNDLES);
                return getBundlesUrls(baseUrl, bundlePatterns);
        }
 
index a9067a213c04e912985fb139651db012c4b3ff3b..acc0302e62b2178690052f192946edf36f277da5 100644 (file)
@@ -16,6 +16,7 @@
 \r
 package org.argeo.osgi.boot;\r
 \r
+/** Utilities, mostly related to logging. */\r
 public class OsgiBootUtils {\r
 \r
        public static void info(Object obj) {\r
@@ -23,7 +24,7 @@ public class OsgiBootUtils {
        }\r
 \r
        public static void debug(Object obj) {\r
-                       System.out.println("# OSGiBOOT DBG  # " + obj);\r
+               System.out.println("# OSGiBOOT DBG  # " + obj);\r
        }\r
 \r
        public static void warn(Object obj) {\r
@@ -35,14 +36,18 @@ public class OsgiBootUtils {
                // System.err.println("# WARN " + obj);\r
        }\r
 \r
-       //FIXE: returns null when defaultValue is ""\r
+       /**\r
+        * Gets a property value\r
+        * \r
+        * @return null when defaultValue is ""\r
+        */\r
        public static String getProperty(String name, String defaultValue) {\r
                final String value;\r
                if (defaultValue != null)\r
                        value = System.getProperty(name, defaultValue);\r
                else\r
                        value = System.getProperty(name);\r
-               \r
+\r
                if (value == null || value.equals(""))\r
                        return null;\r
                else\r
@@ -53,36 +58,4 @@ public class OsgiBootUtils {
                return getProperty(name, null);\r
        }\r
 \r
-       public static String getPropertyCompat(String name, String oldName) {\r
-               return getPropertyCompat(name, oldName, null);\r
-       }\r
-\r
-       public static String getPropertyCompat(String name, String oldName,\r
-                       String defaultValue) {\r
-               String res = null;\r
-\r
-               if (defaultValue != null) {\r
-                       res = getProperty(name, defaultValue);\r
-                       if (res.equals(defaultValue)) {\r
-                               res = getProperty(oldName, defaultValue);\r
-                               if (!res.equals(defaultValue))\r
-                                       warnDeprecated(name, oldName);\r
-                       }\r
-               } else {\r
-                       res = getProperty(name, null);\r
-                       if (res == null) {\r
-                               res = getProperty(oldName, null);\r
-                               if (res != null)\r
-                                       warnDeprecated(name, oldName);\r
-                       }\r
-               }\r
-               return res;\r
-       }\r
-\r
-       public static void warnDeprecated(String name, String oldName) {\r
-               warn("Property '" + oldName\r
-                               + "' is deprecated and will be removed soon, use '" + name\r
-                               + "' instead.");\r
-       }       \r
-       \r
 }\r
diff --git a/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootNoRuntimeTest.java b/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootNoRuntimeTest.java
new file mode 100644 (file)
index 0000000..1985478
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ *
+ * Licensed 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.argeo.osgi.boot;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.argeo.osgi.boot.OsgiBoot;
+
+/** Tests which do not require a runtime. */
+public class OsgiBootNoRuntimeTest extends TestCase {
+       public final static String BUNDLES = "src/test/bundles/some;in=*;ex=excluded,"
+                       + "src/test/bundles/others;in=**/org.argeo.*";
+
+       /** Tests that location lists are properly parsed. */
+       public void testLocations() {
+               String baseUrl = "file:";
+               String locations = "/mydir/myfile" + File.pathSeparator
+                               + "/myotherdir/myotherfile";
+
+               OsgiBoot osgiBoot = new OsgiBoot(null);
+               List urls = osgiBoot.getLocationsUrls(baseUrl, locations);
+               assertEquals(2, urls.size());
+               assertEquals("file:/mydir/myfile", urls.get(0));
+               assertEquals("file:/myotherdir/myotherfile", urls.get(1));
+       }
+
+       /** Tests that bundle lists are properly parsed. */
+       public void testBundles() {
+               String baseUrl = "file:";
+               String bundles = BUNDLES;
+               OsgiBoot osgiBoot = new OsgiBoot(null);
+               List urls = osgiBoot.getBundlesUrls(baseUrl, bundles);
+               for (int i = 0; i < urls.size(); i++)
+                       System.out.println(urls.get(i));
+               assertEquals(3, urls.size());
+
+               List jarUrls = osgiBoot.getBundlesUrls(baseUrl,
+                               "src/test/bundles/jars;in=*.jar");
+               for (int i = 0; i < jarUrls.size(); i++)
+                       System.out.println(jarUrls.get(i));
+               assertEquals(1, jarUrls.size());
+       }
+}
diff --git a/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootRuntimeTest.java b/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootRuntimeTest.java
new file mode 100644 (file)
index 0000000..93f5c92
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ *
+ * Licensed 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.argeo.osgi.boot;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.argeo.osgi.boot.OsgiBoot;
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/** Starts an Equinox runtime and provision it with OSGi boot. */
+public class OsgiBootRuntimeTest extends TestCase {
+       protected OsgiBoot osgiBoot = null;
+
+       public void testInstallAndStart() throws Exception {
+               osgiBoot.installUrls(osgiBoot.getBundlesUrls(OsgiBoot.DEFAULT_BASE_URL,
+                               OsgiBootNoRuntimeTest.BUNDLES));
+               Map map = new TreeMap(osgiBoot.getBundles());
+               for (Iterator keys = map.keySet().iterator(); keys.hasNext();) {
+                       Object key = keys.next();
+                       Bundle bundle = (Bundle) map.get(key);
+                       System.out.println(key + " : " + bundle.getLocation());
+               }
+               assertEquals(4, map.size());
+               Iterator keys = map.keySet().iterator();
+               assertEquals("org.argeo.osgi.boot.test.bundle1", keys.next());
+               assertEquals("org.argeo.osgi.boot.test.bundle2", keys.next());
+               assertEquals("org.argeo.osgi.boot.test.bundle3", keys.next());
+               assertEquals("org.eclipse.osgi", keys.next());
+
+               osgiBoot.startBundles("org.argeo.osgi.boot.test.bundle2");
+               long begin = System.currentTimeMillis();
+               while (System.currentTimeMillis() - begin < 10000) {
+                       Map mapBundles = osgiBoot.getBundles();
+                       Bundle bundle = (Bundle) mapBundles
+                                       .get("org.argeo.osgi.boot.test.bundle2");
+                       if (bundle.getState() == Bundle.ACTIVE) {
+                               System.out.println("Bundle " + bundle + " started.");
+                               return;
+                       }
+               }
+               fail("Bundle not started after timeout limit.");
+       }
+
+       protected BundleContext startRuntime() throws Exception {
+               String[] args = { "-console", "-clean" };
+               BundleContext bundleContext = EclipseStarter.startup(args, null);
+               return bundleContext;
+       }
+
+       protected void stopRuntime() throws Exception {
+               EclipseStarter.shutdown();
+       }
+
+       public void setUp() throws Exception {
+               BundleContext bundleContext = startRuntime();
+               osgiBoot = new OsgiBoot(bundleContext);
+       }
+
+       public void tearDown() throws Exception {
+               osgiBoot = null;
+               stopRuntime();
+       }
+
+}
diff --git a/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/slc/osgiboot/OsgiBootNoRuntimeTest.java b/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/slc/osgiboot/OsgiBootNoRuntimeTest.java
deleted file mode 100644 (file)
index 77f74d3..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
- *
- * Licensed 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.argeo.slc.osgiboot;
-
-import java.io.File;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.argeo.osgi.boot.OsgiBoot;
-
-public class OsgiBootNoRuntimeTest extends TestCase {
-       public final static String BUNDLES = "src/test/bundles/some;in=*;ex=excluded,"
-                       + "src/test/bundles/others;in=**/org.argeo.*";
-
-       public void testLocations() {
-               String baseUrl = "file:";
-               String locations = "/mydir/myfile" + File.pathSeparator
-                               + "/myotherdir/myotherfile";
-
-               OsgiBoot osgiBoot = new OsgiBoot(null);
-               List urls = osgiBoot.getLocationsUrls(baseUrl, locations);
-               assertEquals(2, urls.size());
-               assertEquals("file:/mydir/myfile", urls.get(0));
-               assertEquals("file:/myotherdir/myotherfile", urls.get(1));
-       }
-
-       public void testBundles() {
-               String baseUrl = "file:";
-               String bundles = BUNDLES;
-               OsgiBoot osgiBoot = new OsgiBoot(null);
-               List urls = osgiBoot.getBundlesUrls(baseUrl, bundles);
-               for (int i = 0; i < urls.size(); i++)
-                       System.out.println(urls.get(i));
-               assertEquals(3, urls.size());
-
-               List jarUrls = osgiBoot.getBundlesUrls(baseUrl,
-                               "src/test/bundles/jars;in=*.jar");
-               for (int i = 0; i < jarUrls.size(); i++)
-                       System.out.println(jarUrls.get(i));
-               assertEquals(1, jarUrls.size());
-       }
-}
diff --git a/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/slc/osgiboot/OsgiBootRuntimeTest.java b/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/slc/osgiboot/OsgiBootRuntimeTest.java
deleted file mode 100644 (file)
index b717c3a..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
- *
- * Licensed 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.argeo.slc.osgiboot;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.argeo.osgi.boot.OsgiBoot;
-import org.eclipse.core.runtime.adaptor.EclipseStarter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-public class OsgiBootRuntimeTest extends TestCase {
-       protected OsgiBoot osgiBoot = null;
-
-       public void testInstallAndStart() throws Exception {
-               osgiBoot.installUrls(osgiBoot.getBundlesUrls(OsgiBoot.DEFAULT_BASE_URL,
-                               OsgiBootNoRuntimeTest.BUNDLES));
-               Map map = new TreeMap(osgiBoot.getBundles());
-               for (Iterator keys = map.keySet().iterator(); keys.hasNext();) {
-                       Object key = keys.next();
-                       Bundle bundle = (Bundle) map.get(key);
-                       System.out.println(key + " : " + bundle.getLocation());
-               }
-               assertEquals(4, map.size());
-               Iterator keys = map.keySet().iterator();
-               assertEquals("org.argeo.slc.osgiboot.test.bundle1", keys.next());
-               assertEquals("org.argeo.slc.osgiboot.test.bundle2", keys.next());
-               assertEquals("org.argeo.slc.osgiboot.test.bundle3", keys.next());
-               assertEquals("org.eclipse.osgi", keys.next());
-
-               osgiBoot.startBundles("org.argeo.slc.osgiboot.test.bundle2");
-               long begin = System.currentTimeMillis();
-               while (System.currentTimeMillis() - begin < 10000) {
-                       Map mapBundles = osgiBoot.getBundles();
-                       Bundle bundle = (Bundle) mapBundles
-                                       .get("org.argeo.slc.osgiboot.test.bundle2");
-                       if (bundle.getState() == Bundle.ACTIVE) {
-                               System.out.println("Bundle " + bundle + " started.");
-                               return;
-                       }
-               }
-               fail("Bundle not started after timeout limit.");
-       }
-
-       protected BundleContext startRuntime() throws Exception {
-               String[] args = { "-console", "-clean" };
-               BundleContext bundleContext = EclipseStarter.startup(args, null);
-               return bundleContext;
-       }
-
-       protected void stopRuntime() throws Exception {
-               EclipseStarter.shutdown();
-       }
-
-       public void setUp() throws Exception {
-               BundleContext bundleContext = startRuntime();
-               osgiBoot = new OsgiBoot(bundleContext);
-       }
-
-       public void tearDown() throws Exception {
-               osgiBoot = null;
-               stopRuntime();
-       }
-
-}