diff options
author | Thomas Watson | 2016-04-15 18:40:15 +0000 |
---|---|---|
committer | Thomas Watson | 2016-06-15 12:49:17 +0000 |
commit | 3841a41167128ab80ffe8f05bf793694f5c28400 (patch) | |
tree | 8ba64a488b56874cf8326ffb8413355faeb4ddda /bundles/org.eclipse.osgi.tests/src | |
parent | 5db036701b1df4e04b7897d4f00a627fd5b3bb05 (diff) | |
download | rt.equinox.framework-3841a41167128ab80ffe8f05bf793694f5c28400.tar.gz rt.equinox.framework-3841a41167128ab80ffe8f05bf793694f5c28400.tar.xz rt.equinox.framework-3841a41167128ab80ffe8f05bf793694f5c28400.zip |
Bug 449765 - Framework should provide a persistent UUID
Change-Id: Ic26c63aa5fbec649786070447c737bd81cf5521d
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/src')
-rw-r--r--[-rwxr-xr-x] | bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java | 64 |
1 files changed, 63 insertions, 1 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 c1127c9a7..9ad06a4e0 100755..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 @@ -22,6 +22,7 @@ import javax.net.SocketFactory; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.adaptor.EclipseStarter; +import org.eclipse.osgi.container.namespaces.EquinoxPersistentUUIDNamespace; import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.eclipse.osgi.internal.location.EquinoxLocations; import org.eclipse.osgi.launch.Equinox; @@ -1331,7 +1332,7 @@ public class SystemBundleTests extends AbstractBundleTests { System.getProperties().remove("test.url"); } - public void testUUID() { + public void testOSGiUUID() { File config1 = OSGiTestsActivator.getContext().getDataFile(getName() + "_1"); //$NON-NLS-1$ Map configuration1 = new HashMap(); configuration1.put(Constants.FRAMEWORK_STORAGE, config1.getAbsolutePath()); @@ -1391,6 +1392,66 @@ public class SystemBundleTests extends AbstractBundleTests { } } + public void testPersistentUUID() { + File config1 = OSGiTestsActivator.getContext().getDataFile(getName() + "_1"); //$NON-NLS-1$ + Map configuration1 = new HashMap(); + configuration1.put(Constants.FRAMEWORK_STORAGE, config1.getAbsolutePath()); + Equinox equinox1 = new Equinox(configuration1); + try { + equinox1.init(); + } catch (BundleException e) { + fail("Failed init", e); + } + String uuid1_1 = equinox1.getBundleContext().getProperty(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE); + verifyUUID(uuid1_1); + + File config2 = OSGiTestsActivator.getContext().getDataFile(getName() + "_2"); //$NON-NLS-1$ + Map configuration2 = new HashMap(); + configuration2.put(Constants.FRAMEWORK_STORAGE, config2.getAbsolutePath()); + Equinox equinox2 = new Equinox(configuration1); + try { + equinox2.init(); + } catch (BundleException e) { + fail("Failed init", e); + } + String uuid2_1 = equinox2.getBundleContext().getProperty(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE); + verifyUUID(uuid2_1); + + assertFalse("UUIDs are the same: " + uuid1_1, uuid1_1.equals(uuid2_1)); + + try { + equinox1.stop(); + equinox2.stop(); + equinox1.waitForStop(1000); + equinox2.waitForStop(1000); + equinox1.init(); + equinox2.init(); + } catch (BundleException e) { + fail("Failed to re-init frameworks.", e); + } catch (InterruptedException e) { + fail("Failed to stop frameworks.", e); + } + + String uuid1_2 = equinox1.getBundleContext().getProperty(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE); + verifyUUID(uuid1_2); + String uuid2_2 = equinox2.getBundleContext().getProperty(EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE); + verifyUUID(uuid2_2); + assertEquals("UUIDs are not the same: ", uuid1_1, uuid1_2); + assertFalse("UUIDs are the same: " + uuid1_2, uuid1_2.equals(uuid2_2)); + assertEquals("UUIDs are not the same: ", uuid2_1, uuid2_2); + + try { + equinox1.stop(); + equinox2.stop(); + equinox1.waitForStop(1000); + equinox2.waitForStop(1000); + } catch (BundleException e) { + fail("Failed to re-init frameworks.", e); + } catch (InterruptedException e) { + fail("Failed to stop frameworks.", e); + } + } + private void verifyUUID(String uuid) { assertNotNull("Null uuid.", uuid); StringTokenizer st = new StringTokenizer(uuid, "-"); @@ -2270,6 +2331,7 @@ public class SystemBundleTests extends AbstractBundleTests { EquinoxConfiguration.PROP_OSGI_NL, // EquinoxConfiguration.PROP_STATE_SAVE_DELAY_INTERVAL, // EquinoxConfiguration.PROP_INIT_UUID, // + EquinoxPersistentUUIDNamespace.PERSISTENT_UUID_NAMESPACE, // "gosh.args", // EquinoxLocations.PROP_HOME_LOCATION_AREA, // EquinoxLocations.PROP_CONFIG_AREA, // |