Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java38
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java77
2 files changed, 43 insertions, 72 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
index ab849d154..75b74e304 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
@@ -308,6 +308,44 @@ public class AbstractBundleTests extends CoreTest {
return stop(equinox, true, 10000);
}
+ static public FrameworkEvent update(final Framework equinox) {
+ final Exception[] failureException = new BundleException[1];
+ final FrameworkEvent[] success = new FrameworkEvent[] { null };
+ final String uuid = getUUID(equinox);
+ Thread waitForUpdate = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ success[0] = waitForStop(equinox, uuid, false, 10000);
+ }
+ }, "test waitForStop thread"); //$NON-NLS-1$
+ waitForUpdate.start();
+
+ try {
+ // delay hack to allow waitForUpdate thread to block on waitForStop before we
+ // update.
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ fail("unexpected interuption", e);
+ }
+
+ try {
+ equinox.update();
+ } catch (BundleException e) {
+ fail("Failed to update the framework", e); //$NON-NLS-1$
+ }
+ try {
+ waitForUpdate.join();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ fail("unexpected interuption", e); //$NON-NLS-1$
+ }
+ if (failureException[0] != null) {
+ fail("Error occurred while waiting", failureException[0]); //$NON-NLS-1$
+ }
+ return success[0];
+ }
+
static public FrameworkEvent stop(Framework equinox, boolean quietly, long timeout) {
if (equinox == null)
return null;
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 83b9f3429..b67f9f69a 100755
--- 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
@@ -549,39 +549,9 @@ public class SystemBundleTests extends AbstractBundleTests {
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 FrameworkEvent[] success = new FrameworkEvent[] {null};
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- success[0] = equinox.waitForStop(10000);
- } catch (InterruptedException e) {
- failureException[0] = e;
- }
- }
- }, "test waitForStop thread"); //$NON-NLS-1$
- t.start();
- try {
- // delay hack to allow t thread to block on waitForStop before we update.
- Thread.sleep(500);
- } catch (InterruptedException e) {
- fail("unexpected interuption", e);
- }
- 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$
- assertNotNull("Wait for stop event is null", success[0]); //$NON-NLS-1$
- assertEquals("Wait for stop event type is wrong", FrameworkEvent.STOPPED_UPDATE, success[0].getType()); //$NON-NLS-1$
+
+ FrameworkEvent success = update(equinox);
+ assertEquals("Wait for stop event type is wrong", FrameworkEvent.STOPPED_UPDATE, success.getType()); //$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 {
@@ -939,37 +909,7 @@ public class SystemBundleTests extends AbstractBundleTests {
openAllBundleFiles(equinox.getBundleContext());
- final Exception[] failureException = new BundleException[1];
- final FrameworkEvent[] success = new FrameworkEvent[] {null};
- Thread waitForUpdate = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- success[0] = equinox.waitForStop(10000);
- } catch (InterruptedException e) {
- failureException[0] = e;
- }
- }
- }, "test waitForStop thread"); //$NON-NLS-1$
- waitForUpdate.start();
- try {
- // delay hack to allow waitForUpdate thread to block on waitForStop before we update.
- Thread.sleep(100);
- } catch (InterruptedException e) {
- fail("unexpected interuption", e);
- }
- try {
- equinox.update();
- } catch (BundleException e) {
- fail("Failed to update the framework", e); //$NON-NLS-1$
- }
- try {
- waitForUpdate.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$
+ update(equinox);
// we can either have a hack here that waits until the system bundle is active
// or we can just try to start it and race with the update() call above
@@ -1623,14 +1563,7 @@ public class SystemBundleTests extends AbstractBundleTests {
equinox.start();
assertEquals("Unexpected state", Bundle.ACTIVE, testTCCL.getState()); //$NON-NLS-1$
- String uuid = getUUID(equinox);
- // test that the correct tccl is used for framework update
- try {
- equinox.update();
- } catch (Exception e) {
- fail("Unexpected exception", e); //$NON-NLS-1$
- }
- waitForStop(equinox, uuid, false, 10000);
+ update(equinox);
checkActive(testTCCL);

Back to the top