Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-07-06 11:44:08 -0400
committerThomas Watson2016-07-06 15:21:41 -0400
commit2ec8c52c2cf5c575e69533a479f32257566d4236 (patch)
tree19b573aa6228cebac1ae37fb5459667edef89ada
parentadda20fca8b82495927ba45d158b53e22a5ca7f8 (diff)
downloadrt.equinox.framework-2ec8c52c2cf5c575e69533a479f32257566d4236.tar.gz
rt.equinox.framework-2ec8c52c2cf5c575e69533a479f32257566d4236.tar.xz
rt.equinox.framework-2ec8c52c2cf5c575e69533a479f32257566d4236.zip
Bug 497407 - Handle @initial locations for bundle update operationsY20160707-1000
Change-Id: I396cf341934c0de5f0b589ba691a913f0745766a Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java61
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java9
2 files changed, 69 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 8ea31cdb7..983fabf9e 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
@@ -27,6 +27,7 @@ import org.eclipse.osgi.internal.location.EquinoxLocations;
import org.eclipse.osgi.launch.Equinox;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
+import org.eclipse.osgi.storage.url.reference.Handler;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.junit.Assert;
import org.osgi.framework.*;
@@ -2826,4 +2827,64 @@ public class SystemBundleTests extends AbstractBundleTests {
equinox.waitForStop(5000);
}
}
+
+ public void testInitialBundleUpdate() throws IOException {
+ // test installing bundle with empty manifest
+ File config = OSGiTestsActivator.getContext().getDataFile(getName());
+ Map<String, Object> configuration = new HashMap<String, Object>();
+ configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+
+ Equinox equinox = new Equinox(configuration);
+ try {
+ equinox.init();
+ } catch (BundleException e) {
+ fail("Unexpected exception in init()", e); //$NON-NLS-1$
+ }
+ // should be in the STARTING state
+ assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
+ BundleContext systemContext = equinox.getBundleContext();
+ assertNotNull("System context is null", systemContext); //$NON-NLS-1$
+ 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$
+
+ File bundleFile = null;
+ try {
+ File baseDir = new File(config, "bundles");
+ baseDir.mkdirs();
+ bundleFile = createBundle(baseDir, getName(), true, true);
+ } catch (IOException e) {
+ fail("Unexpected error creating bundles.", e);
+ }
+ Bundle testBundle = null;
+ try {
+ String location = "reference:file:///" + bundleFile.getAbsolutePath();
+ URL url = new URL(null, location, new Handler(systemContext.getProperty(EquinoxLocations.PROP_INSTALL_AREA)));
+ testBundle = systemContext.installBundle("initial@" + location, url.openStream()); //$NON-NLS-1$
+ } catch (BundleException e) {
+ fail("Unexpected install error", e); //$NON-NLS-1$
+ }
+
+ try {
+ testBundle.update();
+ } catch (BundleException e) {
+ fail("Unexpected update error", e); //$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$
+ }
+
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
index 2170875bd..eb554cddc 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
@@ -62,6 +62,7 @@ public class Storage {
private static final String JAVASE = "JavaSE"; //$NON-NLS-1$
private static final String PROFILE_EXT = ".profile"; //$NON-NLS-1$
private static final String NUL = new String(new byte[] {0});
+ private static final String INITIAL_LOCATION = "initial@"; //$NON-NLS-1$
static final SecureAction secureAction = AccessController.doPrivileged(SecureAction.createSecureAction());
@@ -448,7 +449,13 @@ public class Storage {
ModuleRevision current = module.getCurrentRevision();
Generation generation = (Generation) current.getRevisionInfo();
String updateLocation = generation.getHeaders().get(Constants.BUNDLE_UPDATELOCATION);
- return updateLocation == null ? module.getLocation() : updateLocation;
+ if (updateLocation == null) {
+ updateLocation = module.getLocation();
+ }
+ if (updateLocation.startsWith(INITIAL_LOCATION)) {
+ updateLocation = updateLocation.substring(INITIAL_LOCATION.length());
+ }
+ return updateLocation;
}
private URLConnection getContentConnection(final String spec) throws IOException {

Back to the top