Lines 15-20
Link Here
|
15 |
import org.eclipse.core.resources.IMarker; |
15 |
import org.eclipse.core.resources.IMarker; |
16 |
import org.eclipse.core.resources.ResourcesPlugin; |
16 |
import org.eclipse.core.resources.ResourcesPlugin; |
17 |
import org.eclipse.core.runtime.*; |
17 |
import org.eclipse.core.runtime.*; |
|
|
18 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
18 |
import org.eclipse.jdt.core.*; |
19 |
import org.eclipse.jdt.core.*; |
19 |
import org.eclipse.jdt.core.compiler.CategorizedProblem; |
20 |
import org.eclipse.jdt.core.compiler.CategorizedProblem; |
20 |
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; |
21 |
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; |
Lines 28-469
Link Here
|
28 |
|
29 |
|
29 |
public class BuildpathTests extends BuilderTests { |
30 |
public class BuildpathTests extends BuilderTests { |
30 |
|
31 |
|
31 |
public BuildpathTests(String name) { |
32 |
public BuildpathTests(String name) { |
32 |
super(name); |
33 |
super(name); |
33 |
} |
34 |
} |
34 |
|
|
|
35 |
public static Test suite() { |
36 |
return buildTestSuite(BuildpathTests.class); |
37 |
} |
38 |
public void testClasspathFileChange() throws JavaModelException { |
39 |
// create project with src folder, and alternate unused src2 folder |
40 |
IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ |
41 |
env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ |
42 |
IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ |
43 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
44 |
env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ |
45 |
IPath classTest1 = env.addClass(root, "p1", "Test1", //$NON-NLS-1$ //$NON-NLS-2$ |
46 |
"package p1;\n"+ //$NON-NLS-1$ |
47 |
"public class Test1 extends Zork1 {}" //$NON-NLS-1$ |
48 |
); |
49 |
// not yet on the classpath |
50 |
IPath src2Path = env.addFolder(projectPath, "src2"); //$NON-NLS-1$ |
51 |
IPath src2p1Path = env.addFolder(src2Path, "p1"); //$NON-NLS-1$ |
52 |
env.addFile(src2p1Path, "Zork1.java", //$NON-NLS-1$ //$NON-NLS-2$ |
53 |
"package p1;\n"+ //$NON-NLS-1$ |
54 |
"public class Zork1 {}" //$NON-NLS-1$ |
55 |
); |
56 |
|
57 |
fullBuild(); |
58 |
expectingSpecificProblemFor(classTest1, new Problem("src", "Zork1 cannot be resolved to a type", classTest1,39, 44, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
59 |
|
35 |
|
60 |
//---------------------------- |
36 |
public static Test suite() { |
61 |
// Step 2 |
37 |
return buildTestSuite(BuildpathTests.class); |
62 |
//---------------------------- |
38 |
} |
63 |
StringBuffer buffer = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ |
|
|
64 |
buffer.append("<classpath>\n"); //$NON-NLS-1$ |
65 |
buffer.append(" <classpathentry kind=\"src\" path=\"src\"/>\n"); //$NON-NLS-1$ |
66 |
buffer.append(" <classpathentry kind=\"src\" path=\"src2\"/>\n"); // add src2 on classpath through resource change //$NON-NLS-1$ |
67 |
String[] classlibs = Util.getJavaClassLibs(); |
68 |
for (int i = 0; i < classlibs.length; i++) { |
69 |
buffer.append(" <classpathentry kind=\"lib\" path=\"").append(classlibs[i]).append("\"/>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
70 |
} |
71 |
buffer.append(" <classpathentry kind=\"output\" path=\"bin\"/>\n"); //$NON-NLS-1$ |
72 |
buffer.append("</classpath>"); //$NON-NLS-1$ |
73 |
boolean wasAutoBuilding = env.isAutoBuilding(); |
74 |
try { |
75 |
// turn autobuild on |
76 |
env.setAutoBuilding(true); |
77 |
// write new .classpath, will trigger autobuild |
78 |
env.addFile(projectPath, ".classpath", buffer.toString()); //$NON-NLS-1$ |
79 |
// ensures the builder did see the classpath change |
80 |
env.waitForAutoBuild(); |
81 |
expectingNoProblems(); |
82 |
} finally { |
83 |
env.setAutoBuilding(wasAutoBuilding); |
84 |
} |
85 |
} |
86 |
|
39 |
|
87 |
public void testClosedProject() throws JavaModelException { |
40 |
private String getJdkLevelProblem(String expectedRuntime, String path, int severity) { |
88 |
IPath project1Path = env.addProject("CP1"); //$NON-NLS-1$ |
41 |
Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), new Path(path).makeAbsolute(), true); |
89 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
42 |
long libraryJDK = org.eclipse.jdt.internal.core.util.Util.getJdkLevel(target); |
90 |
IPath jarPath = env.addInternalJar(project1Path, "temp.jar", new byte[] {0}); //$NON-NLS-1$ |
43 |
String jclRuntime = CompilerOptions.versionFromJdkLevel(libraryJDK); |
91 |
|
44 |
StringBuffer jdkLevelProblem = new StringBuffer("Problem : Incompatible .class files version in required binaries. Project 'Project' is targeting a "); |
92 |
IPath project2Path = env.addProject("CP2"); //$NON-NLS-1$ |
45 |
jdkLevelProblem.append(expectedRuntime); |
93 |
env.addExternalJars(project2Path, Util.getJavaClassLibs()); |
46 |
jdkLevelProblem.append(" runtime, but is compiled against '"); |
94 |
env.addRequiredProject(project2Path, project1Path); |
47 |
jdkLevelProblem.append(path); |
95 |
|
48 |
jdkLevelProblem.append("' which requires a "); |
96 |
IPath project3Path = env.addProject("CP3"); //$NON-NLS-1$ |
49 |
jdkLevelProblem.append(jclRuntime); |
97 |
env.addExternalJars(project3Path, Util.getJavaClassLibs()); |
50 |
jdkLevelProblem.append(" runtime [ resource : </Project> range : <-1,-1> category : <10> severity : <"); |
98 |
env.addExternalJar(project3Path, jarPath.toString()); |
51 |
jdkLevelProblem.append(severity); |
|
|
52 |
jdkLevelProblem.append(">]"); |
53 |
return jdkLevelProblem.toString(); |
54 |
} |
99 |
|
55 |
|
100 |
fullBuild(); |
56 |
public void testClasspathFileChange() throws JavaModelException { |
101 |
expectingNoProblems(); |
57 |
// create project with src folder, and alternate unused src2 folder |
|
|
58 |
IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ |
59 |
env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ |
60 |
IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ |
61 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
62 |
env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ |
63 |
IPath classTest1 = env.addClass(root, "p1", "Test1", //$NON-NLS-1$ //$NON-NLS-2$ |
64 |
"package p1;\n"+ //$NON-NLS-1$ |
65 |
"public class Test1 extends Zork1 {}" //$NON-NLS-1$ |
66 |
); |
67 |
// not yet on the classpath |
68 |
IPath src2Path = env.addFolder(projectPath, "src2"); //$NON-NLS-1$ |
69 |
IPath src2p1Path = env.addFolder(src2Path, "p1"); //$NON-NLS-1$ |
70 |
env.addFile(src2p1Path, "Zork1.java", //$NON-NLS-1$ //$NON-NLS-2$ |
71 |
"package p1;\n"+ //$NON-NLS-1$ |
72 |
"public class Zork1 {}" //$NON-NLS-1$ |
73 |
); |
102 |
|
74 |
|
103 |
//---------------------------- |
75 |
fullBuild(); |
104 |
// Step 2 |
76 |
expectingSpecificProblemFor(classTest1, new Problem("src", "Zork1 cannot be resolved to a type", classTest1,39, 44, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
105 |
//---------------------------- |
|
|
106 |
env.closeProject(project1Path); |
107 |
|
77 |
|
108 |
incrementalBuild(); |
78 |
//---------------------------- |
109 |
expectingOnlyProblemsFor(new IPath[] {project2Path, project3Path}); |
79 |
// Step 2 |
110 |
expectingOnlySpecificProblemsFor(project2Path, |
80 |
//---------------------------- |
111 |
new Problem[] { |
81 |
StringBuffer buffer = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ |
112 |
new Problem("", "The project cannot be built until build path errors are resolved", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), //$NON-NLS-1$ //$NON-NLS-2$ |
82 |
buffer.append("<classpath>\n"); //$NON-NLS-1$ |
113 |
new Problem("Build path", "Project 'CP2' is missing required Java project: 'CP1'", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
83 |
buffer.append(" <classpathentry kind=\"src\" path=\"src\"/>\n"); //$NON-NLS-1$ |
114 |
} |
84 |
buffer.append(" <classpathentry kind=\"src\" path=\"src2\"/>\n"); // add src2 on classpath through resource change //$NON-NLS-1$ |
115 |
); |
85 |
String[] classlibs = Util.getJavaClassLibs(); |
116 |
expectingOnlySpecificProblemsFor(project3Path, |
86 |
for (int i = 0; i < classlibs.length; i++) { |
117 |
new Problem[] { |
87 |
buffer.append(" <classpathentry kind=\"lib\" path=\"").append(classlibs[i]).append("\"/>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
118 |
new Problem("", "The project cannot be built until build path errors are resolved", project3Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), //$NON-NLS-1$ //$NON-NLS-2$ |
88 |
} |
119 |
new Problem("Build path", "Project 'CP3' is missing required library: '/CP1/temp.jar'", project3Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
89 |
buffer.append(" <classpathentry kind=\"output\" path=\"bin\"/>\n"); //$NON-NLS-1$ |
120 |
} |
90 |
buffer.append("</classpath>"); //$NON-NLS-1$ |
121 |
); |
91 |
boolean wasAutoBuilding = env.isAutoBuilding(); |
|
|
92 |
try { |
93 |
// turn autobuild on |
94 |
env.setAutoBuilding(true); |
95 |
// write new .classpath, will trigger autobuild |
96 |
env.addFile(projectPath, ".classpath", buffer.toString()); //$NON-NLS-1$ |
97 |
// ensures the builder did see the classpath change |
98 |
env.waitForAutoBuild(); |
99 |
expectingNoProblems(); |
100 |
} finally { |
101 |
env.setAutoBuilding(wasAutoBuilding); |
102 |
} |
103 |
} |
104 |
|
105 |
public void testClosedProject() throws JavaModelException { |
106 |
IPath project1Path = env.addProject("CP1"); //$NON-NLS-1$ |
107 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
108 |
IPath jarPath = env.addInternalJar(project1Path, "temp.jar", new byte[] {0}); //$NON-NLS-1$ |
109 |
|
110 |
IPath project2Path = env.addProject("CP2"); //$NON-NLS-1$ |
111 |
env.addExternalJars(project2Path, Util.getJavaClassLibs()); |
112 |
env.addRequiredProject(project2Path, project1Path); |
113 |
|
114 |
IPath project3Path = env.addProject("CP3"); //$NON-NLS-1$ |
115 |
env.addExternalJars(project3Path, Util.getJavaClassLibs()); |
116 |
env.addExternalJar(project3Path, jarPath.toString()); |
122 |
|
117 |
|
123 |
env.openProject(project1Path); |
118 |
fullBuild(); |
124 |
incrementalBuild(); |
119 |
expectingNoProblems(); |
125 |
expectingNoProblems(); |
|
|
126 |
|
120 |
|
127 |
//---------------------------- |
121 |
//---------------------------- |
128 |
// Step 3 |
122 |
// Step 2 |
129 |
//---------------------------- |
123 |
//---------------------------- |
130 |
Hashtable options = JavaCore.getOptions(); |
124 |
env.closeProject(project1Path); |
131 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE); |
|
|
132 |
JavaCore.setOptions(options); |
133 |
env.closeProject(project1Path); |
134 |
|
125 |
|
135 |
incrementalBuild(); |
126 |
incrementalBuild(); |
136 |
expectingOnlyProblemsFor(new IPath[] {project2Path, project3Path}); |
127 |
expectingOnlyProblemsFor(new IPath[] {project2Path, project3Path}); |
137 |
expectingOnlySpecificProblemFor(project2Path, |
128 |
expectingOnlySpecificProblemsFor(project2Path, |
|
|
129 |
new Problem[] { |
130 |
new Problem("", "The project cannot be built until build path errors are resolved", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), //$NON-NLS-1$ //$NON-NLS-2$ |
138 |
new Problem("Build path", "Project 'CP2' is missing required Java project: 'CP1'", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
131 |
new Problem("Build path", "Project 'CP2' is missing required Java project: 'CP1'", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
139 |
); |
132 |
} |
140 |
expectingOnlySpecificProblemFor(project3Path, |
133 |
); |
|
|
134 |
expectingOnlySpecificProblemsFor(project3Path, |
135 |
new Problem[] { |
136 |
new Problem("", "The project cannot be built until build path errors are resolved", project3Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), //$NON-NLS-1$ //$NON-NLS-2$ |
141 |
new Problem("Build path", "Project 'CP3' is missing required library: '/CP1/temp.jar'", project3Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
137 |
new Problem("Build path", "Project 'CP3' is missing required library: '/CP1/temp.jar'", project3Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
142 |
); |
138 |
} |
|
|
139 |
); |
143 |
|
140 |
|
144 |
env.openProject(project1Path); |
141 |
env.openProject(project1Path); |
145 |
incrementalBuild(); |
142 |
incrementalBuild(); |
146 |
expectingNoProblems(); |
143 |
expectingNoProblems(); |
147 |
|
144 |
|
148 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT); |
145 |
//---------------------------- |
149 |
JavaCore.setOptions(options); |
146 |
// Step 3 |
150 |
} |
147 |
//---------------------------- |
|
|
148 |
Hashtable options = JavaCore.getOptions(); |
149 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE); |
150 |
JavaCore.setOptions(options); |
151 |
env.closeProject(project1Path); |
151 |
|
152 |
|
152 |
public void testCorruptBuilder() throws JavaModelException { |
153 |
incrementalBuild(); |
153 |
IPath project1Path = env.addProject("P1"); //$NON-NLS-1$ |
154 |
expectingOnlyProblemsFor(new IPath[] {project2Path, project3Path}); |
154 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
155 |
expectingOnlySpecificProblemFor(project2Path, |
155 |
|
156 |
new Problem("Build path", "Project 'CP2' is missing required Java project: 'CP1'", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
156 |
env.addClass(project1Path, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
157 |
); |
157 |
"package p;" + //$NON-NLS-1$ |
158 |
expectingOnlySpecificProblemFor(project3Path, |
158 |
"public class Test {}" //$NON-NLS-1$ |
159 |
new Problem("Build path", "Project 'CP3' is missing required library: '/CP1/temp.jar'", project3Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
159 |
); |
160 |
); |
160 |
|
161 |
|
161 |
fullBuild(); |
162 |
env.openProject(project1Path); |
162 |
expectingNoProblems(); |
163 |
incrementalBuild(); |
|
|
164 |
expectingNoProblems(); |
163 |
|
165 |
|
164 |
IPath outputFolderPackage = env.getOutputLocation(project1Path).append("p"); //$NON-NLS-1$ |
166 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT); |
165 |
env.removeBinaryClass(outputFolderPackage, "Test"); //$NON-NLS-1$ |
167 |
JavaCore.setOptions(options); |
|
|
168 |
} |
166 |
|
169 |
|
167 |
IPath subTest = env.addClass(project1Path, "", "SubTest", //$NON-NLS-1$ //$NON-NLS-2$ |
170 |
public void testCorruptBuilder() throws JavaModelException { |
168 |
"public class SubTest extends p.Test {}" //$NON-NLS-1$ |
171 |
IPath project1Path = env.addProject("P1"); //$NON-NLS-1$ |
169 |
); |
172 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
|
|
173 |
|
174 |
env.addClass(project1Path, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
175 |
"package p;" + //$NON-NLS-1$ |
176 |
"public class Test {}" //$NON-NLS-1$ |
177 |
); |
170 |
|
178 |
|
171 |
incrementalBuild(); |
179 |
fullBuild(); |
172 |
expectingOnlySpecificProblemFor(subTest, new Problem("", "p.Test cannot be resolved to a type", subTest, 29, 35, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$) |
180 |
expectingNoProblems(); |
173 |
|
181 |
|
174 |
env.addClass(project1Path, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
182 |
IPath outputFolderPackage = env.getOutputLocation(project1Path).append("p"); //$NON-NLS-1$ |
175 |
"package p;" + //$NON-NLS-1$ |
183 |
env.removeBinaryClass(outputFolderPackage, "Test"); //$NON-NLS-1$ |
176 |
"public class Test {}" //$NON-NLS-1$ |
|
|
177 |
); |
178 |
|
184 |
|
179 |
fullBuild(); |
185 |
IPath subTest = env.addClass(project1Path, "", "SubTest", //$NON-NLS-1$ //$NON-NLS-2$ |
180 |
expectingNoProblems(); |
186 |
"public class SubTest extends p.Test {}" //$NON-NLS-1$ |
|
|
187 |
); |
181 |
|
188 |
|
182 |
Hashtable options = JavaCore.getOptions(); |
189 |
incrementalBuild(); |
183 |
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.ENABLED); |
190 |
expectingOnlySpecificProblemFor(subTest, new Problem("", "p.Test cannot be resolved to a type", subTest, 29, 35, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$) |
184 |
JavaCore.setOptions(options); |
|
|
185 |
|
191 |
|
186 |
env.removeBinaryClass(outputFolderPackage, "Test"); //$NON-NLS-1$ |
192 |
env.addClass(project1Path, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
193 |
"package p;" + //$NON-NLS-1$ |
194 |
"public class Test {}" //$NON-NLS-1$ |
195 |
); |
187 |
|
196 |
|
188 |
incrementalBuild(); |
197 |
fullBuild(); |
189 |
expectingNoProblems(); |
198 |
expectingNoProblems(); |
190 |
|
199 |
|
191 |
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.IGNORE); |
200 |
Hashtable options = JavaCore.getOptions(); |
192 |
JavaCore.setOptions(options); |
201 |
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.ENABLED); |
193 |
} |
202 |
JavaCore.setOptions(options); |
194 |
|
203 |
|
195 |
public void testCorruptBuilder2() throws JavaModelException { |
204 |
env.removeBinaryClass(outputFolderPackage, "Test"); //$NON-NLS-1$ |
196 |
IPath project1Path = env.addProject("P1"); //$NON-NLS-1$ |
|
|
197 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
198 |
env.removePackageFragmentRoot(project1Path, ""); //$NON-NLS-1$ |
199 |
IPath src = env.addPackageFragmentRoot(project1Path, "src"); //$NON-NLS-1$ |
200 |
IPath bin = env.setOutputFolder(project1Path, "bin"); //$NON-NLS-1$ |
201 |
|
202 |
env.addClass(src, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
203 |
"package p;" + //$NON-NLS-1$ |
204 |
"public class Test {}" //$NON-NLS-1$ |
205 |
); |
206 |
|
205 |
|
207 |
fullBuild(); |
206 |
incrementalBuild(); |
208 |
expectingNoProblems(); |
207 |
expectingNoProblems(); |
209 |
|
208 |
|
210 |
IPath outputFolderPackage = bin.append("p"); //$NON-NLS-1$ |
209 |
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.IGNORE); |
211 |
env.removeBinaryClass(outputFolderPackage, "Test"); //$NON-NLS-1$ |
210 |
JavaCore.setOptions(options); |
|
|
211 |
} |
212 |
|
212 |
|
213 |
IPath subTest = env.addClass(src, "p2", "SubTest", //$NON-NLS-1$ //$NON-NLS-2$ |
213 |
public void testCorruptBuilder2() throws JavaModelException { |
214 |
"package p2;" + //$NON-NLS-1$ |
214 |
IPath project1Path = env.addProject("P1"); //$NON-NLS-1$ |
215 |
"public class SubTest extends p.Test {}" //$NON-NLS-1$ |
215 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
216 |
); |
216 |
env.removePackageFragmentRoot(project1Path, ""); //$NON-NLS-1$ |
|
|
217 |
IPath src = env.addPackageFragmentRoot(project1Path, "src"); //$NON-NLS-1$ |
218 |
IPath bin = env.setOutputFolder(project1Path, "bin"); //$NON-NLS-1$ |
219 |
|
220 |
env.addClass(src, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
221 |
"package p;" + //$NON-NLS-1$ |
222 |
"public class Test {}" //$NON-NLS-1$ |
223 |
); |
217 |
|
224 |
|
218 |
incrementalBuild(); |
225 |
fullBuild(); |
219 |
expectingOnlySpecificProblemFor(subTest, new Problem("", "p.Test cannot be resolved to a type", subTest, 40, 46, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$) |
226 |
expectingNoProblems(); |
220 |
|
227 |
|
221 |
env.addClass(src, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
228 |
IPath outputFolderPackage = bin.append("p"); //$NON-NLS-1$ |
222 |
"package p;" + //$NON-NLS-1$ |
229 |
env.removeBinaryClass(outputFolderPackage, "Test"); //$NON-NLS-1$ |
223 |
"public class Test {}" //$NON-NLS-1$ |
|
|
224 |
); |
225 |
|
230 |
|
226 |
fullBuild(); |
231 |
IPath subTest = env.addClass(src, "p2", "SubTest", //$NON-NLS-1$ //$NON-NLS-2$ |
227 |
expectingNoProblems(); |
232 |
"package p2;" + //$NON-NLS-1$ |
|
|
233 |
"public class SubTest extends p.Test {}" //$NON-NLS-1$ |
234 |
); |
228 |
|
235 |
|
229 |
Hashtable options = JavaCore.getOptions(); |
236 |
incrementalBuild(); |
230 |
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.ENABLED); |
237 |
expectingOnlySpecificProblemFor(subTest, new Problem("", "p.Test cannot be resolved to a type", subTest, 40, 46, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$) |
231 |
JavaCore.setOptions(options); |
|
|
232 |
|
238 |
|
233 |
env.removeBinaryClass(outputFolderPackage, "Test"); //$NON-NLS-1$ |
239 |
env.addClass(src, "p", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
240 |
"package p;" + //$NON-NLS-1$ |
241 |
"public class Test {}" //$NON-NLS-1$ |
242 |
); |
234 |
|
243 |
|
235 |
incrementalBuild(); |
244 |
fullBuild(); |
236 |
expectingNoProblems(); |
245 |
expectingNoProblems(); |
237 |
|
246 |
|
238 |
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.IGNORE); |
247 |
Hashtable options = JavaCore.getOptions(); |
239 |
JavaCore.setOptions(options); |
248 |
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.ENABLED); |
240 |
} |
249 |
JavaCore.setOptions(options); |
241 |
|
250 |
|
242 |
/* |
251 |
env.removeBinaryClass(outputFolderPackage, "Test"); //$NON-NLS-1$ |
243 |
* Ensures that changing an external jar and refreshing the projects triggers a rebuild |
|
|
244 |
* (regression test for bug 50207 Compile errors fixed by 'refresh' do not reset problem list or package explorer error states) |
245 |
*/ |
246 |
public void testExternalJarChange() throws JavaModelException, IOException { |
247 |
// setup |
248 |
IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ |
249 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
250 |
IPath root = env.getPackageFragmentRootPath(projectPath, ""); //$NON-NLS-1$ |
251 |
IPath classTest = env.addClass(root, "p", "X", //$NON-NLS-1$ //$NON-NLS-2$ |
252 |
"package p;\n"+ //$NON-NLS-1$ |
253 |
"public class X {\n" + //$NON-NLS-1$ |
254 |
" void foo() {\n" + //$NON-NLS-1$ |
255 |
" new q.Y().bar();\n" + //$NON-NLS-1$ |
256 |
" }\n" + //$NON-NLS-1$ |
257 |
"}" //$NON-NLS-1$ |
258 |
); |
259 |
String externalJar = Util.getOutputDirectory() + File.separator + "test.jar"; //$NON-NLS-1$ |
260 |
Util.createJar( |
261 |
new String[] { |
262 |
"q/Y.java", //$NON-NLS-1$ |
263 |
"package q;\n" + //$NON-NLS-1$ |
264 |
"public class Y {\n" + //$NON-NLS-1$ |
265 |
"}" //$NON-NLS-1$ |
266 |
}, |
267 |
new HashMap(), |
268 |
externalJar |
269 |
); |
270 |
long lastModified = new java.io.File(externalJar).lastModified(); |
271 |
env.addExternalJar(projectPath, externalJar); |
272 |
|
273 |
// build -> expecting problems |
274 |
fullBuild(); |
275 |
expectingProblemsFor(classTest); |
276 |
|
277 |
try { |
278 |
Thread.sleep(1000); |
279 |
} catch(InterruptedException e) { |
280 |
} |
281 |
// fix jar |
282 |
Util.createJar( |
283 |
new String[] { |
284 |
"q/Y.java", //$NON-NLS-1$ |
285 |
"package q;\n" + //$NON-NLS-1$ |
286 |
"public class Y {\n" + //$NON-NLS-1$ |
287 |
" public void bar() {\n" + //$NON-NLS-1$ |
288 |
" }\n" + //$NON-NLS-1$ |
289 |
"}" //$NON-NLS-1$ |
290 |
}, |
291 |
new HashMap(), |
292 |
externalJar |
293 |
); |
294 |
|
295 |
new java.io.File(externalJar).setLastModified(lastModified + 1000); // to be sure its different |
296 |
// refresh project and rebuild -> expecting no problems |
297 |
IJavaProject project = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("Project")); //$NON-NLS-1$ |
298 |
project.getJavaModel().refreshExternalArchives(new IJavaElement[] {project}, null); |
299 |
incrementalBuild(); |
300 |
expectingNoProblems(); |
301 |
|
302 |
} |
303 |
|
252 |
|
304 |
public void testMissingBuilder() throws JavaModelException { |
253 |
incrementalBuild(); |
305 |
IPath project1Path = env.addProject("P1"); //$NON-NLS-1$ |
254 |
expectingNoProblems(); |
306 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
|
|
307 |
|
308 |
IPath project2Path = env.addProject("P2"); //$NON-NLS-1$ |
309 |
env.addExternalJars(project2Path, Util.getJavaClassLibs()); |
310 |
env.addRequiredProject(project2Path, project1Path); |
311 |
|
255 |
|
312 |
env.addClass(project1Path, "", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
256 |
options.put(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, JavaCore.IGNORE); |
313 |
"public class Test {}" //$NON-NLS-1$ |
257 |
JavaCore.setOptions(options); |
314 |
); |
258 |
} |
315 |
|
259 |
|
316 |
IPath sub = env.addClass(project2Path, "", "SubTest", //$NON-NLS-1$ //$NON-NLS-2$ |
260 |
/* |
317 |
"public class SubTest extends Test {}" //$NON-NLS-1$ |
261 |
* Ensures that changing an external jar and refreshing the projects triggers a rebuild |
318 |
); |
262 |
* (regression test for bug 50207 Compile errors fixed by 'refresh' do not reset problem list or package explorer error states) |
|
|
263 |
*/ |
264 |
public void testExternalJarChange() throws JavaModelException, IOException { |
265 |
// setup |
266 |
IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ |
267 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
268 |
IPath root = env.getPackageFragmentRootPath(projectPath, ""); //$NON-NLS-1$ |
269 |
IPath classTest = env.addClass(root, "p", "X", //$NON-NLS-1$ //$NON-NLS-2$ |
270 |
"package p;\n"+ //$NON-NLS-1$ |
271 |
"public class X {\n" + //$NON-NLS-1$ |
272 |
" void foo() {\n" + //$NON-NLS-1$ |
273 |
" new q.Y().bar();\n" + //$NON-NLS-1$ |
274 |
" }\n" + //$NON-NLS-1$ |
275 |
"}" //$NON-NLS-1$ |
276 |
); |
277 |
String externalJar = Util.getOutputDirectory() + File.separator + "test.jar"; //$NON-NLS-1$ |
278 |
Util.createJar( |
279 |
new String[] { |
280 |
"q/Y.java", //$NON-NLS-1$ |
281 |
"package q;\n" + //$NON-NLS-1$ |
282 |
"public class Y {\n" + //$NON-NLS-1$ |
283 |
"}" //$NON-NLS-1$ |
284 |
}, |
285 |
new HashMap(), |
286 |
externalJar |
287 |
); |
288 |
long lastModified = new java.io.File(externalJar).lastModified(); |
289 |
env.addExternalJar(projectPath, externalJar); |
290 |
|
291 |
// build -> expecting problems |
292 |
fullBuild(); |
293 |
expectingProblemsFor( |
294 |
classTest, |
295 |
"Problem : The method bar() is undefined for the type Y [ resource : </Project/p/X.java> range : <57,60> category : <50> severity : <2>]" |
296 |
); |
297 |
|
298 |
try { |
299 |
Thread.sleep(1000); |
300 |
} catch(InterruptedException e) { |
301 |
} |
302 |
// fix jar |
303 |
Util.createJar( |
304 |
new String[] { |
305 |
"q/Y.java", //$NON-NLS-1$ |
306 |
"package q;\n" + //$NON-NLS-1$ |
307 |
"public class Y {\n" + //$NON-NLS-1$ |
308 |
" public void bar() {\n" + //$NON-NLS-1$ |
309 |
" }\n" + //$NON-NLS-1$ |
310 |
"}" //$NON-NLS-1$ |
311 |
}, |
312 |
new HashMap(), |
313 |
externalJar |
314 |
); |
315 |
|
316 |
new java.io.File(externalJar).setLastModified(lastModified + 1000); // to be sure its different |
317 |
// refresh project and rebuild -> expecting no problems |
318 |
IJavaProject project = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("Project")); //$NON-NLS-1$ |
319 |
project.getJavaModel().refreshExternalArchives(new IJavaElement[] {project}, null); |
320 |
incrementalBuild(); |
321 |
expectingNoProblems(); |
322 |
|
323 |
} |
319 |
|
324 |
|
320 |
fullBuild(); |
325 |
public void testMissingBuilder() throws JavaModelException { |
321 |
expectingNoProblems(); |
326 |
IPath project1Path = env.addProject("P1"); //$NON-NLS-1$ |
|
|
327 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
328 |
|
329 |
IPath project2Path = env.addProject("P2"); //$NON-NLS-1$ |
330 |
env.addExternalJars(project2Path, Util.getJavaClassLibs()); |
331 |
env.addRequiredProject(project2Path, project1Path); |
322 |
|
332 |
|
323 |
env.removeRequiredProject(project2Path, project1Path); |
333 |
env.addClass(project1Path, "", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
334 |
"public class Test {}" //$NON-NLS-1$ |
335 |
); |
324 |
|
336 |
|
325 |
incrementalBuild(); |
337 |
IPath sub = env.addClass(project2Path, "", "SubTest", //$NON-NLS-1$ //$NON-NLS-2$ |
326 |
expectingOnlySpecificProblemFor(sub, new Problem("", "Test cannot be resolved to a type", sub, 29, 33, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$) |
338 |
"public class SubTest extends Test {}" //$NON-NLS-1$ |
|
|
339 |
); |
327 |
|
340 |
|
328 |
env.addRequiredProject(project2Path, project1Path); |
341 |
fullBuild(); |
|
|
342 |
expectingNoProblems(); |
329 |
|
343 |
|
330 |
try { |
344 |
env.removeRequiredProject(project2Path, project1Path); |
331 |
JavaProject p = (JavaProject) env.getJavaProject(project1Path); |
|
|
332 |
p.deconfigure(); |
333 |
JavaModelManager.getJavaModelManager().setLastBuiltState(p.getProject(), null); |
334 |
} catch (CoreException e) { |
335 |
e.printStackTrace(); |
336 |
} |
337 |
|
345 |
|
338 |
env.addClass(project2Path, "", "SubTest", //$NON-NLS-1$ //$NON-NLS-2$ |
346 |
incrementalBuild(); |
339 |
"public class SubTest extends Test {}" //$NON-NLS-1$ |
347 |
expectingOnlySpecificProblemFor(sub, new Problem("", "Test cannot be resolved to a type", sub, 29, 33, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$) |
340 |
); |
|
|
341 |
|
348 |
|
342 |
incrementalBuild(); |
349 |
env.addRequiredProject(project2Path, project1Path); |
343 |
expectingNoProblems(); |
|
|
344 |
} |
345 |
|
350 |
|
346 |
public void testMissingFieldType() throws JavaModelException { |
351 |
try { |
347 |
IPath projectPath = env.addProject("Project1"); //$NON-NLS-1$ |
352 |
JavaProject p = (JavaProject) env.getJavaProject(project1Path); |
348 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
353 |
p.deconfigure(); |
349 |
IPath root = env.getPackageFragmentRootPath(projectPath, ""); //$NON-NLS-1$ |
354 |
JavaModelManager.getJavaModelManager().setLastBuiltState(p.getProject(), null); |
350 |
env.addClass(root, "p1", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
355 |
} catch (CoreException e) { |
351 |
"package p1;\n"+ //$NON-NLS-1$ |
356 |
e.printStackTrace(); |
352 |
"public class Test {}" //$NON-NLS-1$ |
357 |
} |
353 |
); |
|
|
354 |
|
358 |
|
355 |
fullBuild(); |
359 |
env.addClass(project2Path, "", "SubTest", //$NON-NLS-1$ //$NON-NLS-2$ |
356 |
expectingNoProblems(); |
360 |
"public class SubTest extends Test {}" //$NON-NLS-1$ |
|
|
361 |
); |
357 |
|
362 |
|
358 |
IPath projectPath2 = env.addProject("Project2"); //$NON-NLS-1$ |
363 |
incrementalBuild(); |
359 |
env.addExternalJars(projectPath2, Util.getJavaClassLibs()); |
364 |
expectingNoProblems(); |
360 |
env.addRequiredProject(projectPath2, projectPath); |
365 |
} |
361 |
IPath root2 = env.getPackageFragmentRootPath(projectPath2, ""); //$NON-NLS-1$ |
|
|
362 |
env.addClass(root2, "p2", "Test2", //$NON-NLS-1$ //$NON-NLS-2$ |
363 |
"package p2;\n"+ //$NON-NLS-1$ |
364 |
"public class Test2 {\n" + //$NON-NLS-1$ |
365 |
" public static p1.Test field;\n" + //$NON-NLS-1$ |
366 |
"}" //$NON-NLS-1$ |
367 |
); |
368 |
|
366 |
|
369 |
incrementalBuild(); |
367 |
public void testMissingFieldType() throws JavaModelException { |
370 |
expectingNoProblems(); |
368 |
IPath projectPath = env.addProject("Project1"); //$NON-NLS-1$ |
|
|
369 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
370 |
IPath root = env.getPackageFragmentRootPath(projectPath, ""); //$NON-NLS-1$ |
371 |
env.addClass(root, "p1", "Test", //$NON-NLS-1$ //$NON-NLS-2$ |
372 |
"package p1;\n"+ //$NON-NLS-1$ |
373 |
"public class Test {}" //$NON-NLS-1$ |
374 |
); |
371 |
|
375 |
|
372 |
IPath projectPath3 = env.addProject("Project3"); //$NON-NLS-1$ |
376 |
fullBuild(); |
373 |
env.addExternalJars(projectPath3, Util.getJavaClassLibs()); |
377 |
expectingNoProblems(); |
374 |
env.addRequiredProject(projectPath3, projectPath2); |
|
|
375 |
IPath root3 = env.getPackageFragmentRootPath(projectPath3, ""); //$NON-NLS-1$ |
376 |
env.addClass(root3, "p3", "Test3", //$NON-NLS-1$ //$NON-NLS-2$ |
377 |
"package p3;\n"+ //$NON-NLS-1$ |
378 |
"public class Test3 extends p2.Test2 {\n" + //$NON-NLS-1$ |
379 |
" static Object field;\n" + //$NON-NLS-1$ |
380 |
"}" //$NON-NLS-1$ |
381 |
); |
382 |
|
378 |
|
383 |
incrementalBuild(); |
379 |
IPath projectPath2 = env.addProject("Project2"); //$NON-NLS-1$ |
384 |
expectingNoProblems(); |
380 |
env.addExternalJars(projectPath2, Util.getJavaClassLibs()); |
385 |
} |
381 |
env.addRequiredProject(projectPath2, projectPath); |
|
|
382 |
IPath root2 = env.getPackageFragmentRootPath(projectPath2, ""); //$NON-NLS-1$ |
383 |
env.addClass(root2, "p2", "Test2", //$NON-NLS-1$ //$NON-NLS-2$ |
384 |
"package p2;\n"+ //$NON-NLS-1$ |
385 |
"public class Test2 {\n" + //$NON-NLS-1$ |
386 |
" public static p1.Test field;\n" + //$NON-NLS-1$ |
387 |
"}" //$NON-NLS-1$ |
388 |
); |
386 |
|
389 |
|
387 |
public void testMissingLibrary1() throws JavaModelException { |
390 |
incrementalBuild(); |
388 |
IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ |
391 |
expectingNoProblems(); |
389 |
env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ |
|
|
390 |
IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ |
391 |
IPath bin = env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ |
392 |
IPath classTest1 = env.addClass(root, "p1", "Test1", //$NON-NLS-1$ //$NON-NLS-2$ |
393 |
"package p1;\n"+ //$NON-NLS-1$ |
394 |
"public class Test1 {}" //$NON-NLS-1$ |
395 |
); |
396 |
|
392 |
|
397 |
fullBuild(); |
393 |
IPath projectPath3 = env.addProject("Project3"); //$NON-NLS-1$ |
398 |
expectingOnlyProblemsFor(new IPath[] {projectPath, classTest1}); |
394 |
env.addExternalJars(projectPath3, Util.getJavaClassLibs()); |
399 |
expectingOnlySpecificProblemsFor(projectPath, |
395 |
env.addRequiredProject(projectPath3, projectPath2); |
400 |
new Problem[] { |
396 |
IPath root3 = env.getPackageFragmentRootPath(projectPath3, ""); //$NON-NLS-1$ |
401 |
new Problem("", "The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), //$NON-NLS-1$ //$NON-NLS-2$ |
397 |
env.addClass(root3, "p3", "Test3", //$NON-NLS-1$ //$NON-NLS-2$ |
402 |
new Problem("p1", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest1, 0, 1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
398 |
"package p3;\n"+ //$NON-NLS-1$ |
403 |
} |
399 |
"public class Test3 extends p2.Test2 {\n" + //$NON-NLS-1$ |
404 |
); |
400 |
" static Object field;\n" + //$NON-NLS-1$ |
|
|
401 |
"}" //$NON-NLS-1$ |
402 |
); |
405 |
|
403 |
|
406 |
//---------------------------- |
404 |
incrementalBuild(); |
407 |
// Step 2 |
405 |
expectingNoProblems(); |
408 |
//---------------------------- |
406 |
} |
409 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
|
|
410 |
|
407 |
|
411 |
incrementalBuild(); |
408 |
public void testMissingLibrary1() throws JavaModelException { |
412 |
expectingNoProblems(); |
409 |
IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ |
413 |
expectingPresenceOf(new IPath[]{ |
410 |
env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ |
414 |
bin.append("p1").append("Test1.class"), //$NON-NLS-1$ //$NON-NLS-2$ |
411 |
IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ |
415 |
}); |
412 |
IPath bin = env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ |
416 |
} |
413 |
IPath classTest1 = env.addClass(root, "p1", "Test1", //$NON-NLS-1$ //$NON-NLS-2$ |
417 |
|
414 |
"package p1;\n"+ //$NON-NLS-1$ |
418 |
public void testMissingLibrary2() throws JavaModelException { |
415 |
"public class Test1 {}" //$NON-NLS-1$ |
419 |
IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ |
416 |
); |
420 |
env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ |
|
|
421 |
IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ |
422 |
IPath bin = env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ |
423 |
IPath classTest1 = env.addClass(root, "p1", "Test1", //$NON-NLS-1$ //$NON-NLS-2$ |
424 |
"package p1;\n"+ //$NON-NLS-1$ |
425 |
"public class Test1 {}" //$NON-NLS-1$ |
426 |
); |
427 |
IPath classTest2 = env.addClass(root, "p2", "Test2", //$NON-NLS-1$ //$NON-NLS-2$ |
428 |
"package p2;\n"+ //$NON-NLS-1$ |
429 |
"public class Test2 {}" //$NON-NLS-1$ |
430 |
); |
431 |
IPath classTest3 = env.addClass(root, "p2", "Test3", //$NON-NLS-1$ //$NON-NLS-2$ |
432 |
"package p2;\n"+ //$NON-NLS-1$ |
433 |
"public class Test3 {}" //$NON-NLS-1$ |
434 |
); |
435 |
|
417 |
|
436 |
fullBuild(); |
418 |
fullBuild(); |
437 |
expectingSpecificProblemFor( |
419 |
expectingOnlyProblemsFor(new IPath[] {projectPath, classTest1}); |
438 |
projectPath, |
420 |
expectingOnlySpecificProblemsFor(projectPath, |
439 |
new Problem("", "The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
421 |
new Problem[] { |
440 |
|
422 |
new Problem("", "The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), //$NON-NLS-1$ //$NON-NLS-2$ |
441 |
Problem[] prob1 = env.getProblemsFor(classTest1); |
423 |
new Problem("p1", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest1, 0, 1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
442 |
Problem[] prob2 = env.getProblemsFor(classTest2); |
|
|
443 |
Problem[] prob3 = env.getProblemsFor(classTest3); |
444 |
assertEquals("too many problems", prob1.length + prob2.length + prob3.length, 1); //$NON-NLS-1$ |
445 |
if(prob1.length == 1) { |
446 |
expectingSpecificProblemFor(classTest1, new Problem("p1", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest1, -1, -1, -1, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
447 |
} else if (prob2.length == 1) { |
448 |
expectingSpecificProblemFor(classTest2, new Problem("p2", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest2, -1, -1, -1, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
449 |
} else { |
450 |
expectingSpecificProblemFor(classTest3, new Problem("p2", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest3, 0, 1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
451 |
} |
424 |
} |
|
|
425 |
); |
452 |
|
426 |
|
453 |
//---------------------------- |
427 |
//---------------------------- |
454 |
// Step 2 |
428 |
// Step 2 |
455 |
//---------------------------- |
429 |
//---------------------------- |
456 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
430 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
457 |
|
431 |
|
458 |
incrementalBuild(); |
432 |
incrementalBuild(); |
459 |
expectingNoProblems(); |
433 |
expectingNoProblems(); |
460 |
expectingPresenceOf(new IPath[]{ |
434 |
expectingPresenceOf(new IPath[]{ |
461 |
bin.append("p1").append("Test1.class"), //$NON-NLS-1$ //$NON-NLS-2$ |
435 |
bin.append("p1").append("Test1.class"), //$NON-NLS-1$ //$NON-NLS-2$ |
462 |
bin.append("p2").append("Test2.class"), //$NON-NLS-1$ //$NON-NLS-2$ |
436 |
}); |
463 |
bin.append("p2").append("Test3.class") //$NON-NLS-1$ //$NON-NLS-2$ |
437 |
env.removeProject(projectPath); |
464 |
}); |
438 |
} |
|
|
439 |
|
440 |
public void testMissingLibrary2() throws JavaModelException { |
441 |
IPath projectPath = env.addProject("Project"); //$NON-NLS-1$ |
442 |
env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ |
443 |
IPath root = env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$ |
444 |
IPath bin = env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ |
445 |
IPath classTest1 = env.addClass(root, "p1", "Test1", //$NON-NLS-1$ //$NON-NLS-2$ |
446 |
"package p1;\n"+ //$NON-NLS-1$ |
447 |
"public class Test1 {}" //$NON-NLS-1$ |
448 |
); |
449 |
IPath classTest2 = env.addClass(root, "p2", "Test2", //$NON-NLS-1$ //$NON-NLS-2$ |
450 |
"package p2;\n"+ //$NON-NLS-1$ |
451 |
"public class Test2 {}" //$NON-NLS-1$ |
452 |
); |
453 |
IPath classTest3 = env.addClass(root, "p2", "Test3", //$NON-NLS-1$ //$NON-NLS-2$ |
454 |
"package p2;\n"+ //$NON-NLS-1$ |
455 |
"public class Test3 {}" //$NON-NLS-1$ |
456 |
); |
457 |
|
458 |
fullBuild(); |
459 |
expectingSpecificProblemFor( |
460 |
projectPath, |
461 |
new Problem("", "The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
462 |
|
463 |
Problem[] prob1 = env.getProblemsFor(classTest1); |
464 |
Problem[] prob2 = env.getProblemsFor(classTest2); |
465 |
Problem[] prob3 = env.getProblemsFor(classTest3); |
466 |
assertEquals("too many problems", prob1.length + prob2.length + prob3.length, 1); //$NON-NLS-1$ |
467 |
if(prob1.length == 1) { |
468 |
expectingSpecificProblemFor(classTest1, new Problem("p1", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest1, -1, -1, -1, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
469 |
} else if (prob2.length == 1) { |
470 |
expectingSpecificProblemFor(classTest2, new Problem("p2", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest2, -1, -1, -1, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
471 |
} else { |
472 |
expectingSpecificProblemFor(classTest3, new Problem("p2", "The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files", classTest3, 0, 1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$ |
465 |
} |
473 |
} |
466 |
|
474 |
|
|
|
475 |
//---------------------------- |
476 |
// Step 2 |
477 |
//---------------------------- |
478 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
479 |
|
480 |
incrementalBuild(); |
481 |
expectingNoProblems(); |
482 |
expectingPresenceOf(new IPath[]{ |
483 |
bin.append("p1").append("Test1.class"), //$NON-NLS-1$ //$NON-NLS-2$ |
484 |
bin.append("p2").append("Test2.class"), //$NON-NLS-1$ //$NON-NLS-2$ |
485 |
bin.append("p2").append("Test3.class") //$NON-NLS-1$ //$NON-NLS-2$ |
486 |
}); |
487 |
env.removeProject(projectPath); |
488 |
} |
489 |
|
467 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
490 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
468 |
public void testMissingLibrary3() throws JavaModelException { |
491 |
public void testMissingLibrary3() throws JavaModelException { |
469 |
this.abortOnFailure = false; // this test is failing on some releng boxes => do not abort on failures |
492 |
this.abortOnFailure = false; // this test is failing on some releng boxes => do not abort on failures |
Lines 491-496
Link Here
|
491 |
expectingSpecificProblemFor( |
514 |
expectingSpecificProblemFor( |
492 |
projectPath, |
515 |
projectPath, |
493 |
new Problem("Build path", "Project 'Project' is missing required library: 'lib/dummy.jar'", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); |
516 |
new Problem("Build path", "Project 'Project' is missing required library: 'lib/dummy.jar'", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); |
|
|
517 |
env.removeProject(projectPath); |
494 |
} |
518 |
} |
495 |
|
519 |
|
496 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
520 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
Lines 509-621
Link Here
|
509 |
projectPath, |
533 |
projectPath, |
510 |
new Problem("Build path", "Project 'Project' is missing required library: 'lib/dummy.jar'", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); |
534 |
new Problem("Build path", "Project 'Project' is missing required library: 'lib/dummy.jar'", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR)); |
511 |
project.setOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, CompilerOptions.WARNING); |
535 |
project.setOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, CompilerOptions.WARNING); |
512 |
cleanBuild(); |
536 |
incrementalBuild(); |
513 |
expectingSpecificProblemFor( |
537 |
expectingSpecificProblemFor( |
514 |
projectPath, |
538 |
projectPath, |
515 |
new Problem("Build path", "Project 'Project' is missing required library: 'lib/dummy.jar'", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, |
539 |
new Problem("Build path", "Project 'Project' is missing required library: 'lib/dummy.jar'", projectPath, -1, -1, CategorizedProblem.CAT_BUILDPATH, |
516 |
IMarker.SEVERITY_WARNING)); |
540 |
IMarker.SEVERITY_WARNING)); |
|
|
541 |
env.removeProject(projectPath); |
517 |
} |
542 |
} |
|
|
543 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
544 |
public void testIncompatibleJdkLEvelOnProject() throws JavaModelException { |
545 |
this.abortOnFailure = false; // NOT sure this test will pass on releng boxes => do not abort on failures |
518 |
|
546 |
|
519 |
public void testMissingProject() throws JavaModelException { |
547 |
// Create project |
520 |
IPath project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
548 |
IPath projectPath = env.addProject("Project"); |
521 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
549 |
IJavaProject project = env.getJavaProject(projectPath); |
522 |
|
550 |
String[] classlibs = Util.getJavaClassLibs(); |
523 |
IPath project2Path = env.addProject("MP2"); //$NON-NLS-1$ |
551 |
env.addExternalJars(projectPath, classlibs); |
524 |
env.addExternalJars(project2Path, Util.getJavaClassLibs()); |
552 |
|
525 |
env.addRequiredProject(project2Path, project1Path); |
553 |
// Build it expecting no problem |
|
|
554 |
fullBuild(); |
555 |
expectingNoProblems(); |
556 |
|
557 |
// Build incompatible jdk level problem string |
558 |
String jclPath = project.getPackageFragmentRoot(classlibs[0]).getPath().makeRelative().toString(); |
559 |
String projectRuntime = project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true); |
560 |
|
561 |
// Change project incompatible jdk level preferences to warning, perform incremental build and expect 1 problem |
562 |
project.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, CompilerOptions.WARNING); |
563 |
incrementalBuild(); |
564 |
expectingProblemsFor( |
565 |
projectPath, |
566 |
getJdkLevelProblem(projectRuntime, jclPath, IMarker.SEVERITY_WARNING) |
567 |
); |
526 |
|
568 |
|
|
|
569 |
// Change project incompatible jdk level preferences to error, perform incremental build and expect 2 problems |
570 |
project.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, CompilerOptions.ERROR); |
571 |
incrementalBuild(); |
572 |
expectingProblemsFor( |
573 |
projectPath, |
574 |
"Problem : The project cannot be built until build path errors are resolved [ resource : </Project> range : <-1,-1> category : <10> severity : <2>]\n" + |
575 |
getJdkLevelProblem(projectRuntime, jclPath, IMarker.SEVERITY_ERROR) |
576 |
); |
577 |
|
578 |
// Remove project to avoid side effect on other tests |
579 |
env.removeProject(projectPath); |
580 |
} |
581 |
|
582 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
583 |
public void testIncompatibleJdkLEvelOnWksp() throws JavaModelException { |
584 |
|
585 |
// Save preference |
586 |
JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
587 |
IEclipsePreferences preferences = manager.getInstancePreferences(); |
588 |
String incompatibleJdkLevel = preferences.get(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, null); |
589 |
try { |
590 |
this.abortOnFailure = false; // NOT sure this test will pass on all releng boxes => do not abort on failures |
591 |
|
592 |
// Create project |
593 |
IPath projectPath = env.addProject("Project"); |
594 |
IJavaProject project = env.getJavaProject(projectPath); |
595 |
String[] classlibs = Util.getJavaClassLibs(); |
596 |
env.addExternalJars(projectPath, classlibs); |
597 |
|
598 |
// Build it expecting no problem |
527 |
fullBuild(); |
599 |
fullBuild(); |
528 |
expectingNoProblems(); |
600 |
expectingNoProblems(); |
529 |
|
601 |
|
530 |
//---------------------------- |
602 |
// Build incompatible jdk level problem string |
531 |
// Step 2 |
603 |
String jclPath = project.getPackageFragmentRoot(classlibs[0]).getPath().makeRelative().toString(); |
532 |
//---------------------------- |
604 |
String wkspRuntime = JavaCore.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); |
533 |
env.removeProject(project1Path); |
605 |
|
534 |
|
606 |
// Change workspace incompatible jdk level preferences to warning, perform incremental build and expect 1 problem |
|
|
607 |
preferences.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.WARNING); |
535 |
incrementalBuild(); |
608 |
incrementalBuild(); |
536 |
expectingOnlyProblemsFor(project2Path); |
609 |
expectingProblemsFor( |
537 |
expectingOnlySpecificProblemsFor(project2Path, |
610 |
projectPath, |
538 |
new Problem[] { |
611 |
getJdkLevelProblem(wkspRuntime, jclPath, IMarker.SEVERITY_WARNING) |
539 |
new Problem("", "The project cannot be built until build path errors are resolved", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), //$NON-NLS-1$ //$NON-NLS-2$ |
612 |
); |
540 |
new Problem("Build path", "Project 'MP2' is missing required Java project: 'MP1'", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
613 |
|
541 |
} |
614 |
// Change workspace incompatible jdk level preferences to error, perform incremental build and expect 2 problems |
|
|
615 |
preferences.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.ERROR); |
616 |
incrementalBuild(); |
617 |
expectingProblemsFor( |
618 |
projectPath, |
619 |
"Problem : The project cannot be built until build path errors are resolved [ resource : </Project> range : <-1,-1> category : <10> severity : <2>]\n" + |
620 |
getJdkLevelProblem(wkspRuntime, jclPath, IMarker.SEVERITY_ERROR) |
542 |
); |
621 |
); |
|
|
622 |
|
623 |
// Remove project to avoid side effect on other tests |
624 |
env.removeProject(projectPath); |
625 |
} finally { |
626 |
// Put back workspace preferences same as before running the test |
627 |
if (incompatibleJdkLevel == null) { |
628 |
preferences.remove(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL); |
629 |
} else { |
630 |
preferences.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, incompatibleJdkLevel); |
631 |
} |
632 |
} |
633 |
} |
543 |
|
634 |
|
544 |
project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
635 |
public void testMissingProject() throws JavaModelException { |
545 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
636 |
IPath project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
|
|
637 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
638 |
|
639 |
IPath project2Path = env.addProject("MP2"); //$NON-NLS-1$ |
640 |
env.addExternalJars(project2Path, Util.getJavaClassLibs()); |
641 |
env.addRequiredProject(project2Path, project1Path); |
546 |
|
642 |
|
547 |
incrementalBuild(); |
643 |
fullBuild(); |
548 |
expectingNoProblems(); |
644 |
expectingNoProblems(); |
549 |
|
645 |
|
550 |
//---------------------------- |
646 |
//---------------------------- |
551 |
// Step 3 |
647 |
// Step 2 |
552 |
//---------------------------- |
648 |
//---------------------------- |
553 |
Hashtable options = JavaCore.getOptions(); |
649 |
env.removeProject(project1Path); |
554 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE); |
|
|
555 |
JavaCore.setOptions(options); |
556 |
env.removeProject(project1Path); |
557 |
|
650 |
|
558 |
incrementalBuild(); |
651 |
incrementalBuild(); |
559 |
expectingOnlyProblemsFor(project2Path); |
652 |
expectingOnlyProblemsFor(project2Path); |
560 |
expectingOnlySpecificProblemFor(project2Path, |
653 |
expectingOnlySpecificProblemsFor(project2Path, |
|
|
654 |
new Problem[] { |
655 |
new Problem("", "The project cannot be built until build path errors are resolved", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), //$NON-NLS-1$ //$NON-NLS-2$ |
561 |
new Problem("Build path", "Project 'MP2' is missing required Java project: 'MP1'", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
656 |
new Problem("Build path", "Project 'MP2' is missing required Java project: 'MP1'", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
562 |
); |
657 |
} |
|
|
658 |
); |
563 |
|
659 |
|
564 |
project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
660 |
project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
565 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
661 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
566 |
|
662 |
|
567 |
incrementalBuild(); |
663 |
incrementalBuild(); |
568 |
expectingNoProblems(); |
664 |
expectingNoProblems(); |
569 |
|
665 |
|
570 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT); |
666 |
//---------------------------- |
571 |
JavaCore.setOptions(options); |
667 |
// Step 3 |
572 |
} |
668 |
//---------------------------- |
573 |
|
669 |
Hashtable options = JavaCore.getOptions(); |
574 |
public void testMissingOptionalProject() throws JavaModelException { |
670 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE); |
575 |
IPath project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
671 |
JavaCore.setOptions(options); |
576 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
672 |
env.removeProject(project1Path); |
577 |
|
|
|
578 |
IPath project2Path = env.addProject("MP2"); //$NON-NLS-1$ |
579 |
env.addExternalJars(project2Path, Util.getJavaClassLibs()); |
580 |
env.addRequiredProject(project2Path, project1Path, true/*optional*/); |
581 |
|
673 |
|
582 |
fullBuild(); |
674 |
incrementalBuild(); |
583 |
expectingNoProblems(); |
675 |
expectingOnlyProblemsFor(project2Path); |
|
|
676 |
expectingOnlySpecificProblemFor(project2Path, |
677 |
new Problem("Build path", "Project 'MP2' is missing required Java project: 'MP1'", project2Path, -1, -1, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR) //$NON-NLS-1$ //$NON-NLS-2$ |
678 |
); |
584 |
|
679 |
|
585 |
//---------------------------- |
680 |
project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
586 |
// Step 2 |
681 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
587 |
//---------------------------- |
|
|
588 |
env.removeProject(project1Path); |
589 |
|
682 |
|
590 |
incrementalBuild(); |
683 |
incrementalBuild(); |
591 |
expectingNoProblems(); |
684 |
expectingNoProblems(); |
592 |
|
685 |
|
593 |
project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
686 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT); |
594 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
687 |
JavaCore.setOptions(options); |
|
|
688 |
} |
595 |
|
689 |
|
596 |
incrementalBuild(); |
690 |
public void testMissingOptionalProject() throws JavaModelException { |
597 |
expectingNoProblems(); |
691 |
IPath project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
|
|
692 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
693 |
|
694 |
IPath project2Path = env.addProject("MP2"); //$NON-NLS-1$ |
695 |
env.addExternalJars(project2Path, Util.getJavaClassLibs()); |
696 |
env.addRequiredProject(project2Path, project1Path, true/*optional*/); |
598 |
|
697 |
|
599 |
//---------------------------- |
698 |
fullBuild(); |
600 |
// Step 3 |
699 |
expectingNoProblems(); |
601 |
//---------------------------- |
|
|
602 |
Hashtable options = JavaCore.getOptions(); |
603 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE); |
604 |
JavaCore.setOptions(options); |
605 |
env.removeProject(project1Path); |
606 |
|
700 |
|
607 |
incrementalBuild(); |
701 |
//---------------------------- |
608 |
expectingNoProblems(); |
702 |
// Step 2 |
|
|
703 |
//---------------------------- |
704 |
env.removeProject(project1Path); |
609 |
|
705 |
|
610 |
project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
706 |
incrementalBuild(); |
611 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
707 |
expectingNoProblems(); |
612 |
|
708 |
|
613 |
incrementalBuild(); |
709 |
project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
614 |
expectingNoProblems(); |
710 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
615 |
|
711 |
|
616 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT); |
712 |
incrementalBuild(); |
617 |
JavaCore.setOptions(options); |
713 |
expectingNoProblems(); |
618 |
} |
714 |
|
|
|
715 |
//---------------------------- |
716 |
// Step 3 |
717 |
//---------------------------- |
718 |
Hashtable options = JavaCore.getOptions(); |
719 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE); |
720 |
JavaCore.setOptions(options); |
721 |
env.removeProject(project1Path); |
722 |
|
723 |
incrementalBuild(); |
724 |
expectingNoProblems(); |
725 |
|
726 |
project1Path = env.addProject("MP1"); //$NON-NLS-1$ |
727 |
env.addExternalJars(project1Path, Util.getJavaClassLibs()); |
728 |
|
729 |
incrementalBuild(); |
730 |
expectingNoProblems(); |
731 |
|
732 |
options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT); |
733 |
JavaCore.setOptions(options); |
734 |
} |
619 |
|
735 |
|
620 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=160132 |
736 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=160132 |
621 |
public void test0100() throws JavaModelException { |
737 |
public void test0100() throws JavaModelException { |