Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2008 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.*; |
14 |
import junit.framework.Test; |
15 |
import junit.framework.TestSuite; |
16 |
import org.eclipse.core.resources.*; |
17 |
import org.eclipse.core.runtime.CoreException; |
18 |
import org.eclipse.core.tests.resources.ResourceTest; |
19 |
|
20 |
public class Bug_198291 extends ResourceTest { |
21 |
/** |
22 |
* Constructor for Bug_198291. |
23 |
*/ |
24 |
public Bug_198291() { |
25 |
super(); |
26 |
} |
27 |
|
28 |
/** |
29 |
* Constructor for Bug_198291. |
30 |
* @param name |
31 |
*/ |
32 |
public Bug_198291(String name) { |
33 |
super(name); |
34 |
} |
35 |
|
36 |
public static Test suite() { |
37 |
return new TestSuite(Bug_198291.class); |
38 |
} |
39 |
|
40 |
public void testBug() { |
41 |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
42 |
|
43 |
try { |
44 |
IProject project1 = workspace.getRoot().getProject("project1"); |
45 |
project1.create(null); |
46 |
project1.open(null); |
47 |
|
48 |
IFolder folder1 = project1.getFolder("folder1"); |
49 |
folder1.create(true, true, getMonitor()); |
50 |
assertExistsInWorkspace("1.0", folder1); |
51 |
|
52 |
mkLink(project1.getLocation().toFile(), "folder2" , folder1.getLocation().toString(), true); |
53 |
|
54 |
project1.refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); |
55 |
IFolder folder2 = project1.getFolder("folder2"); |
56 |
assertExistsInWorkspace("2.0", folder2); |
57 |
|
58 |
IFile file1 = folder1.getFile("file1"); |
59 |
file1.create(new ByteArrayInputStream("elo".getBytes()),true, getMonitor()); |
60 |
assertExistsInWorkspace("3.0", file1); |
61 |
|
62 |
assertExistsInWorkspace("4.0",folder2.getFile("file1")); |
63 |
} catch (CoreException e) { |
64 |
fail("5.0", e); |
65 |
} |
66 |
} |
67 |
|
68 |
protected void mkLink(File dir, String src, String tgt, boolean isDir) { |
69 |
String[] envp = {}; |
70 |
try { |
71 |
Process p; |
72 |
String[] cmd = {"ln", "-s", tgt, src}; |
73 |
p = Runtime.getRuntime().exec(cmd, envp, dir); |
74 |
int exitcode = p.waitFor(); |
75 |
assertEquals(exitcode, 0); |
76 |
} catch (IOException e) { |
77 |
fail("mkLink", e); |
78 |
} catch (InterruptedException e) { |
79 |
fail("mkLink", e); |
80 |
} |
81 |
} |
82 |
} |