Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-01-14 22:11:50 +0000
committerBrian Vosburgh2016-01-14 22:11:50 +0000
commit1299e5e061febdba053f82871f277a8ba0670e66 (patch)
tree8086226efcd96f63b1e539091e7402071d42c1a0 /common/tests
parent7a014a1a25c8d452ffb7ac19a74991c2ee80647e (diff)
downloadwebtools.dali-1299e5e061febdba053f82871f277a8ba0670e66.tar.gz
webtools.dali-1299e5e061febdba053f82871f277a8ba0670e66.tar.xz
webtools.dali-1299e5e061febdba053f82871f277a8ba0670e66.zip
[468637] fix StackOverflowError when type hierarchy has a cycle
Diffstat (limited to 'common/tests')
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JDTToolsTests.java65
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java5
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/TypeToolsTests.java63
3 files changed, 65 insertions, 68 deletions
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JDTToolsTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JDTToolsTests.java
deleted file mode 100644
index 9dd9abe400..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JDTToolsTests.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. 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
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import java.util.AbstractCollection;
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Vector;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jpt.common.core.internal.utility.TypeTools;
-
-
-public class JDTToolsTests
- extends AnnotationTestCase {
-
- public JDTToolsTests(String name) {
- super(name);
- }
-
-
- public void testTypeIsSubtype() throws Exception {
- IJavaProject jProj = this.getJavaProject();
-
- // same type
- assertTrue(TypeTools.isSubType(ArrayList.class.getName(), ArrayList.class.getName(), jProj));
- assertTrue(TypeTools.isSubType(List.class.getName(), List.class.getName(), jProj));
-
- // concrete type is subtype of interface
- assertTrue(TypeTools.isSubType(ArrayList.class.getName(), List.class.getName(), jProj));
- assertTrue(TypeTools.isSubType(TreeSet.class.getName(), Iterable.class.getName(), jProj));
-
- // concrete type is not subtype of interface
- assertFalse(TypeTools.isSubType(ArrayList.class.getName(), Map.class.getName(), jProj));
- assertFalse(TypeTools.isSubType(TreeSet.class.getName(), Map.class.getName(), jProj));
-
- // interface is subtype of interface
- assertTrue(TypeTools.isSubType(List.class.getName(), Collection.class.getName(), jProj));
- assertTrue(TypeTools.isSubType(SortedSet.class.getName(), Iterable.class.getName(), jProj));
-
- // interface is not subtype of interface
- assertFalse(TypeTools.isSubType(List.class.getName(), Map.class.getName(), jProj));
- assertFalse(TypeTools.isSubType(SortedSet.class.getName(), Map.class.getName(), jProj));
-
- // concrete type is subtype of concrete type
- assertTrue(TypeTools.isSubType(ArrayList.class.getName(), AbstractList.class.getName(), jProj));
- assertTrue(TypeTools.isSubType(LinkedList.class.getName(), AbstractCollection.class.getName(), jProj));
-
- // concrete type is not subtype of concrete type
- assertFalse(TypeTools.isSubType(ArrayList.class.getName(), Vector.class.getName(), jProj));
- assertFalse(TypeTools.isSubType(LinkedList.class.getName(), Vector.class.getName(), jProj));
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java
index 0f485953b4..f735366cc9 100644
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java
+++ b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2016 Oracle. 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.
@@ -19,12 +19,12 @@ public class JptCommonCoreUtilityJdtTests {
suite.addTestSuite(CombinationIndexedDeclarationAnnotationAdapterTests.class);
suite.addTestSuite(DefaultAnnotationEditFormatterTests.class);
suite.addTestSuite(ASTToolsTests.class);
- suite.addTestSuite(JDTToolsTests.class);
suite.addTestSuite(MemberAnnotationElementAdapterTests.class);
suite.addTestSuite(NestedDeclarationAnnotationAdapterTests.class);
suite.addTestSuite(NestedIndexedDeclarationAnnotationAdapterTests.class);
suite.addTestSuite(SimpleDeclarationAnnotationAdapterTests.class);
suite.addTestSuite(TypeTests.class);
+ suite.addTestSuite(TypeToolsTests.class);
return suite;
}
@@ -32,5 +32,4 @@ public class JptCommonCoreUtilityJdtTests {
super();
throw new UnsupportedOperationException();
}
-
}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/TypeToolsTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/TypeToolsTests.java
new file mode 100644
index 0000000000..39fd459c34
--- /dev/null
+++ b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/TypeToolsTests.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2016 Oracle. 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
+
+import java.util.AbstractCollection;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Vector;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jpt.common.core.internal.utility.TypeTools;
+
+public class TypeToolsTests
+ extends AnnotationTestCase
+{
+ public TypeToolsTests(String name) {
+ super(name);
+ }
+
+ public void testIsSubtypeOf() throws Exception {
+ IJavaProject jProj = this.getJavaProject();
+
+ // same type
+ assertTrue(TypeTools.isSubTypeOf(ArrayList.class.getName(), ArrayList.class.getName(), jProj));
+ assertTrue(TypeTools.isSubTypeOf(List.class.getName(), List.class.getName(), jProj));
+
+ // concrete type is subtype of interface
+ assertTrue(TypeTools.isSubTypeOf(ArrayList.class.getName(), List.class.getName(), jProj));
+ assertTrue(TypeTools.isSubTypeOf(TreeSet.class.getName(), Iterable.class.getName(), jProj));
+
+ // concrete type is not subtype of interface
+ assertFalse(TypeTools.isSubTypeOf(ArrayList.class.getName(), Map.class.getName(), jProj));
+ assertFalse(TypeTools.isSubTypeOf(TreeSet.class.getName(), Map.class.getName(), jProj));
+
+ // interface is subtype of interface
+ assertTrue(TypeTools.isSubTypeOf(List.class.getName(), Collection.class.getName(), jProj));
+ assertTrue(TypeTools.isSubTypeOf(SortedSet.class.getName(), Iterable.class.getName(), jProj));
+
+ // interface is not subtype of interface
+ assertFalse(TypeTools.isSubTypeOf(List.class.getName(), Map.class.getName(), jProj));
+ assertFalse(TypeTools.isSubTypeOf(SortedSet.class.getName(), Map.class.getName(), jProj));
+
+ // concrete type is subtype of concrete type
+ assertTrue(TypeTools.isSubTypeOf(ArrayList.class.getName(), AbstractList.class.getName(), jProj));
+ assertTrue(TypeTools.isSubTypeOf(LinkedList.class.getName(), AbstractCollection.class.getName(), jProj));
+
+ // concrete type is not subtype of concrete type
+ assertFalse(TypeTools.isSubTypeOf(ArrayList.class.getName(), Vector.class.getName(), jProj));
+ assertFalse(TypeTools.isSubTypeOf(LinkedList.class.getName(), Vector.class.getName(), jProj));
+ }
+}

Back to the top