Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2008, 2010 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.io.IOException; |
14 |
import junit.framework.Test; |
15 |
import junit.framework.TestSuite; |
16 |
import org.eclipse.core.filesystem.EFS; |
17 |
import org.eclipse.core.resources.*; |
18 |
import org.eclipse.core.runtime.CoreException; |
19 |
import org.eclipse.core.runtime.IPath; |
20 |
import org.eclipse.core.tests.resources.ResourceTest; |
21 |
|
22 |
public class Bug_233939 extends ResourceTest { |
23 |
/** |
24 |
* Constructor for Bug_233939. |
25 |
*/ |
26 |
public Bug_233939() { |
27 |
super(); |
28 |
} |
29 |
|
30 |
/** |
31 |
* Constructor for Bug_233939. |
32 |
* @param name |
33 |
*/ |
34 |
public Bug_233939(String name) { |
35 |
super(name); |
36 |
} |
37 |
|
38 |
public static Test suite() { |
39 |
return new TestSuite(Bug_233939.class); |
40 |
} |
41 |
|
42 |
public void testBug() { |
43 |
// only activate this test on platforms that support it |
44 |
if (!isAttributeSupported(EFS.ATTRIBUTE_SYMLINK)) |
45 |
return; |
46 |
String fileName = "file.txt"; |
47 |
|
48 |
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); |
49 |
IProject project = root.getProject(getUniqueString()); |
50 |
IFile file = project.getFile(fileName); |
51 |
|
52 |
IPath fileInTempDirPath = getTempDir().addTrailingSeparator().append(fileName); |
53 |
|
54 |
// create a project |
55 |
try { |
56 |
project.create(getMonitor()); |
57 |
project.open(getMonitor()); |
58 |
} catch (CoreException e) { |
59 |
fail("1.0", e); |
60 |
} |
61 |
|
62 |
// create a file in the temp dir |
63 |
try { |
64 |
fileInTempDirPath.toFile().createNewFile(); |
65 |
} catch (IOException e) { |
66 |
fail("2.0", e); |
67 |
} |
68 |
|
69 |
// create a link to the file in the temp dir and refresh, |
70 |
// the resource in the workspace should have symbolic link attribute set |
71 |
createSymLink(project.getLocation().toFile(), fileName, fileInTempDirPath.toString(), false); |
72 |
try { |
73 |
project.refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); |
74 |
} catch (CoreException e) { |
75 |
fail("3.0", e); |
76 |
} |
77 |
assertExistsInWorkspace("4.0", file); |
78 |
assertTrue("5.0", file.getResourceAttributes().isSymbolicLink()); |
79 |
|
80 |
IFile[] files = root.findFilesForLocation(file.getLocation()); |
81 |
assertEquals("7.0", 1, files.length); |
82 |
assertEquals("7.1", file, files[0]); |
83 |
|
84 |
// IFile[] files = root.findFilesForLocation(fileInTempDirPath); |
85 |
// assertEquals("6.0", 1, files.length); |
86 |
// assertEquals("6.1", file, files[0]); |
87 |
} |
88 |
|
89 |
} |