]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.osgi.boot/ext/test/org/argeo/osgi/boot/OsgiBootRuntimeTest.java
Introduce open closeable method
[lgpl/argeo-commons.git] / org.argeo.osgi.boot / ext / test / org / argeo / osgi / boot / OsgiBootRuntimeTest.java
index 7596c56a3f87f006ab828258cbfd48d232cf9d6c..25404bad617f46e673cb981f7a3fa3d6f34a3f37 100644 (file)
@@ -1,18 +1,3 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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;
@@ -26,7 +11,6 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
 /** Starts an Equinox runtime and provision it with OSGi boot. */
-@SuppressWarnings({ "unchecked", "rawtypes", "deprecation", "restriction" })
 public class OsgiBootRuntimeTest extends TestCase {
        protected OsgiBoot osgiBoot = null;
        private boolean osgiRuntimeAlreadyRunning = false;
@@ -39,25 +23,26 @@ public class OsgiBootRuntimeTest extends TestCase {
                }
                osgiBoot.installUrls(osgiBoot.getBundlesUrls(OsgiBoot.DEFAULT_BASE_URL,
                                OsgiBootNoRuntimeTest.BUNDLES));
-               Map map = new TreeMap(osgiBoot.getBundlesBySymbolicName());
-               for (Iterator keys = map.keySet().iterator(); keys.hasNext();) {
-                       Object key = keys.next();
-                       Bundle bundle = (Bundle) map.get(key);
+               Map<String, Bundle> map = new TreeMap<String, Bundle>(
+                               osgiBoot.getBundlesBySymbolicName());
+               for (Iterator<String> keys = map.keySet().iterator(); keys.hasNext();) {
+                       String key = keys.next();
+                       Bundle bundle = map.get(key);
                        System.out.println(key + " : " + bundle.getLocation());
                }
                assertEquals(4, map.size());
-               Iterator keys = map.keySet().iterator();
+               Iterator<String> 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");
+               // osgiBoot.startBundles("org.argeo.osgi.boot.test.bundle2");
                long begin = System.currentTimeMillis();
                while (System.currentTimeMillis() - begin < 10000) {
-                       Map mapBundles = osgiBoot.getBundlesBySymbolicName();
-                       Bundle bundle = (Bundle) mapBundles
-                                       .get("org.argeo.osgi.boot.test.bundle2");
+                       Map<String, Bundle> mapBundles = osgiBoot
+                                       .getBundlesBySymbolicName();
+                       Bundle bundle = mapBundles.get("org.argeo.osgi.boot.test.bundle2");
                        if (bundle.getState() == Bundle.ACTIVE) {
                                System.out.println("Bundle " + bundle + " started.");
                                return;
@@ -69,6 +54,11 @@ public class OsgiBootRuntimeTest extends TestCase {
        protected BundleContext startRuntime() throws Exception {
                String[] args = { "-console", "-clean" };
                BundleContext bundleContext = EclipseStarter.startup(args, null);
+
+//             ServiceLoader<FrameworkFactory> ff = ServiceLoader.load(FrameworkFactory.class);
+//             Map<String,String> config = new HashMap<String,String>();               
+//             Framework fwk = ff.iterator().next().newFramework(config);
+//             fwk.start();
                return bundleContext;
        }