diff options
author | Simon Kaegi | 2008-10-31 21:06:34 +0000 |
---|---|---|
committer | Simon Kaegi | 2008-10-31 21:06:34 +0000 |
commit | dda657e84879df85aa4ccfb069c12d4c995c9d52 (patch) | |
tree | 5f02ce3d9bc592ad9a6caca0f8863a7ef457e16c /bundles/org.eclipse.equinox.p2.touchpoint.eclipse | |
parent | 3418bc38985420692dbab116e717b37ad5cdee17 (diff) | |
download | rt.equinox.p2-dda657e84879df85aa4ccfb069c12d4c995c9d52.tar.gz rt.equinox.p2-dda657e84879df85aa4ccfb069c12d4c995c9d52.tar.xz rt.equinox.p2-dda657e84879df85aa4ccfb069c12d4c995c9d52.zip |
Adding Eclipse Touchpoint + Action Tests:
Part1 - Mainly property action related tests and a few slight refactoring / cleanups
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse')
5 files changed, 14 insertions, 48 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java index 0e3c28d86..d9de01044 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java @@ -18,20 +18,17 @@ import java.util.WeakHashMap; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdminRuntimeException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.util.NLS; -import org.osgi.framework.Version; public class EclipseTouchpoint extends Touchpoint { - private static final TouchpointType TOUCHPOINT_TYPE = MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.osgi", new Version("1.0")); //$NON-NLS-1$ //$NON-NLS-2$ - // TODO: phase id constants should be defined elsewhere. public static final String INSTALL_PHASE_ID = "install"; //$NON-NLS-1$ public static final String UNINSTALL_PHASE_ID = "uninstall"; //$NON-NLS-1$ @@ -96,11 +93,6 @@ public class EclipseTouchpoint extends Touchpoint { return Activator.ID + "." + actionId; //$NON-NLS-1$ } - public TouchpointType getTouchpointType() { - //TODO this data probably needs to come from the XML - return TOUCHPOINT_TYPE; - } - public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map touchpointParameters) { touchpointParameters.put(PARM_INSTALL_FOLDER, Util.getInstallFolder(profile)); LazyManipulator manipulator = getManipulator(profile); @@ -160,17 +152,4 @@ public class EclipseTouchpoint extends Touchpoint { BundleDescription bundleDescription = BundlesAction.createBundleDescription(bundleFile); return PublisherHelper.createBundleIU(bundleDescription, (Map) bundleDescription.getUserObject(), bundleFile.isDirectory(), artifactKey); } - - public static IStatus loadManipulator(Manipulator manipulator) { - try { - manipulator.load(); - } catch (IllegalStateException e) { - return Util.createError(Messages.error_loading_manipulator); - } catch (FrameworkAdminRuntimeException e) { - return Util.createError(Messages.error_loading_manipulator); - } catch (IOException e) { - return Util.createError(Messages.error_loading_manipulator); - } - return Status.OK_STATUS; - } } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetFrameworkDependentPropertyAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetFrameworkDependentPropertyAction.java index b2d980f60..904650740 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetFrameworkDependentPropertyAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetFrameworkDependentPropertyAction.java @@ -26,8 +26,6 @@ public class SetFrameworkDependentPropertyAction extends ProvisioningAction { if (propName == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_NAME, ID)); String propValue = (String) parameters.get(ActionConstants.PARM_PROP_VALUE); - if (propValue == null) - return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_VALUE, ID)); getMemento().put(ActionConstants.PARM_PREVIOUS_VALUE, manipulator.getConfigData().getFwDependentProp(propName)); manipulator.getConfigData().setFwDependentProp(propName, propValue); return Status.OK_STATUS; @@ -39,8 +37,6 @@ public class SetFrameworkDependentPropertyAction extends ProvisioningAction { if (propName == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_NAME, ID)); String previousValue = (String) getMemento().get(ActionConstants.PARM_PREVIOUS_VALUE); - if (previousValue == null) - return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PREVIOUS_VALUE, ID)); manipulator.getConfigData().setFwDependentProp(propName, previousValue); return Status.OK_STATUS; } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetFrameworkIndependentPropertyAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetFrameworkIndependentPropertyAction.java index c93ff5c73..d69624c97 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetFrameworkIndependentPropertyAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetFrameworkIndependentPropertyAction.java @@ -26,8 +26,6 @@ public class SetFrameworkIndependentPropertyAction extends ProvisioningAction { if (propName == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_NAME, ID)); String propValue = (String) parameters.get(ActionConstants.PARM_PROP_VALUE); - if (propValue == null) - return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_VALUE, ID)); getMemento().put(ActionConstants.PARM_PREVIOUS_VALUE, manipulator.getConfigData().getFwDependentProp(propName)); manipulator.getConfigData().setFwIndependentProp(propName, propValue); return Status.OK_STATUS; @@ -39,8 +37,6 @@ public class SetFrameworkIndependentPropertyAction extends ProvisioningAction { if (propName == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_NAME, ID)); String previousValue = (String) getMemento().get(ActionConstants.PARM_PREVIOUS_VALUE); - if (previousValue == null) - return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PREVIOUS_VALUE, ID)); manipulator.getConfigData().setFwIndependentProp(propName, previousValue); return Status.OK_STATUS; } 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 c2e869ec8..1584cd1ad 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 @@ -20,26 +20,25 @@ import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction; public class SetLauncherNameAction extends ProvisioningAction { public static final String ID = "setLauncherName"; //$NON-NLS-1$ - private IStatus changeName(String newName, Manipulator manipulator, Profile profile) { - //force the load to make sure we read the values in the old filename - IStatus status = EclipseTouchpoint.loadManipulator(manipulator); - if (status != null && !status.isOK()) - return status; - getMemento().put(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME, profile.getProperty(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME)); - profile.setProperty(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME, newName); - manipulator.getLauncherData().setLauncher(Util.getLauncherPath(profile)); - return Status.OK_STATUS; - } - public IStatus execute(Map parameters) { Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE); - return changeName((String) parameters.get(ActionConstants.PARM_LAUNCHERNAME), manipulator, profile); + getMemento().put(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME, profile.getProperty(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME)); + String launcherName = (String) parameters.get(ActionConstants.PARM_LAUNCHERNAME); + setLauncher(manipulator, profile, launcherName); + return Status.OK_STATUS; } public IStatus undo(Map parameters) { Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE); - return changeName((String) getMemento().get(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME), manipulator, profile); + String previousLauncherName = (String) getMemento().get(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME); + setLauncher(manipulator, profile, previousLauncherName); + return Status.OK_STATUS; + } + + private static void setLauncher(Manipulator manipulator, Profile profile, String launcherName) { + profile.setProperty(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME, launcherName); + manipulator.getLauncherData().setLauncher(Util.getLauncherPath(profile)); } }
\ 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/SetProgramPropertyAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java index 2e6529384..f3bd95f26 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java @@ -26,8 +26,6 @@ public class SetProgramPropertyAction extends ProvisioningAction { if (propName == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_NAME, ID)); String propValue = (String) parameters.get(ActionConstants.PARM_PROP_VALUE); - if (propValue == null) - return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_VALUE, ID)); getMemento().put(ActionConstants.PARM_PREVIOUS_VALUE, manipulator.getConfigData().getFwDependentProp(propName)); manipulator.getConfigData().setFwDependentProp(propName, propValue); return Status.OK_STATUS; @@ -39,8 +37,6 @@ public class SetProgramPropertyAction extends ProvisioningAction { if (propName == null) return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROP_NAME, ID)); String previousValue = (String) getMemento().get(ActionConstants.PARM_PREVIOUS_VALUE); - if (previousValue == null) - return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PREVIOUS_VALUE, ID)); manipulator.getConfigData().setFwDependentProp(propName, previousValue); return Status.OK_STATUS; } |