### Eclipse Workspace Patch 1.0 #P org.eclipse.core.tests.resources Index: src/org/eclipse/core/tests/resources/regression/Bug_198291.java =================================================================== RCS file: src/org/eclipse/core/tests/resources/regression/Bug_198291.java diff -N src/org/eclipse/core/tests/resources/regression/Bug_198291.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/core/tests/resources/regression/Bug_198291.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2008 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.io.*; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.tests.resources.ResourceTest; + +public class Bug_198291 extends ResourceTest { + /** + * Constructor for Bug_198291. + */ + public Bug_198291() { + super(); + } + + /** + * Constructor for Bug_198291. + * @param name + */ + public Bug_198291(String name) { + super(name); + } + + public static Test suite() { + return new TestSuite(Bug_198291.class); + } + + public void testBug() { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + + try { + IProject project1 = workspace.getRoot().getProject("project1"); + project1.create(null); + project1.open(null); + + IFolder folder1 = project1.getFolder("folder1"); + folder1.create(true, true, getMonitor()); + assertExistsInWorkspace("1.0", folder1); + + mkLink(project1.getLocation().toFile(), "folder2" , folder1.getLocation().toString(), true); + + project1.refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); + IFolder folder2 = project1.getFolder("folder2"); + assertExistsInWorkspace("2.0", folder2); + + IFile file1 = folder1.getFile("file1"); + file1.create(new ByteArrayInputStream("elo".getBytes()),true, getMonitor()); + assertExistsInWorkspace("3.0", file1); + + assertExistsInWorkspace("4.0",folder2.getFile("file1")); + } catch (CoreException e) { + fail("5.0", e); + } + } + + protected void mkLink(File dir, String src, String tgt, boolean isDir) { + String[] envp = {}; + try { + Process p; + String[] cmd = {"ln", "-s", tgt, src}; + p = Runtime.getRuntime().exec(cmd, envp, dir); + int exitcode = p.waitFor(); + assertEquals(exitcode, 0); + } catch (IOException e) { + fail("mkLink", e); + } catch (InterruptedException e) { + fail("mkLink", e); + } + } +}