Skip to content

Commit

Permalink
WIP, DONT MERGE
Browse files Browse the repository at this point in the history
Fixes: eclipse-platform#470
Signed-off-by: Simeon Andreev <[email protected]>
  • Loading branch information
trancexpress committed Jun 1, 2023
1 parent 2b5b76c commit c6d4a7c
Showing 1 changed file with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*******************************************************************************
* Copyright (c) 2023 Simeon Andreev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Simeon Andreev - initial API and implementation
*******************************************************************************/
package org.eclipse.core.tests.resources;

import java.nio.file.*;
import java.util.List;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.IPath;

/**
*
*/
public class ProjectLinksTest extends ResourceTest {

private Path tmpFolder;
private IPath tmpPath;

@Override
protected void setUp() throws Exception {
super.setUp();
tmpPath = getRandomLocation();
tmpFolder = Paths.get(tmpPath.toOSString());
Files.createDirectory(tmpFolder);
}

@Override
protected void tearDown() throws Exception {
try {
Files.deleteIfExists(tmpFolder);
} finally {
super.tearDown();
}
}

/**
* Tests that link information is updated after closing a project, deleting a
* link in the {@code .project} file and then opening the project.
*/
public void testCloseProjectDeleteLinksAndOpen_GH470() throws Exception {
String linkedFolderName = "test";
IWorkspaceRoot root = getWorkspace().getRoot();
IProject project = root.getProject(getUniqueString());

project.create(getMonitor());
project.open(getMonitor());
project.refreshLocal(IResource.DEPTH_INFINITE, getMonitor());

IFolder folder = project.getFolder(linkedFolderName);

IFile dotProject = project.getFile(".project");
Path dotProjectPath = Paths.get(dotProject.getLocationURI());

List<String> dotProjectContentsWithoutLink = Files.readAllLines(dotProjectPath);

folder.createLink(tmpPath, IResource.NONE, getMonitor());
project.refreshLocal(IResource.DEPTH_INFINITE, getMonitor());

assertTrue("Failed to create linked folder in test project", folder.isLinked());

project.close(getMonitor());

Files.write(dotProjectPath, dotProjectContentsWithoutLink);

project.open(getMonitor());
project.refreshLocal(IResource.DEPTH_INFINITE, getMonitor());

folder = project.getFolder(linkedFolderName);
assertFalse("Expected folder to not be linked after re-opening project", folder.isLinked());
}
}

0 comments on commit c6d4a7c

Please sign in to comment.