Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2010-06-12 23:52:38 +0000
committerStephan Herrmann2010-06-12 23:52:38 +0000
commit4fabec2afd076049ba0777c9d75bc63a2f06b86d (patch)
tree075771a32295dbb2a64568a27297dff06021a020 /testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests
parent3d9066f75cfa4b17d12af7b64e1057eed6b8424d (diff)
downloadorg.eclipse.objectteams-4fabec2afd076049ba0777c9d75bc63a2f06b86d.tar.gz
org.eclipse.objectteams-4fabec2afd076049ba0777c9d75bc63a2f06b86d.tar.xz
org.eclipse.objectteams-4fabec2afd076049ba0777c9d75bc63a2f06b86d.zip
Test & fix for Bug 316666 - [dom] IllegalArgumentException in very broken source
Diffstat (limited to 'testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests')
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java98
2 files changed, 101 insertions, 1 deletions
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java
index f8ceafdbe..89951ecb9 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java
@@ -62,7 +62,9 @@ public class AllTests extends TestCase
RoleTypeDeclarationTest.class,
TSuperConstructorInvocationTest.class,
TSuperMessageSendTest.class,
- WithinStatementTest.class
+ WithinStatementTest.class,
+
+ DOMRegressionTests.class
};
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java
new file mode 100644
index 000000000..708d7e864
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java
@@ -0,0 +1,98 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2010 Stephan Herrmann.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * $Id$
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Stephan Herrmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.ui.tests.dom.converter;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
+
+public class DOMRegressionTests extends FileBasedDOMTest {
+
+ public static final String TEST_PROJECT = "DOM_AST";
+ private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS3;
+
+
+ public DOMRegressionTests(String name) {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new Suite(DOMRegressionTests.class);
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir(TEST_PROJECT);
+ super.setUpSuite();
+
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ // Bug 316666 - [dom] IllegalArgumentException in very broken source
+ public void testBug316666() throws JavaModelException {
+ ICompilationUnit teamClass = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "regression.bug316666",
+ "MyTeam.java");
+ ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
+ parser.setProject(getJavaProject(TEST_PROJECT));
+ parser.setSource(teamClass);
+ parser.setResolveBindings(true);
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
+ CompilationUnit compUnit = (CompilationUnit) root;
+ TypeDeclaration topTeam = (TypeDeclaration) compUnit.types().get(0);
+ TypeDeclaration nestedTeam = (TypeDeclaration) topTeam.getTypes()[1];
+ // note: the bug was related to mistakenly converted generated fields.
+ assertEquals("No fields expected",nestedTeam.getFields().length, 0);
+ }
+
+ // version with somewhat repaired structure in the source file (similar(?) to what the parser actually saw):
+ public void testBug316666_repaired() throws JavaModelException {
+ ICompilationUnit teamClass = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "regression.bug316666",
+ "MyTeamRepaired.java");
+ ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
+ parser.setProject(getJavaProject(TEST_PROJECT));
+ parser.setSource(teamClass);
+ parser.setResolveBindings(true);
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
+ CompilationUnit compUnit = (CompilationUnit) root;
+ TypeDeclaration topTeam = (TypeDeclaration) compUnit.types().get(0);
+ TypeDeclaration nestedTeam = (TypeDeclaration) topTeam.getTypes()[0];
+ // note: the bug was related to mistakenly converted generated fields.
+ assertEquals("No fields expected",nestedTeam.getFields().length, 0);
+ }
+
+}

Back to the top