View | Details | Raw Unified | Return to bug 274332 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (-2 / +9 lines)
Lines 4177-4194 Link Here
4177
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 )
4177
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 )
4178
 */
4178
 */
4179
public void testReadOnly() throws CoreException {
4179
public void testReadOnly() throws CoreException {
4180
	if (!org.eclipse.jdt.internal.core.util.Util.isReadOnlySupported())
4180
	if (!org.eclipse.jdt.internal.core.util.Util.isReadOnlySupported()) {
4181
		System.out.println("Read-only not supported => skip test");
4181
		return;
4182
		return;
4183
	}
4182
	IJavaProject project = this.createJavaProject("P", new String[] {"src"}, "bin");
4184
	IJavaProject project = this.createJavaProject("P", new String[] {"src"}, "bin");
4183
	IClasspathEntry[] originalCP= project.getRawClasspath();
4185
	IClasspathEntry[] originalCP= project.getRawClasspath();
4184
4186
4187
	IFile classpathFile = null;
4185
	try {
4188
	try {
4186
		IClasspathEntry newEntry= JavaCore.newSourceEntry(project.getProject().getFullPath().append("extra"));
4189
		IClasspathEntry newEntry= JavaCore.newSourceEntry(project.getProject().getFullPath().append("extra"));
4187
		IClasspathEntry[] newCP= new IClasspathEntry[originalCP.length + 1];
4190
		IClasspathEntry[] newCP= new IClasspathEntry[originalCP.length + 1];
4188
		System.arraycopy(originalCP, 0 , newCP, 0, originalCP.length);
4191
		System.arraycopy(originalCP, 0 , newCP, 0, originalCP.length);
4189
		newCP[originalCP.length]= newEntry;
4192
		newCP[originalCP.length]= newEntry;
4190
		
4193
		
4191
		org.eclipse.jdt.internal.core.util.Util.setReadOnly(getFile("/P/.classpath"), true);
4194
		classpathFile = getFile("/P/.classpath");
4195
		org.eclipse.jdt.internal.core.util.Util.setReadOnly(classpathFile, true);
4192
		JavaModelException expected = null;
4196
		JavaModelException expected = null;
4193
		try {
4197
		try {
4194
			project.setRawClasspath(newCP, null);
4198
			project.setRawClasspath(newCP, null);
Lines 4198-4203 Link Here
4198
		assertExceptionEquals("Unexpected exception", "File /P/.classpath is read-only.", expected);
4202
		assertExceptionEquals("Unexpected exception", "File /P/.classpath is read-only.", expected);
4199
	} finally {
4203
	} finally {
4200
		// cleanup
4204
		// cleanup
4205
		if (classpathFile != null) {
4206
			org.eclipse.jdt.internal.core.util.Util.setReadOnly(classpathFile, false);
4207
		}
4201
		this.deleteProject("P");
4208
		this.deleteProject("P");
4202
	}
4209
	}
4203
}
4210
}

Return to bug 274332