View | Details | Raw Unified | Return to bug 172207
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java (+40 lines)
Lines 1198-1203 Link Here
1198
}
1198
}
1199
1199
1200
/**
1200
/**
1201
 * @bug 172207: [model] Marker for deprecated classpath variable should always have WARNING severity
1202
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=172207"
1203
 */
1204
public void testVariableInitializerBug172207() throws CoreException {
1205
	try {
1206
		// Create initializer
1207
		String varName = "TEST_DEPRECATED_READ_ONLY";
1208
		String path = "/P1/lib.jar";
1209
		VariablesInitializer.setInitializer(new DefaultVariableInitializer(new String[] { varName, path }));
1210
		assertEquals("JavaCore classpath value should have been initialized", JavaCore.getClasspathVariable(varName).toString(), path);
1211
1212
		// verify that Classpath Variable is read-only
1213
		assertEquals("JavaCore classpath variable should be deprecated", "A deprecated and read-only initializer", JavaCore.getClasspathVariableDeprecationMessage(varName));
1214
		assertTrue("JavaCore classpath variable should be read-only", JavaCore.isClasspathVariableReadOnly(varName));
1215
1216
		// Create project
1217
		IJavaProject project = createJavaProject("P1");
1218
		createFile("/P1/lib.jar", "");
1219
		IClasspathEntry variable = JavaCore.newVariableEntry(new Path("TEST_DEPRECATED_READ_ONLY"), null, null);
1220
		IClasspathEntry[] entries = project.getRawClasspath();
1221
		int length = entries.length;
1222
		System.arraycopy(entries, 0, entries = new IClasspathEntry[length+1], 0, length);
1223
		entries[length] = variable;
1224
		project.setRawClasspath(entries, null);
1225
1226
		// verify markers
1227
		waitForAutoBuild();
1228
		IMarker[] markers = project.getProject().findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
1229
		sortMarkers(markers);
1230
		assertMarkers("Unexpected marker(s)",
1231
			"Classpath variable 'TEST_DEPRECATED_READ_ONLY' in project P1 is deprecated: 'A deprecated and read-only initializer'",
1232
			markers);
1233
		assertEquals("Marker on deprecated variable should be a WARNING", IMarker.SEVERITY_WARNING, markers[0].getAttribute(IMarker.SEVERITY, -1));
1234
	} finally {
1235
		VariablesInitializer.reset();
1236
		deleteProject("P1");
1237
	}
1238
}
1239
1240
/**
1201
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=61872"
1241
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=61872"
1202
 */
1242
 */
1203
public void testUserLibraryInitializer1() throws CoreException {
1243
public void testUserLibraryInitializer1() throws CoreException {
(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-1 / +3 lines)
Lines 37-42 Link Here
37
import org.eclipse.core.runtime.CoreException;
37
import org.eclipse.core.runtime.CoreException;
38
import org.eclipse.core.runtime.IPath;
38
import org.eclipse.core.runtime.IPath;
39
import org.eclipse.core.runtime.IProgressMonitor;
39
import org.eclipse.core.runtime.IProgressMonitor;
40
import org.eclipse.core.runtime.IStatus;
40
import org.eclipse.core.runtime.Path;
41
import org.eclipse.core.runtime.Path;
41
import org.eclipse.core.runtime.Preferences;
42
import org.eclipse.core.runtime.Preferences;
42
import org.eclipse.core.runtime.QualifiedName;
43
import org.eclipse.core.runtime.QualifiedName;
Lines 786-792 Link Here
786
			default:
787
			default:
787
				IPath path = status.getPath();
788
				IPath path = status.getPath();
788
				if (path != null) arguments = new String[] { path.toString() };
789
				if (path != null) arguments = new String[] { path.toString() };
789
				if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true))) {
790
				if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)) &&
791
					status.getSeverity() != IStatus.WARNING) {
790
					severity = IMarker.SEVERITY_ERROR;
792
					severity = IMarker.SEVERITY_ERROR;
791
				} else {
793
				} else {
792
					severity = IMarker.SEVERITY_WARNING;
794
					severity = IMarker.SEVERITY_WARNING;

Return to bug 172207