Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 25663 Details for
Bug 36032
[plan] JavaProject.findType() fails to find second type in source file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Test cases added to ClassNameTests
v00-model.txt (text/plain), 9.33 KB, created by
Frederic Fusier
on 2005-08-04 08:02:03 EDT
(
hide
)
Description:
Test cases added to ClassNameTests
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2005-08-04 08:02:03 EDT
Size:
9.33 KB
patch
obsolete
>Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java,v >retrieving revision 1.12 >diff -u -r1.12 ASTConverterAST3Test.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java 20 May 2005 11:43:44 -0000 1.12 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java 4 Aug 2005 11:55:18 -0000 >@@ -14,7 +14,6 @@ > import java.util.*; > > import junit.framework.Test; >-import junit.framework.TestSuite; > > import org.eclipse.jdt.core.*; > import org.eclipse.jdt.core.dom.*; >@@ -32,13 +31,11 @@ > super(name); > } > >+ static { >+// TESTS_NUMBERS = new int[] { 356 }; >+ } > public static Test suite() { >- if (true) { >- return new Suite(ASTConverterAST3Test.class); >- } >- TestSuite suite = new Suite(ASTConverterAST3Test.class.getName()); >- suite.addTest(new ASTConverterAST3Test("test0001")); >- return suite; >+ return buildTestSuite(ASTConverterAST3Test.class); > } > > public void test0001() throws JavaModelException { >@@ -8701,14 +8698,27 @@ > assertNotNull("No compilation unit", result); //$NON-NLS-1$ > assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$ > CompilationUnit compilationUnit = (CompilationUnit) result; >- assertEquals("errors found", 2, compilationUnit.getMessages().length); //$NON-NLS-1$ >+ assertEquals("errors found", 1, compilationUnit.getMessages().length); //$NON-NLS-1$ > ASTNode node = getASTNode(compilationUnit, 0, 0, 0); > assertNotNull(node); > assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node; > Type type = variableDeclarationStatement.getType(); > ITypeBinding binding = type.resolveBinding(); >- assertNull(binding); >+ assertNotNull("Binding should NOT be null for type: "+type, binding); >+ >+ // Verify that class instance creation has a null binding >+ List fragments = variableDeclarationStatement.fragments(); >+ assertEquals("Expect only one fragment for VariableDeclarationStatement: "+variableDeclarationStatement, 1, fragments.size()); >+ node = (ASTNode) fragments.get(0); >+ assertEquals("Not a variable declaration fragment", ASTNode.VARIABLE_DECLARATION_FRAGMENT, node.getNodeType()); //$NON-NLS-1$ >+ VariableDeclarationFragment fragment = (VariableDeclarationFragment) node; >+ Expression initializer = fragment.getInitializer(); >+ assertEquals("Expect a class instance creation for initializer: "+initializer, ASTNode.CLASS_INSTANCE_CREATION, initializer.getNodeType()); //$NON-NLS-1$ >+ ClassInstanceCreation instanceCreation = (ClassInstanceCreation) initializer; >+ type = instanceCreation.getType(); >+ binding = type.resolveBinding(); >+ assertNull("Binding should BE null for type: "+type, binding); > } > > /** >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java,v >retrieving revision 1.68 >diff -u -r1.68 ASTConverterTest.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java 20 May 2005 11:43:44 -0000 1.68 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java 4 Aug 2005 11:55:28 -0000 >@@ -14,7 +14,6 @@ > import java.util.*; > > import junit.framework.Test; >-import junit.framework.TestSuite; > > import org.eclipse.core.runtime.Preferences; > import org.eclipse.jdt.core.*; >@@ -34,13 +33,11 @@ > super(name); > } > >+ static { >+// TESTS_NUMBERS = new int[] { 356 }; >+ } > public static Test suite() { >- if (true) { >- return new Suite(ASTConverterTest.class); >- } >- TestSuite suite = new Suite(ASTConverterTest.class.getName()); >- suite.addTest(new ASTConverterTest("test0206")); >- return suite; >+ return buildTestSuite(ASTConverterTest.class); > } > > /** @deprecated using deprecated code */ >@@ -8871,14 +8868,14 @@ > assertNotNull("No compilation unit", result); //$NON-NLS-1$ > assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$ > CompilationUnit compilationUnit = (CompilationUnit) result; >- assertEquals("errors found", 2, compilationUnit.getMessages().length); //$NON-NLS-1$ >+ assertEquals("errors found", 1, compilationUnit.getMessages().length); //$NON-NLS-1$ > ASTNode node = getASTNode(compilationUnit, 0, 0, 0); > assertNotNull(node); > assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node; > Type type = variableDeclarationStatement.getType(); > ITypeBinding binding = type.resolveBinding(); >- assertNull(binding); >+ assertNotNull("Binding should NOT be null for type: "+type, binding); > } > > /** >Index: src/org/eclipse/jdt/core/tests/model/ClassNameTests.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassNameTests.java,v >retrieving revision 1.8 >diff -u -r1.8 ClassNameTests.java >--- src/org/eclipse/jdt/core/tests/model/ClassNameTests.java 23 Feb 2005 02:58:37 -0000 1.8 >+++ src/org/eclipse/jdt/core/tests/model/ClassNameTests.java 4 Aug 2005 11:55:29 -0000 >@@ -11,16 +11,13 @@ > package org.eclipse.jdt.core.tests.model; > > import junit.framework.Test; >-import junit.framework.TestSuite; > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.jdt.core.IClasspathEntry; >-import org.eclipse.jdt.core.IJavaProject; >-import org.eclipse.jdt.core.IType; >-import org.eclipse.jdt.core.JavaCore; >-import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.*; >+ >+ > /** > * Test retrieving types by their name. > */ >@@ -30,7 +27,15 @@ > public ClassNameTests(String name) { > super(name); > } >- >+ >+ static { >+// TESTS_NAMES = new String[] { "testFindSecondaryType02" }; >+// TESTS_PREFIX = "testFindSecondaryType"; >+ } >+ public static Test suite() { >+ return buildTestSuite(ClassNameTests.class); >+ } >+ > /** > * Tests that a type in a jar with a name ending with $ can be retrieved. > */ >@@ -945,13 +950,74 @@ > } > } > >- public static Test suite() { >- TestSuite suite = new Suite(ClassNameTests.class.getName()); >- suite.addTest(new ClassNameTests("testClassNameWithDollar")); >- suite.addTest(new ClassNameTests("testFindTypeWithDot")); >- suite.addTest(new ClassNameTests("testSearchTypeNameInJars")); >- return suite; >+ /** >+ * Bug 36032: JavaProject.findType() fails to find second type in source file >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=36032" >+ */ >+ public void testFindSecondaryType01() throws JavaModelException, CoreException { >+ try { >+ IJavaProject javaProject = createJavaProject("P", new String[] {""}, ""); >+ createFolder("/P/test"); >+ createFile( >+ "/P/test/Foo.java", >+ "package test;\n" + >+ "public class Foo {\n" + >+ "}\n" + >+ "class Bar {\n" + >+ "}\n" >+ ); >+ IType type = javaProject.findType("test.Foo"); >+ assertTrue("type Foo should exist!", type != null && type.exists()); >+ assertEquals("Expected type 'Foo' NOT found!", >+ "class Foo [in Foo.java [in test [in <project root> [in P]]]]", >+ type.toString() >+ ); >+ type = javaProject.findType("test.Bar"); >+ assertTrue("type Bar should exist!", type != null && type.exists()); >+ assertEquals("Expected type 'Bar' NOT found!", >+ "class Bar [in Foo.java [in test [in <project root> [in P]]]]", >+ type.toString() >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+ } >+ // duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=72179 >+ public void testFindSecondaryType02() throws JavaModelException, CoreException { >+ try { >+ IJavaProject javaProject = createJavaProject("P", new String[] {""}, ""); >+ createFolder("/P/p1"); >+ createFile( >+ "/P/p1/jc.java", >+ "package p1;\n" + >+ "class jc008{}\n" + >+ "class jc009{}\n" + >+ "class jc010 extends jc009 {\n" + >+ " jc008 a;\n" + >+ "}\n" >+ ); >+ IType type = javaProject.findType("p1", "jc008"); >+ assertTrue("type 'jc008' should exist!", type != null && type.exists()); >+ assertEquals("Expected type 'jc008' NOT found!", >+ "class jc008 [in jc.java [in p1 [in <project root> [in P]]]]", >+ type.toString() >+ ); >+ type = javaProject.findType("p1", "jc009"); >+ assertTrue("type 'jc009' should exist!", type != null && type.exists()); >+ assertEquals("Expected type 'jc009' NOT found!", >+ "class jc009 [in jc.java [in p1 [in <project root> [in P]]]]", >+ type.toString() >+ ); >+ type = javaProject.findType("p1", "jc010"); >+ assertTrue("type 'jc010' should exist!", type != null && type.exists()); >+ assertEquals("Expected type 'jc010' NOT found!", >+ "class jc010 [in jc.java [in p1 [in <project root> [in P]]]]\n" + >+ " jc008 a", >+ type.toString() >+ ); >+ } finally { >+ deleteProject("P"); >+ } > } >- > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 36032
:
25662
|
25663
|
25676
|
25752
|
30620