Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 338792 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 511-516 Link Here
511
					return 1;
511
					return 1;
512
				}
512
				}
513
513
514
				// compare hosts
515
				compare = compareStringOrNull(uri1.getHost(), uri2.getHost());
516
				if (compare != 0)
517
					return compare;
518
514
				IPath path1 = new Path(uri1.getPath());
519
				IPath path1 = new Path(uri1.getPath());
515
				IPath path2 = new Path(uri2.getPath());
520
				IPath path2 = new Path(uri2.getPath());
516
				// compare devices
521
				// compare devices
(-)a/tests/org.eclipse.core.tests.resources/plugin.xml (+6 lines)
Lines 563-568 Link Here
563
   </filesystem>
563
   </filesystem>
564
</extension>
564
</extension>
565
<extension
565
<extension
566
      point="org.eclipse.core.filesystem.filesystems">
567
   <filesystem scheme="remote">
568
      <run class="org.eclipse.core.tests.internal.filesystem.remote.RemoteFileSystem"/>
569
   </filesystem>
570
</extension>
571
<extension
566
      id="modelProvider"
572
      id="modelProvider"
567
      point="org.eclipse.core.resources.modelProviders">
573
      point="org.eclipse.core.resources.modelProviders">
568
   <modelProvider
574
   <modelProvider
(-)a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileStore.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2012 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.tests.internal.filesystem.remote;
12
13
import java.net.URI;
14
import java.net.URISyntaxException;
15
import org.eclipse.core.filesystem.IFileStore;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileStore;
18
19
/**
20
 * A test file store that mocks remote file store and keeps everything in memory.
21
 */
