Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-06-20 20:36:23 +0000
committerThomas Watson2011-06-20 20:36:23 +0000
commit3f021f7cf9ea0aa3fcdc2c7055b657bf72523762 (patch)
treee07fad7a04b2565bbfb8e6917848698c736e2640 /bundles/org.eclipse.osgi.tests
parent54cf0305c869f3b94b63643b5e460319cf06d5c2 (diff)
downloadrt.equinox.framework-3f021f7cf9ea0aa3fcdc2c7055b657bf72523762.tar.gz
rt.equinox.framework-3f021f7cf9ea0aa3fcdc2c7055b657bf72523762.tar.xz
rt.equinox.framework-3f021f7cf9ea0aa3fcdc2c7055b657bf72523762.zip
Bug 349309 - Clean up code for initializing MRUBundleFileListv20110620
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java75
1 files changed, 60 insertions, 15 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 e618b5512..06fcfb686 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
@@ -919,14 +919,22 @@ public class SystemBundleTests extends AbstractBundleTests {
assertEquals("Wrong stopEvent", FrameworkEvent.STOPPED, stopEvent.getType()); //$NON-NLS-1$
}
- public void testBug253942() {
+ public void testMRUBundleFileList() {
+ doMRUBundleFileList(10);
+ }
+
+ // public void testMRUBundleFileListExpectedToFail() {
+ // doMRUBundleFileList(0);
+ // }
+
+ private void doMRUBundleFileList(int limit) {
// create/start/stop/start/stop test
- File config = OSGiTestsActivator.getContext().getDataFile("testBug253942"); //$NON-NLS-1$
+ File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$
Properties configuration = new Properties();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
- configuration.put("osgi.bundlefile.limit", "10"); //$NON-NLS-1$//$NON-NLS-2$
+ configuration.put("osgi.bundlefile.limit", Integer.toString(limit)); //$NON-NLS-1$//$NON-NLS-2$
- Equinox equinox = new Equinox(configuration);
+ final Equinox equinox = new Equinox(configuration);
try {
equinox.init();
} catch (BundleException e) {
@@ -945,7 +953,7 @@ public class SystemBundleTests extends AbstractBundleTests {
File[] testBundles = null;
try {
- testBundles = createBundles(new File(config, "bundles"), 20); //$NON-NLS-1$
+ testBundles = createBundles(new File(config, "bundles"), 3000); //$NON-NLS-1$
} catch (IOException e) {
fail("Unexpected error creating budnles", e); //$NON-NLS-1$
}
@@ -973,18 +981,41 @@ public class SystemBundleTests extends AbstractBundleTests {
} catch (BundleException e) {
fail("Failed to start the framework", e); //$NON-NLS-1$
}
- systemContext = equinox.getBundleContext();
- Bundle[] bundles = systemContext.getBundles();
- // get an entry from each bundle to ensure each one gets opened.
- try {
- for (int i = 0; i < bundles.length; i++) {
- bundles[i].getEntry("/META-INF/MANIFEST.MF"); //$NON-NLS-1$
+
+ openAllBundleFiles(equinox.getBundleContext());
+
+ final Exception[] failureException = new BundleException[1];
+ final FrameworkEvent[] success = new FrameworkEvent[] {null};
+ Thread waitForUpdate = new Thread(new Runnable() {
+ public void run() {
+ try {
+ success[0] = equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ failureException[0] = e;
+ }
}
- } catch (Throwable t) {
- // An exception used to get thrown here when we tried to close
- // the least used bundle file
- fail("Failed to get bundle entries", t);
+ }, "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$
+
+ openAllBundleFiles(equinox.getBundleContext());
try {
equinox.stop();
@@ -999,6 +1030,20 @@ public class SystemBundleTests extends AbstractBundleTests {
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
}
+ private void openAllBundleFiles(BundleContext context) {
+ Bundle[] bundles = context.getBundles();
+ // get an entry from each bundle to ensure each one gets opened.
+ try {
+ for (int i = 0; i < bundles.length; i++) {
+ assertNotNull("No manifest for: " + bundles[i], bundles[i].getEntry("/META-INF/MANIFEST.MF"));
+ }
+ } catch (Throwable t) {
+ // An exception used to get thrown here when we tried to close
+ // the least used bundle file
+ fail("Failed to get bundle entries", t);
+ }
+ }
+
public void testURLExternalFormat01() {
// create multiple instances test
File config1 = OSGiTestsActivator.getContext().getDataFile("testURLExternalFormat01_1"); //$NON-NLS-1$

Back to the top