1 /******************************************************************************* 2 * Copyright (c) 2008, 2017 IBM Corporation and others. 3 * 4 * This 5 * program and the accompanying materials are made available under the terms of 6 * the Eclipse Public License 2.0 which accompanies this distribution, and is 7 * available at 8 * https://www.eclipse.org/legal/epl-2.0/ 9 * 10 * SPDX-License-Identifier: EPL-2.0 11 * 12 * Contributors: IBM Corporation - initial API and implementation 13 ******************************************************************************/ 14 package org.eclipse.equinox.p2.tests.touchpoint.natives; 15 16 import java.io.File; 17 import java.util.*; 18 import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; 19 import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; 20 import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.MkdirAction; 21 import org.eclipse.equinox.p2.engine.IProfile; 22 import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; 23 24 public class MkdirActionTest extends AbstractProvisioningTest { 25 MkdirActionTest(String name)26 public MkdirActionTest(String name) { 27 super(name); 28 } 29 MkdirActionTest()30 public MkdirActionTest() { 31 super(""); 32 } 33 testExecuteUndo()34 public void testExecuteUndo() { 35 Map<String, String> profileProperties = new HashMap<>(); 36 File installFolder = getTempFolder(); 37 profileProperties.put(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); 38 IProfile profile = createProfile("test", profileProperties); 39 40 Map<String, Object> parameters = new HashMap<>(); 41 parameters.put(ActionConstants.PARM_PROFILE, profile); 42 NativeTouchpoint touchpoint = new NativeTouchpoint(); 43 touchpoint.initializePhase(null, profile, "test", parameters); 44 45 File testFolder = new File(installFolder, "test"); 46 47 parameters.put(ActionConstants.PARM_PATH, testFolder.getAbsolutePath()); 48 parameters = Collections.unmodifiableMap(parameters); 49 50 assertFalse(testFolder.exists()); 51 52 MkdirAction action = new MkdirAction(); 53 action.execute(parameters); 54 assertTrue(testFolder.exists()); 55 56 action.undo(parameters); 57 assertFalse(testFolder.exists()); 58 } 59 }