Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2010-06-22 14:43:10 +0000
committerJohn Arthorne2010-06-22 14:43:10 +0000
commit33fe4dadc9c5f7ae48d06ddece9123ca56cab696 (patch)
tree780540048dea9f9d18be9c3b19eebcbcac307ec9 /bundles/org.eclipse.equinox.p2.tests
parent98db8d34ef0f581a7855b3153a6650037c4e6e40 (diff)
downloadrt.equinox.p2-33fe4dadc9c5f7ae48d06ddece9123ca56cab696.tar.gz
rt.equinox.p2-33fe4dadc9c5f7ae48d06ddece9123ca56cab696.tar.xz
rt.equinox.p2-33fe4dadc9c5f7ae48d06ddece9123ca56cab696.zip
Bug 316650 - PathUtil doesn't make paths relative correctly across volumes
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/PathUtilTest.java52
2 files changed, 54 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java
index c2edb992d..5f4c9399a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -32,6 +32,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(JVMArgumentActionLogicTest.class);
suite.addTestSuite(LinkActionTest.class);
suite.addTestSuite(MarkStartedActionTest.class);
+ suite.addTestSuite(PathUtilTest.class);
suite.addTestSuite(RemoveJVMArgumentActionTest.class);
suite.addTestSuite(RemoveProgramArgumentActionTest.class);
suite.addTestSuite(RemoveRepositoryActionTest.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/PathUtilTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/PathUtilTest.java
new file mode 100644
index 000000000..a3dd65191
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/PathUtilTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.touchpoint.eclipse;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.eclipse.equinox.internal.p2.update.PathUtil;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+
+/**
+ * Tests for {@link org.eclipse.equinox.internal.p2.update.PathUtil}.
+ */
+public class PathUtilTest extends AbstractProvisioningTest {
+ /** Constant value indicating if the current platform is Windows */
+ private static final boolean WINDOWS = java.io.File.separatorChar == '\\';
+
+ public void testMakeRelative() throws MalformedURLException {
+ if (!WINDOWS)
+ return;
+ Object[][] data = new Object[][] {
+ // simple path
+ new Object[] {"file:/c:/a/b", new URL("file:/c:/a/x"), "file:../b"},
+ // common root
+ new Object[] {"file:/c:/eclipse/plugins/foo.jar", new URL("file:/c:/eclipse/"), "file:plugins\\foo.jar"},
+ // different drives
+ new Object[] {"file:/c:/a/b", new URL("file:/d:/a/x"), "file:/c:/a/b"}, //
+ new Object[] {"file:/c:/eclipse/plugins/foo.jar", new URL("file:/d:/eclipse/"), "file:/c:/eclipse/plugins/foo.jar"},
+ // non-local
+ new Object[] {"http:/c:/a/b", new URL("file:/c:/a/x"), "http:/c:/a/b"}, //
+ new Object[] {"file:/c:/a/b", new URL("http:/c:/a/x"), "file:/c:/a/b"}, //
+ //
+ new Object[] {"file:/c:/a/b", new URL("file:/C:/a/x"), "file:../b"}, //
+ new Object[] {"file:/c:/", new URL("file:/d:/"), "file:/c:/"}, //
+ new Object[] {"file:/c:/", new URL("file:/c:/"), "file:/c:/"}, //
+ };
+ for (int i = 0; i < data.length; i++) {
+ String location = data[i][0].toString();
+ URL root = (URL) data[i][1];
+ String expected = data[i][2].toString();
+ String actual = PathUtil.makeRelative(location, root);
+ assertEquals("2." + Integer.toString(i), expected, actual);
+ }
+ }
+}

Back to the top