Lines 89-95
Link Here
|
89 |
static { |
89 |
static { |
90 |
// Names of tests to run: can be "testBugXXXX" or "BugXXXX") |
90 |
// Names of tests to run: can be "testBugXXXX" or "BugXXXX") |
91 |
// TESTS_PREFIX = "testClasspathDuplicateExtraAttribute"; |
91 |
// TESTS_PREFIX = "testClasspathDuplicateExtraAttribute"; |
92 |
// TESTS_NAMES = new String[] {"testClasspathValidation42"}; |
92 |
// TESTS_NAMES = new String[] {"testBug304081"}; |
93 |
// TESTS_NUMBERS = new int[] { 23, 28, 38 }; |
93 |
// TESTS_NUMBERS = new int[] { 23, 28, 38 }; |
94 |
// TESTS_RANGE = new int[] { 21, 38 }; |
94 |
// TESTS_RANGE = new int[] { 21, 38 }; |
95 |
} |
95 |
} |
Lines 4881-4887
Link Here
|
4881 |
*/ |
4881 |
*/ |
4882 |
public void testNoResourceChange06() throws CoreException { |
4882 |
public void testNoResourceChange06() throws CoreException { |
4883 |
ILogListener listener = new ILogListener(){ |
4883 |
ILogListener listener = new ILogListener(){ |
4884 |
private StringBuffer buffer = new StringBuffer(); |
4884 |
private final StringBuffer buffer = new StringBuffer(); |
4885 |
public void logging(IStatus status, String plugin) { |
4885 |
public void logging(IStatus status, String plugin) { |
4886 |
this.buffer.append(status); |
4886 |
this.buffer.append(status); |
4887 |
this.buffer.append('\n'); |
4887 |
this.buffer.append('\n'); |
Lines 6427-6431
Link Here
|
6427 |
deleteProject("P"); |
6427 |
deleteProject("P"); |
6428 |
} |
6428 |
} |
6429 |
} |
6429 |
} |
|
|
6430 |
/** |
6431 |
* @bug 304081:IJavaProject#isOnClasspath(IJavaElement) returns false for type from referenced JAR |
6432 |
* When the JAR, which a variable classpath entry resolves to, references other JAR via |
6433 |
* MANIFEST, test that {@link IJavaProject#isOnClasspath(IJavaElement)} returns true |
6434 |
* for the referenced classpath entries. |
6435 |
* |
6436 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304081" |
6437 |
* @throws Exception |
6438 |
*/ |
6439 |
public void testBug304081() throws Exception { |
6440 |
File libDir = null; |
6441 |
try { |
6442 |
|
6443 |
IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); |
6444 |
IPath libPath = proj.getResource().getLocation(); |
6445 |
JavaCore.setClasspathVariable("MyVar", libPath, null); |
6446 |
libDir = new File(libPath.toPortableString()); |
6447 |
IClasspathEntry[] classpath = new IClasspathEntry[1]; |
6448 |
File libJar = new File(libDir, "variable.jar"); |
6449 |
libJar.createNewFile(); |
6450 |
|
6451 |
addLibrary(proj, "variable.jar", null, new String[0], |
6452 |
new String[] { |
6453 |
"META-INF/MANIFEST.MF", |
6454 |
"Manifest-Version: 1.0\n" + |
6455 |
"Class-Path: lib1.jar\n", |
6456 |
}, |
6457 |
JavaCore.VERSION_1_4); |
6458 |
|
6459 |
createFile("/P/lib1.jar", ""); |
6460 |
|
6461 |
classpath[0] = JavaCore.newVariableEntry(new Path( |
6462 |
"/MyVar/variable.jar"), null, null); |
6463 |
|
6464 |
proj.setRawClasspath(classpath, null); |
6465 |
waitForAutoBuild(); |
6466 |
IProject project = getWorkspaceRoot().getProject("P"); |
6467 |
IResource resource = project.getFile("variable.jar"); |
6468 |
assertTrue(proj.isOnClasspath(resource)); |
6469 |
IJavaElement element = proj.getPackageFragmentRoot(resource); |
6470 |
assertTrue(proj.isOnClasspath(element)); |
6471 |
|
6472 |
resource = project.getFile("lib1.jar"); |
6473 |
assertTrue(proj.isOnClasspath(resource)); |
6474 |
element = proj.getPackageFragmentRoot(resource); |
6475 |
assertTrue(proj.isOnClasspath(element)); |
6476 |
} finally { |
6477 |
this.deleteProject("P"); |
6478 |
JavaCore.removeClasspathVariable("MyVar", null); |
6479 |
} |
6480 |
} |
6481 |
/** |
6482 |
* Additional tests for 304081 |
6483 |
* When the JAR, which is in the raw classpath, references other JAR via |
6484 |
* MANIFEST, test that {@link IJavaProject#isOnClasspath(IJavaElement)} returns true |
6485 |
* for the referenced classpath entries. |
6486 |
* |
6487 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304081" |
6488 |
* @throws Exception |
6489 |
*/ |
6490 |
public void testBug304081a() throws Exception { |
6491 |
try { |
6492 |
|
6493 |
IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); |
6494 |
IClasspathEntry[] classpath = new IClasspathEntry[1]; |
6495 |
|
6496 |
addLibrary(proj, "library.jar", null, new String[0], |
6497 |
new String[] { |
6498 |
"META-INF/MANIFEST.MF", |
6499 |
"Manifest-Version: 1.0\n" + |
6500 |
"Class-Path: lib1.jar\n", |
6501 |
}, |
6502 |
JavaCore.VERSION_1_4); |
6503 |
createFile("/P/lib1.jar", ""); |
6504 |
classpath[0] = JavaCore.newLibraryEntry(new Path("/P/library.jar"), null, null); |
6505 |
|
6506 |
proj.setRawClasspath(classpath, null); |
6507 |
waitForAutoBuild(); |
6508 |
IProject project = getWorkspaceRoot().getProject("P"); |
6509 |
IResource resource = project.getFile("library.jar"); |
6510 |
assertTrue(proj.isOnClasspath(resource)); |
6511 |
IJavaElement element = proj.getPackageFragmentRoot(resource); |
6512 |
assertTrue(proj.isOnClasspath(element)); |
6513 |
|
6514 |
resource = project.getFile("lib1.jar"); |
6515 |
assertTrue(proj.isOnClasspath(resource)); |
6516 |
element = proj.getPackageFragmentRoot(resource); |
6517 |
assertTrue(proj.isOnClasspath(element)); |
6518 |
} finally { |
6519 |
this.deleteProject("P"); |
6520 |
} |
6521 |
} |
6522 |
/** |
6523 |
* Additional tests for 304081 |
6524 |
* When the JAR, which is part of a classpath container, references other JAR via |
6525 |
* MANIFEST, test that {@link IJavaProject#isOnClasspath(IJavaElement)} returns true |
6526 |
* for the referenced classpath entries. |
6527 |
* |
6528 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304081" |
6529 |
* @throws Exception |
6530 |
*/ |
6531 |
public void testBug304081b() throws Exception { |
6532 |
File libDir = null; |
6533 |
try { |
6534 |
|
6535 |
IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); |
6536 |
IClasspathEntry[] classpath = new IClasspathEntry[1]; |
6537 |
File libJar = new File(libDir, "container.jar"); |
6538 |
|
6539 |
addLibrary(proj, "container.jar", null, new String[0], |
6540 |
new String[] { |
6541 |
"META-INF/MANIFEST.MF", |
6542 |
"Manifest-Version: 1.0\n" + |
6543 |
"Class-Path: lib1.jar\n", |
6544 |
}, |
6545 |
JavaCore.VERSION_1_4); |
6546 |
createFile("/P/lib1.jar", ""); |
6547 |
|
6548 |
ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(JavaCore.USER_LIBRARY_CONTAINER_ID); |
6549 |
String libraryName = "TestUserLibrary"; |
6550 |
IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID); |
6551 |
UserLibraryClasspathContainer containerSuggestion = new UserLibraryClasspathContainer(libraryName); |
6552 |
initializer.requestClasspathContainerUpdate(containerPath.append(libraryName), null, containerSuggestion); |
6553 |
|
6554 |
IEclipsePreferences preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID); |
6555 |
String propertyName = JavaModelManager.CP_USERLIBRARY_PREFERENCES_PREFIX+"TestUserLibrary"; |
6556 |
StringBuffer propertyValue = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<userlibrary systemlibrary=\"false\" version=\"1\">\r\n<archive"); |
6557 |
propertyValue.append(" path=\"" + libJar.getAbsolutePath()); |
6558 |
propertyValue.append("\"/>\r\n</userlibrary>\r\n"); |
6559 |
preferences.put(propertyName, propertyValue.toString()); |
6560 |
preferences.flush(); |
6561 |
|
6562 |
classpath[0] = JavaCore.newContainerEntry(containerSuggestion.getPath()); |
6563 |
|
6564 |
proj.setRawClasspath(classpath, null); |
6565 |
waitForAutoBuild(); |
6566 |
IProject project = getWorkspaceRoot().getProject("P"); |
6567 |
IResource resource = project.getFile("container.jar"); |
6568 |
assertTrue(proj.isOnClasspath(resource)); |
6569 |
IJavaElement element = proj.getPackageFragmentRoot(resource); |
6570 |
assertTrue(proj.isOnClasspath(element)); |
6571 |
|
6572 |
resource = project.getFile("lib1.jar"); |
6573 |
assertTrue(proj.isOnClasspath(resource)); |
6574 |
element = proj.getPackageFragmentRoot(resource); |
6575 |
assertTrue(proj.isOnClasspath(element)); |
6576 |
|
6577 |
} finally { |
6578 |
this.deleteProject("P"); |
6579 |
} |
6580 |
} |
6430 |
|
6581 |
|
6431 |
} |
6582 |
} |