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 212383 Details for
Bug 338792
AliasManager compare method does not check host names of uri
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]
Patch with test
patch338792.txt (text/plain), 10.70 KB, created by
Szymon Ptaszkiewicz
on 2012-03-09 09:16:43 EST
(
hide
)
Description:
Patch with test
Filename:
MIME Type:
Creator:
Szymon Ptaszkiewicz
Created:
2012-03-09 09:16:43 EST
Size:
10.70 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java >index 54d2157..329aafb 100644 >--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java >+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -511,6 +511,11 @@ > return 1; > } > >+ // compare hosts >+ compare = compareStringOrNull(uri1.getHost(), uri2.getHost()); >+ if (compare != 0) >+ return compare; >+ > IPath path1 = new Path(uri1.getPath()); > IPath path2 = new Path(uri2.getPath()); > // compare devices >diff --git a/tests/org.eclipse.core.tests.resources/plugin.xml b/tests/org.eclipse.core.tests.resources/plugin.xml >index 1879212..f27c228 100644 >--- a/tests/org.eclipse.core.tests.resources/plugin.xml >+++ b/tests/org.eclipse.core.tests.resources/plugin.xml >@@ -563,6 +563,12 @@ > </filesystem> > </extension> > <extension >+ point="org.eclipse.core.filesystem.filesystems"> >+ <filesystem scheme="remote"> >+ <run class="org.eclipse.core.tests.internal.filesystem.remote.RemoteFileSystem"/> >+ </filesystem> >+</extension> >+<extension > id="modelProvider" > point="org.eclipse.core.resources.modelProviders"> > <modelProvider >diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileStore.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileStore.java >new file mode 100644 >index 0000000..c7cdf5b >--- /dev/null >+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileStore.java >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 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.core.tests.internal.filesystem.remote; >+ >+import java.net.URI; >+import java.net.URISyntaxException; >+import org.eclipse.core.filesystem.IFileStore; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileStore; >+ >+/** >+ * A test file store that mocks remote file store and keeps everything in memory. >+ */ >+public class RemoteFileStore extends MemoryFileStore { >+ public RemoteFileStore(IPath path) { >+ super(path); >+ } >+ >+ public IFileStore getChild(String name) { >+ return new RemoteFileStore(path.append(name)); >+ } >+ >+ public IFileStore getParent() { >+ if (path.segmentCount() == 0) >+ return null; >+ return new RemoteFileStore(path.removeLastSegments(1)); >+ } >+ >+ public URI toURI() { >+ try { >+ String host = null; >+ if (path.segmentCount() > 0) >+ host = path.segment(0).toString(); >+ String pathString = "/"; >+ if (path.segmentCount() > 1) >+ pathString += path.removeFirstSegments(1).toString(); >+ return new URI(RemoteFileSystem.SCHEME_REMOTE, host, pathString, null); >+ } catch (URISyntaxException e) { >+ //should not happen >+ throw new RuntimeException(e); >+ } >+ } >+} >diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileSystem.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileSystem.java >new file mode 100644 >index 0000000..c989cd5 >--- /dev/null >+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileSystem.java >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 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.core.tests.internal.filesystem.remote; >+ >+import java.net.URI; >+import org.eclipse.core.filesystem.IFileStore; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileSystem; >+ >+/** >+ * A test file system that mocks remote file system and keeps everything in memory. >+ */ >+public class RemoteFileSystem extends MemoryFileSystem { >+ public static final String SCHEME_REMOTE = "remote"; >+ >+ public RemoteFileSystem() { >+ super(); >+ } >+ >+ public IFileStore getStore(URI uri) { >+ return new RemoteFileStore(Path.ROOT.append(uri.getHost()).append(uri.getPath())); >+ } >+} >diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllTests.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllTests.java >index 087525f..fa046d8 100644 >--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllTests.java >+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllTests.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 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 >@@ -62,6 +62,7 @@ > suite.addTest(Bug_329836.suite()); > suite.addTest(Bug_331445.suite()); > suite.addTest(Bug_332543.suite()); >+ suite.addTest(Bug_338792.suite()); > suite.addTest(IFileTest.suite()); > suite.addTest(IFolderTest.suite()); > suite.addTest(IProjectTest.suite()); >diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_338792.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_338792.java >new file mode 100644 >index 0000000..33fbfad >--- /dev/null >+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_338792.java >@@ -0,0 +1,98 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 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.core.tests.resources.regression; >+ >+import java.net.URI; >+import java.net.URISyntaxException; >+import java.util.*; >+import junit.framework.Test; >+import junit.framework.TestSuite; >+import org.eclipse.core.filesystem.EFS; >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.tests.internal.filesystem.ram.MemoryTree; >+import org.eclipse.core.tests.internal.filesystem.remote.RemoteFileSystem; >+import org.eclipse.core.tests.resources.ResourceTest; >+ >+/** >+ * Test for bug 338792 >+ */ >+public class Bug_338792 extends ResourceTest { >+ private static final String HOST_A = "hostA.example.com"; >+ private static final String HOST_B = "hostB.example.com"; >+ private static final String COMMON = "/common"; >+ >+ private static final String FOLDER_A = "/common/folderA"; >+ private static final String FOLDER_B = "/common/folderB"; >+ >+ public static Test suite() { >+ return new TestSuite(Bug_338792.class); >+ } >+ >+ @Override >+ protected void setUp() throws Exception { >+ super.setUp(); >+ MemoryTree.TREE.deleteAll(); >+ } >+ >+ @Override >+ protected void tearDown() throws Exception { >+ MemoryTree.TREE.deleteAll(); >+ super.tearDown(); >+ } >+ >+ public void testBug() throws CoreException, URISyntaxException { >+ URI commonA = new URI(RemoteFileSystem.SCHEME_REMOTE, HOST_A, COMMON, null); >+ URI commonB = new URI(RemoteFileSystem.SCHEME_REMOTE, HOST_B, COMMON, null); >+ URI folderA = new URI(RemoteFileSystem.SCHEME_REMOTE, HOST_A, FOLDER_A, null); >+ URI folderB = new URI(RemoteFileSystem.SCHEME_REMOTE, HOST_B, FOLDER_B, null); >+ >+ final Set<URI> toVisit = new HashSet<URI>(); >+ final int toVisitCount[] = new int[] {0}; >+ IResourceVisitor visitor = new IResourceVisitor() { >+ public boolean visit(IResource resource) { >+ toVisit.remove(resource.getLocationURI()); >+ toVisitCount[0]--; >+ return true; >+ } >+ }; >+ >+ EFS.getStore(folderA).mkdir(EFS.NONE, null); >+ EFS.getStore(folderB).mkdir(EFS.NONE, null); >+ >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ >+ IProject projectA = workspace.getRoot().getProject("projectA"); >+ ensureExistsInWorkspace(projectA, true); >+ IFolder linkA = projectA.getFolder("link_to_commonA"); >+ linkA.createLink(commonA, IResource.NONE, getMonitor()); >+ >+ IProject projectB = workspace.getRoot().getProject("projectB"); >+ ensureExistsInWorkspace(projectB, true); >+ IFolder linkB = projectB.getFolder("link_to_commonB"); >+ linkB.createLink(commonB, IResource.NONE, getMonitor()); >+ >+ toVisit.addAll(Arrays.asList(new URI[] {projectA.getLocationURI(), commonA, folderA, projectA.getFile(".project").getLocationURI()})); >+ toVisitCount[0] = 4; >+ projectA.accept(visitor); >+ assertTrue("1.1", toVisit.isEmpty()); >+ assertEquals("1.2", 0, toVisitCount[0]); >+ >+ toVisit.addAll(Arrays.asList(new URI[] {projectB.getLocationURI(), commonB, folderB, projectB.getFile(".project").getLocationURI()})); >+ toVisitCount[0] = 4; >+ projectB.accept(visitor); >+ assertTrue("2.1", toVisit.isEmpty()); >+ assertEquals("2.2", 0, toVisitCount[0]); >+ >+ projectA.delete(true, getMonitor()); >+ projectB.delete(true, getMonitor()); >+ } >+}
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 338792
:
190259
|
212383