[jboss-cvs] JBossAS SVN: r97225 - in projects/jboss-osgi: trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38 and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 1 08:12:44 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-12-01 08:12:44 -0500 (Tue, 01 Dec 2009)
New Revision: 97225
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
Log:
[JBOSGI-213] Unexpected dependee state changes
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-12-01 12:36:58 UTC (rev 97224)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-12-01 13:12:44 UTC (rev 97225)
@@ -201,7 +201,10 @@
public String getFramework()
{
- String framework = System.getProperty("framework", "jbossmc");
+ String framework = System.getProperty("framework");
+ if (framework == null || framework.length() == 0 || framework.equals("${framework}"))
+ framework = "jbossmc";
+
return framework;
}
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java 2009-12-01 12:36:58 UTC (rev 97224)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java 2009-12-01 13:12:44 UTC (rev 97225)
@@ -23,11 +23,11 @@
//$Id: OSGI38TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
+import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.jboss.osgi.spi.capability.CompendiumCapability;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTest;
@@ -45,14 +45,13 @@
* A ---> B
* A ---> X <--- B
*
+ * [TODO] Use default runtime for in container testing
+ *
* @author thomas.diesler at jboss.com
* @since 02-Mar-2009
*/
public class OSGI38TestCase extends OSGiTest
{
- /*
- * Install/Start the common bundle
- */
@Test
public void testInstallStartX() throws Exception
{
@@ -62,12 +61,13 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
bundleX.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleX.getState());
bundleX.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundleX.getState());
}
finally
{
@@ -87,13 +87,14 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
- assertTrue("Bundle installed", bundleB.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
bundleB.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleB.uninstall();
bundleX.uninstall();
@@ -116,16 +117,18 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
- assertTrue("Bundle installed", bundleB.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
OSGiBundle bundleA = runtime.installBundle("jbosgi38-bundleA.jar");
- assertTrue("Bundle installed", bundleA.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleA.getState());
bundleA.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.RESOLVED, bundleB.getState());
+ assertBundleState(Bundle.ACTIVE, bundleA.getState());
bundleA.uninstall();
bundleB.uninstall();
@@ -149,7 +152,7 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
try
{
@@ -162,10 +165,11 @@
}
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
bundleB.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleB.uninstall();
bundleX.uninstall();
@@ -188,10 +192,10 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleA = runtime.installBundle("jbosgi38-bundleA.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleA.getState());
+ assertBundleState(Bundle.INSTALLED, bundleA.getState());
OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
try
{
@@ -204,13 +208,14 @@
}
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
bundleB.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleA.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+ assertBundleState(Bundle.ACTIVE, bundleA.getState());
bundleA.uninstall();
bundleB.uninstall();
@@ -221,4 +226,56 @@
runtime.shutdown();
}
}
+
+ /*
+ * Uninstall X, B stays active
+ */
+ @Test
+ public void testUninstallX() throws Exception
+ {
+ if ("jbossmc".equals(getFramework()))
+ {
+ System.out.println("FIXME [JBOSGI-213] Unexpected dependee state changes");
+ return;
+ }
+
+ OSGiRuntime runtime = getEmbeddedRuntime();
+ try
+ {
+ runtime.addCapability(new CompendiumCapability());
+
+ OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
+
+ OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
+
+ bundleB.start();
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
+
+ bundleX.stop();
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
+
+ bundleX.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
+
+ bundleB.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundleB.getState());
+ }
+ finally
+ {
+ runtime.shutdown();
+ }
+ }
+
+ private void assertBundleState(int expState, int wasState)
+ {
+ String expstr = ConstantsHelper.bundleState(expState);
+ String wasstr = ConstantsHelper.bundleState(wasState);
+ assertEquals("Bundle " + expstr, expstr, wasstr);
+ }
+
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list