Lines 11-26
Link Here
|
11 |
package org.eclipse.jdt.core.tests.model; |
11 |
package org.eclipse.jdt.core.tests.model; |
12 |
|
12 |
|
13 |
import junit.framework.Test; |
13 |
import junit.framework.Test; |
14 |
import junit.framework.TestSuite; |
|
|
15 |
|
14 |
|
16 |
import org.eclipse.core.resources.IFile; |
15 |
import org.eclipse.core.resources.IFile; |
17 |
import org.eclipse.core.runtime.CoreException; |
16 |
import org.eclipse.core.runtime.CoreException; |
18 |
import org.eclipse.core.runtime.NullProgressMonitor; |
17 |
import org.eclipse.core.runtime.NullProgressMonitor; |
19 |
import org.eclipse.jdt.core.IClasspathEntry; |
18 |
import org.eclipse.jdt.core.*; |
20 |
import org.eclipse.jdt.core.IJavaProject; |
19 |
|
21 |
import org.eclipse.jdt.core.IType; |
20 |
|
22 |
import org.eclipse.jdt.core.JavaCore; |
|
|
23 |
import org.eclipse.jdt.core.JavaModelException; |
24 |
/** |
21 |
/** |
25 |
* Test retrieving types by their name. |
22 |
* Test retrieving types by their name. |
26 |
*/ |
23 |
*/ |
Lines 30-36
Link Here
|
30 |
public ClassNameTests(String name) { |
27 |
public ClassNameTests(String name) { |
31 |
super(name); |
28 |
super(name); |
32 |
} |
29 |
} |
33 |
|
30 |
|
|
|
31 |
static { |
32 |
// TESTS_NAMES = new String[] { "testFindSecondaryType02" }; |
33 |
// TESTS_PREFIX = "testFindSecondaryType"; |
34 |
} |
35 |
public static Test suite() { |
36 |
return buildTestSuite(ClassNameTests.class); |
37 |
} |
38 |
|
34 |
/** |
39 |
/** |
35 |
* Tests that a type in a jar with a name ending with $ can be retrieved. |
40 |
* Tests that a type in a jar with a name ending with $ can be retrieved. |
36 |
*/ |
41 |
*/ |
Lines 945-957
Link Here
|
945 |
} |
950 |
} |
946 |
} |
951 |
} |
947 |
|
952 |
|
948 |
public static Test suite() { |
953 |
/** |
949 |
TestSuite suite = new Suite(ClassNameTests.class.getName()); |
954 |
* Bug 36032: JavaProject.findType() fails to find second type in source file |
950 |
suite.addTest(new ClassNameTests("testClassNameWithDollar")); |
955 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=36032" |
951 |
suite.addTest(new ClassNameTests("testFindTypeWithDot")); |
956 |
*/ |
952 |
suite.addTest(new ClassNameTests("testSearchTypeNameInJars")); |
957 |
public void testFindSecondaryType01() throws JavaModelException, CoreException { |
953 |
return suite; |
958 |
try { |
|
|
959 |
IJavaProject javaProject = createJavaProject("P", new String[] {""}, ""); |
960 |
createFolder("/P/test"); |
961 |
createFile( |
962 |
"/P/test/Foo.java", |
963 |
"package test;\n" + |
964 |
"public class Foo {\n" + |
965 |
"}\n" + |
966 |
"class Bar {\n" + |
967 |
"}\n" |
968 |
); |
969 |
IType type = javaProject.findType("test.Foo"); |
970 |
assertTrue("type Foo should exist!", type != null && type.exists()); |
971 |
assertEquals("Expected type 'Foo' NOT found!", |
972 |
"class Foo [in Foo.java [in test [in <project root> [in P]]]]", |
973 |
type.toString() |
974 |
); |
975 |
type = javaProject.findType("test.Bar"); |
976 |
assertTrue("type Bar should exist!", type != null && type.exists()); |
977 |
assertEquals("Expected type 'Bar' NOT found!", |
978 |
"class Bar [in Foo.java [in test [in <project root> [in P]]]]", |
979 |
type.toString() |
980 |
); |
981 |
} finally { |
982 |
deleteProject("P"); |
983 |
} |
984 |
} |
985 |
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=72179 |
986 |
public void testFindSecondaryType02() throws JavaModelException, CoreException { |
987 |
try { |
988 |
IJavaProject javaProject = createJavaProject("P", new String[] {""}, ""); |
989 |
createFolder("/P/p1"); |
990 |
createFile( |
991 |
"/P/p1/jc.java", |
992 |
"package p1;\n" + |
993 |
"class jc008{}\n" + |
994 |
"class jc009{}\n" + |
995 |
"class jc010 extends jc009 {\n" + |
996 |
" jc008 a;\n" + |
997 |
"}\n" |
998 |
); |
999 |
IType type = javaProject.findType("p1", "jc008"); |
1000 |
assertTrue("type 'jc008' should exist!", type != null && type.exists()); |
1001 |
assertEquals("Expected type 'jc008' NOT found!", |
1002 |
"class jc008 [in jc.java [in p1 [in <project root> [in P]]]]", |
1003 |
type.toString() |
1004 |
); |
1005 |
type = javaProject.findType("p1", "jc009"); |
1006 |
assertTrue("type 'jc009' should exist!", type != null && type.exists()); |
1007 |
assertEquals("Expected type 'jc009' NOT found!", |
1008 |
"class jc009 [in jc.java [in p1 [in <project root> [in P]]]]", |
1009 |
type.toString() |
1010 |
); |
1011 |
type = javaProject.findType("p1", "jc010"); |
1012 |
assertTrue("type 'jc010' should exist!", type != null && type.exists()); |
1013 |
assertEquals("Expected type 'jc010' NOT found!", |
1014 |
"class jc010 [in jc.java [in p1 [in <project root> [in P]]]]\n" + |
1015 |
" jc008 a", |
1016 |
type.toString() |
1017 |
); |
1018 |
} finally { |
1019 |
deleteProject("P"); |
1020 |
} |
954 |
} |
1021 |
} |
955 |
|
|
|
956 |
|
1022 |
|
957 |
} |
1023 |
} |