felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r954594 - /felix/sandbox/rickhall/vb-bnd-test/org.apache.felix.framework.vb/src/org/apache/felix/framework/vb/TestVirtualBundle.java
Date Mon, 14 Jun 2010 19:15:51 GMT
Author: rickhall
Date: Mon Jun 14 19:15:51 2010
New Revision: 954594

URL: http://svn.apache.org/viewvc?rev=954594&view=rev
Log:
Add another uninstalled handler variation.

Modified:
    felix/sandbox/rickhall/vb-bnd-test/org.apache.felix.framework.vb/src/org/apache/felix/framework/vb/TestVirtualBundle.java

Modified: felix/sandbox/rickhall/vb-bnd-test/org.apache.felix.framework.vb/src/org/apache/felix/framework/vb/TestVirtualBundle.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb-bnd-test/org.apache.felix.framework.vb/src/org/apache/felix/framework/vb/TestVirtualBundle.java?rev=954594&r1=954593&r2=954594&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb-bnd-test/org.apache.felix.framework.vb/src/org/apache/felix/framework/vb/TestVirtualBundle.java
(original)
+++ felix/sandbox/rickhall/vb-bnd-test/org.apache.felix.framework.vb/src/org/apache/felix/framework/vb/TestVirtualBundle.java
Mon Jun 14 19:15:51 2010
@@ -84,7 +84,7 @@ public class TestVirtualBundle extends F
         }
     }
 
-    public void testVirtualBundleRestart001() throws Exception
+    public void testVirtualBundleRestart() throws Exception
     {
         InputStream is = null;
 
@@ -141,7 +141,7 @@ public class TestVirtualBundle extends F
         }
     }
 
-    public void testVirtualBundleRestart002() throws Exception
+    public void testManagerUninstall001() throws Exception
     {
         InputStream is = null;
 
@@ -166,11 +166,10 @@ public class TestVirtualBundle extends F
             // Uninstall manager.
             m_bundleA.uninstall();
             assertEquals(
-                "Handler should be UNINSTALLED", Bundle.UNINSTALLED, m_bundleA.getState());
+                "Manager should be UNINSTALLED", Bundle.UNINSTALLED, m_bundleA.getState());
 
             // Refresh the manager.
-            PackageAdmin pa = getPackageAdmin();
-            pa.refreshPackages(null);
+            refreshAndWait();
             m_bundleA = getBundle("org.apache.felix.framework.vb.b001");
             assertNull("Manager shouldn't be installed", m_bundleA);
 
@@ -191,7 +190,96 @@ public class TestVirtualBundle extends F
             assertEquals(
                 "Virtual bundle shouldn't resolve", Bundle.INSTALLED, m_bundleB.getState());
 
-            // Install and start client bundle.
+            // Install and start client bundle, which should fail.
+            is = this.getClass().getClassLoader().getResourceAsStream("vb.b003.jar");
+            m_bundleC = getBundleContext().installBundle("vb.b003.jar", is);
+            try
+            {
+                m_bundleC.start();
+            }
+            catch (BundleException ex)
+            {
+                // Expected
+            }
+            assertEquals(
+                "Client bundle shouldn't resolve", Bundle.INSTALLED, m_bundleC.getState());
+        }
+        finally
+        {
+            cleanup();
+        }
+    }
+
+    public void testManagerUninstall002() throws Exception
+    {
+        InputStream is = null;
+
+        try
+        {
+            // Install and start manager bundle, which will install a virtual bundle.
+            is = this.getClass().getClassLoader().getResourceAsStream("vb.b001.jar");
+            m_bundleA = getBundleContext().installBundle("vb.b001.jar", is);
+
+            int before = getBundleContext().getBundles().length;
+            try
+            {
+                m_bundleA.start();
+            }
+            catch (BundleException ex)
+            {
+                assertTrue("Manager should start", false);
+            }
+            assertEquals("A virtual bundle should have been installed.",
+                before + 1, getBundleContext().getBundles().length);
+
+            // Get the virtual bundle.
+            m_bundleB = getBundle("org.apache.felix.framework.vb.b002");
+            assertEquals(
+                "Virtual bundle should be INSTALLED", Bundle.INSTALLED, m_bundleB.getState());
+
+            // Resolve the virtual bundle.
+            PackageAdmin pa = getPackageAdmin();
+            pa.resolveBundles(new Bundle[] { m_bundleB });
+            assertEquals("Virtual bundle should be RESOLVED", Bundle.RESOLVED, m_bundleB.getState());
+
+            // Start the virtual bundle.
+            try
+            {
+                m_bundleB.start();
+                assertEquals("Virtual bundle should be ACTIVE", Bundle.ACTIVE, m_bundleB.getState());
+            }
+            catch (BundleException ex)
+            {
+                assertTrue("Virtual bundle should start: " + ex, false);
+            }
+
+            // Uninstall manager.
+            m_bundleA.uninstall();
+            assertEquals(
+                "Manager should be UNINSTALLED", Bundle.UNINSTALLED, m_bundleA.getState());
+
+            // Refresh the manager.
+            refreshAndWait();
+            m_bundleA = getBundle("org.apache.felix.framework.vb.b001");
+            assertNull("Manager shouldn't be installed", m_bundleA);
+
+            // Virtual bundle should be refreshed too.
+            assertEquals(
+                "Virtual bundle should be INSTALLED", Bundle.INSTALLED, m_bundleB.getState());
+
+            // Start the virtual bundle, which should fail.
+            try
+            {
+                m_bundleB.start();
+            }
+            catch (BundleException ex)
+            {
+                // Expected
+            }
+            assertEquals(
+                "Virtual bundle shouldn't resolve", Bundle.INSTALLED, m_bundleB.getState());
+
+            // Install and start client bundle, which should fail.
             is = this.getClass().getClassLoader().getResourceAsStream("vb.b003.jar");
             m_bundleC = getBundleContext().installBundle("vb.b003.jar", is);
             try



Mime
View raw message