blob: 1b22940e81e5640ab11e922586b815b792f4d2c6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*******************************************************************************
* Copyright (c) 2008, 2013 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.tests.core.regression;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourceAttributes;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.tests.core.TeamTest;
public class Bug_217673 extends TeamTest {
public void test() throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject project = workspace.getRoot().getProject(
getUniqueString());
project.create(null);
project.open(null);
IResource resource = project.getFile(".project");
IPath linkTarget = getRandomLocation();
try {
RepositoryProvider.map(project,
PessimisticRepositoryProvider.NATURE_ID);
PessimisticRepositoryProvider.markWritableOnEdit = true;
setReadOnly(resource, true);
linkTarget.toFile().mkdir();
project.getFolder("test").createLink(linkTarget, IResource.NONE,
null);
assertTrue(".project should no longer be read-only",
!isReadOnly(resource));
} finally {
PessimisticRepositoryProvider.markWritableOnEdit = false;
RepositoryProvider.unmap(project);
linkTarget.toFile().delete();
}
}
private boolean isReadOnly(IResource resource) {
ResourceAttributes resourceAttributes = resource
.getResourceAttributes();
return resourceAttributes.isReadOnly();
}
public static Test suite() {
return new TestSuite(Bug_217673.class);
}
}
|