[jboss-osgi-commits] JBoss-OSGI SVN: r90194 - in projects/jboss-osgi/trunk: husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context and 3 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Mon Jun 15 08:10:17 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-06-15 08:10:16 -0400 (Mon, 15 Jun 2009)
New Revision: 90194

Removed:
   projects/jboss-osgi/trunk/husky/testsuite/${basedir}/
Modified:
   projects/jboss-osgi/trunk/husky/testsuite/pom.xml
   projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
   projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
   projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
Log:
[JBOSGi-93] - Uninstall bundles on OSGiRuntime.shutdown()

Modified: projects/jboss-osgi/trunk/husky/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/pom.xml	2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/husky/testsuite/pom.xml	2009-06-15 12:10:16 UTC (rev 90194)
@@ -116,53 +116,11 @@
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <systemProperties>
-            <property>
-              <name>log4j.output.dir</name>
-              <value>${project.build.directory}</value>
-            </property>
-            <property>
-              <name>org.jboss.osgi.husky.Invoker</name>
-              <value>org.jboss.osgi.husky.internal.OSGiInvoker</value>
-            </property>
-            <property>
-              <name>test.archive.directory</name>
-              <value>${project.build.directory}/test-libs</value>
-            </property>
-          </systemProperties>
-        </configuration>
-      </plugin>
     </plugins>
   </build>
   
   <!-- Profiles -->
   <profiles>
-
-    <!--
-      Name: remote-testing 
-      Descr: Setup for remote integration testing
-    -->
-    <profile>
-      <id>remote-testing</id>
-      <activation>
-        <property>
-          <name>target.container</name>
-        </property>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <skipTests>true</skipTests>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
   </profiles>
   
 </project>

Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java	2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java	2009-06-15 12:10:16 UTC (rev 90194)
@@ -51,7 +51,6 @@
    public BundleContext context;
 
    private OSGiRuntime runtime;
-   private OSGiBundle bundle;
 
    @Before
    public void setUp() throws BundleException
@@ -62,7 +61,7 @@
          runtime.addCapability(new JMXCapability());
          runtime.addCapability(new HuskyCapability());
          
-         bundle = runtime.installBundle("context-basic.jar");
+         OSGiBundle bundle = runtime.installBundle("context-basic.jar");
          bundle.start();
       }
    }
@@ -71,12 +70,7 @@
    public void tearDown() throws BundleException
    {
       if (context == null)
-      {
-         if (bundle != null)
-            bundle.uninstall();
-         
          runtime.shutdown();
-      }
    }
 
    @Test

Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java	2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java	2009-06-15 12:10:16 UTC (rev 90194)
@@ -50,9 +50,8 @@
 {
    @ProvideContext
    public static BundleContext context;
-
+   
    private static OSGiRuntime runtime;
-   private static OSGiBundle bundle;
 
    @BeforeClass
    public static void beforeClass() throws BundleException
@@ -63,21 +62,16 @@
          runtime.addCapability(new JMXCapability());
          runtime.addCapability(new HuskyCapability());
          
-         bundle = runtime.installBundle("context-basic.jar");
+         OSGiBundle bundle = runtime.installBundle("context-basic.jar");
          bundle.start();
       }
    }
 
    @AfterClass
-   public static void afterDown() throws BundleException
+   public static void afterClass() throws BundleException
    {
       if (context == null)
-      {
-         if (bundle != null)
-            bundle.uninstall();
-         
          runtime.shutdown();
-      }
    }
 
    @Test

Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties	2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties	2009-06-15 12:10:16 UTC (rev 90194)
@@ -8,7 +8,7 @@
 org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
 
 # Properties to configure the Framework
-org.osgi.framework.storage=${basedir}/target/osgi-store
+org.osgi.framework.storage=${test.archive.directory}/../osgi-store
 org.osgi.framework.storage.clean=onFirstInit
 
 # Husky socket connector properties

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java	2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java	2009-06-15 12:10:16 UTC (rev 90194)
@@ -128,11 +128,7 @@
    /**
     * Shutdown the {@link OSGiRuntime}.
     * 
-    * This will remove all added {@link Capability}.
-    * 
-    * The installed bundles are currently NOT uninstalled automatically.
-    * 
-    * [TODO] JBOSGI-93
+    * This will remove all installed {@link OSGiBundle}s and added {@link Capability}.
     */
    void shutdown();
 }

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java	2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java	2009-06-15 12:10:16 UTC (rev 90194)
@@ -75,7 +75,7 @@
       service.deploy(bundleURL);
       
       OSGiBundle bundle = getBundle(symbolicName, null);
-      return bundle;
+      return registerBundleForUninstall(bundle);
    }
 
    public OSGiBundle[] getBundles()

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java	2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java	2009-06-15 12:10:16 UTC (rev 90194)
@@ -60,6 +60,7 @@
    final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
 
    private OSGiTestHelper helper;
+   private List<OSGiBundle> registeredBundles = new ArrayList<OSGiBundle>();
    private Map<String, OSGiBundle> capBundles = new HashMap<String, OSGiBundle>();
    private List<Capability> capabilities = new ArrayList<Capability>();
    private LogReaderService logReaderService;
@@ -86,6 +87,12 @@
       return logReaderService;
    }
 
+   protected OSGiBundle registerBundleForUninstall(OSGiBundle bundle)
+   {
+      registeredBundles.add(bundle);
+      return bundle;
+   }
+   
    public void addCapability(Capability capability) throws BundleException
    {
       // Add dependent capabilies
@@ -175,12 +182,26 @@
 
       stopLogEntryTracking();
 
-      List<Capability> reverse = new ArrayList<Capability>(capabilities);
-      Collections.reverse(reverse);
+      // Uninstall the registered bundles
+      Collections.reverse(registeredBundles);
+      while (registeredBundles.size() > 0)
+      {
+         OSGiBundle bundle = registeredBundles.remove(0);
+         try
+         {
+            bundle.uninstall();
+         }
+         catch (BundleException ex)
+         {
+            log.warn("Cannot uninstall: " + bundle, ex);
+         }
+      }
       
-      while (reverse.size() > 0)
+      // Uninstall the capabilities
+      Collections.reverse(capabilities);
+      while (capabilities.size() > 0)
       {
-         Capability capability = reverse.remove(0);
+         Capability capability = capabilities.get(0);
          removeCapability(capability);
       }
 

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java	2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java	2009-06-15 12:10:16 UTC (rev 90194)
@@ -77,8 +77,9 @@
       try
       {
          deploy(location);
-         ManagedBundleMBean bundle = getRemoteFramework().getBundle(symbolicName);
-         return new RemoteBundle(this, bundle, location);
+         ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName);
+         RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
+         return registerBundleForUninstall(bundle);
       }
       catch (RuntimeException rte)
       {




More information about the jboss-osgi-commits mailing list