X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=osgi%2Fruntime%2Forg.argeo.osgi.boot%2Fsrc%2Ftest%2Fjava%2Forg%2Fargeo%2Fosgi%2Fboot%2FOsgiBootRuntimeTest.java;fp=osgi%2Fruntime%2Forg.argeo.osgi.boot%2Fsrc%2Ftest%2Fjava%2Forg%2Fargeo%2Fosgi%2Fboot%2FOsgiBootRuntimeTest.java;h=0000000000000000000000000000000000000000;hb=2fd18c91abdcdd118abef6ce81a1afe3e4d1bfb8;hp=fd32f1ae08a3bebfb95954b230a4b7513840be74;hpb=c3f8e165014d2ef6ecec57c44a59e816791db01d;p=lgpl%2Fargeo-commons.git 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 deleted file mode 100644 index fd32f1ae0..000000000 --- a/osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootRuntimeTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * 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.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; - private boolean osgiRuntimeAlreadyRunning = false; - - public void testInstallAndStart() throws Exception { - if (osgiRuntimeAlreadyRunning) { - System.out - .println("OSGi runtime already running, skipping test..."); - return; - } - 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); - 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.getBundlesBySymbolicName(); - 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 { - osgiRuntimeAlreadyRunning = EclipseStarter.isRunning(); - if (osgiRuntimeAlreadyRunning) - return; - BundleContext bundleContext = startRuntime(); - osgiBoot = new OsgiBoot(bundleContext); - } - - public void tearDown() throws Exception { - if (osgiRuntimeAlreadyRunning) - return; - osgiBoot = null; - stopRuntime(); - } - -}