Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2008-10-08 21:11:20 +0000
committerThomas Watson2008-10-08 21:11:20 +0000
commitee6ccf350b150aa07181ad0c3cd5ad27cbf7dd1b (patch)
treed1036fc2b190eb3a55ec4f58a1e42aff79b5c209
parent71006f19161d78f29ba5350b62736db0cc633198 (diff)
downloadrt.equinox.framework-ee6ccf350b150aa07181ad0c3cd5ad27cbf7dd1b.tar.gz
rt.equinox.framework-ee6ccf350b150aa07181ad0c3cd5ad27cbf7dd1b.tar.xz
rt.equinox.framework-ee6ccf350b150aa07181ad0c3cd5ad27cbf7dd1b.zip
Add a SystemBundle update testcase.
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index 8cbb21a95..4a6ea59f8 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -552,4 +552,68 @@ public class SystemBundleTests extends AbstractBundleTests {
}
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
}
+
+ public void testSystemBundle10() {
+ // create/start/update/stop test
+ File config = OSGiTestsActivator.getContext().getDataFile("testSystemBundle10"); //$NON-NLS-1$
+ Properties configuration = new Properties();
+ configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+ final Equinox equinox = new Equinox(configuration);
+ try {
+ equinox.start();
+ } catch (BundleException e) {
+ fail("Failed to start the framework", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState()); //$NON-NLS-1$
+ final Exception[] failureException = new BundleException[1];
+ final boolean succeed[] = new boolean[] {true};
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ try {
+ // TODO this is a hack; this will be improved with OSGi API updates to return info from waitForStop()
+ long time = System.currentTimeMillis();
+ equinox.waitForStop(10000);
+ time = System.currentTimeMillis() - time;
+ if (time < 10000)
+ succeed[0] = true;
+ } catch (InterruptedException e) {
+ failureException[0] = e;
+ }
+ }
+ }, "test waitForStop thread"); //$NON-NLS-1$
+ t.start();
+ try {
+ equinox.update();
+ } catch (BundleException e) {
+ fail("Failed to update the framework", e); //$NON-NLS-1$
+ }
+ try {
+ t.join();
+ } catch (InterruptedException e) {
+ fail("unexpected interuption", e); //$NON-NLS-1$
+ }
+ if (failureException[0] != null)
+ fail("Error occurred while waiting", failureException[0]); //$NON-NLS-1$
+ assertTrue("Wait for stop failed", succeed[0]); //$NON-NLS-1$
+ // TODO delay hack to allow the framework to get started again
+ for (int i = 0; i < 5 && Bundle.ACTIVE != equinox.getState(); i++)
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // nothing
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState()); //$NON-NLS-1$
+ try {
+ equinox.stop();
+ } catch (BundleException e) {
+ fail("Unexpected erorr stopping framework", e); //$NON-NLS-1$
+ }
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
+ }
+
}

Back to the top