[jboss-cvs] JBossAS SVN: r96940 - projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 25 04:36:37 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-11-25 04:36:36 -0500 (Wed, 25 Nov 2009)
New Revision: 96940
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java
Log:
Use refresh in setUp
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java 2009-11-25 09:24:18 UTC (rev 96939)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java 2009-11-25 09:36:36 UTC (rev 96940)
@@ -24,13 +24,14 @@
//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiPackageAdmin;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTest;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -49,39 +50,48 @@
*/
public class OSGI39TestCase extends OSGiTest
{
+ private OSGiRuntime runtime;
+
+ @Before
+ public void setUp()
+ {
+ runtime = getDefaultRuntime();
+
+ OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
+ packageAdmin.refreshPackages(null);
+ }
+
+ @After
+ public void tearDown()
+ {
+ runtime.shutdown();
+ }
+
@Test
public void testVerifyUnresolved() throws Exception
{
- OSGiRuntime runtime = getDefaultRuntime();
+ OSGiBundle bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+
try
{
- OSGiBundle bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
-
- try
- {
- bundleB.start();
- fail("Unresolved constraint expected");
- }
- catch (BundleException ex)
- {
- // expected
- }
-
- OSGiBundle bundleX = runtime.installBundle("jbosgi39-bundleX.jar");
-
bundleB.start();
-
- assertTrue("Bundle resolved", bundleX.getState() <= Bundle.ACTIVE);
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
-
- bundleB.uninstall();
- bundleX.uninstall();
+ fail("Unresolved constraint expected");
}
- finally
+ catch (BundleException ex)
{
- runtime.shutdown();
+ // expected
}
+
+ OSGiBundle bundleX = runtime.installBundle("jbosgi39-bundleX.jar");
+
+ bundleB.start();
+
+ assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ bundleB.uninstall();
+ bundleX.uninstall();
}
/*
@@ -98,84 +108,68 @@
@Test
public void testWiringToUninstalled() throws Exception
{
- OSGiRuntime runtime = getDefaultRuntime();
- try
- {
- OSGiBundle bundleX = runtime.installBundle("jbosgi39-bundleX.jar");
- OSGiBundle bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
-
- bundleB.start();
-
- assertTrue("Bundle resolved", + Bundle.RESOLVED == bundleX.getState() || Bundle.ACTIVE == bundleX.getState());
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ OSGiBundle bundleX = runtime.installBundle("jbosgi39-bundleX.jar");
+ OSGiBundle bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
- // Uninstall X before B
- bundleX.uninstall();
- bundleB.uninstall();
-
- // Install B without X
- bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
-
- bundleB.start();
-
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ bundleB.start();
- bundleB.uninstall();
- }
- finally
- {
- runtime.shutdown();
- }
+ assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ // Uninstall X before B
+ bundleX.uninstall();
+ bundleB.uninstall();
+
+ // Install B without X
+ bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
+
+ bundleB.start();
+
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ bundleB.uninstall();
}
@Test
public void testWiringToUninstalledPackageAdmin() throws Exception
{
- OSGiRuntime runtime = getDefaultRuntime();
+ OSGiBundle bundleX = runtime.installBundle("jbosgi39-bundleX.jar");
+ OSGiBundle bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
+
+ bundleB.start();
+
+ assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ // Uninstall X before B
+ bundleX.uninstall();
+ bundleB.uninstall();
+
+ // Forces the update (replacement) or removal of packages exported by the specified bundles.
+ OSGiPackageAdmin packAdmin = runtime.getPackageAdmin();
+ packAdmin.refreshPackages(null);
+
+ // Install B without X
+ bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
+
try
{
- OSGiBundle bundleX = runtime.installBundle("jbosgi39-bundleX.jar");
- OSGiBundle bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
-
bundleB.start();
-
- assertTrue("Bundle resolved", + Bundle.RESOLVED == bundleX.getState() || Bundle.ACTIVE == bundleX.getState());
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
-
- // Uninstall X before B
- bundleX.uninstall();
- bundleB.uninstall();
-
- // Forces the update (replacement) or removal of packages exported by the specified bundles.
- OSGiPackageAdmin packAdmin = runtime.getPackageAdmin();
- packAdmin.refreshPackages(null);
-
- // Install B without X
- bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
-
- try
- {
- bundleB.start();
- fail("Unresolved constraint expected");
- }
- catch (BundleException ex)
- {
- // expected
- }
-
- bundleX = runtime.installBundle("jbosgi39-bundleX.jar");
-
- bundleB.start();
-
- assertTrue("Bundle resolved", + Bundle.RESOLVED == bundleX.getState() || Bundle.ACTIVE == bundleX.getState());
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
-
- bundleB.uninstall();
- bundleX.uninstall();
+ fail("Unresolved constraint expected");
}
- finally
+ catch (BundleException ex)
{
- runtime.shutdown();
+ // expected
}
+
+ bundleX = runtime.installBundle("jbosgi39-bundleX.jar");
+
+ bundleB.start();
+
+ assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ bundleB.uninstall();
+ bundleX.uninstall();
}
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list