]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootRuntimeTest.java
Introduce check-osgi profile
[lgpl/argeo-commons.git] / osgi / runtime / org.argeo.osgi.boot / src / test / java / org / argeo / osgi / boot / OsgiBootRuntimeTest.java
index 07567b8ca3b6c22adac28fd9361b2a36dfe04e67..fd32f1ae08a3bebfb95954b230a4b7513840be74 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ * 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.
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.argeo.osgi.boot;
 
 import java.util.Iterator;
@@ -22,7 +21,6 @@ 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;
@@ -30,8 +28,14 @@ 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());
@@ -72,11 +76,16 @@ public class OsgiBootRuntimeTest extends TestCase {
        }
 
        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();
        }