Lines 169-177
Link Here
|
169 |
} |
169 |
} |
170 |
|
170 |
|
171 |
// Test that the same index file is used even after restarting |
171 |
// Test that the same index file is used even after restarting |
172 |
public void _testUseIndexInternalJarAfterRestart() throws IOException, CoreException { |
172 |
public void testUseIndexInternalJarAfterRestart() throws IOException, CoreException { |
173 |
String indexFilePath = getExternalResourcePath("Test.index"); |
173 |
String indexFilePath = getExternalResourcePath("Test.index"); |
174 |
String jarFilePath = "/P/Test.jar"; |
174 |
String jarFilePath = "/P/Test.jar"; |
|
|
175 |
String fullJarPath = getWorkspacePath() + jarFilePath; |
175 |
try { |
176 |
try { |
176 |
IJavaProject p = createJavaProject("P"); |
177 |
IJavaProject p = createJavaProject("P"); |
177 |
createJar(new String[] { |
178 |
createJar(new String[] { |
Lines 179-186
Link Here
|
179 |
"package pkg;\n" + |
180 |
"package pkg;\n" + |
180 |
"public class Test {\n" + |
181 |
"public class Test {\n" + |
181 |
" protected Test(int i) {}\n" + |
182 |
" protected Test(int i) {}\n" + |
182 |
"}"}, jarFilePath); |
183 |
"}"}, fullJarPath); |
183 |
JavaIndexer.generateIndexForJar(jarFilePath, indexFilePath); |
184 |
p.getProject().refreshLocal(1, null); |
|
|
185 |
JavaIndexer.generateIndexForJar(fullJarPath, indexFilePath); |
184 |
long modified = new File(indexFilePath).lastModified(); |
186 |
long modified = new File(indexFilePath).lastModified(); |
185 |
IPath libPath = new Path(jarFilePath); |
187 |
IPath libPath = new Path(jarFilePath); |
186 |
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, "file:///"+indexFilePath); |
188 |
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, "file:///"+indexFilePath); |
Lines 189-205
Link Here
|
189 |
waitUntilIndexesReady(); |
191 |
waitUntilIndexesReady(); |
190 |
|
192 |
|
191 |
search("Test", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); |
193 |
search("Test", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); |
192 |
assertSearchResults("\\P\\Test.jar pkg.Test"); |
194 |
assertSearchResults("Test.jar pkg.Test [No source]"); |
|
|
195 |
java.io.File indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile(); |
196 |
assertEquals(indexFilePath,indexFile.toString()); |
193 |
|
197 |
|
194 |
simulateExitRestart(); |
198 |
simulateExitRestart(); |
195 |
getJavaModel().refreshExternalArchives(null, null); |
|
|
196 |
waitUntilIndexesReady(); |
199 |
waitUntilIndexesReady(); |
197 |
|
200 |
|
198 |
this.resultCollector = new JavaSearchResultCollector(); |
201 |
this.resultCollector = new JavaSearchResultCollector(); |
199 |
search("Test", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); |
202 |
search("Test", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); |
200 |
assertSearchResults("\\P\\Test.jar pkg.Test"); |
203 |
assertSearchResults("Test.jar pkg.Test [No source]"); |
201 |
|
204 |
|
202 |
java.io.File indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile(); |
205 |
indexFile = JavaModelManager.getIndexManager().getIndex(libPath, false, false).getIndexFile(); |
203 |
assertEquals(indexFilePath,indexFile.toString()); |
206 |
assertEquals(indexFilePath,indexFile.toString()); |
204 |
// Ensure that the file is not modified |
207 |
// Ensure that the file is not modified |
205 |
assertEquals(modified, new File(indexFilePath).lastModified()); |
208 |
assertEquals(modified, new File(indexFilePath).lastModified()); |
Lines 593-601
Link Here
|
593 |
} |
596 |
} |
594 |
|
597 |
|
595 |
// Test changing the classpath |
598 |
// Test changing the classpath |
596 |
public void _testChangeClasspathForInternalJar() throws CoreException, IOException { |
599 |
public void testChangeClasspathForInternalJar() throws CoreException, IOException { |
597 |
String indexFilePath = getExternalResourcePath("Test.index"); |
600 |
String indexFilePath = getExternalResourcePath("Test.index"); |
598 |
String jarFilePath = "/P/Test.jar"; |
601 |
String jarFilePath = "/P/Test.jar"; |
|
|
602 |
String fullJarPath = getWorkspacePath() + jarFilePath; |
599 |
try { |
603 |
try { |
600 |
IJavaProject p = createJavaProject("P"); |
604 |
IJavaProject p = createJavaProject("P"); |
601 |
createJar(new String[] { |
605 |
createJar(new String[] { |
Lines 603-610
Link Here
|
603 |
"package pkg;\n" + |
607 |
"package pkg;\n" + |
604 |
"public class Test {\n" + |
608 |
"public class Test {\n" + |
605 |
" protected Test(int i) {}\n" + |
609 |
" protected Test(int i) {}\n" + |
606 |
"}"}, jarFilePath); |
610 |
"}"}, fullJarPath); |
607 |
JavaIndexer.generateIndexForJar(jarFilePath, indexFilePath); |
611 |
JavaIndexer.generateIndexForJar(fullJarPath, indexFilePath); |
608 |
createJar(new String[] { |
612 |
createJar(new String[] { |
609 |
"pkg/Test.java", |
613 |
"pkg/Test.java", |
610 |
"package pkg;\n" + |
614 |
"package pkg;\n" + |
Lines 615-628
Link Here
|
615 |
"package pkg;\n" + |
619 |
"package pkg;\n" + |
616 |
"public class NewTest {\n" + |
620 |
"public class NewTest {\n" + |
617 |
" protected NewTest(int i) {}\n" + |
621 |
" protected NewTest(int i) {}\n" + |
618 |
"}"}, jarFilePath); |
622 |
"}"}, fullJarPath); |
|
|
623 |
p.getProject().refreshLocal(1, null); |
619 |
Path libPath = new Path(jarFilePath); |
624 |
Path libPath = new Path(jarFilePath); |
620 |
|
625 |
|
621 |
IClasspathEntry entry = JavaCore.newLibraryEntry(libPath, null, null, null, null, false); |
626 |
IClasspathEntry entry = JavaCore.newLibraryEntry(libPath, null, null, null, null, false); |
622 |
setClasspath(p, new IClasspathEntry[] {entry}); |
627 |
setClasspath(p, new IClasspathEntry[] {entry}); |
623 |
waitUntilIndexesReady(); |
628 |
waitUntilIndexesReady(); |
624 |
search("NewTest", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); |
629 |
search("NewTest", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); |
625 |
assertSearchResults("\\P\\Test.jar pkg.NewTest"); |
630 |
assertSearchResults("Test.jar pkg.NewTest [No source]"); |
626 |
|
631 |
|
627 |
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, "file:///"+indexFilePath); |
632 |
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, "file:///"+indexFilePath); |
628 |
entry = JavaCore.newLibraryEntry(libPath, null, null, null, new IClasspathAttribute[]{attribute}, false); |
633 |
entry = JavaCore.newLibraryEntry(libPath, null, null, null, new IClasspathAttribute[]{attribute}, false); |
Lines 637-645
Link Here
|
637 |
waitUntilIndexesReady(); |
642 |
waitUntilIndexesReady(); |
638 |
this.resultCollector = new JavaSearchResultCollector(); |
643 |
this.resultCollector = new JavaSearchResultCollector(); |
639 |
search("NewTest", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); |
644 |
search("NewTest", TYPE, DECLARATIONS, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaElement[]{p})); |
640 |
assertSearchResults("\\P\\Test.jar pkg.NewTest"); |
645 |
assertSearchResults("Test.jar pkg.NewTest [No source]"); |
641 |
|
|
|
642 |
|
643 |
} finally { |
646 |
} finally { |
644 |
deleteProject("P"); |
647 |
deleteProject("P"); |
645 |
new File(indexFilePath).delete(); |
648 |
new File(indexFilePath).delete(); |
Lines 766-772
Link Here
|
766 |
} |
769 |
} |
767 |
|
770 |
|
768 |
// Test that it works if the index file is in the jar file |
771 |
// Test that it works if the index file is in the jar file |
769 |
public void _testIndexInJar() throws IOException, CoreException { |
772 |
public void testIndexInJar() throws IOException, CoreException { |
770 |
String indexFilePath = getExternalResourcePath("Test.index"); |
773 |
String indexFilePath = getExternalResourcePath("Test.index"); |
771 |
String jarFilePath = getExternalResourcePath("Test.jar"); |
774 |
String jarFilePath = getExternalResourcePath("Test.jar"); |
772 |
String indexZipPath = getExternalResourcePath("TestIndex.zip"); |
775 |
String indexZipPath = getExternalResourcePath("TestIndex.zip"); |
Lines 783-789
Link Here
|
783 |
|
786 |
|
784 |
IJavaProject p = createJavaProject("P"); |
787 |
IJavaProject p = createJavaProject("P"); |
785 |
Path libPath = new Path(jarFilePath); |
788 |
Path libPath = new Path(jarFilePath); |
786 |
String url = "jar:file:/"+indexZipPath+"!/Test.index"; |
789 |
String url = "jar:file:"+indexZipPath+"!/Test.index"; |
787 |
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, url); |
790 |
IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, url); |
788 |
IClasspathEntry entry = JavaCore.newLibraryEntry(libPath, null, null, null, new IClasspathAttribute[]{attribute}, false); |
791 |
IClasspathEntry entry = JavaCore.newLibraryEntry(libPath, null, null, null, new IClasspathAttribute[]{attribute}, false); |
789 |
setClasspath(p, new IClasspathEntry[] {entry}); |
792 |
setClasspath(p, new IClasspathEntry[] {entry}); |