1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 326957 EFSExtensionProvider does not handle URI's correctly

This commit is contained in:
Vivian Kong 2011-01-26 20:00:26 +00:00
parent 8e355ea4b2
commit 5ca9b3b6d1
2 changed files with 42 additions and 3 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 IBM Corporation and others. * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -129,6 +129,44 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
public void testReplaceURIWithAuthority() {
URI originalURI = null;
URI expected = null;
try {
originalURI = new URI("rse", "recoskie@dbgaix3.torolab.ibm.com:1000", "/home/recoskie", null, null);
expected = new URI("rse", "recoskie@dbgaix3.torolab.ibm.com:1000", "/home/recoskie/subdirectory", null, null);
} catch (URISyntaxException e) {
fail(e.getMessage());
}
String workingDirPath = EFSExtensionManager.getDefault()
.getPathFromURI(originalURI);
IPath path = new Path("subdirectory");
IPath newPath = new Path(workingDirPath).append(path).makeAbsolute();
URI uri = EFSExtensionManager.getDefault()
.createNewURIFromPath(originalURI, newPath.toString());
assertEquals(expected, uri);
}
public void testReplaceURIWithAuthority2() {
URI originalURI = null;
URI expected = null;
try {
originalURI = new URI("rse", "recoskie@dbgaix3.torolab.ibm.com:1000", "/home/recoskie", null, null);
expected = new URI("rse", "recoskie", "dbgaix3.torolab.ibm.com", 1000, "/home/recoskie/subdirectory", null, null);
} catch (URISyntaxException e) {
fail(e.getMessage());
}
String workingDirPath = EFSExtensionManager.getDefault()
.getPathFromURI(originalURI);
IPath path = new Path("subdirectory");
IPath newPath = new Path(workingDirPath).append(path).makeAbsolute();
URI uri = EFSExtensionManager.getDefault()
.createNewURIFromPath(originalURI, newPath.toString());
assertEquals(expected, uri);
}
public void testAppendinRSEURI() { public void testAppendinRSEURI() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 IBM Corporation and others. * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -101,7 +101,8 @@ public abstract class EFSExtensionProvider {
pathBuf.append(pathString); pathBuf.append(pathString);
try { try {
return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), pathBuf.toString(), // replaced! //Bug 326957 - EFSExtensionProvider does not handle URI's correctly
return new URI(uri.getScheme(), uri.getAuthority(), pathBuf.toString(), // replaced!
uri.getQuery(), uri.getFragment()); uri.getQuery(), uri.getFragment());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
CCorePlugin.log(e); CCorePlugin.log(e);