Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2009-07-24 19:07:16 +0000
committerAndrew Niefer2009-07-24 19:07:16 +0000
commit98d9cda0076571aac97aa9011f4356deeed7b261 (patch)
tree8fed99cc1763e2c1a18ccffbc242faebb7d2c4e1
parentde14ca2e0682df7e604712530ac4d71dd0ba132d (diff)
downloadrt.equinox.p2-98d9cda0076571aac97aa9011f4356deeed7b261.tar.gz
rt.equinox.p2-98d9cda0076571aac97aa9011f4356deeed7b261.tar.xz
rt.equinox.p2-98d9cda0076571aac97aa9011f4356deeed7b261.zip
bug 284303 - launcher.ini arguments lost
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java5
3 files changed, 57 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index 7285ee7b9..b39e046bb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -584,6 +584,18 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
}
+ public static void writeBuffer(File outputFile, StringBuffer buffer) throws IOException {
+ FileOutputStream stream = null;
+ try {
+ outputFile.getParentFile().mkdirs();
+ stream = new FileOutputStream(outputFile);
+ stream.write(buffer.toString().getBytes());
+ } finally {
+ if (stream != null)
+ stream.close();
+ }
+ }
+
private static void write(IStatus status, int indent, PrintStream output) {
indent(output, indent);
output.println("Severity: " + status.getSeverity());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java
index 7765c2472..e441465cb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java
@@ -13,6 +13,7 @@ import java.util.*;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.SetLauncherNameAction;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand;
@@ -80,4 +81,44 @@ public class SetLauncherNameActionTest extends AbstractProvisioningTest {
action.execute(parameters);
}
+ public void testChangeName() throws Exception {
+ File tempFolder = getTempFolder();
+
+ Properties profileProperties = new Properties();
+ profileProperties.put(IProfile.PROP_INSTALL_FOLDER, tempFolder.toString());
+ profileProperties.put(IProfile.PROP_ENVIRONMENTS, "osgi.ws=win32,osgi.os=win32,osgi.arch=x86");
+ IProfile profile = createProfile("changeNameProfile", null, profileProperties);
+
+ //profile will start using "eclipse" by default, give it some content and see if it
+ //survives a name change.
+ File eclipseIni = new File(tempFolder, "eclipse.ini");
+ StringBuffer ini = new StringBuffer();
+ ini.append("-startup\n");
+ ini.append("plugins/org.eclipse.equinox.launcher_1.2.4.v1234.jar\n");
+ writeBuffer(eclipseIni, ini);
+
+ Map parameters = new HashMap();
+ InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test"));
+ EclipseTouchpoint touchpoint = new EclipseTouchpoint();
+ touchpoint.initializePhase(null, profile, "test", parameters);
+ parameters.put(ActionConstants.PARM_PROFILE, profile);
+ parameters.put("iu", operand.second());
+ touchpoint.initializeOperand(profile, operand, parameters);
+
+ parameters.put(ActionConstants.PARM_LAUNCHERNAME, "foo");
+ parameters = Collections.unmodifiableMap(parameters);
+
+ SetLauncherNameAction action = new SetLauncherNameAction();
+ action.execute(parameters);
+
+ Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
+ File bundle = new File(tempFolder, "plugins/aBundle_1.0.0.jar");
+ bundle.getParentFile().mkdirs();
+ copy("1.0", getTestData("1.1", "/testData/testRepos/simple.1/plugins/aBundle_1.0.0.jar"), bundle);
+ manipulator.getConfigData().addBundle(new BundleInfo(bundle.toURI()));
+ manipulator.save(false);
+
+ assertLogContainsLines(new File(tempFolder, "foo.ini"), new String[] {"-startup", "plugins/org.eclipse.equinox.launcher_1.2.4.v1234.jar"});
+ assertFalse(eclipseIni.exists());
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java
index 1584cd1ad..040c44de8 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java
@@ -14,6 +14,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.engine.Profile;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
@@ -38,7 +39,9 @@ public class SetLauncherNameAction extends ProvisioningAction {
}
private static void setLauncher(Manipulator manipulator, Profile profile, String launcherName) {
+ //Get the launcherData before changing the name so we don't lose anything from the old launcher.ini
+ LauncherData launcherData = manipulator.getLauncherData();
profile.setProperty(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME, launcherName);
- manipulator.getLauncherData().setLauncher(Util.getLauncherPath(profile));
+ launcherData.setLauncher(Util.getLauncherPath(profile));
}
} \ No newline at end of file

Back to the top