22
public class RemoteFileStore extends MemoryFileStore {
23
	public RemoteFileStore(IPath path) {
24
		super(path);
25
	}
26
27
	public IFileStore getChild(String name) {
28
		return new RemoteFileStore(path.append(name));
29
	}
30
31
	public IFileStore getParent() {
32
		if (path.segmentCount() == 0)
33
			return null;
34
		return new RemoteFileStore(path.removeLastSegments(1));
35
	}
36
37
	public URI toURI() {
38
		try {
39
			String host = null;
40
			if (path.segmentCount() > 0)
41
				host = path.segment(0).toString();
42
			String pathString = "/";
43
			if (path.segmentCount() > 1)
44
				pathString += path.removeFirstSegments(1).toString();
45
			return new URI(RemoteFileSystem.SCHEME_REMOTE, host, pathString, null);
46
		} catch (URISyntaxException e) {
47
			//should not happen
48
			throw new RuntimeException(e);
49
		}
50
	}
51
}
(-)a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileSystem.java (+31 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.tests.internal.filesystem.remote;
12
13
import java.net.URI;
14
import org.eclipse.core.filesystem.IFileStore;
15
import org.eclipse.core.runtime.Path;
16
import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileSystem;
17
18
/**
19
 * A test file system that mocks remote file system and keeps everything in memory.
20
 */
21
public class RemoteFileSystem extends MemoryFileSystem {
22
	public static final String SCHEME_REMOTE = "remote";
23
24
	public RemoteFileSystem() {
25
		super();
26
	}
27
28
	public IFileStore getStore(URI uri) {
29
		return new RemoteFileStore(Path.ROOT.append(uri.getHost()).append(uri.getPath()));
30
	}
31
}
(-)a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllTests.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 62-67 Link Here
62
		suite.addTest(Bug_329836.suite());
62
		suite.addTest(Bug_329836.suite());
63
		suite.addTest(Bug_331445.suite());
63
		suite.addTest(Bug_331445.suite());
64
		suite.addTest(Bug_332543.suite());
64
		suite.addTest(Bug_332543.suite());
65
		suite.addTest(Bug_338792.suite());
65
		suite.addTest(IFileTest.suite());
66
		suite.addTest(IFileTest.suite());
66
		suite.addTest(IFolderTest.suite());
67
		suite.addTest(IFolderTest.suite());
67
		suite.addTest(IProjectTest.suite());
68
		suite.addTest(IProjectTest.suite());
(-)a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_338792.java (+98 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.tests.resources.regression;
12
13
import java.net.URI;
14
import java.net.URISyntaxException;
15
import java.util.*;
16
import junit.framework.Test;
17
import junit.framework.TestSuite;
18
import org.eclipse.core.filesystem.EFS;
19
import org.eclipse.core.resources.*;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.tests.internal.filesystem.ram.MemoryTree;
22
import org.eclipse.core.tests.internal.filesystem.remote.RemoteFileSystem;
23
import org.eclipse.core.tests.resources.ResourceTest;
24
25
/**
26
 * Test for bug 338792
27
 */
28
public class Bug_338792 extends ResourceTest {
29
	private static final String HOST_A = "hostA.example.com";
30
	private static final String HOST_B = "hostB.example.com";
31
	private static final String COMMON = "/common";
32
33
	private static final String FOLDER_A = "/common/folderA";
34
	private static final String FOLDER_B = "/common/folderB";
35
36
	public static Test suite() {
37
		return new TestSuite(Bug_338792.class);
38
	}
39
40
	@Override
41
	protected void setUp() throws Exception {
42
		super.setUp();
43
		MemoryTree.TREE.deleteAll();
44
	}
45
46
	@Override
47
	protected void tearDown() throws Exception {
48
		MemoryTree.TREE.deleteAll();
49
		super.tearDown();
50
	}
51
52
	public void testBug() throws CoreException, URISyntaxException {
53
		URI commonA = new URI(RemoteFileSystem.SCHEME_REMOTE, HOST_A, COMMON, null);
54
		URI commonB = new URI(RemoteFileSystem.SCHEME_REMOTE, HOST_B, COMMON, null);
55
		URI folderA = new URI(RemoteFileSystem.SCHEME_REMOTE, HOST_A, FOLDER_A, null);
56
		URI folderB = new URI(RemoteFileSystem.SCHEME_REMOTE, HOST_B, FOLDER_B, null);
57
58
		final Set<URI> toVisit = new HashSet<URI>();
59
		final int toVisitCount[] = new int[] {0};
60
		IResourceVisitor visitor = new IResourceVisitor() {
61
			public boolean visit(IResource resource) {
62
				toVisit.remove(resource.getLocationURI());
63
				toVisitCount[0]--;
64
				return true;
65
			}
66
		};
67
68
		EFS.getStore(folderA).mkdir(EFS.NONE, null);
69
		EFS.getStore(folderB).mkdir(EFS.NONE, null);
70
71
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
72
73
		IProject projectA = workspace.getRoot().getProject("projectA");
74
		ensureExistsInWorkspace(projectA, true);
75
		IFolder linkA = projectA.getFolder("link_to_commonA");
76
		linkA.createLink(commonA, IResource.NONE, getMonitor());
77
78
		IProject projectB = workspace.getRoot().getProject("projectB");
79
		ensureExistsInWorkspace(projectB, true);
80
		IFolder linkB = projectB.getFolder("link_to_commonB");
81
		linkB.createLink(commonB, IResource.NONE, getMonitor());
82
83
		toVisit.addAll(Arrays.asList(new URI[] {projectA.getLocationURI(), commonA, folderA, projectA.getFile(".project").getLocationURI()}));
84
		toVisitCount[0] = 4;
85
		projectA.accept(visitor);
86
		assertTrue("1.1", toVisit.isEmpty());
87
		assertEquals("1.2", 0, toVisitCount[0]);
88
89
		toVisit.addAll(Arrays.asList(new URI[] {projectB.getLocationURI(), commonB, folderB, projectB.getFile(".project").getLocationURI()}));
90
		toVisitCount[0] = 4;
91
		projectB.accept(visitor);
92
		assertTrue("2.1", toVisit.isEmpty());
93
		assertEquals("2.2", 0, toVisitCount[0]);
94
95
		projectA.delete(true, getMonitor());
96
		projectB.delete(true, getMonitor());
97
	}
98
}

Return to bug 338792