Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 171764 Details for
Bug 316650
PathUtil doesn't make paths relative correctly across volumes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix and regression test v01
patch.txt (text/plain), 6.50 KB, created by
John Arthorne
on 2010-06-11 15:59:35 EDT
(
hide
)
Description:
Fix and regression test v01
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2010-06-11 15:59:35 EDT
Size:
6.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.tests >Index: src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java,v >retrieving revision 1.12 >diff -u -r1.12 AllTests.java >--- src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java 13 Jan 2010 17:28:21 -0000 1.12 >+++ src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java 11 Jun 2010 19:59:20 -0000 >@@ -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 @@ > 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); >Index: src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/PathUtilTest.java >=================================================================== >RCS file: src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/PathUtilTest.java >diff -N src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/PathUtilTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/PathUtilTest.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+ } >+} >#P org.eclipse.equinox.p2.touchpoint.eclipse >Index: src/org/eclipse/equinox/internal/p2/update/PathUtil.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/PathUtil.java,v >retrieving revision 1.2 >diff -u -r1.2 PathUtil.java >--- src/org/eclipse/equinox/internal/p2/update/PathUtil.java 17 Aug 2009 20:04:03 -0000 1.2 >+++ src/org/eclipse/equinox/internal/p2/update/PathUtil.java 11 Jun 2010 19:59:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 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 >@@ -12,11 +12,12 @@ > > import java.io.File; > import java.net.URL; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.*; > > /** >- * >+ * Note the methods on this class have inconsistent and unintuitive behaviour. However >+ * they are unchanged for backwards compatibility. Clients should really use >+ * {@link URIUtil} instead. > * @since 1.0 > */ > public class PathUtil { >@@ -64,10 +65,12 @@ > /* > * Make the given path relative to the specified root, if applicable. If not, then > * return the path as-is. >- * >- * Method similar to one from SimpleConfigurationManipulatorImpl. > */ > private static String makeRelative(IPath toRel, IPath base) { >+ //can't make relative if devices are not equal >+ final String device = toRel.getDevice(); >+ if (device != base.getDevice() && (device == null || !device.equalsIgnoreCase(base.getDevice()))) >+ return toRel.toOSString(); > int i = base.matchingFirstSegments(toRel); > if (i == 0) { > return toRel.toOSString(); >@@ -78,6 +81,7 @@ > } > if (i == toRel.segmentCount()) > return "."; //$NON-NLS-1$ >+ //TODO This will return mixed path with some / and some \ on windows!! > result += toRel.setDevice(null).removeFirstSegments(i).toOSString(); > return result; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 316650
: 171764