Lines 77-83
Link Here
|
77 |
|
77 |
|
78 |
//---------------------------- |
78 |
//---------------------------- |
79 |
// Step 2 |
79 |
// Step 2 |
80 |
//---------------------------- |
80 |
//---------------------------- |
81 |
StringBuffer buffer = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ |
81 |
StringBuffer buffer = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$ |
82 |
buffer.append("<classpath>\n"); //$NON-NLS-1$ |
82 |
buffer.append("<classpath>\n"); //$NON-NLS-1$ |
83 |
buffer.append(" <classpathentry kind=\"src\" path=\"src\"/>\n"); //$NON-NLS-1$ |
83 |
buffer.append(" <classpathentry kind=\"src\" path=\"src\"/>\n"); //$NON-NLS-1$ |
Lines 100-106
Link Here
|
100 |
} finally { |
100 |
} finally { |
101 |
env.setAutoBuilding(wasAutoBuilding); |
101 |
env.setAutoBuilding(wasAutoBuilding); |
102 |
} |
102 |
} |
103 |
} |
103 |
} |
104 |
|
104 |
|
105 |
public void testClosedProject() throws JavaModelException { |
105 |
public void testClosedProject() throws JavaModelException { |
106 |
IPath project1Path = env.addProject("CP1"); //$NON-NLS-1$ |
106 |
IPath project1Path = env.addProject("CP1"); //$NON-NLS-1$ |
Lines 287-300
Link Here
|
287 |
); |
287 |
); |
288 |
long lastModified = new java.io.File(externalJar).lastModified(); |
288 |
long lastModified = new java.io.File(externalJar).lastModified(); |
289 |
env.addExternalJar(projectPath, externalJar); |
289 |
env.addExternalJar(projectPath, externalJar); |
290 |
|
290 |
|
291 |
// build -> expecting problems |
291 |
// build -> expecting problems |
292 |
fullBuild(); |
292 |
fullBuild(); |
293 |
expectingProblemsFor( |
293 |
expectingProblemsFor( |
294 |
classTest, |
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>]" |
295 |
"Problem : The method bar() is undefined for the type Y [ resource : </Project/p/X.java> range : <57,60> category : <50> severity : <2>]" |
296 |
); |
296 |
); |
297 |
|
297 |
|
298 |
try { |
298 |
try { |
299 |
Thread.sleep(1000); |
299 |
Thread.sleep(1000); |
300 |
} catch(InterruptedException e) { |
300 |
} catch(InterruptedException e) { |
Lines 312-325
Link Here
|
312 |
new HashMap(), |
312 |
new HashMap(), |
313 |
externalJar |
313 |
externalJar |
314 |
); |
314 |
); |
315 |
|
315 |
|
316 |
new java.io.File(externalJar).setLastModified(lastModified + 1000); // to be sure its different |
316 |
new java.io.File(externalJar).setLastModified(lastModified + 1000); // to be sure its different |
317 |
// refresh project and rebuild -> expecting no problems |
317 |
// refresh project and rebuild -> expecting no problems |
318 |
IJavaProject project = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("Project")); //$NON-NLS-1$ |
318 |
IJavaProject project = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("Project")); //$NON-NLS-1$ |
319 |
project.getJavaModel().refreshExternalArchives(new IJavaElement[] {project}, null); |
319 |
project.getJavaModel().refreshExternalArchives(new IJavaElement[] {project}, null); |
320 |
incrementalBuild(); |
320 |
incrementalBuild(); |
321 |
expectingNoProblems(); |
321 |
expectingNoProblems(); |
322 |
|
322 |
|
323 |
} |
323 |
} |
324 |
|
324 |
|
325 |
public void testMissingBuilder() throws JavaModelException { |
325 |
public void testMissingBuilder() throws JavaModelException { |
Lines 426-432
Link Here
|
426 |
|
426 |
|
427 |
//---------------------------- |
427 |
//---------------------------- |
428 |
// Step 2 |
428 |
// Step 2 |
429 |
//---------------------------- |
429 |
//---------------------------- |
430 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
430 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
431 |
|
431 |
|
432 |
incrementalBuild(); |
432 |
incrementalBuild(); |
Lines 459-465
Link Here
|
459 |
expectingSpecificProblemFor( |
459 |
expectingSpecificProblemFor( |
460 |
projectPath, |
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$ |
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 |
|
462 |
|
463 |
Problem[] prob1 = env.getProblemsFor(classTest1); |
463 |
Problem[] prob1 = env.getProblemsFor(classTest1); |
464 |
Problem[] prob2 = env.getProblemsFor(classTest2); |
464 |
Problem[] prob2 = env.getProblemsFor(classTest2); |
465 |
Problem[] prob3 = env.getProblemsFor(classTest3); |
465 |
Problem[] prob3 = env.getProblemsFor(classTest3); |
Lines 474-480
Link Here
|
474 |
|
474 |
|
475 |
//---------------------------- |
475 |
//---------------------------- |
476 |
// Step 2 |
476 |
// Step 2 |
477 |
//---------------------------- |
477 |
//---------------------------- |
478 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
478 |
env.addExternalJars(projectPath, Util.getJavaClassLibs()); |
479 |
|
479 |
|
480 |
incrementalBuild(); |
480 |
incrementalBuild(); |
Lines 516-522
Link Here
|
516 |
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); |
517 |
env.removeProject(projectPath); |
518 |
} |
518 |
} |
519 |
|
519 |
|
520 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
520 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
521 |
public void testMissingLibrary4() throws JavaModelException { |
521 |
public void testMissingLibrary4() throws JavaModelException { |
522 |
this.abortOnFailure = false; // this test is failing on some releng boxes => do not abort on failures |
522 |
this.abortOnFailure = false; // this test is failing on some releng boxes => do not abort on failures |
Lines 543-580
Link Here
|
543 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
543 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=172345 |
544 |
public void testIncompatibleJdkLEvelOnProject() throws JavaModelException { |
544 |
public void testIncompatibleJdkLEvelOnProject() throws JavaModelException { |
545 |
this.abortOnFailure = false; // NOT sure this test will pass on releng boxes => do not abort on failures |
545 |
this.abortOnFailure = false; // NOT sure this test will pass on releng boxes => do not abort on failures |
546 |
|
546 |
|
547 |
// Create project |
547 |
// Create project |
548 |
IPath projectPath = env.addProject("Project"); |
548 |
IPath projectPath = env.addProject("Project"); |
549 |
IJavaProject project = env.getJavaProject(projectPath); |
549 |
IJavaProject project = env.getJavaProject(projectPath); |
550 |
String[] classlibs = Util.getJavaClassLibs(); |
550 |
String[] classlibs = Util.getJavaClassLibs(); |
551 |
env.addExternalJars(projectPath, classlibs); |
551 |
env.addExternalJars(projectPath, classlibs); |
552 |
|
552 |
Arrays.sort(classlibs); |
|
|
553 |
|
553 |
// Build it expecting no problem |
554 |
// Build it expecting no problem |
554 |
fullBuild(); |
555 |
fullBuild(); |
555 |
expectingNoProblems(); |
556 |
expectingNoProblems(); |
556 |
|
557 |
|
557 |
// Build incompatible jdk level problem string |
558 |
// 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); |
559 |
String projectRuntime = project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true); |
560 |
|
560 |
|
561 |
// Change project incompatible jdk level preferences to warning, perform incremental build and expect 1 problem |
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); |
562 |
project.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, CompilerOptions.WARNING); |
563 |
incrementalBuild(); |
563 |
incrementalBuild(); |
|
|
564 |
StringBuffer buffer = new StringBuffer(); |
565 |
for (int i = 0, max = classlibs.length; i < max; i++) { |
566 |
if (i>0) buffer.append('\n'); |
567 |
buffer.append(getJdkLevelProblem(projectRuntime, project.getPackageFragmentRoot(classlibs[i]).getPath().makeRelative().toString(), IMarker.SEVERITY_WARNING)); |
568 |
} |
569 |
|
564 |
expectingProblemsFor( |
570 |
expectingProblemsFor( |
565 |
projectPath, |
571 |
projectPath, |
566 |
getJdkLevelProblem(projectRuntime, jclPath, IMarker.SEVERITY_WARNING) |
572 |
String.valueOf(buffer) |
567 |
); |
573 |
); |
568 |
|
574 |
|
569 |
// Change project incompatible jdk level preferences to error, perform incremental build and expect 2 problems |
575 |
// 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); |
576 |
project.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, CompilerOptions.ERROR); |
571 |
incrementalBuild(); |
577 |
incrementalBuild(); |
|
|
578 |
|
579 |
buffer = new StringBuffer(); |
580 |
for (int i = 0, max = classlibs.length; i < max; i++) { |
581 |
if (i>0) buffer.append('\n'); |
582 |
buffer.append(getJdkLevelProblem(projectRuntime, project.getPackageFragmentRoot(classlibs[i]).getPath().makeRelative().toString(), IMarker.SEVERITY_ERROR)); |
583 |
} |
572 |
expectingProblemsFor( |
584 |
expectingProblemsFor( |
573 |
projectPath, |
585 |
projectPath, |
574 |
"Problem : The project cannot be built until build path errors are resolved [ resource : </Project> range : <-1,-1> category : <10> severity : <2>]\n" + |
586 |
"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) |
587 |
String.valueOf(buffer) |
576 |
); |
588 |
); |
577 |
|
589 |
|
578 |
// Remove project to avoid side effect on other tests |
590 |
// Remove project to avoid side effect on other tests |
579 |
env.removeProject(projectPath); |
591 |
env.removeProject(projectPath); |
580 |
} |
592 |
} |
Lines 588-625
Link Here
|
588 |
String incompatibleJdkLevel = preferences.get(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, null); |
600 |
String incompatibleJdkLevel = preferences.get(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, null); |
589 |
try { |
601 |
try { |
590 |
this.abortOnFailure = false; // NOT sure this test will pass on all releng boxes => do not abort on failures |
602 |
this.abortOnFailure = false; // NOT sure this test will pass on all releng boxes => do not abort on failures |
591 |
|
603 |
|
592 |
// Create project |
604 |
// Create project |
593 |
IPath projectPath = env.addProject("Project"); |
605 |
IPath projectPath = env.addProject("Project"); |
594 |
IJavaProject project = env.getJavaProject(projectPath); |
606 |
IJavaProject project = env.getJavaProject(projectPath); |
595 |
String[] classlibs = Util.getJavaClassLibs(); |
607 |
String[] classlibs = Util.getJavaClassLibs(); |
596 |
env.addExternalJars(projectPath, classlibs); |
608 |
env.addExternalJars(projectPath, classlibs); |
597 |
|
609 |
|
598 |
// Build it expecting no problem |
610 |
// Build it expecting no problem |
599 |
fullBuild(); |
611 |
fullBuild(); |
600 |
expectingNoProblems(); |
612 |
expectingNoProblems(); |
601 |
|
613 |
|
602 |
// Build incompatible jdk level problem string |
614 |
// Build incompatible jdk level problem string |
603 |
String jclPath = project.getPackageFragmentRoot(classlibs[0]).getPath().makeRelative().toString(); |
|
|
604 |
String wkspRuntime = JavaCore.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); |
615 |
String wkspRuntime = JavaCore.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM); |
605 |
|
616 |
// sort classlibs |
|
|
617 |
Arrays.sort(classlibs); |
606 |
// Change workspace incompatible jdk level preferences to warning, perform incremental build and expect 1 problem |
618 |
// 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); |
619 |
preferences.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.WARNING); |
608 |
incrementalBuild(); |
620 |
incrementalBuild(); |
|
|
621 |
|
622 |
StringBuffer buffer = new StringBuffer(); |
623 |
for (int i = 0, max = classlibs.length; i < max; i++) { |
624 |
if (i>0) buffer.append('\n'); |
625 |
buffer.append(getJdkLevelProblem(wkspRuntime, project.getPackageFragmentRoot(classlibs[i]).getPath().makeRelative().toString(), IMarker.SEVERITY_WARNING)); |
626 |
} |
627 |
|
609 |
expectingProblemsFor( |
628 |
expectingProblemsFor( |
610 |
projectPath, |
629 |
projectPath, |
611 |
getJdkLevelProblem(wkspRuntime, jclPath, IMarker.SEVERITY_WARNING) |
630 |
String.valueOf(buffer) |
612 |
); |
631 |
); |
613 |
|
632 |
|
614 |
// Change workspace incompatible jdk level preferences to error, perform incremental build and expect 2 problems |
633 |
// 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); |
634 |
preferences.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.ERROR); |
616 |
incrementalBuild(); |
635 |
incrementalBuild(); |
|
|
636 |
|
637 |
buffer = new StringBuffer(); |
638 |
for (int i = 0, max = classlibs.length; i < max; i++) { |
639 |
if (i>0) buffer.append('\n'); |
640 |
buffer.append(getJdkLevelProblem(wkspRuntime, project.getPackageFragmentRoot(classlibs[i]).getPath().makeRelative().toString(), IMarker.SEVERITY_ERROR)); |
641 |
} |
642 |
|
617 |
expectingProblemsFor( |
643 |
expectingProblemsFor( |
618 |
projectPath, |
644 |
projectPath, |
619 |
"Problem : The project cannot be built until build path errors are resolved [ resource : </Project> range : <-1,-1> category : <10> severity : <2>]\n" + |
645 |
"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) |
646 |
String.valueOf(buffer) |
621 |
); |
647 |
); |
622 |
|
648 |
|
623 |
// Remove project to avoid side effect on other tests |
649 |
// Remove project to avoid side effect on other tests |
624 |
env.removeProject(projectPath); |
650 |
env.removeProject(projectPath); |
625 |
} finally { |
651 |
} finally { |
Lines 753-764
Link Here
|
753 |
); |
779 |
); |
754 |
fullBuild(); |
780 |
fullBuild(); |
755 |
expectingNoProblems(); |
781 |
expectingNoProblems(); |
756 |
env.addClass(defaultPackagePath, "Y", |
782 |
env.addClass(defaultPackagePath, "Y", |
757 |
"public class Y implements X.Entry.Internal {\n" + |
783 |
"public class Y implements X.Entry.Internal {\n" + |
758 |
" public Internal createEntry() {\n" + |
784 |
" public Internal createEntry() {\n" + |
759 |
" return null;\n" + |
785 |
" return null;\n" + |
760 |
" }\n" + |
786 |
" }\n" + |
761 |
"}"); |
787 |
"}"); |
762 |
incrementalBuild(); |
788 |
incrementalBuild(); |
763 |
expectingNoProblems(); |
789 |
expectingNoProblems(); |
764 |
} |
790 |
} |