Lines 896-901
Link Here
|
896 |
} |
896 |
} |
897 |
} |
897 |
} |
898 |
|
898 |
|
|
|
899 |
/* |
900 |
* Ensures that a container is not kept in the cache if no longer referenced on the classpath |
901 |
* (regression test for 139446 [build path] bug in the Edit Library dialog box, when changing the default JRE, and switching from alternate JRE to workspace default) |
902 |
*/ |
903 |
public void testContainerInitializer19() throws CoreException { |
904 |
try { |
905 |
// setup |
906 |
ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P1", "/P1/lib1.jar"})); |
907 |
IJavaProject p1 = createJavaProject( |
908 |
"P1", |
909 |
new String[] {}, |
910 |
new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, |
911 |
""); |
912 |
createFile("/P1/lib1.jar", ""); |
913 |
createFile("/P1/lib2.jar", ""); |
914 |
p1.getResolvedClasspath(true); |
915 |
IClasspathEntry[] initialClasspath = p1.getRawClasspath(); |
916 |
|
917 |
// remove reference to container, change initializer, and add reference to container back |
918 |
p1.setRawClasspath(new IClasspathEntry[0], null); |
919 |
ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P1", "/P1/lib2.jar"})); |
920 |
p1.setRawClasspath(initialClasspath, null); |
921 |
|
922 |
assertClasspathEquals( |
923 |
p1.getResolvedClasspath(true), |
924 |
"/P1/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:false]" |
925 |
); |
926 |
} finally { |
927 |
deleteProject("P1"); |
928 |
} |
929 |
} |
930 |
|
931 |
/* |
932 |
* Ensures that container a container is not kept in the cache if no longer referenced on the classpath |
933 |
* (regression test for 136382 [classpath] Discard container if not referenced on classpath) |
934 |
*/ |
935 |
public void testContainerInitializer20() throws CoreException { |
936 |
try { |
937 |
IJavaProject p = createJavaProject("P"); |
938 |
final StringBuffer paths = new StringBuffer(); |
939 |
DefaultContainerInitializer initializer = new DefaultContainerInitializer(new String[] {"P", "/P/lib.jar"}) { |
940 |
public void initialize(IPath containerPath, IJavaProject project) throws CoreException { |
941 |
paths.append(containerPath); |
942 |
paths.append('\n'); |
943 |
super.initialize(containerPath, project); |
944 |
} |
945 |
}; |
946 |
ContainerInitializer.setInitializer(initializer); |
947 |
|
948 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER/JRE1"))}); |
949 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER/JRE2"))}); |
950 |
setClasspath(p, new IClasspathEntry[] {JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER/JRE1"))}); |
951 |
assertStringEquals( |
952 |
"org.eclipse.jdt.core.tests.model.TEST_CONTAINER/JRE1\n" + |
953 |
"org.eclipse.jdt.core.tests.model.TEST_CONTAINER/JRE2\n" + |
954 |
"org.eclipse.jdt.core.tests.model.TEST_CONTAINER/JRE1\n", |
955 |
paths.toString(), |
956 |
false); |
957 |
} finally { |
958 |
stopDeltas(); |
959 |
deleteProject("P"); |
960 |
} |
961 |
} |
962 |
|
899 |
public void testVariableInitializer01() throws CoreException { |
963 |
public void testVariableInitializer01() throws CoreException { |
900 |
try { |
964 |
try { |
901 |
createProject("P1"); |
965 |
createProject("P1"); |