diff options
author | John Ross | 2013-08-09 19:09:17 +0000 |
---|---|---|
committer | John Ross | 2013-08-09 19:20:53 +0000 |
commit | 59a3c895df828b25e603da6d9e2fd829ba43f022 (patch) | |
tree | d9519ed2a259935a0c9181129b93f78009121b9a /bundles | |
parent | 8fa52ddecb8c65656c80f46bce440af66f11767d (diff) | |
download | rt.equinox.framework-59a3c895df828b25e603da6d9e2fd829ba43f022.tar.gz rt.equinox.framework-59a3c895df828b25e603da6d9e2fd829ba43f022.tar.xz rt.equinox.framework-59a3c895df828b25e603da6d9e2fd829ba43f022.zip |
Bug 413723 - testPeriodicPersistence is failing regularly on linux
Provide a buffer, if needed, after the first period elapses to ensure the first equinox instance has time to persist the
bundle.
Diffstat (limited to 'bundles')
-rwxr-xr-x[-rw-r--r--] | bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PersistedBundleTests.java | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PersistedBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PersistedBundleTests.java index 7b033125e..887b2ed7d 100644..100755 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PersistedBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PersistedBundleTests.java @@ -18,8 +18,7 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.osgi.launch.Equinox; import org.eclipse.osgi.tests.OSGiTestsActivator; -import org.osgi.framework.BundleException; -import org.osgi.framework.Constants; +import org.osgi.framework.*; /* * The framework must persist data according to the value of the @@ -142,22 +141,45 @@ public class PersistedBundleTests extends AbstractBundleTests { * periodic persistence. */ public void testPeriodicPersistence() throws Exception { + // Specify periodic persistence in the configuration. Map<String, Object> configuration = createConfiguration(); configuration.put(ECLIPSE_STATESAVEDELAYINTERVAL, PERIODIC_PERSISTENCE); + // Create an equinox instance that will be responsible for persisting + // the bundle once the first period elapses. Equinox equinox1 = new Equinox(configuration); initAndStart(equinox1); try { + // The bundle has not yet been installed. assertNull("Bundle exists", equinox1.getBundleContext().getBundle(getName())); + // Install the bundle. equinox1.getBundleContext().installBundle(getName(), new BundleBuilder().symbolicName(getName()).build()); + // Create a second equinox instance to ensure the first instance + // has not yet persisted the bundle. Equinox equinox2 = new Equinox(configuration); initAndStart(equinox2); try { + // The bundle should not have been persisted and therefore be + // unknown to the second equinox instance. This check must + // happen before the first period elapses. assertNull("Bundle exists", equinox2.getBundleContext().getBundle(getName())); stopQuietly(equinox2); + // Ensure the first period elapses so the bundle has time to be + // persisted. Thread.sleep(Long.valueOf(PERIODIC_PERSISTENCE)); - equinox2 = new Equinox(configuration); - initAndStart(equinox2); - assertNotNull("Bundle does not exist", equinox2.getBundleContext().getBundle(getName())); + Bundle b = null; + // Provide a buffer, if needed, after the first period elapses + // to ensure the first instance has time to persist the bundle. + for (int i = 0; i < 5; i++) { + equinox2 = new Equinox(configuration); + initAndStart(equinox2); + b = equinox2.getBundleContext().getBundle(getName()); + if (b != null) + break; + Thread.sleep(1000); + } + // The persisted bundle should now be visible to the second + // equinox instance. + assertNotNull("Bundle does not exist", b); } finally { stopQuietly(equinox2); } |