Lines 549-558
Link Here
|
549 |
/* |
549 |
/* |
550 |
* Ensures that adding a library entry for an existing external ZIP archive doesn't generate a marker |
550 |
* Ensures that adding a library entry for an existing external ZIP archive doesn't generate a marker |
551 |
*/ |
551 |
*/ |
552 |
public void testAddZIPArchive1() throws CoreException { |
552 |
public void testAddZIPArchive1() throws CoreException, IOException { |
553 |
try { |
553 |
try { |
554 |
IJavaProject p = createJavaProject("P"); |
554 |
IJavaProject p = createJavaProject("P"); |
555 |
createExternalFile("externalLib.abc", ""); |
555 |
org.eclipse.jdt.core.tests.util.Util.createJar( |
|
|
556 |
null, |
557 |
new String[] { |
558 |
"META-INF/MANIFEST.MF", |
559 |
"Manifest-Version: 1.0\n", |
560 |
}, |
561 |
getExternalResourcePath("externalLib.abc"), |
562 |
null, |
563 |
JavaCore.VERSION_1_4); |
556 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)}); |
564 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path(getExternalResourcePath("externalLib.abc")), null, null)}); |
557 |
assertMarkers("Unexpected markers", "", p); |
565 |
assertMarkers("Unexpected markers", "", p); |
558 |
} finally { |
566 |
} finally { |
Lines 564-572
Link Here
|
564 |
/* |
572 |
/* |
565 |
* Ensures that creating a project with a library entry for an existing external ZIP archive doesn't generate a marker |
573 |
* Ensures that creating a project with a library entry for an existing external ZIP archive doesn't generate a marker |
566 |
*/ |
574 |
*/ |
567 |
public void testAddZIPArchive2() throws CoreException { |
575 |
public void testAddZIPArchive2() throws CoreException, IOException { |
568 |
try { |
576 |
try { |
569 |
createExternalFile("externalLib.abc", ""); |
577 |
org.eclipse.jdt.core.tests.util.Util.createJar( |
|
|
578 |
null, |
579 |
new String[] { |
580 |
"META-INF/MANIFEST.MF", |
581 |
"Manifest-Version: 1.0\n", |
582 |
}, |
583 |
getExternalResourcePath("externalLib.abc"), |
584 |
null, |
585 |
JavaCore.VERSION_1_4); |
570 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); |
586 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); |
571 |
assertMarkers("Unexpected markers", "", p); |
587 |
assertMarkers("Unexpected markers", "", p); |
572 |
} finally { |
588 |
} finally { |
Lines 614-626
Link Here
|
614 |
/* |
630 |
/* |
615 |
* Ensures that creating an external ZIP archive referenced by a library entry and refreshing removes the marker |
631 |
* Ensures that creating an external ZIP archive referenced by a library entry and refreshing removes the marker |
616 |
*/ |
632 |
*/ |
617 |
public void testAddZIPArchive5() throws CoreException { |
633 |
public void testAddZIPArchive5() throws CoreException, IOException { |
618 |
try { |
634 |
try { |
619 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); |
635 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); |
620 |
refreshExternalArchives(p); |
636 |
refreshExternalArchives(p); |
621 |
waitForAutoBuild(); |
637 |
waitForAutoBuild(); |
622 |
|
638 |
org.eclipse.jdt.core.tests.util.Util.createJar( |
623 |
createExternalFile("externalLib.abc", ""); |
639 |
null, |
|
|
640 |
new String[] { |
641 |
"META-INF/MANIFEST.MF", |
642 |
"Manifest-Version: 1.0\n", |
643 |
}, |
644 |
getExternalResourcePath("externalLib.abc"), |
645 |
null, |
646 |
JavaCore.VERSION_1_4); |
624 |
refreshExternalArchives(p); |
647 |
refreshExternalArchives(p); |
625 |
assertMarkers("Unexpected markers", "", p); |
648 |
assertMarkers("Unexpected markers", "", p); |
626 |
} finally { |
649 |
} finally { |
Lines 633-645
Link Here
|
633 |
* Ensures that creating an external ZIP archive referenced by a library entry and refreshing after a restart |
656 |
* Ensures that creating an external ZIP archive referenced by a library entry and refreshing after a restart |
634 |
* removes the marker |
657 |
* removes the marker |
635 |
*/ |
658 |
*/ |
636 |
public void testAddZIPArchive6() throws CoreException { |
659 |
public void testAddZIPArchive6() throws CoreException, IOException { |
637 |
try { |
660 |
try { |
638 |
simulateExitRestart(); |
661 |
simulateExitRestart(); |
639 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); |
662 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); |
640 |
refreshExternalArchives(p); |
663 |
refreshExternalArchives(p); |
641 |
|
664 |
org.eclipse.jdt.core.tests.util.Util.createJar( |
642 |
createExternalFile("externalLib.abc", ""); |
665 |
null, |
|
|
666 |
new String[] { |
667 |
"META-INF/MANIFEST.MF", |
668 |
"Manifest-Version: 1.0\n", |
669 |
}, |
670 |
getExternalResourcePath("externalLib.abc"), |
671 |
null, |
672 |
JavaCore.VERSION_1_4); |
643 |
refreshExternalArchives(p); |
673 |
refreshExternalArchives(p); |
644 |
assertMarkers("Unexpected markers", "", p); |
674 |
assertMarkers("Unexpected markers", "", p); |
645 |
} finally { |
675 |
} finally { |
Lines 651-663
Link Here
|
651 |
/* |
681 |
/* |
652 |
* Ensures that adding a library entry for an existing internal ZIP archive doesn't generate a marker |
682 |
* Ensures that adding a library entry for an existing internal ZIP archive doesn't generate a marker |
653 |
*/ |
683 |
*/ |
654 |
public void testAddZIPArchive7() throws CoreException { |
684 |
public void testAddZIPArchive7() throws CoreException, IOException { |
655 |
try { |
685 |
try { |
656 |
IJavaProject p = createJavaProject("P"); |
686 |
IJavaProject p = createJavaProject("P"); |
657 |
refreshExternalArchives(p); |
687 |
refreshExternalArchives(p); |
658 |
waitForAutoBuild(); |
688 |
waitForAutoBuild(); |
659 |
|
689 |
addLibrary(p, "internalLib.abc", null, new String[0], |
660 |
createFile("/P/internalLib.abc", ""); |
690 |
new String[]{"META-INF/MANIFEST.MF", |
|
|
691 |
"Manifest-Version: 1.0\n"} , |
692 |
JavaCore.VERSION_1_4); |
661 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)}); |
693 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/internalLib.abc"), null, null)}); |
662 |
assertMarkers("Unexpected markers", "", p); |
694 |
assertMarkers("Unexpected markers", "", p); |
663 |
} finally { |
695 |
} finally { |
Lines 2729-2735
Link Here
|
2729 |
String externalJarPath = getWorkspaceRoot().getLocation().append("external.jar").toOSString(); |
2761 |
String externalJarPath = getWorkspaceRoot().getLocation().append("external.jar").toOSString(); |
2730 |
try { |
2762 |
try { |
2731 |
IJavaProject p = createJavaProject("P"); |
2763 |
IJavaProject p = createJavaProject("P"); |
2732 |
Util.writeToFile("", externalJarPath); |
2764 |
org.eclipse.jdt.core.tests.util.Util.createJar( |
|
|
2765 |
null, |
2766 |
new String[] { |
2767 |
"META-INF/MANIFEST.MF", |
2768 |
"Manifest-Version: 1.0\n", |
2769 |
}, |
2770 |
externalJarPath, |
2771 |
null, |
2772 |
JavaCore.VERSION_1_4); |
2733 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../external.jar"), null, null)}); |
2773 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("../external.jar"), null, null)}); |
2734 |
assertMarkers( |
2774 |
assertMarkers( |
2735 |
"Unexpected markers", |
2775 |
"Unexpected markers", |
Lines 3122-3129
Link Here
|
3122 |
waitUntilIndexesReady(); |
3162 |
waitUntilIndexesReady(); |
3123 |
waitForAutoBuild(); |
3163 |
waitForAutoBuild(); |
3124 |
// at this point, a marker indicates that test185733.jar has been created: "Project 'P' is missing required library: '[...]\test185733.jar'" |
3164 |
// at this point, a marker indicates that test185733.jar has been created: "Project 'P' is missing required library: '[...]\test185733.jar'" |
3125 |
|
3165 |
org.eclipse.jdt.core.tests.util.Util.createJar( |
3126 |
createFile(new File(getExternalPath()), "test185733.jar", ""); |
3166 |
null, |
|
|
3167 |
new String[] { |
3168 |
"META-INF/MANIFEST.MF", |
3169 |
"Manifest-Version: 1.0\n", |
3170 |
}, |
3171 |
getExternalResourcePath("test185733.jar"), |
3172 |
null, |
3173 |
JavaCore.VERSION_1_4); |
3127 |
refreshExternalArchives(p); |
3174 |
refreshExternalArchives(p); |
3128 |
assertMarkers( |
3175 |
assertMarkers( |
3129 |
"Unexpected markers", |
3176 |
"Unexpected markers", |
Lines 3749-3761
Link Here
|
3749 |
* Ensures that a marker is removed if adding an internal jar that is on the classpath in another project |
3796 |
* Ensures that a marker is removed if adding an internal jar that is on the classpath in another project |
3750 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 ) |
3797 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 ) |
3751 |
*/ |
3798 |
*/ |
3752 |
public void testFixClasspath1() throws CoreException { |
3799 |
public void testFixClasspath1() throws CoreException, IOException { |
3753 |
try { |
3800 |
try { |
3754 |
createProject("P1"); |
3801 |
createProject("P1"); |
3755 |
IJavaProject project = createJavaProject("P2", new String[0], new String[] {"/P1/lib.jar"}, "bin"); |
3802 |
IJavaProject project = createJavaProject("P2", new String[0], new String[0], "bin"); |
3756 |
waitForAutoBuild(); |
3803 |
waitForAutoBuild(); |
3757 |
|
3804 |
addLibrary(project, "lib.jar", null, new String[0], |
3758 |
createFile("/P1/lib.jar", ""); |
3805 |
new String[]{"META-INF/MANIFEST.MF", |
|
|
3806 |
"Manifest-Version: 1.0\n"} , |
3807 |
JavaCore.VERSION_1_4); |
3808 |
|
3759 |
assertMarkers( |
3809 |
assertMarkers( |
3760 |
"Unexpected markers", |
3810 |
"Unexpected markers", |
3761 |
"", |
3811 |
"", |
Lines 3769-3779
Link Here
|
3769 |
* Ensures that a marker is removed if adding an external jar, restarting and refreshing |
3819 |
* Ensures that a marker is removed if adding an external jar, restarting and refreshing |
3770 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=216446 ) |
3820 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=216446 ) |
3771 |
*/ |
3821 |
*/ |
3772 |
public void testFixClasspath2() throws CoreException { |
3822 |
public void testFixClasspath2() throws CoreException, IOException { |
3773 |
try { |
3823 |
try { |
3774 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); |
3824 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); |
3775 |
waitForAutoBuild(); // 1 marker |
3825 |
waitForAutoBuild(); // 1 marker |
3776 |
createExternalFile("externalLib.abc", ""); |
3826 |
org.eclipse.jdt.core.tests.util.Util.createJar( |
|
|
3827 |
null, |
3828 |
new String[] { |
3829 |
"META-INF/MANIFEST.MF", |
3830 |
"Manifest-Version: 1.0\n", |
3831 |
}, |
3832 |
getExternalResourcePath("externalLib.abc"), |
3833 |
null, |
3834 |
JavaCore.VERSION_1_4); |
3777 |
|
3835 |
|
3778 |
simulateExitRestart(); |
3836 |
simulateExitRestart(); |
3779 |
refreshExternalArchives(p); |
3837 |
refreshExternalArchives(p); |
Lines 3939-3949
Link Here
|
3939 |
* Ensures that a file not ending with .jar or .zip can be put on the classpath. |
3997 |
* Ensures that a file not ending with .jar or .zip can be put on the classpath. |
3940 |
* (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 ) |
3998 |
* (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=182360 ) |
3941 |
*/ |
3999 |
*/ |
3942 |
public void testInvalidInternalJar2() throws CoreException { |
4000 |
public void testInvalidInternalJar2() throws CoreException, IOException { |
3943 |
try { |
4001 |
try { |
3944 |
createProject("P1"); |
4002 |
IJavaProject proj = createJavaProject("P1", new String[] {}, new String[0], "bin"); |
3945 |
createFile("/P1/existing.txt", ""); |
4003 |
|
3946 |
IJavaProject proj = createJavaProject("P2", new String[] {}, new String[] {"/P1/existing.txt"}, "bin"); |
4004 |
addLibrary(proj, "existing.txt", null, new String[0], |
|
|
4005 |
new String[]{"META-INF/MANIFEST.MF", |
4006 |
"Manifest-Version: 1.0\n"} , |
4007 |
JavaCore.VERSION_1_4); |
4008 |
proj = createJavaProject("P2", new String[] {}, new String[] {"/P1/existing.txt"}, "bin"); |
3947 |
assertMarkers( |
4009 |
assertMarkers( |
3948 |
"Unexpected markers", |
4010 |
"Unexpected markers", |
3949 |
"", |
4011 |
"", |
Lines 4933-4944
Link Here
|
4933 |
* Ensures that duplicate entries due to resolution are not reported |
4995 |
* Ensures that duplicate entries due to resolution are not reported |
4934 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=175226 ) |
4996 |
* (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=175226 ) |
4935 |
*/ |
4997 |
*/ |
4936 |
public void testDuplicateEntries2() throws CoreException { |
4998 |
public void testDuplicateEntries2() throws CoreException, IOException { |
4937 |
try { |
4999 |
try { |
4938 |
IJavaProject project = createJavaProject("P"); |
5000 |
IJavaProject project = createJavaProject("P"); |
4939 |
VariablesInitializer.setInitializer(new DefaultVariableInitializer(new String[] {"TEST_LIB", "/P/lib.jar"})); |
5001 |
VariablesInitializer.setInitializer(new DefaultVariableInitializer(new String[] {"TEST_LIB", "/P/lib.jar"})); |
4940 |
ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", "/P/lib.jar"})); |
5002 |
ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", "/P/lib.jar"})); |
4941 |
createFile("/P/lib.jar", ""); |
5003 |
addLibrary(project, "lib.jar", null, new String[0], |
|
|
5004 |
new String[]{"META-INF/MANIFEST.MF", |
5005 |
"Manifest-Version: 1.0\n"} , |
5006 |
JavaCore.VERSION_1_4); |
4942 |
editFile( |
5007 |
editFile( |
4943 |
"/P/.classpath", |
5008 |
"/P/.classpath", |
4944 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
5009 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
Lines 4948-4953
Link Here
|
4948 |
" <classpathentry kind=\"output\" path=\"bin\"/>\n" + |
5013 |
" <classpathentry kind=\"output\" path=\"bin\"/>\n" + |
4949 |
"</classpath>" |
5014 |
"</classpath>" |
4950 |
); |
5015 |
); |
|
|
5016 |
waitForAutoBuild(); |
4951 |
assertMarkers( |
5017 |
assertMarkers( |
4952 |
"Unexpected markers", |
5018 |
"Unexpected markers", |
4953 |
"", |
5019 |
"", |
Lines 5497-5509
Link Here
|
5497 |
/* |
5563 |
/* |
5498 |
* Ensures that removing an internal ZIP archive referenced by a library entry creates a marker |
5564 |
* Ensures that removing an internal ZIP archive referenced by a library entry creates a marker |
5499 |
*/ |
5565 |
*/ |
5500 |
public void testRemoveZIPArchive6() throws CoreException { |
5566 |
public void testRemoveZIPArchive6() throws CoreException, IOException { |
5501 |
try { |
5567 |
try { |
5502 |
IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/internalLib.abc"}, ""); |
5568 |
IJavaProject p = createJavaProject("P", new String[0], new String[0], ""); |
5503 |
createFile("/P/internalLib.abc", ""); |
5569 |
|
|
|
5570 |
addLibrary(p, "internalLib.abc", null, new String[0], |
5571 |
new String[]{"META-INF/MANIFEST.MF", |
5572 |
"Manifest-Version: 1.0\n"} , |
5573 |
JavaCore.VERSION_1_4); |
5504 |
waitForAutoBuild(); |
5574 |
waitForAutoBuild(); |
5505 |
|
5575 |
|
5506 |
deleteFile("/P/internalLib.abc"); |
5576 |
deleteFile("/P/internalLib.abc"); |
|
|
5577 |
waitForAutoBuild(); |
5507 |
assertMarkers( |
5578 |
assertMarkers( |
5508 |
"Unexpected markers", |
5579 |
"Unexpected markers", |
5509 |
"Project \'P\' is missing required library: \'internalLib.abc\'", |
5580 |
"Project \'P\' is missing required library: \'internalLib.abc\'", |
Lines 5517-5528
Link Here
|
5517 |
* Ensures that renaming a .jar file and updating the classpath in a PRE_BUILD event doesn't leave markers |
5588 |
* Ensures that renaming a .jar file and updating the classpath in a PRE_BUILD event doesn't leave markers |
5518 |
* (regression test for bug 177922 FlexibleProjectContainer refresh logic sporadically leaves project with "missing library" error on rename/delete) |
5589 |
* (regression test for bug 177922 FlexibleProjectContainer refresh logic sporadically leaves project with "missing library" error on rename/delete) |
5519 |
*/ |
5590 |
*/ |
5520 |
public void testRenameJar() throws CoreException { |
5591 |
public void testRenameJar() throws CoreException, IOException { |
5521 |
IResourceChangeListener listener = null; |
5592 |
IResourceChangeListener listener = null; |
5522 |
try { |
5593 |
try { |
5523 |
final IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/lib/test1.jar"}, ""); |
5594 |
final IJavaProject p = createJavaProject("P", new String[0], new String[0], ""); |
5524 |
createFolder("/P/lib"); |
5595 |
createFolder("/P/lib"); |
5525 |
createFile("/P/lib/test1.jar", ""); |
5596 |
addLibrary(p, "lib/test1.jar", null, new String[0], |
|
|
5597 |
new String[]{"META-INF/MANIFEST.MF", |
5598 |
"Manifest-Version: 1.0\n"} , |
5599 |
JavaCore.VERSION_1_4); |
5526 |
// at this point no markers exist |
5600 |
// at this point no markers exist |
5527 |
|
5601 |
|
5528 |
// register a listener that updates the classpath in a PRE_BUILD event |
5602 |
// register a listener that updates the classpath in a PRE_BUILD event |
Lines 6813-6818
Link Here
|
6813 |
deleteProject("ReferencedProject"); |
6887 |
deleteProject("ReferencedProject"); |
6814 |
} |
6888 |
} |
6815 |
} |
6889 |
} |
6816 |
|
6890 |
/** |
|
|
6891 |
* @bug 229042: [buildpath] could create build path error in case of invalid external JAR format |
6892 |
* |
6893 |
* Test that an invalid archive (JAR) creates a buildpath error |
6894 |
* |
6895 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=229042" |
6896 |
* @throws Exception |
6897 |
*/ |
6898 |
public void testBug229042() throws Exception { |
6899 |
try { |
6900 |
IJavaProject p = createJavaProject("P"); |
6901 |
createFile("/P/library.jar", ""); |
6902 |
setClasspath(p, new IClasspathEntry[] { JavaCore.newLibraryEntry(new Path("/P/library.jar"), null,null)}); |
6903 |
assertMarkers("Unexpected markers", |
6904 |
"Illegal type of archive for required library: \'library.jar\' in project \'P\'", p); |
6905 |
} finally { |
6906 |
deleteExternalResource("library.jar"); |
6907 |
deleteProject("P"); |
6908 |
} |
6909 |
} |
6817 |
|
6910 |
|
6818 |
} |
6911 |
} |