initial commit in accordance with CQ 3784
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/.classpath b/testplugins/org.eclipse.objectteams.otdt.tests/.classpath
new file mode 100644
index 0000000..c991626
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/.classpath
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="model"/>
+ <classpathentry kind="src" path="search"/>
+ <classpathentry kind="src" path="hierarchy"/>
+ <classpathentry kind="src" path="compiler"/>
+ <classpathentry kind="src" path="parser"/>
+ <classpathentry kind="src" path="formatter"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="selection"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/.cvsignore b/testplugins/org.eclipse.objectteams.otdt.tests/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/.project b/testplugins/org.eclipse.objectteams.otdt.tests/.project
new file mode 100644
index 0000000..fbd0226
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.objectteams.otdt.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/.settings/org.eclipse.jdt.core.prefs b/testplugins/org.eclipse.objectteams.otdt.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..05e2501
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,52 @@
+#Thu Mar 08 22:55:51 CET 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/META-INF/MANIFEST.MF b/testplugins/org.eclipse.objectteams.otdt.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..bd8c1ba
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,45 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OTDTTest Plug-in
+Bundle-SymbolicName: org.eclipse.objectteams.otdt.tests;singleton:=true
+Bundle-Version: 1.3.0
+Bundle-ClassPath: otdt-tests.jar
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.junit,
+ org.eclipse.jdt.core;bundle-version="[3.5.0.v_OTDT_r130,4.0.0)",
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core.tests.compiler,
+ org.eclipse.test.performance,
+ org.eclipse.objectteams.otdt,
+ org.eclipse.jdt.core.tests.builder,
+ org.eclipse.objectteams.otdt.debug,
+ org.eclipse.text,
+ org.eclipse.jdt.core.tests.model
+Bundle-Vendor: The TOPPrax consortium
+Export-Package: org.eclipse.objectteams.otdt.tests,
+ org.eclipse.objectteams.otdt.tests.compiler,
+ org.eclipse.objectteams.otdt.tests.compiler.ast,
+ org.eclipse.objectteams.otdt.tests.compiler.errorreporting,
+ org.eclipse.objectteams.otdt.tests.compiler.smap,
+ org.eclipse.objectteams.otdt.tests.hierarchy,
+ org.eclipse.objectteams.otdt.tests.model,
+ org.eclipse.objectteams.otdt.tests.otmodel,
+ org.eclipse.objectteams.otdt.tests.otmodel.anonymousinnerclass.rolelevel.internal,
+ org.eclipse.objectteams.otdt.tests.otmodel.anonymousinnerclass.teamlevel,
+ org.eclipse.objectteams.otdt.tests.otmodel.equals,
+ org.eclipse.objectteams.otdt.tests.otmodel.externalrole,
+ org.eclipse.objectteams.otdt.tests.otmodel.internal,
+ org.eclipse.objectteams.otdt.tests.otmodel.internalrole,
+ org.eclipse.objectteams.otdt.tests.otmodel.role.bound.toordinary,
+ org.eclipse.objectteams.otdt.tests.otmodel.role.bound.toteam,
+ org.eclipse.objectteams.otdt.tests.otmodel.role.unbound,
+ org.eclipse.objectteams.otdt.tests.otmodel.sample,
+ org.eclipse.objectteams.otdt.tests.otmodel.teams,
+ org.eclipse.objectteams.otdt.tests.parser,
+ org.eclipse.objectteams.otdt.tests.search,
+ org.eclipse.objectteams.otdt.tests.selection,
+ org.eclipse.objectteams.otdt.tests.selection.codeselect,
+ org.eclipse.objectteams.otdt.tests.subhierarchy,
+ org.eclipse.objectteams.otdt.tests.superhierarchy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/build.properties b/testplugins/org.eclipse.objectteams.otdt.tests/build.properties
new file mode 100644
index 0000000..c2021fe
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/build.properties
@@ -0,0 +1,19 @@
+source.otdt-tests.jar = src/,\
+ compiler/,\
+ hierarchy/,\
+ model/,\
+ parser/,\
+ search/,\
+ selection/,\
+ analysis/,\
+ formatter/
+output.otdt-tests.jar = bin/
+bin.includes = plugin.xml,\
+ otdt-tests.jar,\
+ workspace/,\
+ META-INF/,\
+ test.xml,\
+ JCL/
+src.includes = .classpath,\
+ .project,\
+ build.properties
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/CustomizedCompiler.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/CustomizedCompiler.java
new file mode 100644
index 0000000..56aeb61
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/CustomizedCompiler.java
@@ -0,0 +1,69 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: CustomizedCompiler.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler;
+
+import java.util.Vector;
+
+import org.eclipse.jdt.internal.compiler.Compiler;
+import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
+import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
+import org.eclipse.jdt.internal.compiler.IProblemFactory;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+/**
+ * @author ike
+ *
+ */
+public class CustomizedCompiler extends Compiler
+{
+ private Vector<ICallbackClient> _callBacks;
+
+ /**
+ * @param environment
+ * @param policy
+ * @param settings
+ * @param requestor
+ * @param problemFactory
+ */
+ public CustomizedCompiler(INameEnvironment environment, IErrorHandlingPolicy policy, CompilerOptions settings, ICompilerRequestor requestor, IProblemFactory problemFactory)
+ {
+ super(environment, policy, settings, requestor, problemFactory);
+ }
+
+ public void addCallBack(ICallbackClient c)
+ {
+ if (_callBacks == null)
+ _callBacks = new Vector<ICallbackClient>();
+
+ _callBacks.add(c);
+ }
+
+ @Override
+ public void process(CompilationUnitDeclaration unit, int i) {
+ super.process(unit, i);
+//{ObjectTeams: callback all waiting tests
+ for (ICallbackClient cbc : this._callBacks)
+ cbc.callback(unit);
+//ike}
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/ICallbackClient.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/ICallbackClient.java
new file mode 100644
index 0000000..735314e
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/ICallbackClient.java
@@ -0,0 +1,32 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: ICallbackClient.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler;
+
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+
+/**
+ * @author ike
+ *
+ */
+public interface ICallbackClient
+{
+ public void callback(CompilationUnitDeclaration cuDecl);
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/SourceElementRequestorTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/SourceElementRequestorTest.java
new file mode 100644
index 0000000..df6a4b6
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/SourceElementRequestorTest.java
@@ -0,0 +1,220 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: SourceElementRequestorTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler;
+import java.util.Locale;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
+import org.eclipse.jdt.internal.compiler.SourceElementParser;
+import org.eclipse.jdt.internal.compiler.ast.Expression;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+/**
+ * @author haebor/mkr
+ * @version $Id: SourceElementRequestorTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class SourceElementRequestorTest extends FileBasedModelTest implements ISourceElementRequestor
+{
+ private char[] source;
+ protected String PROJECT_DIR;
+
+ public SourceElementRequestorTest(String testName)
+ {
+ super(testName);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(SourceElementRequestorTest.class);
+ }
+ junit.framework.TestSuite suite = new Suite(SourceElementRequestorTest.class
+ .getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir(PROJECT_DIR);
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ public void fullParse(String src, String fileName)
+ {
+ this.source = src.toCharArray();
+
+ // km: ctor with new parameter "reportLocalDeclarations", "optimizeStringLiterals" assuming both to be true
+ SourceElementParser parser =
+ new SourceElementParser(this, new DefaultProblemFactory(Locale.getDefault()), new CompilerOptions(), true, true);
+
+ ICompilationUnit sourceUnit = new CompilationUnit(source, fileName, null);
+
+ parser.parseCompilationUnit(sourceUnit, true, null);
+ }
+
+ public void acceptConstructorReference(char[] typeName, int argCount, int sourcePosition)
+ {
+ }
+
+ public void acceptFieldReference(char[] fieldName, int sourcePosition)
+ {
+ }
+
+ public void acceptLineSeparatorPositions(int[] positions)
+ {
+ }
+
+ public void acceptMethodReference(char[] methodName, int argCount, int sourcePosition)
+ {
+ }
+
+ public void acceptTypeReference(char[][] typeName, int sourceStart, int sourceEnd)
+ {
+ }
+
+ public void acceptTypeReference(char[] typeName, int sourcePosition)
+ {
+ }
+
+ public void acceptUnknownReference(char[][] name, int sourceStart, int sourceEnd)
+ {
+ }
+
+ public void acceptUnknownReference(char[] name, int sourcePosition)
+ {
+ }
+
+ public void enterCompilationUnit()
+ {
+ }
+
+ public void enterInitializer(int declarationStart, int modifiers)
+ {
+ }
+
+ public void exitCompilationUnit(int declarationEnd)
+ {
+ }
+
+ public void exitConstructor(int declarationEnd)
+ {
+ }
+
+ public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd)
+ {
+ }
+
+ public void exitInitializer(int declarationEnd)
+ {
+ }
+
+ public void enterCalloutMapping(CalloutInfo calloutInfo)
+ {
+ }
+
+ public void enterCalloutToFieldMapping(CalloutToFieldInfo calloutInfo)
+ {
+ }
+
+ public void enterCallinMapping(CallinInfo callinInfo)
+ {
+ }
+
+ public void exitCallinMapping(int sourceEnd, int declarationSourceEnd)
+ {
+ }
+
+ public void exitCalloutMapping(int sourceEnd, int declarationSourceEnd)
+ {
+ }
+
+ public void exitCalloutToFieldMapping(int sourceEnd, int declarationSourceEnd)
+ {
+ }
+
+ public void acceptBaseReference(char[][] typeName, int sourceStart, int sourceEnd){}
+
+ public void enterConstructor(MethodInfo methodInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void enterField(FieldInfo fieldInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void enterMethod(MethodInfo methodInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void enterType(TypeInfo typeInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void exitType(int declarationEnd) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptProblem(CategorizedProblem problem) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptAnnotationTypeReference(char[][] annotation, int sourceStart, int sourceEnd) {
+ // TODO Auto-generated method stub
+ }
+
+ public void acceptAnnotationTypeReference(char[] annotation, int sourcePosition) {
+ // TODO Auto-generated method stub
+ }
+
+ public void acceptPackage(ImportReference importReference) {
+ // TODO Auto-generated method stub
+ }
+
+ public void exitMethod(int declarationEnd, Expression defaultValue) {
+ // TODO Auto-generated method stub
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/TestBase.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/TestBase.java
new file mode 100644
index 0000000..9622d50
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/TestBase.java
@@ -0,0 +1,698 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: TestBase.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.batch.Main;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
+
+/**
+ * This class represents a base for testing the compiler with several files.
+ *
+ * @author Jan Wloka
+ * @version $Id: TestBase.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class TestBase extends TestCase
+{
+
+ public static final String NL = "\r\n";
+
+ public static final String CLASS_FILE_EXTENSION = ".class";
+ public static final String JAVA_FILE_EXTENSION = ".java";
+ public static final String LOG_FILE_EXTENSION = ".log";
+
+ public static final String WORKSPACE_NAME = "testing-workspace";
+ public static final String PROJECT_NAME = "TestProject";
+
+ public static final String JAVA_HOME = System.getProperty("java.home");
+ public static final String USER_HOME = System.getProperty("user.home");
+
+ public static final String JRE_JAR_PATH = JAVA_HOME
+ + File.separator
+ + "lib"
+ + File.separator
+ + "rt.jar";
+
+ public static final String OT_RUNTIME_PATH;
+ static {
+ OT_RUNTIME_PATH = JavaCore.getClasspathVariable(OTDTPlugin.OTDT_INSTALLDIR).toOSString();
+ }
+
+
+ public static final String OTRE_JAR_PATH = OT_RUNTIME_PATH
+ + File.separator
+ + "lib"
+ + File.separator
+ + "otre.jar";
+
+ public static final String OT_SCRIPT_PATH = OT_RUNTIME_PATH
+ + File.separator
+ + "otj"
+ + File.separator
+ + "bin"
+ + File.separator
+ + "ot";
+
+ public static final String PROJECT_PATH = USER_HOME
+ + File.separator
+ + WORKSPACE_NAME
+ + File.separator
+ + PROJECT_NAME;
+
+
+ private Main _compiler;
+ private String _logFileName;
+ private File _workingDir;
+
+ public TestBase(String testName)
+ {
+ super(testName);
+ }
+
+ private void cleanWorkingDirectory()
+ {
+ if (!_workingDir.isDirectory())
+ {
+ return;
+ }
+ cleanRecursively(_workingDir);
+// File[] containedFiles = _workingDir.listFiles();
+//
+// for (int idx = 0; idx < containedFiles.length; idx++)
+// {
+// containedFiles[idx].delete();
+// }
+//
+// _workingDir.delete();
+ }
+ private void cleanRecursively(File file) {
+ if (file.isDirectory()) {
+ for (File child : file.listFiles()) {
+ cleanRecursively(child);
+ }
+ }
+ file.delete();
+ }
+
+ /**
+ * Executes the main() method of a given classfile.
+ * @param fname e.g. MyMainClass
+ * @param expectedResult e.g. OK
+ * @return e.g. OK
+ */
+ public boolean executeFile(String fname, String expectedResult)
+ {
+ System.out.println(" ***** executed ***** ");
+ String result = executeCommand(OT_SCRIPT_PATH + " -classpath " + PROJECT_PATH +" "+ fname);
+ if(result.compareTo(expectedResult) != 0)
+ {
+ System.out.println(" Expected result: " + expectedResult);
+ System.out.println(" Actual result: " + result);
+
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * execute unix shell command
+ * @param commandToExecute
+ * @return the result from output stream
+ */
+ private static String executeCommand(String commandToExecute)
+ {
+ ArrayList<Exception> exceptions = new ArrayList<Exception>();
+
+ Process commandExecutionProcess;
+
+ StringWriter output = new StringWriter();
+ StringWriter errors = new StringWriter();
+
+ try
+ {
+ commandExecutionProcess = Runtime.getRuntime().exec(commandToExecute);
+
+ StreamRedirectThread outRedirect =
+ new StreamRedirectThread(
+ "output_reader",
+ commandExecutionProcess.getInputStream(),
+ output);
+ StreamRedirectThread errRedirect = new StreamRedirectThread("error_reader",
+ commandExecutionProcess.getErrorStream(), errors);
+
+ outRedirect.start();
+ errRedirect.start();
+
+ commandExecutionProcess.waitFor();
+
+ outRedirect.join(); // wait until output (std out) of commandline tool is fully read
+ errRedirect.join(); // wait until standard error of commandline tool is fully read
+ if (outRedirect.getException() != null)
+ {
+ exceptions.add(outRedirect.getException());
+ }
+ if (errRedirect.getException() != null)
+ {
+ exceptions.add(errRedirect.getException());
+ }
+ }
+ catch (Exception ex)
+ {
+ exceptions.add(ex);
+ }
+ finally
+ {
+ output.flush();
+ try
+ {
+ output.close();
+ }
+ catch (Exception ex)
+ {
+ exceptions.add(ex);
+ }
+ errors.flush();
+ try
+ {
+ errors.close();
+ }
+ catch (Exception ex)
+ {
+ exceptions.add(ex);
+ }
+ }
+
+ return errors.toString() + output.toString();
+
+ }
+ // -- use default options: --
+ public void compileFile(String fname)
+ {
+ compileFile(fname, null);
+ }
+ public void compileFile(String fname, String[] classpath)
+ {
+ Map<String,String> options= new HashMap<String,String>();
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ERROR);
+ compileFile(fname, classpath, options);
+ }
+ // -- use custom options: --
+ public void compileFile(String fname, String[] classpath, Map options)
+ {
+ System.out.println("*************************** "
+ + this.getClass().getName()
+ +" "
+ + this.getName()
+ + " ***************************");
+ _logFileName = fname;
+
+ try
+ {
+ if (!validClasspathEntries())
+ {
+ throw new FileNotFoundException("Whether OTRE_JAR_PATH (otre.jar) or JRE_JAR_PATH (rt.jar) is unvalid.");
+ }
+
+ String[] args = (classpath == null)
+ ? createClassPath(fname)
+ : classpath;
+
+ File javaFile = new File(_workingDir.getAbsolutePath()
+ + File.separator
+ + fname
+ + JAVA_FILE_EXTENSION);
+
+ if(!javaFile.exists())
+ {
+ throw new FileNotFoundException("File to compile was not found!: " + _logFileName);
+ }
+
+ _compiler =
+ new Main(
+ new PrintWriter(
+ new FileOutputStream(PROJECT_PATH
+ + File.separator
+ + _logFileName
+ + LOG_FILE_EXTENSION)),
+ new PrintWriter(
+ new FileOutputStream(PROJECT_PATH
+ + File.separator
+ + _logFileName
+ + LOG_FILE_EXTENSION)),
+ false,
+ options,
+ null);
+
+ _compiler.compile(args);
+ }
+ catch (FileNotFoundException ex)
+ {
+ handleException(ex);
+ }
+ }
+
+ private boolean validClasspathEntries()
+ {
+ File otreJar = new File(OTRE_JAR_PATH);
+ File jreJar = new File(JRE_JAR_PATH);
+
+ return (otreJar.exists() && jreJar.exists());
+ }
+
+ public void createFile(String fname, String content)
+ {
+ try
+ {
+ File pkgDir = createPackageDirectory(content);
+ File file = new File(pkgDir.getAbsolutePath()
+ + File.separator
+ + fname
+ + JAVA_FILE_EXTENSION);
+ file.deleteOnExit();
+
+ FileWriter writer = new FileWriter(file);
+ writer.write(content);
+ writer.close();
+ }
+ catch (IOException ex)
+ {
+ handleException(ex);
+ }
+ }
+
+ /**
+ * Creates a file at given relative position and all necessary directories
+ * The content of package is not evaluatet for saving location
+ * @param fname the name of the new file to create
+ * @param relPath the relative path where to store the file
+ * @param content the content
+ */
+ public void createFileAt(String fname, String relPath, String content)
+ {
+ try
+ {
+ String curPath = _workingDir.getAbsolutePath();
+
+ if(relPath.trim().length() > 0)
+ {
+ curPath+= File.separator + relPath;
+ }
+
+ File pkgDir = new File(curPath);
+ pkgDir.mkdirs();
+
+ File file = new File(pkgDir.getAbsolutePath()
+ + File.separator
+ + fname
+ + JAVA_FILE_EXTENSION);
+ file.deleteOnExit();
+
+ FileWriter writer = new FileWriter(file);
+ writer.write(content);
+ writer.close();
+ }
+ catch (IOException ex)
+ {
+ handleException(ex);
+ }
+ }
+
+ private File createPackageDirectory(String fileContent) throws IOException
+ {
+ String qualPkgName = getQualifiedPackageName(fileContent);
+ String dirPath = getDirectoryPath(qualPkgName);
+
+ String curPath = _workingDir.getAbsolutePath() + File.separator + dirPath;
+ File result = new File(curPath);
+ result.mkdirs();
+
+ return result;
+ }
+
+ private String getDirectoryPath(String qualPkgName)
+ {
+ if ((qualPkgName == null) || (qualPkgName.trim().length() == 0))
+ {
+ return "";
+ }
+
+ if (qualPkgName.indexOf('.') == -1)
+ {
+ return qualPkgName;
+ }
+ else
+ {
+ return qualPkgName.replaceAll("[.]", File.separator);
+ }
+ }
+
+ private String getQualifiedPackageName(String fileContent)
+ {
+ String packageKeyword = "package ";
+
+ int pos1 = fileContent.indexOf(packageKeyword);
+ if (pos1 == -1)
+ {
+ return "";
+ }
+
+ int pos2 = fileContent.indexOf(';', pos1);
+ if (pos2 == -1)
+ {
+ return "";
+ }
+
+
+ return fileContent.substring(pos1 + packageKeyword.length(), pos2);
+ }
+
+ private void handleException(Exception ex)
+ {
+ System.out.println("UNCAUGHT EXCEPTION: " + ex);
+ ex.printStackTrace(System.out);
+ }
+
+
+ /**
+ * checks whether the compiler has proceeded without errors or warnings
+ */
+ public boolean isCompilationSuccessful()
+ {
+ if (_compiler.globalErrorsCount != 0)
+ {
+ printAllProblems();
+ return false;
+ }
+ else
+ {
+ File file = new File(_workingDir.getAbsolutePath()
+ + File.separator
+ + _logFileName
+ + LOG_FILE_EXTENSION);
+ file.delete();
+ return true;
+ }
+ }
+
+ /**
+ * checks whether the compiler has generated the expected errors and warnings,
+ * if it created more problems than specified this is OK for this method.
+ * @param problemIDs IDs of the expected errors and warnings as specified in
+ * org.eclipse.jdt.core.compiler.IProblem
+ */
+ public boolean hasAtLeastExpectedProblems(int[] problemIDs)
+ {
+ expected: for (int i = 0; i < problemIDs.length; i++) {
+ for (int j = 0; j < _compiler.logger._globalProblems.size(); j++) {
+ if (problemIDs[i] == ((IProblem)_compiler.logger._globalProblems.get(j)).getID())
+ continue expected;
+ }
+ printAllProblems();
+ return false;
+ }
+ File file = new File(_workingDir.getAbsolutePath()
+ + File.separator
+ + _logFileName
+ + LOG_FILE_EXTENSION);
+ file.delete();
+ return true;
+ }
+
+ /**
+ * checks whether the compiler has generated the expected errors and warnings
+ * @param problemIDs IDs of the expected errors and warnings as specified in
+ * org.eclipse.jdt.core.compiler.IProblem
+ */
+ public boolean hasExpectedProblems(int[] problemIDs)
+ {
+ if ( areProblemsEqual(_compiler.logger._globalProblems, problemIDs) )
+ {
+ File file = new File(_workingDir.getAbsolutePath()
+ + File.separator
+ + _logFileName
+ + LOG_FILE_EXTENSION);
+ file.delete();
+
+ return true;
+ }
+ else
+ {
+ printAllProblems();
+ return false;
+ }
+ }
+
+ private void printAllProblems()
+ {
+ for (Iterator iter = _compiler.logger._globalProblems.iterator(); iter.hasNext();)
+ {
+ IProblem prob = (IProblem)iter.next();
+ System.err.println(prob.toString());
+ if (prob.getID() == IProblem.Unclassified) // it was an exception.
+ throw new InternalError(prob.toString());
+ }
+ }
+
+ /**
+ * checks whether the compiler has generated the expected errors and warnings
+ * @param errorIDs IDs of the expected errors as specified in
+ * org.eclipse.jdt.core.compiler.IProblem
+ * @param warningIDs analogous
+ */
+ public boolean hasExpectedProblems(int[] errorIDs, int[] warningIDs)
+ {
+ if ( areProblemsEqual(_compiler.logger._globalErrors, errorIDs)
+ && areProblemsEqual(_compiler.logger._globalWarnings, warningIDs) )
+ {
+
+ File file = new File(_workingDir.getAbsolutePath()
+ + File.separator
+ + _logFileName
+ + LOG_FILE_EXTENSION);
+ file.delete();
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ /**
+ * @param problems Vector elements of type IProblem
+ */
+ private boolean areProblemsEqual(List problems, int[] problemIDs)
+ {
+ if ( problemIDs == null)
+ {
+ return problems.isEmpty();
+ }
+
+ boolean result = true;
+
+ if (problems.size() != problemIDs.length)
+ {
+ result = false;
+ }
+ for (Iterator iter = problems.iterator(); result && iter.hasNext();)
+ {
+ IProblem curProblem = (IProblem) iter.next();
+ int curProblemID = curProblem.getID();
+
+ boolean found = false;
+ int idx = 0;
+
+ while (!found && (idx < problemIDs.length))
+ {
+ if (curProblemID == problemIDs[idx])
+ {
+ found = true;
+ }
+ idx++;
+ }
+ if (!found)
+ {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+// public boolean isCompilationSuccessful(int errors, int warnings)
+// {
+// if (_compiler.globalErrorsCount != errors
+// || _compiler.globalProblemsCount > (errors + warnings)
+// || _compiler.globalWarningsCount != warnings)
+// {
+// return false;
+// }
+// else
+// {
+// // TODO (SH): check whether we have the expected problems.
+// File file = new File(_workingDir.getAbsolutePath()
+// + File.separator
+// + _logFileName
+// + LOG_FILE_EXTENSION);
+// file.delete();
+//
+// return true;
+// }
+// }
+
+
+ private String[] createClassPath(String fname)
+ {
+ File javaFile = new File(_workingDir.getAbsolutePath()
+ + File.separator
+ + fname
+ + JAVA_FILE_EXTENSION);
+
+ String[] args =
+ {
+ "-classpath",
+ new Path(OTRE_JAR_PATH).toString()
+ + File.pathSeparator
+ + new Path(JRE_JAR_PATH).toString()
+ + File.pathSeparator
+ + new Path(_workingDir.getAbsolutePath()
+ + File.separator).toString(),
+ javaFile.getAbsolutePath()
+ };
+
+ return args;
+ }
+
+ protected String[] createClassPathNoOTRE(String fname)
+ {
+ File javaFile = new File(_workingDir.getAbsolutePath()
+ + File.separator
+ + fname
+ + JAVA_FILE_EXTENSION);
+
+ String[] args =
+ {
+ "-classpath",
+ new Path(JRE_JAR_PATH).toString()
+ + File.pathSeparator
+ + new Path(_workingDir.getAbsolutePath()
+ + File.separator).toString(),
+ javaFile.getAbsolutePath()
+ };
+
+ return args;
+ }
+
+
+ protected void setUp() throws Exception
+ {
+ _workingDir = new File(PROJECT_PATH);
+ cleanWorkingDirectory();
+ _workingDir.mkdirs();
+ }
+
+ protected void tearDown() throws Exception
+ {
+
+ }
+
+ /**
+ * This method was added for convenient testing of single testmethods in testclasses.
+ * The first commandline argument is expected to be the class where the
+ * testmethod can be found. The following arguments are the testmethodnames
+ * that should run.
+ * example:
+ * java Testbase org.eclipse.objectteams.otdt.tests.compiler.errorreporting.compiler.CalloutBindingTest testMultipleCalloutBinding1
+ * @param args
+ * @throws ClassNotFoundException
+ * @throws SecurityException
+ * @throws NoSuchMethodException
+ * @throws IllegalArgumentException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws InvocationTargetException
+ */
+
+ public static void main(String[] args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ TestSuite selected = null;
+ Constructor clsConst =null;
+
+ switch (args.length)
+ {
+ case 0:
+ {
+ System.err.println("You must specify the class containing the testcases as argument.");
+ System.exit(1);
+ break; // duh
+ }
+
+ case 1: // take all methods
+ {
+ Class testClass = Class.forName(args[0]);
+ selected = new TestSuite(testClass);
+ break;
+ }
+
+ default: // single methods to execute given
+ {
+ Class<?> testClass = Class.forName(args[0]);
+ clsConst = testClass.getConstructor( new Class<?>[] { String.class } );
+ selected = new TestSuite();
+
+ for (int idx = 1; idx < args.length; idx++)
+ {
+ selected.addTest((Test)clsConst.newInstance( new Object[] { args[idx] } ));
+ }
+ }
+ }
+
+ TestRunner.run(selected);
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/ast/TypeDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/ast/TypeDeclarationTest.java
new file mode 100644
index 0000000..cfc5b52
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/ast/TypeDeclarationTest.java
@@ -0,0 +1,104 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: TypeDeclarationTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.ast;
+
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.tests.compiler.SourceElementRequestorTest;
+
+/**
+ * @author haebor
+ * @version $Id: TypeDeclarationTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class TypeDeclarationTest extends SourceElementRequestorTest
+{
+
+ private boolean _testFlag;
+
+ public TypeDeclarationTest(String testName)
+ {
+ super(testName);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(TypeDeclarationTest.class);
+ }
+ junit.framework.TestSuite suite = new Suite(TypeDeclarationTest.class
+ .getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ this.PROJECT_DIR = "ExternalDefinedRole";
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ public void enterType(TypeInfo typeInfo) {
+ _testFlag = typeInfo.isRoleFile;
+ }
+
+ public void testRoleInterface_RolefileFlag() throws JavaModelException
+ {
+ org.eclipse.jdt.core.ICompilationUnit unit = getCompilationUnit(
+ "ExternalDefinedRole",
+ "unbound",
+ "unbound.teampkg.Team_5a",
+ "SampleRole.java");
+
+ String src = unit.getSource();
+
+ String fileName = unit.getCorrespondingResource().toString();
+
+ fullParse(src, fileName);
+
+ assertTrue(_testFlag);
+ }
+
+ public void testRoleClass_RolefileFlag() throws JavaModelException
+ {
+ org.eclipse.jdt.core.ICompilationUnit unit = getCompilationUnit(
+ "ExternalDefinedRole",
+ "unbound",
+ "unbound.teampkg.Team_5b",
+ "SampleRole.java");
+
+ String src = unit.getSource();
+ IResource res = unit.getCorrespondingResource();
+
+ String fileName = res.toString();
+ fullParse(src, fileName);
+
+ assertTrue(_testFlag);
+ }
+
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CallinBindingTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CallinBindingTest.java
new file mode 100644
index 0000000..44bc0ab
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CallinBindingTest.java
@@ -0,0 +1,243 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: CallinBindingTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+
+/**
+ * This class contains tests concerning callin bindings.
+ *
+ * @author kaschja
+ * @version $Id: CallinBindingTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class CallinBindingTest extends TestBase
+{
+ public CallinBindingTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A "replace-callin binding" is used with a base call.
+ * Bound role method is declared as callin method.
+ */
+ public void testCallinInMethodDeclaration()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public int baseMethod(int i) {return 1;}" +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " callin int roleMethod(int i)" +
+ NL + " {" +
+ NL + " return base.roleMethod(i); " +
+ NL + " }" +
+ NL + " roleMethod <- replace baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A base-call must have arguments matching the role-method's signature.
+ */
+ public void testBrokenBaseCall()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(int i) {}" +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " callin void roleMethod(int i)" +
+ NL + " {" +
+ NL + " base.roleMethod(); " +
+ NL + " }" +
+ NL + " roleMethod <- replace baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] { IProblem.BaseCallDoesntMatchRoleMethodSignature }));
+ }
+
+ /**
+ * A base call in a role method.
+ * Bound role method must be declared as callin method.
+ */
+ public void testMissingCallinModifierInMethodDeclaration1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod() {}" +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public void roleMethod()" +
+ NL + " {" +
+ NL + " base.roleMethod(); " +
+ NL + " }" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] {IProblem.BasecallInRegularMethod }));
+ }
+
+ /**
+ * A callin binding declaration must include a modifier
+ * (before/replace/after).
+ */
+ public void testCallinBindingDeclarationWithoutModifier1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod() {}" +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public void roleMethod() {}" +
+ NL + " roleMethod <- baseMethod;" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] { IProblem.CallinReplaceKeyWordNotOptional }));
+ }
+
+ /**
+ * A method in a regular class must not be declared as callin method.
+ */
+ public void testCallinModifierDeclaredInMethodOfRegularClass1()
+ {
+ createFile("MyClass","public class MyClass" +
+ NL + "{" +
+ NL + " callin void classMethod() {}" +
+ NL + "}");
+
+ compileFile("MyClass");
+
+ assertTrue(hasExpectedProblems(new int[] {IProblem.OTKeywordInRegularClass}));
+ }
+
+ /**
+ * A callin method must not be called by the role itself
+ */
+ public void testCallinMethodCalledInOtherMethodOfSameRole1()
+ {
+ createFile("MyBase","public class MyBase {}");
+
+ createFile("MyTeam","public team class MyTeam" +
+ NL + "{" +
+ NL + " protected class MyRole playedBy MyBase" +
+ NL + " {" +
+ NL + " callin void callinMethod() {}" +
+ NL + " void roleMethod()" +
+ NL + " {" +
+ NL + " callinMethod();" +
+ NL + " }" +
+ NL + " }" +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] {IProblem.CallToCallin, IProblem.DefinitelyMissingBaseCall}));
+ }
+
+ /**
+ * It is an allowed alternative to declare a callin-binding
+ * with full method signature
+ */
+ public void testMethodsWithSignaturesInCallinBindings1()
+ {
+ createFile("MyBase","public class MyBase" +
+ NL + "{" +
+ NL + " public void baseMethodA() {}" +
+ NL + " public void baseMethodB() {}" +
+ NL + " public void baseMethodC() {}" +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{" +
+ NL + " protected class MyRole playedBy MyBase" +
+ NL + " {" +
+ NL + " void callinMethodA() {}" +
+ NL + " callin void callinMethodB() {}" +
+ NL + " void callinMethodA() <- after void baseMethodA();" +
+ NL + " void callinMethodB() <- replace void baseMethodB(), void baseMethodC();" +
+ NL + " }" +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * It is an allowed alternative to declare a callin-binding
+ * without method signature
+ */
+ public void testMethodsWithoutSignaturesInCallinBindings1()
+ {
+ createFile("MyBase","public class MyBase" +
+ NL + "{" +
+ NL + " public void baseMethodA() {}" +
+ NL + " public void baseMethodB() {}" +
+ NL + " public void baseMethodC() {}" +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{" +
+ NL + " protected class MyRole playedBy MyBase" +
+ NL + " {" +
+ NL + " void callinMethodA() {}" +
+ NL + " callin void callinMethodB() {}" +
+ NL + " callinMethodA <- before baseMethodA;" +
+ NL + " callinMethodB <- replace baseMethodB, baseMethodC;" +
+ NL + " }" +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CalloutBindingTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CalloutBindingTest.java
new file mode 100644
index 0000000..1f6f328
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CalloutBindingTest.java
@@ -0,0 +1,1279 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: CalloutBindingTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class contains tests concerning callout bindings.
+ *
+ * @author kaschja
+ * @version $Id: CalloutBindingTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class CalloutBindingTest extends TestBase
+{
+ public CalloutBindingTest(String testName)
+ {
+ super(testName);
+ }
+
+// There are no ambiguous base-method matches (there's always a best match
+// (one to one))
+//
+// /**
+// * A callout binding with ambiguous Base-Method Signature
+// */
+// public void testCalloutBindingAmbiguousBaseMethod1()
+// {
+//
+// createFile("MyBase","public class MyBase " +
+// NL + "{ " +
+// NL + " protected void baseMethod(short arg){}" +
+// NL + " public void baseMethod(int arg){}" +
+// NL + "} ");
+//
+// createFile("MySuperTeam","public team class MySuperTeam " +
+// NL + "{ " +
+// NL + " public class MyRole playedBy MyBase " +
+// NL + " { " +
+// NL + " public void roleMethod(long arg){};" +
+// NL + " } " +
+// NL + "}");
+//
+// createFile("MyTeam","public team class MyTeam extends MySuperTeam" +
+// NL + "{ " +
+// NL + " public class MyRole" +
+// NL + " { " +
+// NL + " roleMethod => baseMethod; " +
+// NL + " } " +
+// NL + "}");
+//
+// compileFile("MyTeam");
+//
+// //should throw warning about ambiguous base-method
+// assertTrue(hasExpectedProblems(new int[] { IProblem.CalloutBindingTooManyBaseMatches }));
+// }
+//
+// /**
+// * A callout binding with ambiguous Base-Method Signature
+// */
+// public void testCalloutBindingAmbiguousBaseMethod2()
+// {
+//
+// createFile("MyBase","public class MyBase " +
+// NL + "{ " +
+// NL + " public void baseMethod(long arg){}" +
+// NL + " public void baseMethod(int arg){}" +
+// NL + "} ");
+//
+// createFile("MySuperTeam","public team class MySuperTeam " +
+// NL + "{ " +
+// NL + " public class MyRole playedBy MyBase " +
+// NL + " { " +
+// NL + " public void roleMethod(short arg){};" +
+// NL + " } " +
+// NL + "}");
+//
+// createFile("MyTeam","public team class MyTeam extends MySuperTeam" +
+// NL + "{ " +
+// NL + " public class MyRole" +
+// NL + " { " +
+// NL + " roleMethod => baseMethod; " +
+// NL + " } " +
+// NL + "}");
+//
+// compileFile("MyTeam");
+//
+// //should throw warning about ambiguous base-method
+// assertTrue(hasExpectedProblems(new int[] { IProblem.CalloutBindingTooManyBaseMatches }));
+// }
+//
+// /**
+// * A callout binding with ambiguous Base-Method Signature
+// */
+// public void testCalloutBindingAmbiguousBaseMethod3()
+// {
+//
+// createFile("MyBase","public class MyBase " +
+// NL + "{ " +
+// NL + " public void baseMethod(String arg){}" +
+// NL + " public void baseMethod(Integer arg){}" +
+// NL + "} ");
+//
+// createFile("MySuperTeam","public team class MySuperTeam " +
+// NL + "{ " +
+// NL + " public class MyRole playedBy MyBase " +
+// NL + " { " +
+// NL + " public void roleMethod(String arg){};" +
+// NL + " public void roleMethod(Integer arg){};" +
+// NL + " } " +
+// NL + "}");
+//
+// createFile("MyTeam","public team class MyTeam extends MySuperTeam" +
+// NL + "{ " +
+// NL + " public class MyRole" +
+// NL + " { " +
+// NL + " roleMethod => baseMethod; " +
+// NL + " } " +
+// NL + "}");
+//
+// compileFile("MyTeam");
+//
+// //should throw warning about ambiguous base-method
+// assertTrue(hasExpectedProblems(new int[] { IProblem.CalloutBindingTooManyBaseMatches }));
+// }
+
+ /**
+ * A callout binding declaration must not include a modifier
+ * (before/replace/after).
+ */
+ public void testCalloutBindingDeclarationWithModifier1()
+ {
+
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(){}" +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod();" +
+ NL + " roleMethod -> after baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] { IProblem.UnresolvedCalloutMethodSpec, IProblem.ParsingErrorDeleteToken}));
+ }
+
+ /**
+ * A callout binding declaration must not include a modifier
+ * (before/replace/after).
+ */
+ public void testCalloutBindingMethodArgumentWithModifier1()
+ {
+
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(final String str){}" +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod(final String str);" +
+ NL + " roleMethod -> after baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] { IProblem.UnresolvedCalloutMethodSpec, IProblem.ParsingErrorDeleteToken}));
+ }
+
+ /**
+ * A role method must not be bound to a non-existing base method.
+ */
+ public void testBindingOfNonExistingMethod1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod();" +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ //TODO(SH): this is what I expect in 3.2, but other non-resolve error msg would be acceptable, too
+ assertTrue(hasAtLeastExpectedProblems(new int[]{ IProblem.UnresolvedCalloutMethodSpec}));
+ }
+
+ /**
+ * A non-existing role method must not be bound to a base method.
+ */
+ public void testBindingOfNonExistingMethod2()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(){} " +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ //TODO(SH): this is what I expect in 3.2, but other non-resolve error msg would be acceptable, too
+ assertTrue(hasExpectedProblems(new int[]{ IProblem.UnresolvedCalloutMethodSpec}, null ));
+ }
+
+ /**
+ * An abstract role method must not be bound with the "=>"-operator.
+ */
+ public void testBindingWithWrongOperator1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(){} " +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod();" +
+ NL + " roleMethod => baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[]{ IProblem.AbstractMethodBoundAsOverride }, null ));
+ }
+
+ /**
+ * A non-abstract role method must not be bound with the "->"-operator.
+ */
+ public void testBindingWithWrongOperator2()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(){} " +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public void roleMethod(){}" +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ assertTrue(hasExpectedProblems(new int[]{ IProblem.RegularCalloutOverrides, IProblem.CalloutOverridesLocal } ));
+ }
+
+ /**
+ * A role method must not be bound to the same base method multiple times.
+ */
+ public void testMultipleCalloutBinding1()
+ {
+ createFile("MyBase","public class MyBase"
+ + NL + "{"
+ + NL + " public void baseMethodA(){}"
+ + NL + " public void baseMethodB(){}"
+ + NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{ "
+ + NL + " protected class MyRole playedBy MyBase"
+ + NL + " { "
+ + NL + " public abstract void roleMethod();"
+ + NL + " void roleMethod() -> void baseMethodA();"
+ + NL + " void roleMethod() -> void baseMethodB();"
+ + NL + " } "
+ + NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue( hasExpectedProblems(new int[] { IProblem.DuplicateCalloutBinding, IProblem.DuplicateCalloutBinding} ));
+ }
+
+ /**
+ * A role method must not be bound to various base methods by callout.
+ */
+ public void testMultipleCalloutBinding2()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethodA(){} " +
+ NL + " public void baseMethodB(){} " +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod();" +
+ NL + " roleMethod -> baseMethodA; " +
+ NL + " roleMethod -> baseMethodB; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue( hasExpectedProblems(new int[] { IProblem.DuplicateCalloutBinding, IProblem.DuplicateCalloutBinding} ));
+ }
+
+ /**
+ * A role method must not be bound to various base methods by callout,
+ * no matter where the binding is implemented.
+ */
+ public void testMultipleCalloutBinding3()
+ {
+ createFile("MyBase",
+ "public class MyBase "
+ + NL + "{"
+ + NL + " public void baseMethodA(){}"
+ + NL + " public void baseMethodB(){}"
+ + NL + "}");
+
+ createFile("MySuperTeam",
+ "public team class MySuperTeam "
+ + NL + "{ "
+ + NL + " protected class MyRole playedBy MyBase "
+ + NL + " {"
+ + NL + " public abstract void roleMethod();"
+ + NL + " roleMethod -> baseMethodA;"
+ + NL + " }"
+ + NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam extends MySuperTeam"
+ + NL + "{ "
+ + NL + " protected class MyRole playedBy MyBase"
+ + NL + " {"
+// + NL + " public abstract void roleMethod();"
+ + NL + " roleMethod -> baseMethodB;"
+ + NL + " }"
+ + NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue( hasExpectedProblems(new int[] { IProblem.RegularCalloutOverridesCallout} ));
+ }
+
+ /**
+ * A role method must not be bound to the same base method multiple times.
+ */
+ public void testMultipleCalloutBinding4()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(){} " +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod();" +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue( hasExpectedProblems( new int[] { IProblem.DuplicateCalloutBinding, IProblem.DuplicateCalloutBinding } ));
+ }
+
+ public void testBindingMatchingRoleBaseMethod()
+ {
+ createFile("MyException", "public class MyException extends Exception{}");
+
+ createFile("AClass",
+ "public class AClass {}"
+ + NL);
+
+ createFile("BClass",
+ "public class BClass extends AClass{}"
+ + NL);
+
+ createFile("MyBase",
+ "public class MyBase "
+ + NL + "{ "
+ + NL + " public void baseMethodAClass(AClass o){}"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam "
+ + NL + "{ "
+ + NL + " protected class MyRole playedBy MyBase "
+ + NL + " { "
+ + NL + " public abstract void roleMethodBClass(BClass o);"
+ + NL + " roleMethodBClass -> baseMethodAClass;"
+ + NL + " } "
+ + NL + "}"
+ + NL);
+
+
+ compileFile("MyTeam");
+
+ assertTrue( isCompilationSuccessful() );
+ }
+
+ public void testBindingMatchingRoleBaseMethod2()
+ {
+ createFile("MyException", "public class MyException extends Exception{}");
+
+ createFile("AClass",
+ "public class AClass {}"
+ + NL);
+
+ createFile("BClass",
+ "public class BClass extends AClass{}"
+ + NL);
+
+ createFile("MyBase",
+ "public class MyBase "
+ + NL + "{ "
+ + NL + " public BClass baseMethodBClassReturn(){ return null; }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam "
+ + NL + "{ "
+ + NL + " protected class MyRole playedBy MyBase "
+ + NL + " { "
+ + NL + " public abstract AClass roleMethodAClassReturn2();"
+ + NL + " roleMethodAClassReturn2 -> baseMethodBClassReturn;"
+ + NL + " } "
+ + NL + "}"
+ + NL);
+
+
+ compileFile("MyTeam");
+
+ assertTrue( isCompilationSuccessful());
+ }
+
+ /**
+ * The signatures of role method and bound base method
+ * must have compatible declarations
+ */
+ public void testBindingMismatchingRoleBaseMethod1()
+ {
+ createFile("MyBase",
+ "public class MyBase "
+ + NL + "{ "
+ + NL + " public void baseMethod(int i){}"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam "
+ + NL + "{ "
+ + NL + " protected class MyRole playedBy MyBase "
+ + NL + " { "
+ + NL + " public abstract void roleMethod();"
+ + NL + " roleMethod -> baseMethod; "
+ + NL + " } "
+ + NL + "}"
+ + NL);
+
+
+ compileFile("MyTeam");
+
+ assertTrue( hasExpectedProblems(new int[] { IProblem.TooFewArgumentsInCallout } ));
+ }
+
+ /**
+ * The signatures of role method and bound base method
+ * must have compatible declarations. This is the not-so-easy example!
+ */
+ public void testBindingMismatchingRoleBaseMethod2()
+ {
+ createFile("MyException", "public class MyException extends Exception{static final long serialVersionUID=1234;}");
+
+ createFile("AClass",
+ "public class AClass {}"
+ + NL);
+
+ createFile("BClass",
+ "public class BClass extends AClass{}"
+ + NL);
+
+ createFile("MyBase",
+ "public class MyBase "
+ + NL + "{ "
+ + NL + " public void baseMethodBClass(BClass o) throws MyException{}"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam "
+ + NL + "{ "
+ + NL + " protected class MyRole playedBy MyBase "
+ + NL + " { "
+ + NL + " public abstract void roleMethodAClass(AClass o);"
+ + NL + " roleMethodAClass -> baseMethodBClass;"
+ + NL + " } "
+ + NL + "}"
+ + NL);
+
+
+ compileFile("MyTeam");
+ assertTrue( hasExpectedProblems(new int[] { IProblem.IncompatibleMappedCalloutArgument, IProblem.CalloutUndeclaredException} ));
+ }
+
+
+ public void testBindingMismatchingRoleBaseMethod3()
+ {
+ createFile("MyException", "public class MyException extends Exception{static final long serialVersionUID=1234;}");
+
+ createFile("AClass",
+ "public class AClass {}"
+ + NL);
+
+ createFile("BClass",
+ "public class BClass extends AClass{}"
+ + NL);
+
+ createFile("MyBase",
+ "public class MyBase "
+ + NL + "{ "
+ + NL + " public void baseMethodAClass(AClass o){}"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam "
+ + NL + "{ "
+ + NL + " protected class MyRole playedBy MyBase "
+ + NL + " { "
+ + NL + " public abstract AClass roleMethodAClassReturn1();"
+ + NL + " roleMethodAClassReturn1 -> baseMethodAClass;"
+ + NL + " } "
+ + NL + "}"
+ + NL);
+
+
+ compileFile("MyTeam");
+
+ assertFalse( isCompilationSuccessful() );
+ }
+
+ /**
+ * The signatures of role method and bound base method
+ * must have conform exception declarations (throw-clauses)
+ *
+ * The role method must not declare throwing an exception
+ * while the base method does not
+ *
+ * Actually, why shouldn't you be able to add a throws-clause in the role-method?
+ * IMHO, this shouldn't be an error. (carp)
+ */
+ public void testBindingWithDifferentExceptionDeclarations1()
+ {
+ createFile("MyException", "public class MyException extends Exception{static final long serialVersionUID=1234;}");
+
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(){}" +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod() throws MyException;" +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * The signatures of role method and bound base method
+ * must have conform exception declarations (throw-clauses)
+ *
+ * The role method must declare throwing an exception
+ * if the base method does
+ */
+ public void testBindingWithDifferentExceptionDeclarations2()
+ {
+ createFile("MyException", "public class MyException extends Exception{static final long serialVersionUID=1234;}");
+
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod() throws MyException " +
+ NL + " {" +
+ NL + " throw new MyException();" +
+ NL + " }" +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod();" +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] {IProblem.CalloutUndeclaredException}));
+ }
+
+ /**
+ * The signatures of role method and bound base method
+ * must have conform exception declarations (throw-clauses)
+ *
+ * The declared exceptions must not be of different types.
+ */
+ public void testBindingWithDifferentExceptionDeclarations3()
+ {
+ createFile("MyException", "public class MyException extends Exception{static final long serialVersionUID=1234;}");
+ createFile("YourException", "public class YourException extends Exception{static final long serialVersionUID=1234;}");
+
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod() throws MyException " +
+ NL + " {" +
+ NL + " throw new MyException();" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod() throws YourException;" +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] {IProblem.CalloutUndeclaredException}));
+ }
+
+ public void testBrokenBindingDeclaration1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod()" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam" +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public void roleMethod1() {}" +
+ NL + " public void roleMethod2() {}" +
+ NL + " public void roleMethod3() {}" +
+ NL + " public void roleMethod4() {}" +
+ NL + " public void roleMethod5() {}" +
+ NL + " public void roleMethod6() {}" +
+ NL + "" +
+ NL + " public void roleMethod11() {}" +
+ NL + " public void roleMethod12() {}" +
+ NL + " public void roleMethod13() {}" +
+ NL + " public void roleMethod14() {}" +
+ NL + " public void roleMethod15() {}" +
+ NL + " public void roleMethod16() {}" +
+ NL + "" +
+ NL + " void roleMethod1() -> baseMethod();" +
+ NL + " roleMethod2() -> void baseMethod();" +
+ NL + " roleMethod3() -> baseMethod();" +
+ NL + " roleMethod4() -> baseMethod;" +
+ NL + " roleMethod5 -> baseMethod();" +
+ NL + " roleMethod6() -> baseMethod();" +
+ NL + "" +
+ NL + " void roleMethod11 -> baseMethod;" +
+ NL + " roleMethod12 -> void baseMethod;" +
+ NL + " roleMethod13 -> baseMethod;" +
+ NL + " void roleMethod14 -> void baseMethod;" +
+ NL + " void roleMethod15() -> baseMethod;" +
+ NL + " roleMethod16 -> void baseMethod();" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ //TODO: km: SH, please check
+ // assertTrue( hasExpectedProblems(new int[] { IProblem.SyntaxErrorInCallout} ));
+ }
+
+ public void testRemainingAbstractMethod1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod()" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam" +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void abstractRoleMethod();" +
+ NL + "" +
+ NL + " public abstract void roleMethod();" +
+ NL + "" +
+ NL + " void roleMethod() -> void baseMethod();" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue( hasExpectedProblems(new int[] { IProblem.AbstractMethodsInConcreteClass, IProblem.AbstractMethodInAbstractClass } ));
+ }
+
+ public void testArrayParameters1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(int[] baseArray)" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam" +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void abstractRoleMethod(int[] roleArray);" +
+ NL + "" +
+ NL + " void abstractRoleMethod(int[] r) -> void baseMethod(int[] b);" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+
+ }
+
+ public void testArrayParameters2()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(Object[] baseArray)" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam" +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void abstractRoleMethod(Object[] roleArray);" +
+ NL + "" +
+ NL + " void abstractRoleMethod(Object[] r) -> void baseMethod(Object[] b);" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+
+ }
+
+
+ public void testArrayLowering1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(MyBase[] baseArray)" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam" +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void abstractRoleMethod(MyRole[] roleArray);" +
+ NL + "" +
+ NL + " void abstractRoleMethod(MyRole[] r) -> void baseMethod(MyBase[] b);" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+
+ }
+
+ /**
+ * Simple test that should work.
+ *
+ */
+ public void testSimpleWorkingExample()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(Object obj)" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam" +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void abstractRoleMethod(Object obj);" +
+ NL + "" +
+ NL + " void abstractRoleMethod(Object obj) -> void baseMethod(Object obj);" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+
+ }
+
+ /**
+ * Simple test with static base method.
+ */
+ public void testStaticBaseMethod()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public static void baseMethod(Object obj)" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam" +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void abstractRoleMethod(Object obj);" +
+ NL + "" +
+ NL + " void abstractRoleMethod(Object obj) -> void baseMethod(Object obj);" +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+
+ }
+
+ /**
+ * A common callout binding scenario consisting of a base class, a team
+ * with a default constructor, an abstract role class, a role class with
+ * multiple callout bindings and a main method for team instantiation.
+ */
+ public void testCalloutBinding1()
+ {
+ createFile("MyBase",
+ "public class MyBase"
+ + NL + "{"
+ + NL + " public void myBaseMethod(int a)"
+ + NL + " {"
+ + NL + " System.out.println(\"laber\");"
+ + NL + " }"
+ + NL + " public void myVoidBaseMethod()"
+ + NL + " {"
+ + NL + " System.out.println(\"blubber\");"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{"
+ + NL + " public MyTeam()"
+ + NL + " {"
+ + NL + " super();"
+ + NL + " Role r = new Role(new MyBase());"
+ + NL + " r.myCallout(3);"
+ + NL + " r.myAbstractCallout(4);"
+ + NL + " r.myAbstractInheritedVoidCallout();"
+ + NL + " }"
+ + NL + ""
+ + NL + " public abstract class SuperRole"
+ + NL + " {"
+ + NL + ""
+ + NL + " void myCallout(int a)"
+ + NL + " {"
+ + NL + " System.out.println(\"Hallo\");"
+ + NL + " }"
+ + NL + ""
+ + NL + " abstract void myAbstractInheritedVoidCallout();"
+ + NL + " }"
+ + NL + ""
+ + NL + " public class Role extends SuperRole playedBy MyBase"
+ + NL + " {"
+ + NL + " protected abstract void myAbstractCallout(int a);"
+ + NL + ""
+ + NL + " public void method()"
+ + NL + " {"
+ + NL + " System.out.println(\"normal method\"); "
+ + NL + " }"
+ + NL + ""
+ + NL + " protected void myCallout(int a) => void myBaseMethod(int a);"
+ + NL + " void myAbstractCallout(int a) -> void myBaseMethod(int a);"
+ + NL + " protected void myAbstractInheritedVoidCallout() -> void myVoidBaseMethod();"
+ + NL + " }"
+ + NL + " public static void main(String[] args){"
+ + NL + " new MyTeam();"
+ + NL + " };"
+ + NL + "}"
+ + NL);
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ public void testResultLifting1()
+ {
+
+ createFile("MyBase",
+ "public class MyBase"
+ + NL + "{"
+ + NL + " public MyBase foo()"
+ + NL + " {"
+ + NL + " return this;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{"
+ + NL + " protected class MyRole playedBy MyBase"
+ + NL + " {"
+ + NL + " public void print() {System.out.println(\"OK\");}"
+ + NL + " protected abstract MyRole bar();"
+ + NL + " bar -> foo;"
+ + NL + " }"
+ + NL + ""
+ + NL + " MyTeam()"
+ + NL + " {"
+ + NL + " MyRole r1 = new MyRole(new MyBase());"
+ + NL + " MyRole r2 = r1.bar();"
+ + NL + " r2.print();"
+ + NL + " }"
+ + NL + ""
+ + NL + " public static void main(String[] args)"
+ + NL + " {"
+ + NL + " new MyTeam();"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ public void testResultLifting2()
+ {
+
+ createFile("MyBase",
+ "public class MyBase"
+ + NL + "{"
+ + NL + " public MyBase foo()"
+ + NL + " {"
+ + NL + " return this;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeamInterface",
+ "public team class MyTeamInterface"
+ + NL + "{"
+ + NL + " public interface MyInterface playedBy MyBase"
+ + NL + " {"
+ + NL + " MyInterface bar();"
+ + NL + " void print();"
+ + NL + " }"
+ + NL + ""
+ + NL + " protected class MyRole implements MyInterface"
+ + NL + " {"
+ + NL + " public void print() {System.out.println(\"OK\");}"
+ + NL + " bar -> foo;"
+ + NL + " }"
+ + NL + ""
+ + NL + " MyTeamInterface()"
+ + NL + " {"
+ + NL + " MyRole r = new MyRole(new MyBase());"
+ + NL + " MyInterface rI = r.bar();"
+ + NL + " rI.print();"
+ + NL + " }"
+ + NL + ""
+ + NL + " public static void main(String[] args)"
+ + NL + " {"
+ + NL + " new MyTeamInterface();"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ compileFile("MyTeamInterface");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ public void testResultLifting3()
+ {
+
+ createFile("MyBase",
+ "public class MyBase"
+ + NL + "{"
+ + NL + " public MyBase foo()"
+ + NL + " {"
+ + NL + " return this;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyBase2",
+ "public class MyBase2"
+ + NL + "{"
+ + NL + " public MyBase2 foo()"
+ + NL + " {"
+ + NL + " return this;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{"
+ + NL + " abstract protected class MyInnerClass"// playedBy MyBase2"
+ + NL + " {"
+ + NL + " protected abstract MyRole bar();"
+ + NL + " public abstract void print();"
+ + NL + " }"
+ + NL + ""
+ + NL + " protected class MyRole extends MyInnerClass playedBy MyBase"
+ + NL + " {"
+ + NL + " public void print() {System.out.println(\"OK\");}"
+ + NL + " bar -> foo;"
+ + NL + " }"
+ + NL + ""
+ + NL + " MyTeam()"
+ + NL + " {"
+ + NL + " MyRole r = new MyRole(new MyBase());"
+ + NL + " MyInnerClass rI = r.bar();"
+ + NL + " rI.print();"
+ + NL + " }"
+ + NL + ""
+ + NL + " public static void main(String[] args)"
+ + NL + " {"
+ + NL + " new MyTeam();"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ public void testSimpleSample()
+ {
+
+ createFile("MyBase",
+ "public class MyBase"
+ + NL + "{"
+ + NL + " public String getValue(int i)"
+ + NL + " {"
+ + NL + " return \"Hallo\";"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{"
+ + NL + " protected class MyRole playedBy MyBase"
+ + NL + " {"
+ + NL + " public abstract String getValue(int i);"
+ + NL + " getValue -> getValue;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("Main",
+ "public class Main"
+ + NL + "{"
+ + NL + " public static void main(String[] args)"
+ + NL + " {"
+ + NL + " MyTeam teem = new MyTeam();"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ compileFile("Main");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+
+ public void testIncompatibleReturnTypes()
+ {
+
+ createFile("MyBase",
+ "public class MyBase"
+ + NL + "{"
+ + NL + " public long getValue()"
+ + NL + " {"
+ + NL + " return 1L;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{"
+ + NL + " protected class MyRole playedBy MyBase"
+ + NL + " {"
+ + NL + " public abstract int getValue();"
+ + NL + " getValue -> getValue;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("Main",
+ "public class Main"
+ + NL + "{"
+ + NL + " public static void main(String[] args)"
+ + NL + " {"
+ + NL + " MyTeam teem = new MyTeam();"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ compileFile("Main");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+
+ public void testCalloutOverrideWithCallout()
+ {
+
+ createFile("MyBase",
+ "public class MyBase"
+ + NL + "{"
+ + NL + " public int getValue()"
+ + NL + " {"
+ + NL + " return 1;"
+ + NL + " }"
+ + NL + " public int getValueBad()"
+ + NL + " {"
+ + NL + " return 666;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{"
+ + NL + " public class MyRole playedBy MyBase"
+ + NL + " {"
+ + NL + " protected abstract int getValue();"
+ + NL + " int getValue() -> int getValueBad();"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MySubTeam",
+ "public team class MySubTeam extends MyTeam "
+ + NL + "{"
+ + NL + " public class MyRole"
+ + NL + " {"
+ + NL + " int getValue() => int getValue();"
+ + NL + " }"
+ + NL + " public int getValue(MyBase as MyRole role) { return role.getValue(); }"
+ + NL + "}"
+ + NL);
+
+ createFile("Main",
+ "public class Main"
+ + NL + "{"
+ + NL + " public static void main(String[] args)"
+ + NL + " {"
+ + NL + " MySubTeam teem = new MySubTeam();"
+ + NL + " System.out.println(teem.getValue(new MyBase()));"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ compileFile("Main");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * An overloaded base-method cannot be bound without specifying the full signature.
+ */
+ public void testAmbiguousBinding1()
+ {
+ createFile("MyBase","public class MyBase " +
+ NL + "{ " +
+ NL + " public void baseMethod(){} " +
+ NL + " protected void baseMethod(String arg){} " +
+ NL + "} ");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase " +
+ NL + " { " +
+ NL + " public abstract void roleMethod();" +
+ NL + " roleMethod -> baseMethod; " +
+ NL + " } "+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CompilationUnitContainmentTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CompilationUnitContainmentTest.java
new file mode 100644
index 0000000..06a4a31
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CompilationUnitContainmentTest.java
@@ -0,0 +1,53 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: CompilationUnitContainmentTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+
+/**
+ * This class contains tests concerning compilation units.
+ *
+ * @author brcan
+ * @version $Id: CompilationUnitContainmentTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class CompilationUnitContainmentTest extends TestBase
+{
+ public CompilationUnitContainmentTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * The compilation unit's name doesn't match with the type declaration's name.
+ * Comment:
+ * Just like classes in Java, the name of the team has to be identical to
+ * the file name.
+ */
+ public void testInvalidCompilationUnitName1()
+ {
+ createFile("MyTeam","public team class MyTeamWrongName {}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+}
\ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CopyInheritanceTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CopyInheritanceTest.java
new file mode 100644
index 0000000..02f0bee
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/CopyInheritanceTest.java
@@ -0,0 +1,216 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: CopyInheritanceTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * @author macwitte/haebor
+ */
+public class CopyInheritanceTest extends TestBase {
+
+ /**
+ * Testcases for Copy-Inheritance
+ */
+ public CopyInheritanceTest(String testName) {
+ super(testName);
+ }
+
+ /**
+ * Test copy inheritance for string-array-references
+ */
+ public void testCopyStringArrayReferences()
+ {
+
+
+ createFile("MySuperTeam","public team class MySuperTeam " +
+ NL + "{ " +
+ NL + " public class MyRole" +
+ NL + " { " +
+ NL + " String[] strArray;" +
+ NL + " public void roleMethod()" +
+ NL + " {" +
+ NL + " strArray = new String[1];" +
+ NL + " strArray[0] = \"adsf\";" +
+ NL + " }" +
+ NL + " } " +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam extends MySuperTeam" +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * Test copy inheritance for role-array-references
+ */
+ public void testCopyRoleArrayReferences()
+ {
+
+
+ createFile("MySuperTeam","public team class MySuperTeam " +
+ NL + "{ " +
+ NL + " public class MyRole" +
+ NL + " { " +
+ NL + " MyRole[] roleArray;" +
+ NL + " public void roleMethod()" +
+ NL + " {" +
+ NL + " roleArray = new MyRole[1];" +
+ NL + " roleArray[0] = new MyRole();" +
+ NL + " }" +
+ NL + " } " +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam extends MySuperTeam" +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * Test copy inheritance for int-array-references
+ */
+ public void testCopyIntArrayReferences()
+ {
+
+
+ createFile("MySuperTeam","public team class MySuperTeam " +
+ NL + "{ " +
+ NL + " public class MyRole" +
+ NL + " { " +
+ NL + " int[] intArray;" +
+ NL + " public void roleMethod()" +
+ NL + " {" +
+ NL + " intArray = new int[1];" +
+ NL + " intArray[0] = 42;" +
+ NL + " }" +
+ NL + " } " +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam extends MySuperTeam" +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * Test copy inheritance for array-length-field access
+ */
+ public void testCopyIntArrayLengthFieldAccess()
+ {
+
+ createFile("MySuperTeam","public team class MySuperTeam " +
+ NL + "{ " +
+ NL + " public class MyRole" +
+ NL + " { " +
+ NL + " int[] intArray;" +
+ NL + " public void roleMethod()" +
+ NL + " {" +
+ NL + " intArray = new int[42];" +
+ NL + " intArray[0] = intArray.length;" +
+ NL + " }" +
+ NL + " } " +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam extends MySuperTeam" +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+
+ /**
+ * Test copy inheritance with missing import in subclass
+ */
+ public void testMissingImport1()
+ {
+ createFile("MySuperTeam","" +
+ NL + "public team class MySuperTeam " +
+ NL + "{ " +
+ NL + " public class MyRole {}" +
+ NL + "}");
+
+ createFile("MyTeam","" +
+ NL + "public team class MyTeam extends MySuperTeam" +
+ NL + "{ " +
+ NL + " public class MyRole" +
+ NL + " { " +
+ NL + " BigDecimal roleMethod()" +
+ NL + " {" +
+ NL + " return null;" +
+ NL + " }" +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * Test copy inheritance with missing import in subclass
+ */
+ public void testMissingImport2()
+ {
+ createFile("MySuperTeam","" +
+ NL + "public team class MySuperTeam " +
+ NL + "{ " +
+ NL + " public class MyRole {" +
+ //NL + " public void method(){}" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("MyTeam","" +
+ NL + "public team class MyTeam extends MySuperTeam" +
+ NL + "{ " +
+ NL + " public class MyRole" +
+ NL + " { " +
+ NL + " BigDecimal roleMethod()" +
+ NL + " {" +
+ NL + " return null;" +
+ NL + " }" +
+ NL + " void roleMethod1()" +
+ NL + " {" +
+ NL + " return null;" +
+ NL + " }" +
+
+ NL + " } " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ExternalRoleTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ExternalRoleTest.java
new file mode 100644
index 0000000..794249f
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ExternalRoleTest.java
@@ -0,0 +1,152 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: ExternalRoleTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import java.io.File;
+
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * @author macwitte
+ */
+public class ExternalRoleTest extends TestBase implements IOTConstants{
+
+ public ExternalRoleTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * Test for external defined role with special team-package declaration
+ */
+ public void testExternalRoleWithCompiledTeam()
+ {
+ createFile("MyRole","team package MyTeam;" +
+ NL + "public class MyRole {" +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam { " +
+ NL + " private MyRole r = null;" +
+ NL + "}");
+
+ compileFile("MyTeam");
+ assertTrue(isCompilationSuccessful());
+
+ compileFile("MyTeam"+File.separator+"MyRole");
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * Test for external defined role with special team-package declaration
+ */
+ public void testExternalRoleWithUncompiledTeam()
+ {
+ createFile("MyRole","team package MyTeam;" +
+ NL + "public class MyRole {" +
+ NL + " void foo() { System.out.println(MyTeam.this); }" +
+ NL + "}");
+
+ createFile("MyTeam","public team class MyTeam { " +
+ NL + " private MyRole r = null;" +
+ NL + "}");
+
+ compileFile("MyTeam"+File.separator+"MyRole");
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * Test for external defined role with special team-package declaration
+ */
+ public void testExternalRoleWithQualifiedPackageName()
+ {
+ createFile("MyRole","team package org.eclipse.objectteams.MyTeam;" +
+ NL + "public class MyRole {" +
+ NL + "}");
+
+ createFile("MyTeam","package org.eclipse.objectteams;" +
+ NL + "public team class MyTeam { " +
+ NL + " private MyRole r = null;" +
+ NL + "}");
+
+ compileFile("org"+File.separator+"objectteams"+File.separator+"MyTeam"+File.separator+"MyRole");
+ assertTrue(isCompilationSuccessful());
+
+ compileFile("org"+File.separator+"objectteams"+File.separator+"MyTeam");
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * Test for external defined role with special team-package declaration
+ * Expected Team has missing team Modifier
+ */
+ public void testExternalRoleWithMissingTeamModifier()
+ {
+ createFile("MyRole","team package MyTeam;" +
+ NL + "public class MyRole {" +
+ NL + "}");
+
+ createFile("MyTeam","public class MyTeam { " +
+ NL + " private MyRole r = null;" +
+ NL + "}");
+
+ compileFile("MyTeam"+File.separator+"MyRole");
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * Test for external defined role with special team-package declaration
+ * Expected Team does not exist
+ */
+ public void testExternalRoleWithMissingTeam()
+ {
+ createFile("MyRole","team package MyTeam;" +
+ NL + "public class MyRole {" +
+ NL + "}");
+
+ compileFile("MyTeam"+File.separator+"MyRole");
+ assertFalse(isCompilationSuccessful());
+ }
+
+ //http://nevermind.cs.tu-berlin.de/~gis/ot/2.4.2-otjld-inaccessible-base-class-9.html
+ public void inaccessiblebaseclass()
+ {
+ createFile("MyClass","package p1;"+
+ NL + "public class MyClass {"+
+ NL + " class InnerClass {}"+
+ NL + "}");
+
+ createFile("MyTeam","package p2;"+
+ NL + "public team class MyTeam {"+
+ NL + "public class MyRole extends p1.MyClass playedBy InnerClass {}"+
+ NL + "}");
+
+ compileFile("p1"+File.separator+"MyClass");
+ assertTrue(isCompilationSuccessful());
+
+ compileFile("p2"+File.separator+"MyTeam");
+ assertFalse(isCompilationSuccessful());
+
+ }
+
+
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/LiftingTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/LiftingTest.java
new file mode 100644
index 0000000..4039e8f
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/LiftingTest.java
@@ -0,0 +1,96 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: LiftingTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class contains tests concerning the Lifting mechanism in ObjectTeams.
+ *
+ * @author brcan
+ * @version $Id: LiftingTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class LiftingTest extends TestBase implements IOTConstants
+{
+ public LiftingTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A test for declared lifting.
+ */
+ public void testDeclaredLifting1()
+ {
+ createFile("MyBase","public class MyBase {}");
+
+ createFile("MyTeam","public team class MyTeam { " +
+ NL + " protected class MyRole playedBy MyBase {" +
+ NL + " }" +
+ NL + " public void method(MyBase as MyRole obj){" +
+ NL + " System.out.println(\"method(\"+obj+\")\");" +
+ NL + " }" +
+ NL + " public static void main (String[] args) {" +
+ NL + " (new MyTeam()).method(new MyBase());" +
+ NL + " }"+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A test for smart lifting.
+ */
+ public void testSmartLifting1()
+ {
+ createFile("Base2", "public class Base2 {}");
+
+ createFile("Base3", "public class Base3 extends Base2{}");
+
+ createFile("MyTeam","public team class MyTeam extends org.objectteams.Team {" +
+ NL + " public static void main(String[] args){" +
+ NL + " System.out.println(\"MyTeam\");" +
+ NL + " new MyTeam();" +
+ NL + " }" +
+ NL + " public MyTeam() {" +
+ NL + " super();" +
+ NL + " System.out.println(\"MyTeam.MyTeam()\");" +
+ NL + " System.out.println("+new String(_OT_LIFT_TO)+OT_DELIM+"Role2(this, new Base2(), 0));" +
+ NL + " }" +
+ NL + " public class Role1 {}" +
+ NL + " public class Role2 extends Role1 playedBy Base2{}" +
+ NL + " public class Role3 extends Role2 playedBy Base3{}" +
+ NL + " public class Role4 extends Role3 playedBy Base3{}" +
+ NL + " public class Role6 extends Role4 playedBy Base3{}" +
+ NL + " public class Role5 extends Role4 playedBy Base3{}" +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ // TODO (SH): what problem expected? definite ambiguity 7.3(b)?
+ // need to replace explicit lift-invocation with some legal syntax.
+ assertFalse(isCompilationSuccessful());
+ }
+}
+
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/LoweringTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/LoweringTest.java
new file mode 100644
index 0000000..33c0690
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/LoweringTest.java
@@ -0,0 +1,153 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: LoweringTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class contains tests concerning the Lowering mechanism in ObjectTeams.
+ *
+ * @author brcan
+ * @version $Id: LoweringTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class LoweringTest extends TestBase
+{
+ public LoweringTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * Testing arraylowering; simple structure of classes,
+ * complex lowering.
+ */
+ public void testArrayLowering1()
+ {
+ createFile("MyBase","public class MyBase"
+ + NL + "{"
+ + NL + ""
+ + NL + " public void myBaseLowerMethod(MyBase[][] b1, MyBase[][] b2)"
+ + NL + " {"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{"
+ + NL + ""
+ + NL + " public class Role playedBy MyBase"
+ + NL + " {"
+ + NL + ""
+ + NL + " abstract void myLoweringCallout(Role[][] r1, Role[][] r2);"
+ + NL + ""
+ + NL + " void myLoweringCallout(Role[][] r1, Role[][] r2) -> void myBaseLowerMethod(MyBase[][] r1, MyBase[][] r2);"
+ + NL + " }"
+ + NL + ""
+ + NL + " public static void main(String[] args){"
+ + NL + " new MyTeam();"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A test for lowering.
+ */
+ public void testLowering1()
+ {
+ createFile("MyBase","public class MyBase"
+ + NL + "{"
+ + NL + " public void myBaseMethod(int a)"
+ + NL + " {"
+ + NL + " System.out.println(\"normal\");"
+ + NL + " }"
+ + NL + ""
+ + NL + " public int myBaseLowerMethod(MyBase b)"
+ + NL + " {"
+ + NL + " System.out.println(\"lowered\");"
+ + NL + " return 5;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyBase2","public class MyBase2 extends MyBase"
+ + NL + "{"
+ + NL + " public void myBaseMethod(int a)"
+ + NL + " {"
+ + NL + " System.out.println(\"normal\");"
+ + NL + " }"
+ + NL + ""
+ + NL + " public int myBaseLowerMethod(MyBase b)"
+ + NL + " {"
+ + NL + " System.out.println(\"lowered\");"
+ + NL + " return 5;"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ createFile("MyTeam",
+ "public team class MyTeam extends org.objectteams.Team"
+ + NL + "{"
+ + NL + " public MyTeam()"
+ + NL + " {"
+ + NL + " Role r = new Role(new MyBase());"
+ + NL + " r.myCallout(4);"
+ + NL + " }"
+ + NL + ""
+ + NL + " public class Role0"
+ + NL + " {"
+ + NL + ""
+ + NL + " void myCallout(int a)"
+ + NL + " {"
+ + NL + " System.out.println(\"Hallo\");"
+ + NL + " }"
+ + NL + " }"
+ + NL + ""
+ + NL + " public class Role extends Role0 playedBy MyBase"
+ + NL + " {"
+ + NL + ""
+ + NL + " abstract int myLoweringCallout(Role r);"
+ + NL + ""
+ + NL + " void myCallout(int a) => void myBaseMethod(int a);"
+ + NL + " int myLoweringCallout(Role r) -> int myBaseLowerMethod(MyBase r);"
+ + NL + " }"
+ + NL + ""
+ + NL + " public class Role2 playedBy MyBase2"
+ + NL + " {"
+ + NL + " }"
+ + NL + ""
+ + NL + " public static void main(String[] args){"
+ + NL + " new MyTeam();"
+ + NL + " }"
+ + NL + "}"
+ + NL);
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ParameterMappingsTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ParameterMappingsTest.java
new file mode 100644
index 0000000..34e11a6
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ParameterMappingsTest.java
@@ -0,0 +1,215 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: ParameterMappingsTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class contains tests concerning the parameter mappings in callin and
+ * callout bindings.
+ *
+ * @author brcan
+ * @version $Id: ParameterMappingsTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class ParameterMappingsTest extends TestBase
+{
+ public ParameterMappingsTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A base method with a parameter is used in a callout binding.
+ */
+ public void testCalloutParameterMappingResult1()
+ {
+ createFile("MyBase",
+ "public class MyBase { \r\n"+
+ " public int baseMethod() { return 2; } \r\n"+
+ "} \r\n"
+ );
+
+ createFile("SuperRoleClass",
+ "public class SuperRoleClass { \r\n"+
+ " public int roleMethod() { return 1000; } \r\n"+
+ "} \r\n"
+ );
+
+ createFile("MyTeam",
+ "public team class MyTeam { \r\n"+
+ " protected class MyRole extends SuperRoleClass playedBy MyBase { \r\n"+
+ " int roleMethod() => int baseMethod() with { \r\n"+
+ " result <- result * 5 \r\n"+
+ " } \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A base method with a parameter is used in a callout binding.
+ */
+ public void testCalloutParameterMappings1()
+ {
+ createFile("MyBase",
+ "public class MyBase { \r\n"+
+ " public void baseMethod(boolean valueB) {} \r\n"+
+ "} \r\n"
+ );
+
+ createFile("MyTeam",
+ "public team class MyTeam { \r\n"+
+ " protected class MyRole playedBy MyBase { \r\n"+
+ " public abstract void roleMethod(int valueA); \r\n"+
+ " void roleMethod(int valueA) -> void baseMethod(boolean valueB) with { \r\n"+
+ " valueA == 1 -> valueB \r\n"+
+ " } \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A base method with a parameter is used in a callin binding.
+ */
+ public void testCallinParameterMappings1()
+ {
+ createFile("MyBase",
+ "public class MyBase { \r\n"+
+ " public void baseMethod(float valueB) {} \r\n"+
+ "} \r\n"
+ );
+
+ createFile("MyTeam",
+ "public team class MyTeam { \r\n"+
+ " protected class MyRole playedBy MyBase { \r\n"+
+ " public void roleMethod(float valueA) { \r\n"+
+ " } \r\n"+
+ " void roleMethod(float valueA) <- before void baseMethod(float valueB) with { \r\n"+
+ " valueA <- valueB * 3.14f \r\n"+
+ " } \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A base method with a parameter list is used in a callout binding.
+ */
+ public void testCalloutParameterMappingList1()
+ {
+ createFile("MyBase",
+ "public class MyBase { \r\n"+
+ " public void baseMethod(float valueB, float valueC) { \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ createFile("MyTeam",
+ "public team class MyTeam{ \r\n"+
+ " protected class MyRole playedBy MyBase { \r\n"+
+ " public abstract void roleMethod(float valueA); \r\n"+
+ " void roleMethod(float valueA) -> void baseMethod(float valueB, float valueC) with { \r\n"+
+ " valueA * 3.14f -> valueB , \r\n"+
+ " valueA * 3.14f -> valueC \r\n"+
+ " } \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A base method with a parameter list is used in a callin binding.
+ */
+ public void testCallinParameterMappingList1()
+ {
+ createFile("MyBase",
+ "public class MyBase { \r\n"+
+ " public void baseMethod(float valueB, float valueC) { \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ createFile("MyTeam",
+ "public team class MyTeam{ \r\n"+
+ " protected class MyRole playedBy MyBase { \r\n"+
+ " public void roleMethod(float valueA) { \r\n"+
+ " } \r\n"+
+ " void roleMethod(float valueA) <- after void baseMethod(float valueB, float valueC) with { \r\n"+
+ " valueA <- valueC * 3.14f \r\n"+
+ " } \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+
+ /**
+ * Broken callin-binding:
+ * the base-method's argument list is different from the one in the binding declaration.
+ */
+ public void testCallinParameterMappingList2()
+ {
+ createFile("MyBase",
+ "public class MyBase { \r\n"+
+ " public void baseMethod(float valueB) { \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ createFile("MyTeam",
+ "public team class MyTeam{ \r\n"+
+ " protected class MyRole playedBy MyBase { \r\n"+
+ " public void roleMethod(float valueA) { \r\n"+
+ " } \r\n"+
+ " void roleMethod(float valueA) <- replace void baseMethod(float valueB, float valueC) with { \r\n"+
+ " valueA <- valueB * 3.14, \r\n"+
+ " valueA <- valueC * 3.14 \r\n"+
+ " } \r\n"+
+ " } \r\n"+
+ "} \r\n"
+ );
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ParserTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ParserTest.java
new file mode 100644
index 0000000..ec186d1
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/ParserTest.java
@@ -0,0 +1,125 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: ParserTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class contains tests concerning the parser.
+ *
+ * @author brcan
+ * @version $Id: ParserTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class ParserTest extends TestBase
+{
+ public ParserTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A test consisting of a main class, a base class, a team with two
+ * methods (team-level methods) and a role which has a callin method
+ * and a callin + callout binding.
+ */
+// TODO(jwl): What is the gist we are actually testing here?
+ public void testParser()
+ {
+ createFile("Main",
+ "public class Main"
+ + NL + "{"
+ + NL + " public static void main(String[] args)"
+ + NL + " {"
+ + NL + " MyClass baseObj = new MyClass();"
+ + NL + " MyTeam teamInstance = new MyTeam();"
+ + NL + " within(teamInstance)"
+ + NL + " {"
+ + NL + " System.out.println();"
+ + NL + " System.out.println(\" Main.main --> MyTeam.whisper Hello \");"
+ + NL + " teamInstance.whisper(baseObj, \"Hello\");"
+ + NL + " }"
+ + NL + " }"
+ + NL + "}");
+
+ createFile("MyClass",
+ "public class MyClass "
+ + NL + "{"
+ + NL + " public void say(String msg)"
+ + NL + " {"
+ + NL + " System.out.println(\" MyBase says : \" + msg);"
+ + NL + " }"
+ + NL + " public void whisper(String msg)"
+ + NL + " {"
+ + NL + " System.out.println(\" MyBase whispers : \" + msg);"
+ + NL + " }"
+ + NL + "}");
+
+ createFile("MyTeam",
+ "public team class MyTeam"
+ + NL + "{"
+ + NL + " public class MyRole playedBy MyClass"
+ + NL + " {"
+ + NL + " callin void say(String msg)"
+ + NL + " {"
+ + NL + " System.out.println(\" MyRole says : \" + msg);"
+ + NL + " base.say(msg);"
+ + NL + " }"
+ + NL + " say <- replace whisper;"
+ + NL + " public abstract void whisper(String msg);"
+ + NL + " whisper -> whisper;"
+ + NL + " }"
+ + NL + " public void say(String msg)"
+ + NL + " {"
+ + NL + " System.out.println(\" MyTeam says : \" + msg);"
+ + NL + " }"
+ + NL + " public void whisper(MyClass as MyRole role, String msg)"
+ + NL + " {"
+ + NL + " System.out.println(\" MyTeam whispers : \" + msg );"
+ + NL + " role.whisper(msg);"
+ + NL + " }"
+ + NL + "}");
+
+ compileFile("Main");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ public void testScopedKeywordJavadoc()
+ {
+ createFile("Main",
+ "public class Main"
+ + NL + "{"
+ + NL + " /**"
+ + NL + " * @param base an input"
+ + NL + " */"
+ + NL + " public void foo(String base)"
+ + NL + " {"
+ + NL + " System.out.println(base);"
+ + NL + " }"
+ + NL + "}");
+
+
+
+ compileFile("Main");
+
+ assertTrue(isCompilationSuccessful());
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleBaseInheritanceTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleBaseInheritanceTest.java
new file mode 100644
index 0000000..c1eba20
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleBaseInheritanceTest.java
@@ -0,0 +1,255 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: RoleBaseInheritanceTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+
+/**
+ * Tests the relationship between role and base classes.
+ *
+ * @author kaschja
+ * @version $Id: RoleBaseInheritanceTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class RoleBaseInheritanceTest extends TestBase
+{
+ public RoleBaseInheritanceTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A role class must not be bound to a non-existing base class.
+ */
+ public void testBindingOfNonExistingBaseClass1()
+ {
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " class MyRole playedBy NonExistingBase " +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A regular class (non-team) must not be bound to a base class.
+ */
+ public void testBindingRegularClassWithBaseClass1()
+ {
+ createFile("MyBase","public class MyBase {}");
+
+ createFile("MyClass","public class MyClass " +
+ NL + "{" +
+ NL + " class MyRole playedBy MyBase {}" +
+ NL + "}");
+
+ compileFile("MyClass");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role class must not be bound to a primitive type.
+ * In this testing sample the primitive type is int.
+ */
+ public void testBindingOfPrimitiveType1()
+ {
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " class MyRole playedBy int " +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role class must not be bound to an array.
+ * In this testing sample the array element type is the primitive type int.
+ */
+ public void testBindingOfArrayType1()
+ {
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " class MyRole playedBy int[] " +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role class must not be bound to an array.
+ * In this testing sample the array element type is a class type.
+ */
+ public void testBindingOfArrayType2()
+ {
+ createFile("MyBase", "public class MyBase{}");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " class MyRole playedBy MyBase[] " +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+
+ /**
+ * A role class must not be bound to a base class
+ * if both classes have identical names
+ * In this testing sample the classes reside in the same package
+ */
+ public void testBindingWithNamingClash1()
+ {
+ createFile("Role", "public class Role{}");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " class Role playedBy Role " +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+
+//TODO fix problem with creating packages with method TestBase.createFile
+ /**
+ * A role class must not be bound to a base class
+ * if both classes have identical names
+ * In this testing sample the classes reside in different packages
+ */
+// public void testBindingWithNamingClash2()
+// {
+// createFile("basepackage/Role", "package basepackage;\npublic class Role{}");
+//
+// createFile("teampackage/MyTeam",
+// "package teampackage;" +
+// NL + "public team class MyTeam " +
+// NL + "{ " +
+// NL + " class Role playedBy Role " +
+// NL + " { " +
+// NL + " } " +
+// NL + "}");
+//
+// compileFile("MyTeam");
+//
+// assertFalse(isCompilationSuccessful());
+// }
+
+ /**
+ * A role class must not be bound to a base class
+ * if there is another role in the same team
+ * which has the same name as the bound base class.
+ */
+ public void testBindingWithNamingClash3()
+ {
+ createFile("RoleB", "public class RoleB{}");
+
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " class RoleA playedBy RoleB" +
+ NL + " { " +
+ NL + " } " +
+ NL + " class RoleB" +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role class must not be bound to a base class
+ * if there is a role in a superteam
+ * which has the same name as the bound base class.
+ */
+ public void testBindingWithNamingClash4()
+ {
+ createFile("RoleB", "public class RoleB{}");
+
+ createFile("Superteam","public team class Superteam " +
+ NL + "{ " +
+ NL + " class RoleB" +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ createFile("Subteam","public team class Subteam extends Superteam" +
+ NL + "{ " +
+ NL + " class RoleA playedBy RoleB" +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("Subteam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role class must not be bound to a base class
+ * if there is a role in a subteam
+ * which has the same name as the bound base class.
+ */
+ public void testBindingWithNamingClash5()
+ {
+ createFile("RoleB", "public class RoleB{}");
+
+ createFile("Superteam","public team class Superteam " +
+ NL + "{ " +
+ NL + " class RoleA playedBy RoleB" +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ createFile("Subteam","public team class Subteam extends Superteam" +
+ NL + "{ " +
+ NL + " class RoleB" +
+ NL + " { " +
+ NL + " } " +
+ NL + "}");
+
+ compileFile("Subteam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleContainmentTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleContainmentTest.java
new file mode 100644
index 0000000..4c1a890
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleContainmentTest.java
@@ -0,0 +1,56 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: RoleContainmentTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class contains tests concerning roles.
+ *
+ * @author kaschja
+ * @version $Id: RoleContainmentTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class RoleContainmentTest extends TestBase
+{
+ public RoleContainmentTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A role that is not declared as abstract contains an abstract method.
+ * Comment:
+ * A role has to be declared as abstract if it contains an abstract method.
+ */
+ public void testAbstractMethodInNonAbstractRole1()
+ {
+ createFile("MyTeam","public team class MyTeam { " +
+ NL + " protected class MyRole {" +
+ NL + " public abstract void roleMethod();" +
+ NL + " }"+
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[] { IProblem.AbstractMethodsInConcreteClass, IProblem.AbstractMethodInAbstractClass } ));
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleInheritanceTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleInheritanceTest.java
new file mode 100644
index 0000000..330165b
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/RoleInheritanceTest.java
@@ -0,0 +1,357 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: RoleInheritanceTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class contains tests concerning role inheritance.
+ *
+ * @author kaschja
+ * @version $Id: RoleInheritanceTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class RoleInheritanceTest extends TestBase
+{
+ public RoleInheritanceTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A role extends explicitly a role of a foreign team (non-superteam).
+ * Both roles have the same name.
+ * Comment:
+ * A role can only extend explicitly another role of the same team.
+ */
+ public void testRoleExtendsRoleWithSameNameOfForeignTeam1()
+ {
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " protected class Role {} " +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB " +
+ NL + "{ " +
+ NL + " protected class Role extends TeamA.Role {} " +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role extends explicitly a role of a foreign team (non-superteam).
+ * Comment:
+ * A role can only extend explicitly another role of the same team.
+ */
+ public void testRoleExtendsRoleOfForeignTeam1()
+ {
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " protected class RoleA {} " +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB " +
+ NL + "{ " +
+ NL + " protected class RoleB extends TeamA.RoleA {} " +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role inherits implicitly and explicitly a role from the superteam.
+ * Comment:
+ * A role may not inherit a role explicitly if it is already inherited
+ * implicitly from the superteam (by name-matching).
+ */
+ public void testRoleInheritsRoleImplicitlyAndExplicitlyFromSuperTeam1()
+ {
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " protected class Role {} " +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB extends TeamA" +
+ NL + "{ " +
+ NL + " protected class Role extends TeamA.Role {} " +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role inherits from an external class.
+ */
+ public void testRoleExtendsExternalClass1()
+ {
+ createFile("MyClass","public class MyClass " +
+ NL + "{ " +
+ NL + "}");
+
+ createFile("Team","public team class Team " +
+ NL + "{ " +
+ NL + " protected class Role extends MyClass {} " +
+ NL + "}");
+
+ compileFile("Team");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A role inherits explicitly from an abstract role.
+ * It does not implement the abstract methods.
+ * Comment:
+ * A role has to implement the abstract methods if it extends
+ * an abstract role.
+ */
+ public void testRoleInheritsExplicitlyFromAbstractRole1()
+ {
+ createFile("MyTeam","public team class MyTeam { " +
+ NL + " abstract class Role1 {" +
+ NL + " public abstract void role1Method();" +
+ NL + " }" +
+ NL + " class Role2 extends Role1 {} " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A role inherits implicitly from an abstract role.
+ * It does not implement the abstract methods.
+ * Comment:
+ * A role has to implement the abstract methods of the implicitly
+ * inherited abstract role.
+ */
+ public void testRoleInheritsImplicitlyFromAbstractRole1()
+ {
+ createFile("TeamA","public team class TeamA { " +
+ NL + " abstract class RoleA {" +
+ NL + " public abstract void roleMethod();" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB extends TeamA " +
+ NL + "{ " +
+ NL + " protected class RoleA {} " +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * An implicitly inherited role inherits explicitly from an external class.
+ * The super-role does not extend any class.
+ */
+ public void testImplicitInheritedRoleExtendsExternalClass1()
+ {
+ createFile("ExternalClass","public class ExternalClass " +
+ NL + "{ " +
+ NL + "}");
+
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " protected class Role {} " +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB extends TeamA" +
+ NL + "{ " +
+ NL + " protected class Role extends ExternalClass {} " +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * An implicitly inherited role inherits explicitly from an external class.
+ * The super-role extends a different class than the sub-role.
+ * Comment:
+ * An implicitly inherited role has to extend the same external class
+ * as the super-role.
+ */
+ public void testImplicitInheritedRoleExtendsExternalClass2()
+ {
+ createFile("ExternalClass","public class ExternalClass " +
+ NL + "{ " +
+ NL + "}");
+
+ createFile("DifferentClass","public class DifferentClass " +
+ NL + "{ " +
+ NL + "}");
+
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " protected class Role extends DifferentClass {} " +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB extends TeamA" +
+ NL + "{ " +
+ NL + " protected class Role extends ExternalClass {} " +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A sub-role has a restricted visibility compared to the super-role.
+ * Comment:
+ * A role may not restrain the visibility of the implicitly inherited role.
+ * (does the private modifier actually makes sense in a role context?)
+ */
+ public void testRestrictedVisibilityOfSubRole1()
+ {
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " public class Role {} " +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB extends TeamA" +
+ NL + "{ " +
+ NL + " protected class Role {} " +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * An overwriting method in a sub-role has a restricted visibility compared
+ * to the overwritten method in the super-role.
+ * Comment:
+ * A method in a role may not restrain the visibility of the
+ * implicitly inherited role-method.
+ */
+ public void testRestrictedVisibilityOfMethodInSubRole1()
+ {
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " protected class Role {" +
+ NL + " public void roleMethod() {};" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB extends TeamA" +
+ NL + "{ " +
+ NL + " protected class Role {" +
+ NL + " private void roleMethod() {};" +
+ NL + " }" +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * An implicitly inherited role does not implement all the interfaces
+ * of the super-role.
+ * Commment:
+ * An implicitly inherited role has to implement all the interfaces of the
+ * super-role.
+ */
+ public void testImplementationOfInterfacesBySubRole1()
+ {
+ createFile("IState","public interface IState" +
+ NL + "{" +
+ NL + " public IState getState();" +
+ NL + "}");
+
+ createFile("ITransfer","public interface ITransfer" +
+ NL + "{" +
+ NL + " public void doTransfer();" +
+ NL + "}");
+
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " protected class Role implements IState, ITransfer " +
+ NL + " {" +
+ NL + " public IState getState() {}" +
+ NL + " public void doTransfer() {}" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB extends TeamA" +
+ NL + "{ " +
+ NL + " protected class Role implements IState " +
+ NL + " {" +
+ NL + " public IState getState() {}" +
+ NL + " }" +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * An implicitly inherited role implements more interfaces than
+ * the super-role.
+ */
+ public void testImplementationOfInterfacesBySubRole2()
+ {
+ createFile("IState","public interface IState" +
+ NL + "{" +
+ NL + " public IState getState();" +
+ NL + "}");
+
+ createFile("ITransfer","public interface ITransfer" +
+ NL + "{" +
+ NL + " public void doTransfer();" +
+ NL + "}");
+
+ createFile("TeamA","public team class TeamA " +
+ NL + "{ " +
+ NL + " protected class Role implements IState" +
+ NL + " {" +
+ NL + " public IState getState() { return null; }" +
+ NL + " }" +
+ NL + "}");
+
+ createFile("TeamB","public team class TeamB extends TeamA" +
+ NL + "{ " +
+ NL + " protected class Role implements IState, ITransfer " +
+ NL + " {" +
+ NL + " public IState getState() { return tsuper.getState(); }" +
+ NL + " public void doTransfer() {}" +
+ NL + " }" +
+ NL + "}");
+
+ compileFile("TeamB");
+
+ assertTrue(isCompilationSuccessful());
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/SourceSnippetRecoveryTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/SourceSnippetRecoveryTest.java
new file mode 100644
index 0000000..cd31c03
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/SourceSnippetRecoveryTest.java
@@ -0,0 +1,55 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: SourceSnippetRecoveryTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+
+/**
+ * This class contains tests concerning source code snippets, or wrong code.
+ *
+ * @author Markus Witte
+ */
+public class SourceSnippetRecoveryTest extends TestBase {
+
+ public SourceSnippetRecoveryTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A "replace-callin binding" is used with a base call.
+ * Bound role method must be declared as callin method.
+ */
+ public void testIncompleteCallinBinding()
+ {
+ createFile("MyClass","public class MyClass " +
+ NL + "{ " +
+ NL + " baseMethod <- met1, met2;" +
+ NL + "} ");
+
+
+ compileFile("MyClass");
+
+ assertTrue(hasExpectedProblems(new int[] {IProblem.ParsingErrorMergeTokens})); // silly but factual
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamActivationTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamActivationTest.java
new file mode 100644
index 0000000..4894d12
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamActivationTest.java
@@ -0,0 +1,84 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: TeamActivationTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class is for testing team activation.
+ * Note, test cases which tried to test sequences of activation statements are removed,
+ * because
+ * (a) this can only be tested when also executing the program, and
+ * (b) test goals stated in comments were wrong.
+ *
+ * @author kaschja
+ * @version $Id: TeamActivationTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class TeamActivationTest extends TestBase
+{
+ public TeamActivationTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * team activation with "within" must have team as argument
+ */
+ public void testWithinWithTeamAsArgument() {
+ createFile("MyTeam","public team class MyTeam {}");
+
+ createFile("MyClient","public class MyClient"+
+ NL + "{"+
+ NL + " public static void main(String[] argv) {"+
+ NL + " MyTeam myTeam = new MyTeam();"+
+ NL + " within(myTeam) {"+
+ NL + " System.out.println(\"MyClient.main.within\");"+
+ NL + " }"+
+ NL + " }"+
+ NL + "}");
+
+ compileFile("MyClient");
+
+ assertTrue(isCompilationSuccessful());
+ }
+ /**
+ * team activation with "within" dont have normal class as argument
+ */
+ public void testWithinWithRegularClassAsArgument() {
+ createFile("MyClass","public class MyClass {}");
+
+ createFile("MyClient","public class MyClient"+
+ NL + "{"+
+ NL + " public static void main(String[] argv) {"+
+ NL + " MyClass myClass = new MyClass();"+
+ NL + " within(myClass) {"+
+ NL + " System.out.println(\"MyClient.main.within\");"+
+ NL + " }"+
+ NL + " }"+
+ NL + "}");
+
+ compileFile("MyClient");
+
+ assertTrue(hasExpectedProblems(new int[] {IProblem.WithinStatementNeedsTeamInstance}));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamContainmentTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamContainmentTest.java
new file mode 100644
index 0000000..108bd0c
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamContainmentTest.java
@@ -0,0 +1,188 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: TeamContainmentTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+
+/**
+ * This class contains tests concerning team inheritance.
+ *
+ * @author kaschja
+ * @version $Id: TeamContainmentTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class TeamContainmentTest extends TestBase
+{
+ public TeamContainmentTest(String testName)
+ {
+ super(testName);
+ }
+
+ /* An empty team with no package statement should compile without
+ * problems.
+ */
+ public void testEmptyTeam1()
+ {
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /* An empty team with a specific package statement should compile without
+ * problems.
+ */
+ public void testEmptyTeam2()
+ {
+ createFile("MyTeam","package teams;" +
+ NL + "public team class MyTeam " +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("teams"+File.separator+"MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /* An empty team with a specific package statement should compile without
+ * problems.
+ */
+ public void testEmptyTeam3()
+ {
+ createFile("MyTeam","" + "package pkg1.pkg2.pkg3;" +
+ NL + "public team class MyTeam " +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("pkg1"+File.separator+"pkg2"+File.separator+"pkg3"+File.separator+"MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A team that is not declared as abstract contains an abstract role.
+ * Comment:
+ * A team has to be declared as abstract if it contains an abstract relevant role.
+ * For the notion of "relevant roles" see OT lang.def. 7.1(c) (SH).
+ */
+ public void testAbstractRoleInNonAbstractTeam1()
+ {
+ // TODO (SH): differentiate relevant/irrelevant roles (s.above).
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " abstract protected class MyRole " +
+ NL + " {" +
+ NL + " abstract void roleMethod();" +
+ NL + " }" +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A team that is not declared as abstract contains an abstract
+ * team-level method.
+ * Comment:
+ * A team has to be declared as abstract if it contains an abstract
+ * team-level method.
+ */
+ public void testAbstractMethodInNonAbstractTeam1()
+ {
+ createFile("MyTeam","public team class MyTeam " +
+ NL + "{ " +
+ NL + " abstract void teamMethod();" +
+ NL + "}");
+
+ compileFile("MyTeam");
+
+ assertTrue(hasExpectedProblems(new int[]{ IProblem.AbstractMethodsInConcreteClass, IProblem.AbstractMethodInAbstractClass}));
+ }
+
+ public void testRoleLackingJavadoc1()
+ {
+ createFile("MyBase","/** Comment for MyBase. */" +
+ NL + "public class MyBase " +
+ NL + "{ " +
+ NL + "}");
+
+ createFile("MyTeam","/** Comment for MyTeam. */" +
+ NL + "public team class MyTeam " +
+ NL + "{ " +
+ NL + " public class MyRole playedBy MyBase" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ Map<String,String> options= new HashMap<String,String>();
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocComments, CompilerOptions.ERROR);
+
+ compileFile("MyTeam", null, options);
+
+ assertTrue(hasExpectedProblems(new int[]{ IProblem.JavadocMissing})); // reported only once!
+ }
+
+ public void testRoleLackingJavadoc2()
+ {
+ createFile("MyBase","/** Comment for MyBase. */" +
+ NL + "public class MyBase " +
+ NL + "{ " +
+ NL + "}");
+
+ createFile("MyTeam","/** Comment for MyTeam. */" +
+ NL + "public team class MyTeam " +
+ NL + "{ " +
+ NL + " protected class MyRole playedBy MyBase" +
+ NL + " {" +
+ NL + " }" +
+ NL + "}");
+
+ Map<String,String> options= new HashMap<String,String>();
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportMissingJavadocComments, CompilerOptions.ERROR);
+
+ compileFile("MyTeam", null, options);
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamInheritanceTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamInheritanceTest.java
new file mode 100644
index 0000000..c0e0489
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TeamInheritanceTest.java
@@ -0,0 +1,146 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: TeamInheritanceTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.objectteams.otdt.tests.compiler.TestBase;
+
+/**
+ * This class contains tests concerning team inheritance.
+ *
+ * @author kaschja
+ * @version $Id: TeamInheritanceTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class TeamInheritanceTest extends TestBase
+{
+ public TeamInheritanceTest(String testName)
+ {
+ super(testName);
+ }
+
+ /**
+ * A team class inherits from a non-team class.
+ * Comment:
+ * This is legal since Trac #144.
+ */
+ public void testTeamInheritance1()
+ {
+ createFile("OrdinaryClass","public class OrdinaryClass {}");
+
+ createFile("MyTeam","public team class MyTeam extends OrdinaryClass {}");
+
+ compileFile("MyTeam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * A regular class (non-team class) inherits from a team class.
+ * Comment:
+ * A regular Java class can only extend another Java class,not a team class.
+ */
+ public void testInvalidTeamInheritance2()
+ {
+ createFile("MyTeam","public team class MyTeam {}");
+
+ createFile("MyClass","public class MyClass extends MyTeam {}");
+
+ compileFile("MyClass");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A team class inherits from an abstract team class.
+ * It does not implement the inherited abstract method.
+ * Comment:
+ * A team has to implement the inherited abstract methods of the superteam.
+ */
+ public void testNotImplementedAbstractMethod1()
+ {
+ createFile("Superteam","public abstract team class Superteam " +
+ NL + "{ " +
+ NL + " abstract void teamMethod(); " +
+ NL + "}");
+
+ createFile("Subteam","public team class Subteam extends Superteam" +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("Subteam");
+
+ assertFalse(isCompilationSuccessful());
+ }
+
+ /**
+ * A team class contains a role class.
+ * Another team class that inherits from this team, does not have to
+ * contain the inherited role explicitly.
+ */
+ public void testImplicitInheritance1()
+ {
+ createFile("Superteam","public team class Superteam " +
+ NL + "{ " +
+ NL + " protected class Role {}; " +
+ NL + "}");
+
+ createFile("Subteam","public team class Subteam extends Superteam" +
+ NL + "{ " +
+ NL + "}");
+
+ compileFile("Superteam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ /**
+ * @see testImplicitInheritance1
+ * additional instantiation of inherited role
+ */
+ public void testImplicitInheritance2()
+ {
+ createFile("Superteam","public team class Superteam " +
+ NL + "{ " +
+ NL + " protected class Role {}; " +
+ NL + "}");
+
+ createFile("Subteam","public team class Subteam extends Superteam" +
+ NL + "{ " +
+ NL + " Role _myRole = new Role(); " +
+ NL + "}");
+
+ compileFile("Superteam");
+
+ assertTrue(isCompilationSuccessful());
+ }
+
+ public void testMissingOTRE1() {
+ createFile("T",
+ "import static org.objectteams.Team.ALL_THREADS;\n" +
+ "class B {}\n" +
+ "public team class T {\n" +
+ " protected class R playedBy B {}\n" +
+ " Thread a = ALL_THREADS;\n" +
+ "}");
+ compileFile("T", createClassPathNoOTRE("T"));
+ assertTrue(hasAtLeastExpectedProblems(new int[] {IProblem.ImportNotFound, IProblem.IsClassPathCorrect, IProblem.HierarchyHasProblems}));
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TestAll.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TestAll.java
new file mode 100644
index 0000000..18965e0
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/errorreporting/TestAll.java
@@ -0,0 +1,72 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: TestAll.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.errorreporting;
+
+import junit.framework.TestSuite;
+
+/**
+ * This class collects all test cases in one test suite.
+ *
+ * @author brcan
+ * @version $Id: TestAll.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class TestAll extends TestSuite
+{
+ public TestAll()
+ {
+ super();
+ }
+
+ public static TestSuite suite()
+ {
+ TestSuite suite = new TestSuite("All Compiler Tests");
+
+ // containment tests
+ suite.addTestSuite(CompilationUnitContainmentTest.class);
+ suite.addTestSuite(RoleContainmentTest.class);
+ suite.addTestSuite(TeamContainmentTest.class);
+ // inheritance tests
+ suite.addTestSuite(RoleBaseInheritanceTest.class);
+ suite.addTestSuite(RoleInheritanceTest.class);
+ suite.addTestSuite(TeamInheritanceTest.class);
+ // Copy Inheritance
+ suite.addTestSuite(CopyInheritanceTest.class);
+ // binding tests
+ suite.addTestSuite(CallinBindingTest.class);
+ suite.addTestSuite(CalloutBindingTest.class);
+ // lifting and lowering tests
+ suite.addTestSuite(LiftingTest.class);
+ suite.addTestSuite(LoweringTest.class);
+ // parameter mapping tests
+ suite.addTestSuite(ParameterMappingsTest.class);
+ // team activation tests
+ suite.addTestSuite(TeamActivationTest.class);
+ // parser tests
+ suite.addTestSuite(ParserTest.class);
+ //Code snippets and wrong code tests
+ suite.addTestSuite(SourceSnippetRecoveryTest.class);
+ //External Role tests
+ suite.addTestSuite(ExternalRoleTest.class);
+
+
+ return suite;
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/AbstractSourceMapGeneratorTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/AbstractSourceMapGeneratorTest.java
new file mode 100644
index 0000000..0442647
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/AbstractSourceMapGeneratorTest.java
@@ -0,0 +1,488 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: AbstractSourceMapGeneratorTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.core.tests.compiler.regression.InMemoryNameEnvironment;
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
+import org.eclipse.jdt.internal.compiler.IProblemFactory;
+import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
+import org.eclipse.jdt.internal.compiler.SourceElementParser;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.Expression;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
+import org.eclipse.jdt.internal.compiler.batch.FileSystem;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
+import org.eclipse.objectteams.otdt.debug.core.breakpoints.IOOTBreakPoints;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.SmapStratum;
+import org.eclipse.objectteams.otdt.tests.compiler.CustomizedCompiler;
+import org.eclipse.objectteams.otdt.tests.compiler.ICallbackClient;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+/**
+ * @author ike
+ */
+public abstract class AbstractSourceMapGeneratorTest extends FileBasedModelTest implements ICallbackClient, ISourceElementRequestor
+{
+
+ protected String PROJECT_DIR;
+
+ public static final String COMPLIANCE_1_3 = "1.3";
+ public static final String COMPLIANCE_1_4 = "1.4";
+ public static final String COMPLIANCE_1_5 = "1.5";
+
+ private String complianceLevel = COMPLIANCE_1_5;
+ protected String[] classpaths;
+ protected Hashtable <String, List<SmapStratum>>expectedStrata;
+
+ protected String TYPENAME;
+
+ public static boolean optimizeStringLiterals = false;
+ public static long sourceLevel = ClassFileConstants.JDK1_5; //$NON-NLS-1$
+
+ public String OTRE_JAR_PATH = getOTRE_Path();
+
+ public static String OUTPUT_DIR = Util.getOutputDirectory() + File.separator + "smaptest";
+
+ // the source line within method Team.java:__OT__Confined._OT$getTeam().
+ public static int OT_CONFINED_GET_TEAM_LINE = IOOTBreakPoints.LINE_ConfinedGetTeam;
+
+ public AbstractSourceMapGeneratorTest(String testName)
+ {
+ super(testName);
+ }
+
+ private String getOTRE_Path()
+ {
+ URL url = FileLocator.find(OTDTPlugin.getDefault().getBundle(), new Path("lib/otre.jar"), null);
+ URL resolved_url = null;
+ try
+ {
+ resolved_url = FileLocator.resolve(url);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+
+ if (resolved_url != null)
+ return resolved_url.getPath();
+ else
+ return url.getPath();
+
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(AbstractSourceMapGeneratorTest.class);
+ }
+ junit.framework.TestSuite suite = new Suite(AbstractSourceMapGeneratorTest.class
+ .getName());
+ return suite;
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ expectedStrata = new Hashtable<String, List<SmapStratum>>();
+ }
+
+ protected INameEnvironment getNameEnvironment(final String[] testFiles,
+ String[] classPaths)
+ {
+ this.classpaths = classPaths == null ? getDefaultClassPaths() : classPaths;
+ return new InMemoryNameEnvironment(testFiles, getClassLibs());
+ }
+
+ protected INameEnvironment[] getClassLibs()
+ {
+ String encoding = (String)getCompilerOptions().getMap().get(CompilerOptions.OPTION_Encoding);
+ if ("".equals(encoding))
+ encoding = null;
+
+ INameEnvironment[] classLibs = new INameEnvironment[1];
+ classLibs[0] = new FileSystem(this.classpaths, new String[] {}, // ignore initial file names
+ encoding // default encoding
+ );
+ return classLibs;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected CompilerOptions getCompilerOptions()
+ {
+ CompilerOptions cOptions = new CompilerOptions();
+ Map<String, String> options = cOptions.getMap();
+ if (COMPLIANCE_1_3.equals(this.complianceLevel))
+ {
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_3);
+ }
+ else if (COMPLIANCE_1_4.equals(this.complianceLevel))
+ {
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
+ }
+ else if (COMPLIANCE_1_5.equals(this.complianceLevel))
+ {
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
+ }
+
+ options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
+ options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING);
+ options.put(CompilerOptions.OPTION_ReportLocalVariableHiding, CompilerOptions.WARNING);
+ options.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.WARNING);
+ options.put(CompilerOptions.OPTION_ReportPossibleAccidentalBooleanAssignment, CompilerOptions.WARNING);
+ options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.WARNING);
+ options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
+ options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
+ options.put(CompilerOptions.OPTION_ReportUnnecessaryElse, CompilerOptions.WARNING);
+
+ return new CompilerOptions(options);
+ }
+
+ protected String[] getDefaultClassPaths()
+ {
+ return Util.concatWithClassLibs(OTRE_JAR_PATH, false);
+ }
+
+ protected IErrorHandlingPolicy getErrorHandlingPolicy()
+ {
+ return new IErrorHandlingPolicy()
+ {
+ public boolean stopOnFirstError()
+ {
+ return false;
+ }
+
+ public boolean proceedOnErrors()
+ {
+ return true;
+ }
+ };
+ }
+
+ protected IProblemFactory getProblemFactory()
+ {
+ return new DefaultProblemFactory(Locale.getDefault());
+ }
+
+ /**
+ * @param team
+ * @param role
+ * @throws JavaModelException
+ */
+ public boolean parseAndCompile(org.eclipse.jdt.core.ICompilationUnit[] units ) throws JavaModelException
+ {
+ return parseAndCompile(units, null);
+ }
+ public boolean parseAndCompile(org.eclipse.jdt.core.ICompilationUnit[] units, HashMap<String, int[]> methodLineNumbers ) throws JavaModelException
+ {
+ return parseAndCompile(units, methodLineNumbers, null, null);
+ }
+ public boolean parseAndCompile(org.eclipse.jdt.core.ICompilationUnit[] units,
+ HashMap<String, int[]> methodLineNumbers,
+ String[] classPaths,
+ String outputPath)
+ throws JavaModelException
+ {
+ SourceElementParser parser = new SourceElementParser(this,
+ new DefaultProblemFactory(Locale.getDefault()),
+ new CompilerOptions(), false, false);
+ ICompilationUnit [] cUnits = new ICompilationUnit[units.length];
+
+ for (int idx = 0; idx < units.length; idx++)
+ {
+ org.eclipse.jdt.core.ICompilationUnit unit = units[idx];
+
+ String unit_src = unit.getSource();
+ IResource unit_res = unit.getCorrespondingResource();
+ String unit_fileName = unit_res.toString();
+ char[] unit_source = unit_src.toCharArray();
+ ICompilationUnit unit_sourceUnit = new CompilationUnit(unit_source,
+ unit_fileName, null);
+
+ CompilationUnitDeclaration cuDecl = parser.parseCompilationUnit(
+ unit_sourceUnit, true, null);
+
+ if (cuDecl.hasErrors())
+ return false;
+
+ cUnits[idx] = unit_sourceUnit;
+ }
+
+ Requestor requestor = new Requestor(
+ false,
+ null, /*no custom requestor */
+ false, /* show category */
+ false /* show warning token*/,
+ methodLineNumbers);
+ if (outputPath != null) {
+ requestor.outputPath = outputPath;
+ File outDir = new File(outputPath);
+ if (!outDir.exists())
+ outDir.mkdir();
+ }
+
+ CompilerOptions options = getCompilerOptions();
+
+ CustomizedCompiler batchCompiler = new CustomizedCompiler(
+ getNameEnvironment( new String[] {}, classPaths),
+ getErrorHandlingPolicy(),
+ options,
+ requestor,
+ getProblemFactory()
+ );
+
+ batchCompiler.addCallBack(this);
+
+ batchCompiler.compile(cUnits); // compile all files together
+
+ boolean hasErrors = requestor.hasErrors;
+
+ //errorlog contains errore and warnings, skip warnings
+ if (hasErrors)
+ {
+ String expectedErrorlog = "";
+ String actualErrorlog = requestor.problemLog;
+ assertEquals("COMPILATION FAILED. Errorlog should be empty.", expectedErrorlog, actualErrorlog);
+ }
+
+ if (methodLineNumbers != null)
+ requestor.checkAllLineNumbersSeen();
+
+ return !hasErrors;
+ }
+
+ public abstract void callback(CompilationUnitDeclaration cuDecl);
+
+ public void acceptConstructorReference(char[] typeName, int argCount, int sourcePosition)
+ {
+ }
+
+ public void acceptFieldReference(char[] fieldName, int sourcePosition)
+ {
+ }
+
+ public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand, int modifiers)
+ {
+ }
+
+ public void acceptLineSeparatorPositions(int[] positions)
+ {
+ }
+
+ public void acceptMethodReference(char[] methodName, int argCount, int sourcePosition)
+ {
+ }
+
+ public void acceptPackage(ImportReference importReference)
+ {
+ }
+
+ public void acceptProblem(IProblem problem)
+ {
+ }
+
+ public void acceptTypeReference(char[][] typeName, int sourceStart, int sourceEnd)
+ {
+ }
+
+ public void acceptTypeReference(char[] typeName, int sourcePosition)
+ {
+ }
+
+ public void acceptUnknownReference(char[][] name, int sourceStart, int sourceEnd)
+ {
+ }
+
+ public void acceptUnknownReference(char[] name, int sourcePosition)
+ {
+ }
+
+ public void enterClass(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[] superclass, char[][] superinterfaces)
+ {
+ }
+
+ public void enterCompilationUnit()
+ {
+ }
+
+ public void enterConstructor(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes)
+ {
+ }
+
+ public void enterField(int declarationStart, int modifiers, char[] type, char[] name, int nameSourceStart, int nameSourceEnd)
+ {
+ }
+
+ public void enterInitializer(int declarationStart, int modifiers)
+ {
+ }
+
+ public void enterInterface(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] superinterfaces)
+ {
+ }
+
+ public void enterMethod(int declarationStart, int modifiers, char[] returnType, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes)
+ {
+ }
+
+ public void exitClass(int declarationEnd)
+ {
+ }
+
+ public void exitCompilationUnit(int declarationEnd)
+ {
+ }
+
+ public void exitConstructor(int declarationEnd)
+ {
+ }
+
+ public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd)
+ {
+ }
+
+ public void exitInitializer(int declarationEnd)
+ {
+ }
+
+ public void exitMethod(int declarationEnd, Expression defaultValue)
+ {
+ }
+
+ public void acceptBaseReference(char[][] typeName, int sourceStart, int sourceEnd)
+ {
+ }
+
+ public void enterInterface(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] superinterfaces, char[] baseclassName, boolean isRoleFile)
+ {
+ }
+
+ public void enterClass(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[] superclass, char[][] superinterfaces, char[] baseclassName, boolean isRoleFile)
+ {
+ }
+
+ public void enterCalloutMapping(CalloutInfo calloutInfo)
+ {
+ }
+
+ public void enterCalloutToFieldMapping(CalloutToFieldInfo calloutInfo)
+ {
+ }
+
+ public void enterCallinMapping(CallinInfo callinInfo)
+ {
+ }
+
+ public void exitCalloutMapping(int sourceEnd, int declarationSourceEnd)
+ {
+ }
+
+ public void exitCalloutToFieldMapping(int sourceEnd, int declarationSourceEnd)
+ {
+ }
+
+ public void exitCallinMapping(int sourceEnd, int declarationSourceEnd)
+ {
+ }
+
+ public void acceptProblem(CategorizedProblem problem) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void enterConstructor(MethodInfo methodInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void enterField(FieldInfo fieldInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void enterMethod(MethodInfo methodInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void enterType(TypeInfo typeInfo) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void exitMethod(int declarationEnd, int defaultValueStart, int defaultValueEnd) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void exitType(int declarationEnd) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptAnnotationTypeReference(char[][] annotation,
+ int sourceStart, int sourceEnd) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptAnnotationTypeReference(char[] annotation,
+ int sourcePosition) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/AllTests.java
new file mode 100644
index 0000000..c5ff3cc
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/AllTests.java
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: AllTests.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author ike
+ *
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "All Tests for generation of SourceMaps");
+ //$JUnit-BEGIN$
+ suite.addTest(OTJStratumGenerationTest003.suite());
+ suite.addTest(OTJStratumGenerationTest005.suite());
+ suite.addTest(OTJStratumGenerationTest006.suite());
+ suite.addTest(OTJStratumGenerationTest007.suite());
+ suite.addTest(OTJStratumGenerationTest002.suite());
+ suite.addTestSuite(BaseClassSmapGenerationMethodTest.class);
+ suite.addTest(OTJStratumGenerationTest004.suite());
+ suite.addTest(OTJStratumGenerationTest001.suite());
+ //$JUnit-END$
+ return suite;
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/BaseClassSmapGenerationMethodTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/BaseClassSmapGenerationMethodTest.java
new file mode 100644
index 0000000..8df76a3
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/BaseClassSmapGenerationMethodTest.java
@@ -0,0 +1,610 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: BaseClassSmapGenerationMethodTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+/** Tests the Method which generates the Smap for Baseclasse.
+ * @author ike
+ */
+public class BaseClassSmapGenerationMethodTest extends TestCase
+{
+
+ public void testMethod001()
+ {
+ String baseClassFileName = "SimpleClass$1" ;
+ String baseClassSourceUnit = "path/to/SimpleClass";
+ int endlineNumber = 3;
+ Hashtable<String, int[][]> mappings = new Hashtable<String, int[][]>();
+ int lineMappings[][] = new int[2][3];
+ lineMappings[0] = new int[]{2,2,7};
+ lineMappings[1] = new int[]{3,0,8};
+
+ mappings.put("path/to/TeamA.java", lineMappings);
+
+ int baseMapping [][] = null;
+
+ String expectedString =
+ "SMAP" + "\n" +
+ "SimpleClass$1.class" + "\n" +
+ "OTJ" + "\n" +
+ "*S OTJ" + "\n" +
+ "*F" + "\n" +
+ "+ 1 TeamA.java" + "\n" +
+ "path/to/TeamA.java" + "\n" +
+ "+ 2 SimpleClass.java" + "\n" +
+ "path/to/SimpleClass.java" + "\n" +
+ "*L" + "\n" +
+ "1#2:1" + "\n" +
+ "2#1,2:7" + "\n" +
+ "3#1:8" + "\n" +
+ "*E"
+ ;
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+
+ String actualString = new String(actual);
+
+ assertEquals("SMAP should be equal.", expectedString, actualString);
+ }
+
+ public void testMethod002()
+ {
+ String baseClassFileName = "SimpleClass$1" ;
+ String baseClassSourceUnit = "SimpleClass";
+ int endlineNumber = 3;
+ Hashtable<String, int[][]> mappings = new Hashtable<String, int[][]>();
+ int lineMappings[][] = new int[2][3];
+ lineMappings[0] = new int[]{2,2,7};
+ lineMappings[1] = new int[]{3,0,8};
+
+ mappings.put("TeamA.java", lineMappings);
+
+ int baseMapping [][] = null;
+
+ String expectedString =
+ "SMAP" + "\n" +
+ "SimpleClass$1.class" + "\n" +
+ "OTJ" + "\n" +
+ "*S OTJ" + "\n" +
+ "*F" + "\n" +
+ "1 TeamA.java" + "\n" +
+ "2 SimpleClass.java" + "\n" +
+ "*L" + "\n" +
+ "1#2:1" + "\n" +
+ "2#1,2:7" + "\n" +
+ "3#1:8" + "\n" +
+ "*E";
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+
+ String actualString = new String(actual);
+
+ assertEquals("SMAP should be equal.", expectedString, actualString);
+
+ }
+
+ public void testMethod003()
+ {
+ String baseClassFileName = "SimpleClass$1" ;
+ String baseClassSourceUnit = "SimpleClass";
+ int endlineNumber = 3;
+ Hashtable<String, int[][]> mappings = new Hashtable<String, int[][]>();
+
+ int baseMapping [][] = null;
+
+ String expectedString =
+ "SMAP" + "\n" +
+ "SimpleClass$1.class" + "\n" +
+ "OTJ" + "\n" +
+ "*S OTJ" + "\n" +
+ "*F" + "\n" +
+ "1 SimpleClass.java" + "\n" +
+ "*L" + "\n" +
+ "1#1,3:1" + "\n" +
+ "*E";
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+
+ String actualString = new String(actual);
+
+ assertEquals("SMAP should be equal.", expectedString, actualString);
+
+ }
+
+ public void testMethod004()
+ {
+ String baseClassFileName = "BaseClass" ;
+ String baseClassSourceUnit = "very/very/long/path/to/BaseClass";
+ int endlineNumber = 50;
+ Hashtable<String, int[][]> mappings = new Hashtable<String, int[][]>();
+ int lineMappings1[][] = new int[7][3];
+ lineMappings1[0] = new int[]{7,0,10};
+ lineMappings1[1] = new int[]{14,1,25};
+ lineMappings1[2] = new int[]{21,0,30};
+ lineMappings1[3] = new int[]{28,2,35};
+ lineMappings1[4] = new int[]{35,0,40};
+ lineMappings1[5] = new int[]{42,3,45};
+ lineMappings1[6] = new int[]{125,0,250};
+
+ mappings.put("path/to/TeamB.java", lineMappings1);
+
+ int lineMappings2[][] = new int[4][3];
+ lineMappings2[0] = new int[]{8,0,3};
+ lineMappings2[1] = new int[]{16,1,9};
+ lineMappings2[2] = new int[]{24,0,12};
+ lineMappings2[3] = new int[]{32,5,15};
+
+ mappings.put("very/long/path/to/TeamA.java", lineMappings1);
+
+ int baseMapping [][] = null;
+
+ String expectedString =
+ "SMAP" + "\n" +
+ "BaseClass.class" + "\n" +
+ "OTJ" + "\n" +
+ "*S OTJ" + "\n" +
+ "*F" + "\n" +
+ "+ 1 TeamA.java" + "\n" +
+ "very/long/path/to/TeamA.java" + "\n" +
+ "+ 2 TeamB.java" + "\n" +
+ "path/to/TeamB.java" + "\n" +
+ "+ 3 BaseClass.java" + "\n" +
+ "very/very/long/path/to/BaseClass.java" + "\n" +
+ "*L" + "\n" +
+ "1#3,6:1" + "\n" +
+ "7#2:10" + "\n" +
+ "8#3,6:8" + "\n" +
+ "14#2,1:25" + "\n" +
+ "15#3,6:15" + "\n" +
+ "21#2:30" + "\n" +
+ "22#3,6:22" + "\n" +
+ "28#2,2:35" + "\n" +
+ "29#3,6:29" + "\n" +
+ "35#2:40" + "\n" +
+ "36#3,6:36" + "\n" +
+ "42#2,3:45" + "\n" +
+ "43#3,8:43" + "\n" +
+ "125#2:250" + "\n" +
+ "*E";
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+
+ String actualString = new String(actual);
+
+ assertEquals("SMAP should be equal.", expectedString, actualString);
+
+ }
+
+ public void testSMAPIsNull001()
+ {
+ String baseClassFileName = "SimpleClass$1" ;
+ String baseClassSourceUnit = "path/to/SimpleClass";
+ int endlineNumber = 3;
+ Hashtable<String, int[][]> mappings = null;
+
+ int baseMapping [][] = null;
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+
+ assertNull("No SMAP should be generated.", actual);
+ }
+
+ public void testSMAPIsNull002()
+ {
+ String baseClassFileName = null;
+ String baseClassSourceUnit = "path/to/SimpleClass";
+ int endlineNumber = 3;
+ Hashtable<String, int[][]> mappings = new Hashtable<String, int[][]>();;
+ int lineMappings[][] = new int[2][3];
+ lineMappings[0] = new int[]{2,2,7};
+ lineMappings[1] = new int[]{3,0,8};
+ mappings.put("path/to/TeamA.java", lineMappings);
+
+ int baseMapping[][] = null;
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+
+ assertNull("No SMAP should be generated.", actual);
+ }
+
+ public void testSMAPIsNotNull001()
+ {
+ String baseClassFileName = "SimpleClass$1";
+ String baseClassSourceUnit = null;
+ int endlineNumber = 3;
+ Hashtable<String, int[][]> mappings = new Hashtable<String, int[][]>();;
+ int lineMappings[][] = new int[2][3];
+ lineMappings[0] = new int[]{2,2,7};
+ lineMappings[1] = new int[]{3,0,8};
+ mappings.put("path/to/TeamA.java", lineMappings);
+
+ int baseMapping[][] = null;
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+
+ String expectedString =
+ "SMAP" + "\n" +
+ "SimpleClass$1.class" + "\n" +
+ "OTJ" + "\n" +
+ "*S OTJ" + "\n" +
+ "*F" + "\n" +
+ "+ 1 TeamA.java" + "\n" +
+ "path/to/TeamA.java" + "\n" +
+ "2 SimpleClass$1.java" + "\n" +
+ "*L" + "\n" +
+ "1#2:1" + "\n" +
+ "2#1,2:7" + "\n" +
+ "3#1:8" + "\n" +
+ "*E";
+
+
+ String actualString = new String(actual);
+
+ assertEquals("SMAP should be equal.", expectedString, actualString);
+
+ }
+
+ public void testSMAPIsNotNull002()
+ {
+ String baseClassFileName = "pkg.subpkg.SimpleClass$1";
+ String baseClassSourceUnit = null;
+ int endlineNumber = 3;
+ Hashtable<String, int[][]> mappings = new Hashtable<String, int[][]>();;
+ int lineMappings[][] = new int[2][3];
+ lineMappings[0] = new int[]{2,2,7};
+ lineMappings[1] = new int[]{3,0,8};
+ mappings.put("path/to/TeamA.java", lineMappings);
+
+ int baseMapping [][] = null;
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+
+ String expectedString =
+ "SMAP" + "\n" +
+ "SimpleClass$1.class" + "\n" +
+ "OTJ" + "\n" +
+ "*S OTJ" + "\n" +
+ "*F" + "\n" +
+ "+ 1 TeamA.java" + "\n" +
+ "path/to/TeamA.java" + "\n" +
+ "+ 2 SimpleClass$1.java" + "\n" +
+ "pkg/subpkg/SimpleClass$1.java" + "\n" +
+ "*L" + "\n" +
+ "1#2:1" + "\n" +
+ "2#1,2:7" + "\n" +
+ "3#1:8" + "\n" +
+ "*E";
+
+
+ String actualString = new String(actual);
+
+ assertEquals("SMAP should be equal.", expectedString, actualString);
+
+ }
+
+
+ public void testSMAPBaseMappings()
+ {
+ String baseClassFileName = "path.to.SimpleClass";
+ String baseClassSourceUnit = "path/to/SimpleClass";
+ int endlineNumber = 15;
+ Hashtable<String, int[][]> mappings = new Hashtable<String, int[][]>();;
+ int lineMappings[][] = new int[2][3];
+ lineMappings[0] = new int[]{2,2,7};
+ lineMappings[1] = new int[]{3,0,8};
+ mappings.put("path/to/TeamA.java", lineMappings);
+
+ int baseMapping[][] = new int[2][2];
+ baseMapping[0] = new int[]{10,1};
+ baseMapping[1] = new int[]{12,6};
+
+ byte actual[] = generateSMAP(baseClassFileName, baseClassSourceUnit, endlineNumber, mappings, baseMapping);
+ String actualString = new String(actual);
+
+ String expectedString =
+ "SMAP" + "\n" +
+ "SimpleClass.class" + "\n" +
+ "OTJ" + "\n" +
+ "*S OTJ" + "\n" +
+ "*F" + "\n" +
+ "+ 1 TeamA.java" + "\n" +
+ "path/to/TeamA.java" + "\n" +
+ "+ 2 SimpleClass.java" + "\n" +
+ "path/to/SimpleClass.java" + "\n" +
+ "*L" + "\n" +
+ "1#2:1" + "\n" +
+ "2#1,2:7" + "\n" +
+ "3#1:8" + "\n" +
+ "4#2,6:4" + "\n" +
+ "10#2:1" + "\n" +
+ "11#2:11" + "\n" +
+ "12#2:6" + "\n" +
+ "13#2,3:13" + "\n" +
+ "*E";
+
+ assertEquals("SMAP should be equal.", expectedString, actualString);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////
+ //// THIS METHOD IS TESTED ////
+ ///////////////////////////////////////////////////////////////////////////////////////
+
+ /** This method generates a SMAP for Baseclasses. This SMAP maps generated code for
+ * callin bindings to theirs corresponding sourcecodepresentation.
+ *
+ * @param baseClassfileName - name of classfile this smap is generated for (e.g. pkg.subpkg.SimpleClass)
+ * @param baseSourceunitName - path of sourceunit of corresponding baseclasstype,
+ * (e.g path/to/SimpleClass);
+ * if baseSourceunitName is not available name and path are generated from
+ * baseClassfileName
+ *
+ * @param endlineNumber - this linenumber is the maximum linenumber of all entries in linenumbertables of all methods;
+ * it is not the endlinenumber of sourcefile.
+ * @param mappings -
+ * String -> int[][]<br>
+ * key: path of Team or RoleFile sourceunit which has callins"<br>
+ * value: int-array with:<br> int[0][0] - inputstartline of callin<br>
+ * int[0][1] - offset, if callin has more as one line(0 means one line, 1 means 2 lines, ...)<br>
+ * int[0][2] - written linenumber in baseclasscode (linenumber of _OT$MyRole$roleMethod$baseMethod() call in chainMethod)<br>
+ * e.g.<br>
+ * path/to/Teamname.java -> <br>[9][0][16]<br> [20][2][18]
+ *
+ * @param baseMappings - contains mappings to itself (int[][]):<br>
+ * int[0][0] - generated linenumber<br>
+ * int[0][1] - fixed linenumber (linenumber of e.g. signature of "_OT$xyz$orig(..)")
+ *
+ * @return smap - the string which should be stored in Classfileattribute SourceDebugExtension
+ *
+ * @author ike
+ */
+ public byte[] generateSMAP(String baseClassfileName, String baseSourceunitName, int endlineNumber, Hashtable<String, int[][]> mappings, int baseMappings [][])
+ {
+ if (baseClassfileName==null || mappings==null)
+ {
+ return null;
+ }
+
+ String OTJ_STRATUM_NAME = "OTJ";
+ String CLASS_ENDING = ".class";
+ String JAVA_ENDING = ".java";
+ String generatedFileName = new String();
+ String components[] = baseClassfileName.split("\\.");
+ String newBaseSourceunitName = null;
+ String absoluteBaseSourceunitName = null;
+ boolean baseSourceunitNameAvailable = (baseSourceunitName != null);
+
+ if (components.length > 1)
+ {
+ generatedFileName = components[components.length -1] + CLASS_ENDING;
+ newBaseSourceunitName = components[components.length -1] + JAVA_ENDING;
+ absoluteBaseSourceunitName = (baseClassfileName.replaceAll("\\.", "/") + JAVA_ENDING);
+ }
+ else
+ {
+ generatedFileName = baseClassfileName + CLASS_ENDING;
+ newBaseSourceunitName = baseClassfileName + JAVA_ENDING;
+ absoluteBaseSourceunitName = null;
+ }
+
+ if (baseSourceunitNameAvailable)
+ {
+ String tmp[] = baseSourceunitName.split("/");
+ int index = tmp.length;
+
+ newBaseSourceunitName = tmp[index-1] + JAVA_ENDING;
+
+ if (tmp.length > 1)
+ {
+ absoluteBaseSourceunitName = baseSourceunitName + JAVA_ENDING;
+ }
+ }
+
+ Hashtable<String, Integer> typeNameToFileId = new Hashtable<String, Integer>();
+ int fileSectionIdCounter = 1;
+
+ StringBuffer out = new StringBuffer();
+
+ // print Header
+ out.append("SMAP\n");
+ out.append(generatedFileName + "\n");
+
+ // print strata
+ out.append(OTJ_STRATUM_NAME+ "\n");
+
+ // begin StratumSection
+ out.append("*S " + OTJ_STRATUM_NAME + "\n");
+
+ // print FileSection
+ out.append("*F" + "\n");
+
+ for (Iterator<String> iter = mappings.keySet().iterator(); iter.hasNext();)
+ {
+ String fullqualifiedName = iter.next();
+ typeNameToFileId.put(fullqualifiedName, new Integer(fileSectionIdCounter));
+
+ // extract filename and absoluteFileName from typename
+ String tmp[] = fullqualifiedName.split("/");
+ int index = tmp.length;
+
+ String fileName = tmp[index-1];
+ String absoluteFileName = null;
+
+ typeNameToFileId.put(fileName, new Integer(fileSectionIdCounter));
+
+ if (tmp.length >= 2)
+ {
+ absoluteFileName = fullqualifiedName;
+ }
+
+ if (absoluteFileName != null)
+ {
+ out.append("+ " );
+ }
+
+ out.append(fileSectionIdCounter + " " + fileName + "\n");
+
+ if (absoluteFileName != null)
+ {
+ out.append(absoluteFileName + "\n");
+ }
+
+ fileSectionIdCounter++;
+ }
+
+ // add basename to smap
+ int baseClassFileId = -1;
+ typeNameToFileId.put(newBaseSourceunitName, new Integer(fileSectionIdCounter));
+ baseClassFileId = typeNameToFileId.get(newBaseSourceunitName).intValue();
+
+ if (absoluteBaseSourceunitName != null)
+ {
+ out.append("+ " );
+ }
+
+ out.append(baseClassFileId + " " + newBaseSourceunitName + "\n");
+
+ if (absoluteBaseSourceunitName != null)
+ {
+ out.append(absoluteBaseSourceunitName + "\n");
+ }
+
+
+ // print LineSection
+ out.append("*L" + "\n");
+
+ TreeMap<Integer, String> lineInfos = new TreeMap<Integer, String>();
+ StringBuffer lineBuffer = new StringBuffer();
+ for (Iterator<String> iter = mappings.keySet().iterator(); iter.hasNext();)
+ {
+ String typeName = iter.next();
+ int[][] linemappings = mappings.get(typeName);
+ int fileId = typeNameToFileId.get(typeName).intValue();
+
+ for (int idx = 0; idx < linemappings.length; idx++)
+ {
+ int[] singleLineMapping = linemappings[idx];
+
+ Integer inputStartLine = new Integer( singleLineMapping[0]);
+ int inputOffset = singleLineMapping[1];
+ int outputLine = singleLineMapping[2];
+
+ if (inputOffset == 0)
+ {
+ lineBuffer.append(inputStartLine.intValue());
+ lineBuffer.append("#" + fileId);
+ lineBuffer.append(":" + outputLine + "\n");
+ }
+ else
+ {
+ lineBuffer.append(inputStartLine.intValue());
+ lineBuffer.append("#" + fileId);
+ lineBuffer.append("," + inputOffset);
+ lineBuffer.append(":" + outputLine + "\n");
+ }
+
+ lineInfos.put(inputStartLine, lineBuffer.toString());
+ lineBuffer.delete(0, lineBuffer.length());
+ }
+ }
+
+ //add given mappings to itself (basemappings)
+ if (baseMappings != null && baseMappings.length > 0)
+ {
+ for (int idx = 0; idx < baseMappings.length; idx++)
+ {
+ int key = baseMappings[idx][0];
+ int value = baseMappings[idx][1];
+
+ lineBuffer.append(key);
+ lineBuffer.append("#" + baseClassFileId);
+ lineBuffer.append(":" + value + "\n");
+
+ lineInfos.put(new Integer(key), lineBuffer.toString());
+ lineBuffer.delete(0, lineBuffer.length());
+ }
+ }
+
+ //add mappings to itself,
+ //endlinenumber is the maximum linenumber of all entries in linenumbertables of all methods;
+ //endlinenumber is not the endlinenumber of sourcefile, cause it is available at this time
+ TreeMap<Integer, int[]> baseToBaselineInfos = new TreeMap<Integer, int[]>();
+ for (int idx = 1; idx <= endlineNumber; idx++)
+ {
+ Integer currentLineNumber = new Integer(idx);
+ if (!lineInfos.containsKey(currentLineNumber))
+ {
+ Integer previousLineNumber = currentLineNumber-1;
+ if (baseToBaselineInfos.containsKey(previousLineNumber))
+ {
+ int[] oldValues = baseToBaselineInfos.get(previousLineNumber);
+ int intputStartline = oldValues[0];
+ int repeatCount= oldValues[1]+1;
+ int newValues[] = {intputStartline, repeatCount};
+ baseToBaselineInfos.put(currentLineNumber, newValues);
+ }
+ else
+ {
+ baseToBaselineInfos.put(currentLineNumber, new int[]{currentLineNumber.intValue(), 1});
+ }
+ }
+ }
+
+ lineBuffer = new StringBuffer();
+ for (Iterator<Integer> iter = baseToBaselineInfos.keySet().iterator(); iter.hasNext();)
+ {
+ Integer key= iter.next();
+ int[] endValues = baseToBaselineInfos.get(key);
+ int inputStartLine = endValues[0];
+ int repeatCount = endValues[1];
+
+ lineBuffer.append(inputStartLine);
+ lineBuffer.append("#" + baseClassFileId);
+
+ if (repeatCount > 1)
+ lineBuffer.append("," + repeatCount);
+
+ lineBuffer.append(":" + inputStartLine + "\n");
+ lineInfos.put(new Integer(inputStartLine), lineBuffer.toString());
+ lineBuffer.delete(0, lineBuffer.length());
+ }
+
+
+ for (Iterator<Integer> iter = lineInfos.keySet().iterator(); iter.hasNext();)
+ {
+ Integer inputStartline= iter.next();
+ String lineInfo = lineInfos.get(inputStartline);
+
+ out.append(lineInfo);
+ }
+
+ // print EndStratumSection
+ out.append("*E");
+
+ return out.toString().getBytes();
+ }
+
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest001.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest001.java
new file mode 100644
index 0000000..cbd467c
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest001.java
@@ -0,0 +1,136 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTJStratumGenerationTest001.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.FileInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.LineInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.RoleSmapGenerator;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.SmapStratum;
+
+/**
+ * @author ike
+ *
+ */
+public class OTJStratumGenerationTest001 extends AbstractSourceMapGeneratorTest
+{
+ private org.eclipse.jdt.core.ICompilationUnit _role;
+ private org.eclipse.jdt.core.ICompilationUnit _team;
+
+ public OTJStratumGenerationTest001(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new Suite(OTJStratumGenerationTest001.class);
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("JSR-045");
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ _role = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "roleFile.TeamA",
+ "RoleA.java");
+
+ _team = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "roleFile",
+ "TeamA.java");
+ }
+
+ public void testSimpleRoleSmapGeneration() throws JavaModelException
+ {
+ SmapStratum stratum = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo = stratum.getOrCreateFileInfo("RoleA.java","roleFile/TeamA/RoleA.java");
+ LineInfo lineInfo = new LineInfo(1,1);
+ lineInfo.setRepeatCount(11);
+ LineInfo lineInfo1 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo2 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+ fileInfo.addLineInfo(lineInfo);
+ fileInfo.addLineInfo(lineInfo1);
+ fileInfo.addLineInfo(lineInfo2);
+
+ stratum.optimize();
+
+ TYPENAME = "__OT__RoleA";
+ List <SmapStratum>strata = new ArrayList<SmapStratum>();
+ strata.add(stratum);
+
+ expectedStrata.put(TYPENAME, strata);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_team, _role});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void callback(CompilationUnitDeclaration cuDecl)
+ {
+ TypeDeclaration typeDecl = cuDecl.types[0];
+
+ assertNotNull("TypeDeclaration should not be null.", typeDecl);
+
+ if (typeDecl.memberTypes == null)
+ {
+ return;
+ }
+
+ TypeDeclaration [] members = typeDecl.memberTypes;
+ for (int idx = 0; idx < members.length; idx++)
+ {
+ TypeDeclaration decl = members[idx];
+ String typeName = String.valueOf(decl.name);
+
+ if (decl.isRole() && !decl.isInterface() && typeName.equals(TYPENAME))
+ {
+ RoleSmapGenerator rolefileSmapGenerator = new RoleSmapGenerator(decl);
+ rolefileSmapGenerator.addStratum("OTJ");
+ rolefileSmapGenerator.generate();
+ List actualStrata = rolefileSmapGenerator.getStrata();
+
+ assertEquals("Strata of type \"" + typeName + "\" should be equal.\n", expectedStrata.get(typeName), actualStrata);
+ }
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest002.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest002.java
new file mode 100644
index 0000000..157c164
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest002.java
@@ -0,0 +1,297 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTJStratumGenerationTest002.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.FileInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.LineInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.RoleSmapGenerator;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.SmapStratum;
+
+/**
+ * @author ike
+ *
+ */
+public class OTJStratumGenerationTest002 extends AbstractSourceMapGeneratorTest
+{
+ private org.eclipse.jdt.core.ICompilationUnit _subTeam;
+ private org.eclipse.jdt.core.ICompilationUnit _superTeam;
+ private org.eclipse.jdt.core.ICompilationUnit _superSuperTeam;
+ private String _enclosingTypename;
+
+ public OTJStratumGenerationTest002(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new Suite(OTJStratumGenerationTest002.class);
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("JSR-045");
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ _subTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "copyInheritance",
+ "SubTeam.java");
+
+ _superTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "copyInheritance",
+ "SuperTeam.java");
+
+ _superSuperTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "copyInheritance",
+ "SuperSuperTeam.java");
+ }
+ public void testSimpleCopyInheritanceSmapRoleA() throws JavaModelException
+ {
+ SmapStratum stratum_role = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+
+ // letters (a) ... indicate the order in which lines are assigned
+ // class position is used by ctor, initFields and getTeam
+
+ FileInfo fileInfo0 = stratum_role.getOrCreateFileInfo("SuperSuperTeam.java", "copyInheritance/SuperSuperTeam.java");
+ LineInfo lineInfo1_role0 = new LineInfo(4,25); // (c) class position (4) mapped to synthetic line 25
+ LineInfo lineInfo2_role0 = new LineInfo(8,29); // (e) method roleMethod0 (8..) mapped to synthetic lines 29-30
+ lineInfo2_role0.setRepeatCount(2);
+ LineInfo lineInfo3_role0 = new LineInfo(12,31); // (f) method roleMethod1 (12,14,15) mapped to synthetic lines 31,33,34
+ lineInfo3_role0.setRepeatCount(4); // repeat 4 although line numbers have a "hole" at comment line 32
+
+ fileInfo0.addLineInfo(lineInfo1_role0);
+ fileInfo0.addLineInfo(lineInfo2_role0);
+ fileInfo0.addLineInfo(lineInfo3_role0);
+
+ FileInfo fileInfo1 = stratum_role.getOrCreateFileInfo("SuperTeam.java", "copyInheritance/SuperTeam.java");
+ LineInfo lineInfo1_role1 = new LineInfo(4,24); // (b) class position (4) mapped to synthetic line 24
+ LineInfo lineInfo2_role1 = new LineInfo(11,26); // (d) roleMethod0 (11..) mapped to synthetic lines 26-28
+ lineInfo2_role1.setRepeatCount(3);
+ LineInfo lineInfo3_role1 = new LineInfo(8,35); // (g) method roleMethod2 (8..) mapped to synthetic lines 35-36
+ lineInfo3_role1.setRepeatCount(2);
+
+ fileInfo1.addLineInfo(lineInfo1_role1);
+ fileInfo1.addLineInfo(lineInfo2_role1);
+ fileInfo1.addLineInfo(lineInfo3_role1);
+
+
+ FileInfo fileInfo2 = stratum_role.getOrCreateFileInfo("SubTeam.java", "copyInheritance/SubTeam.java");
+
+ LineInfo lineInfo1_role2 = new LineInfo(1,1); // (a) all original lines from SubTeam
+ lineInfo1_role2.setRepeatCount(23);
+ LineInfo lineInfo2_role2 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo3_role2 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+ fileInfo2.addLineInfo(lineInfo1_role2);
+ fileInfo2.addLineInfo(lineInfo2_role2);
+ fileInfo2.addLineInfo(lineInfo3_role2);
+
+ stratum_role.optimize();
+
+ HashMap<String, int[]> expectedMethodLineNumbers = new HashMap<String, int[]>();
+ expectedMethodLineNumbers.put("copyInheritance.SubTeam$__OT__RoleA.roleMethod0(LcopyInheritance/SubTeam$TSuper__OT__SuperTeam;)V", new int[]{26,27,28});
+ expectedMethodLineNumbers.put("copyInheritance.SubTeam$__OT__RoleA.roleMethod0(LcopyInheritance/SuperTeam$TSuper__OT__SuperSuperTeam;)V", new int[]{29,30});
+ expectedMethodLineNumbers.put("copyInheritance.SubTeam$__OT__RoleA.roleMethod1()V", new int[]{31,33,34});
+ expectedMethodLineNumbers.put("copyInheritance.SubTeam$__OT__RoleA.roleMethod2()V", new int[]{35,36});
+
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename= "SubTeam";
+
+ List <SmapStratum>strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ String outputPath = getWorkspaceRoot().getLocationURI().getPath()+"/"+getTestProjectDir()+"/bin";
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_superSuperTeam, _superTeam, _subTeam},
+ expectedMethodLineNumbers,
+ null/*classPaths*/,
+ outputPath); // need this so that class files are actually written for next phase
+
+ // recompile SubTeam only to check usage of byte code information (CopyInheritanceSrc):
+ String [] classPaths = getDefaultClassPaths();
+ int oldLen = classPaths.length;
+ System.arraycopy(classPaths, 0, classPaths=new String[oldLen+1], 1, oldLen);
+ classPaths[0] = outputPath;
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_subTeam},
+ expectedMethodLineNumbers,
+ classPaths, // needed for retrieving class files from previous phase
+ null/*outputPath*/);
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSimpleCopyInheritanceSmapConfined()
+ {
+ SmapStratum stratum_role = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+
+ FileInfo fileInfo_role0 = stratum_role.getOrCreateFileInfo("Team.java", "org/objectteams/Team.java");
+ LineInfo lineInfo1_role0 = new LineInfo(OT_CONFINED_GET_TEAM_LINE, 25); // mapped line of _OT$getTeam() to synthetic line 25
+
+ fileInfo_role0.addLineInfo(lineInfo1_role0);
+
+ FileInfo fileInfo_role1 = stratum_role.getOrCreateFileInfo("SuperSuperTeam.java", "copyInheritance/SuperSuperTeam.java");
+ LineInfo lineInfo1_role1 = new LineInfo(2,24); // default ctor at team position (2) mapped to synthetic line 25
+
+ fileInfo_role1.addLineInfo(lineInfo1_role1);
+
+ // no contribution from SuperTeam$__OT__Confined
+
+ FileInfo fileInfo_role3 = stratum_role.getOrCreateFileInfo("SubTeam.java", "copyInheritance/SubTeam.java");
+ LineInfo lineInfo3_role3 = new LineInfo(1,1);
+ lineInfo3_role3.setRepeatCount(23); // all 23 lines of SubTeam.java unmapped
+ LineInfo lineInfo5_role3 = new LineInfo(65533,65533);
+ lineInfo5_role3.setRepeatCount(2);
+
+ fileInfo_role3.addLineInfo(lineInfo3_role3);
+ fileInfo_role3.addLineInfo(lineInfo5_role3);
+
+ TYPENAME = "__OT__Confined";
+ _enclosingTypename= "SubTeam";
+ List <SmapStratum>strata_role_confined = new ArrayList<SmapStratum>();
+ strata_role_confined.add(stratum_role);
+
+ expectedStrata.put(TYPENAME, strata_role_confined);
+
+ HashMap<String, int[]> expectedMethodLineNumbers = new HashMap<String, int[]>();
+ expectedMethodLineNumbers.put("copyInheritance.SubTeam$__OT__Confined._OT$getTeam()Lorg/objectteams/ITeam;", new int[]{25});
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_superSuperTeam, _superTeam, _subTeam}, expectedMethodLineNumbers);
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testCopyInheritanceOutOfOrderStatements() {
+ SmapStratum stratum_role = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+
+ FileInfo fileInfo0 = stratum_role.getOrCreateFileInfo("SuperTeam2.java", "copyInheritance/SuperTeam2.java");
+ LineInfo lineInfo1_role0 = new LineInfo(6,7); // class position (6) mapped to synthetic line 7
+ fileInfo0.addLineInfo(lineInfo1_role0);
+ LineInfo lineInfo2_role0 = new LineInfo(8,8); // method (8) mapped to synthetic line 8..
+ lineInfo2_role0.setRepeatCount(5);
+ fileInfo0.addLineInfo(lineInfo2_role0);
+
+ FileInfo fileInfo1 = stratum_role.getOrCreateFileInfo("SubTeam2.java", "copyInheritance/SubTeam2.java");
+ LineInfo lineInfo1_role1 = new LineInfo(1,1); // all 6 lines unmapped
+ lineInfo1_role1.setRepeatCount(6);
+ fileInfo1.addLineInfo(lineInfo1_role1);
+
+ LineInfo lineInfo2_role1 = new LineInfo(65533,65533);
+ lineInfo2_role1.setRepeatCount(2);
+
+ fileInfo1.addLineInfo(lineInfo2_role1);
+
+
+ TYPENAME = "__OT__R";
+ _enclosingTypename = "SubTeam2";
+
+ List <SmapStratum>strata_role = new ArrayList<SmapStratum>();
+ strata_role.add(stratum_role);
+
+ expectedStrata.put(TYPENAME, strata_role);
+
+ HashMap<String, int[]> expectedMethodLineNumbers = new HashMap<String, int[]>();
+ //expectedMethodLineNumbers.put("copyInheritance.SubTeam$__OT__Confined._OT$getTeam()Lorg/objectteams/Team;", new int[]{25});
+
+
+ try
+ {
+ ICompilationUnit superTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "copyInheritance",
+ "SuperTeam2.java");
+
+ ICompilationUnit subTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "copyInheritance",
+ "SubTeam2.java");
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{superTeam, subTeam}, expectedMethodLineNumbers);
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+ public void callback(CompilationUnitDeclaration cuDecl)
+ {
+ String cuDeclName = String.valueOf(cuDecl.getMainTypeName());
+ if (!_enclosingTypename.equals(cuDeclName))
+ return;
+
+ TypeDeclaration typeDecl = cuDecl.types[0];
+
+ assertNotNull("TypeDeclaration should not be null.", typeDecl);
+
+ assertTrue("Membertypes of TypeDeclaration should be greater than 0.", typeDecl.memberTypes.length > 0);
+
+ TypeDeclaration [] members = typeDecl.memberTypes;
+ for (int idx = 0; idx < members.length; idx++)
+ {
+ TypeDeclaration decl = members[idx];
+ String typeName = String.valueOf(decl.name);
+
+ if (decl.isRole() && !decl.isInterface() && typeName.equals(TYPENAME))
+ {
+ RoleSmapGenerator rolefileSmapGenerator = new RoleSmapGenerator(decl);
+ rolefileSmapGenerator.addStratum("OTJ");
+ rolefileSmapGenerator.generate();
+ List actualStrata = rolefileSmapGenerator.getStrata();
+ // note: using assert(String,String,String) helps debugging, since this one supports visual compare
+ assertEquals("Strata of type \"" + typeName + "\" should be equal.\n", expectedStrata.get(typeName).toString(), actualStrata.toString());
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest003.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest003.java
new file mode 100644
index 0000000..0511b7e
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest003.java
@@ -0,0 +1,200 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTJStratumGenerationTest003.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.FileInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.LineInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.RoleSmapGenerator;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.SmapStratum;
+
+/**
+ * @author ike
+ *
+ */
+public class OTJStratumGenerationTest003 extends AbstractSourceMapGeneratorTest
+{
+ private org.eclipse.jdt.core.ICompilationUnit _team1;
+ private org.eclipse.jdt.core.ICompilationUnit _team2;
+ private org.eclipse.jdt.core.ICompilationUnit _role;
+ private String _enclosingTypename;
+ private String _packagePath;
+
+ public OTJStratumGenerationTest003(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new Suite(OTJStratumGenerationTest003.class);
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("JSR-045");
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ _packagePath = "roleFileAndCopyInh";
+
+ _team1 = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ _packagePath,
+ "SubTeam.java");
+
+ _team2 = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ _packagePath,
+ "SuperTeam.java");
+
+ _role = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "roleFileAndCopyInh.SuperTeam",
+ "RoleA.java");
+ }
+
+ public void testSmapGeneration1() throws JavaModelException
+ {
+
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename = "SubTeam";
+
+ String roleFileSourceName = "RoleA.java";
+
+ SmapStratum stratum_role = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo1 = stratum_role.getOrCreateFileInfo(
+ roleFileSourceName, _packagePath + "/" + "SuperTeam" + "/" + roleFileSourceName);
+
+ LineInfo lineInfo1 = new LineInfo(5,1); // role (5..) mapped to synthetic line 1 (no own lines in SubTeam.RoleA).
+ LineInfo lineInfo2 = new LineInfo(9,2); // method roleMethod (9..) mapped to synthetic line 2..
+ lineInfo2.setRepeatCount(2);
+ LineInfo lineInfo3 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo4 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+ fileInfo1.addLineInfo(lineInfo1);
+ fileInfo1.addLineInfo(lineInfo2);
+ fileInfo1.addLineInfo(lineInfo3);
+ fileInfo1.addLineInfo(lineInfo4);
+
+ stratum_role.optimize();
+
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_team2, _team1, _role});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration2()
+ {
+ SmapStratum stratum_role = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+
+ FileInfo fileInfo = stratum_role.getOrCreateFileInfo("Team.java", "org/objectteams/Team.java");
+ LineInfo lineInfo1 = new LineInfo(OT_CONFINED_GET_TEAM_LINE,22); // getTeam mapped to synthetic line 22
+ fileInfo.addLineInfo(lineInfo1);
+
+ FileInfo fileInfo1 = stratum_role.getOrCreateFileInfo("SuperTeam.java", "roleFileAndCopyInh/SuperTeam.java");
+ LineInfo lineInfo2 = new LineInfo(3,21); // class position to first synthetic line 21
+ fileInfo1.addLineInfo(lineInfo2);
+
+ FileInfo fileInfo2 = stratum_role.getOrCreateFileInfo("SubTeam.java", "roleFileAndCopyInh/SubTeam.java");
+ LineInfo lineInfo3 = new LineInfo(1,1); // all lines of SubTeam unmapped
+ lineInfo3.setRepeatCount(20);
+ LineInfo lineInfo5 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo6 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+ fileInfo2.addLineInfo(lineInfo3);
+ fileInfo2.addLineInfo(lineInfo5);
+ fileInfo2.addLineInfo(lineInfo6);
+
+ stratum_role.optimize();
+
+ TYPENAME = "__OT__Confined";
+ _enclosingTypename = "SubTeam";
+ List<SmapStratum> strata_role2 = new ArrayList<SmapStratum>();
+ strata_role2.add(stratum_role);
+
+ expectedStrata.put(TYPENAME, strata_role2);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_team2, _team1, _role});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void callback(CompilationUnitDeclaration cuDecl)
+ {
+ String cuDeclName = String.valueOf(cuDecl.getMainTypeName());
+ if (!_enclosingTypename.equals(cuDeclName))
+ return;
+
+
+ TypeDeclaration typeDecl = cuDecl.types[0];
+
+ assertNotNull("TypeDeclaration should not be null.", typeDecl);
+
+ assertTrue("Membertypes of TypeDeclaration should be greater than 0.", typeDecl.memberTypes.length > 0);
+
+ TypeDeclaration [] members = typeDecl.memberTypes;
+ for (int idx = 0; idx < members.length; idx++)
+ {
+ TypeDeclaration decl = members[idx];
+ String typeName = String.valueOf(decl.name);
+
+ if (decl.isRole() && !decl.isInterface() && typeName.equals(TYPENAME))
+ {
+ RoleSmapGenerator roleSmapGenerator = new RoleSmapGenerator(decl);
+ roleSmapGenerator.addStratum("OTJ");
+ roleSmapGenerator.generate();
+ List actualStrata = roleSmapGenerator.getStrata();
+
+ assertEquals("Strata of type \"" + typeName + "\" should be equal.\n", expectedStrata.get(typeName).toString(), actualStrata.toString());
+ }
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest004.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest004.java
new file mode 100644
index 0000000..46db4b5
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest004.java
@@ -0,0 +1,182 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTJStratumGenerationTest004.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.FileInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.LineInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.RoleSmapGenerator;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.SmapStratum;
+
+/**
+ * @author ike
+ *
+ */
+public class OTJStratumGenerationTest004 extends AbstractSourceMapGeneratorTest
+{
+ private org.eclipse.jdt.core.ICompilationUnit _team1;
+ @SuppressWarnings("unused")
+ private org.eclipse.jdt.core.ICompilationUnit _team2;
+ private org.eclipse.jdt.core.ICompilationUnit _role;
+ private String _enclosingTypename;
+
+ public OTJStratumGenerationTest004(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new Suite(OTJStratumGenerationTest004.class);
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("JSR-045");
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ _team1 = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "roleAndTeam",
+ "TeamA.java");
+
+ _role = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "roleAndTeam.TeamA",
+ "RoleA.java");
+ }
+
+ public void testSmapGeneration1() throws JavaModelException
+ {
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename = "TeamA";
+
+ SmapStratum stratum_role1 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo1 = stratum_role1.getOrCreateFileInfo("RoleA.java", "roleAndTeam/TeamA/RoleA.java");
+ LineInfo lineInfo1 = new LineInfo(1,1);
+ lineInfo1.setRepeatCount(11);
+ LineInfo lineInfo2 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo3 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+ fileInfo1.addLineInfo(lineInfo1);
+ fileInfo1.addLineInfo(lineInfo2);
+ fileInfo1.addLineInfo(lineInfo3);
+
+ stratum_role1.optimize();
+
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_team1, _role});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration2()
+ {
+ TYPENAME = "__OT__Confined";
+ _enclosingTypename = "TeamA";
+
+ SmapStratum stratum_role2 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo1 = stratum_role2.getOrCreateFileInfo("Team.java", "org/objectteams/Team.java");
+ LineInfo lineInfo1 = new LineInfo(OT_CONFINED_GET_TEAM_LINE,16);
+ fileInfo1.addLineInfo(lineInfo1);
+
+ FileInfo fileInfo2 = stratum_role2.getOrCreateFileInfo("TeamA.java", "roleAndTeam/TeamA.java");
+ LineInfo lineInfo2 = new LineInfo(1,1);
+ lineInfo2.setRepeatCount(15);
+ LineInfo lineInfo3 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo4 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+ fileInfo2.addLineInfo(lineInfo2);
+ fileInfo2.addLineInfo(lineInfo3);
+ fileInfo2.addLineInfo(lineInfo4);
+
+ stratum_role2.optimize();
+
+ List<SmapStratum> strata_role2 = new ArrayList<SmapStratum>();
+ strata_role2.add(stratum_role2);
+
+ expectedStrata.put(TYPENAME, strata_role2);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_team1, _role});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void callback(CompilationUnitDeclaration cuDecl)
+ {
+ String cuDeclName = String.valueOf(cuDecl.getMainTypeName());
+ if (!_enclosingTypename.equals(cuDeclName))
+ return;
+
+
+ TypeDeclaration typeDecl = cuDecl.types[0];
+
+ assertNotNull("TypeDeclaration should not be null.", typeDecl);
+
+ assertTrue("Membertypes of TypeDeclaration should be greater than 0.", typeDecl.memberTypes.length > 0);
+
+ TypeDeclaration [] members = typeDecl.memberTypes;
+ for (int idx = 0; idx < members.length; idx++)
+ {
+ TypeDeclaration decl = members[idx];
+ String typeName = String.valueOf(decl.name);
+
+ if (decl.isRole() && !decl.isInterface() && typeName.equals(TYPENAME))
+ {
+ RoleSmapGenerator rolefileSmapGenerator = new RoleSmapGenerator(decl);
+ rolefileSmapGenerator.addStratum("OTJ");
+ rolefileSmapGenerator.generate();
+ List actualStrata = rolefileSmapGenerator.getStrata();
+
+ assertEquals("Strata of type \"" + typeName + "\" should be equal.\n", expectedStrata.get(typeName).toString(), actualStrata.toString());
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest005.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest005.java
new file mode 100644
index 0000000..2261508
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest005.java
@@ -0,0 +1,265 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTJStratumGenerationTest005.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.FileInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.LineInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.RoleSmapGenerator;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.SmapStratum;
+
+/**
+ * @author ike
+ *
+ */
+public class OTJStratumGenerationTest005 extends AbstractSourceMapGeneratorTest
+{
+ private org.eclipse.jdt.core.ICompilationUnit _superTeam;
+ private org.eclipse.jdt.core.ICompilationUnit _subTeam;
+ private org.eclipse.jdt.core.ICompilationUnit _baseClass;
+ private String _enclosingTypename;
+
+
+ public OTJStratumGenerationTest005(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new Suite(OTJStratumGenerationTest005.class);
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("JSR-045");
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ _superTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "callout",
+ "SuperTeam.java");
+
+ _subTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "callout",
+ "SubTeam.java");
+
+ _baseClass = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "callout",
+ "BaseClass.java");
+ }
+
+ public void testSmapGeneration1() throws JavaModelException
+ {
+ SmapStratum stratum_role1 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo_role1 = stratum_role1.getOrCreateFileInfo("SuperTeam.java", "callout/SuperTeam.java");
+ LineInfo lineInfo1_role1 = new LineInfo(1,1);
+ lineInfo1_role1.setRepeatCount(10);
+ LineInfo lineInfo2 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo3 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+ fileInfo_role1.addLineInfo(lineInfo1_role1);
+ fileInfo_role1.addLineInfo(lineInfo2);
+ fileInfo_role1.addLineInfo(lineInfo3);
+
+ stratum_role1.optimize();
+
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename = "SuperTeam";
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_baseClass, _superTeam, _subTeam});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration2()
+ {
+ SmapStratum stratum_role2 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);;
+
+ FileInfo fileinfo = stratum_role2.getOrCreateFileInfo("Team.java", "org/objectteams/Team.java");
+ LineInfo lineInfo1 = new LineInfo(OT_CONFINED_GET_TEAM_LINE,11);
+ fileinfo.addLineInfo(lineInfo1);
+
+ FileInfo fileInfo_role2 = stratum_role2.getOrCreateFileInfo("SuperTeam.java", "callout/SuperTeam.java");
+ LineInfo lineInfo2 = new LineInfo(1,1);
+ lineInfo2.setRepeatCount(10);
+ LineInfo lineInfo3 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo4 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+ fileInfo_role2.addLineInfo(lineInfo2);
+ fileInfo_role2.addLineInfo(lineInfo3);
+ fileInfo_role2.addLineInfo(lineInfo4);
+
+ stratum_role2.optimize();
+
+ TYPENAME = "__OT__Confined";
+ _enclosingTypename = "SuperTeam";
+ List<SmapStratum> strata_role2 = new ArrayList<SmapStratum>();
+ strata_role2.add(stratum_role2);
+
+ expectedStrata.put(TYPENAME, strata_role2);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_baseClass, _superTeam, _subTeam});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration3() throws JavaModelException
+ {
+ SmapStratum stratum_role1 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+
+ FileInfo fileInfo1_role1 = stratum_role1.getOrCreateFileInfo("SuperTeam.java", "callout/SuperTeam.java");
+ LineInfo fileInfo1_lineInfo1 = new LineInfo(4,10);
+ LineInfo fileInfo1_lineInfo2 = new LineInfo(8,11);
+ fileInfo1_role1.addLineInfo(fileInfo1_lineInfo1);
+ fileInfo1_role1.addLineInfo(fileInfo1_lineInfo2);
+ FileInfo fileInfo2_role1 = stratum_role1.getOrCreateFileInfo("SubTeam.java", "callout/SubTeam.java");
+ LineInfo fileInfo2_lineInfo1 = new LineInfo(1,1);
+ fileInfo2_lineInfo1.setRepeatCount(9);
+ LineInfo fileInfo2_lineInfo4 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo fileInfo2_lineInfo5 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+ fileInfo2_role1.addLineInfo(fileInfo2_lineInfo1);
+ fileInfo2_role1.addLineInfo(fileInfo2_lineInfo4);
+ fileInfo2_role1.addLineInfo(fileInfo2_lineInfo5);
+
+ stratum_role1.optimize();
+
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename = "SubTeam";
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_baseClass, _superTeam, _subTeam});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration4()
+ {
+ SmapStratum stratum_role2 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+
+ FileInfo fileinfo = stratum_role2.getOrCreateFileInfo("Team.java", "org/objectteams/Team.java");
+ LineInfo lineInfo1 = new LineInfo(OT_CONFINED_GET_TEAM_LINE,11);
+ fileinfo.addLineInfo(lineInfo1);
+
+ FileInfo fileInfo1 = stratum_role2.getOrCreateFileInfo("SuperTeam.java", "callout/SuperTeam.java");
+ LineInfo lineInfo2 = new LineInfo(2,10);
+ fileInfo1.addLineInfo(lineInfo2);
+
+ FileInfo fileInfo2 = stratum_role2.getOrCreateFileInfo("SubTeam.java", "callout/SubTeam.java");
+ LineInfo lineInfo3 = new LineInfo(1,1);
+ lineInfo3.setRepeatCount(9);
+ LineInfo lineInfo5 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo6 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+ fileInfo2.addLineInfo(lineInfo3);
+ fileInfo2.addLineInfo(lineInfo5);
+ fileInfo2.addLineInfo(lineInfo6);
+
+ stratum_role2.optimize();
+
+ TYPENAME = "__OT__Confined";
+ _enclosingTypename = "SubTeam";
+ List<SmapStratum> strata_role2 = new ArrayList<SmapStratum>();
+ strata_role2.add(stratum_role2);
+
+ expectedStrata.put(TYPENAME, strata_role2);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_baseClass, _superTeam, _subTeam});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void callback(CompilationUnitDeclaration cuDecl)
+ {
+ String cuDeclName = String.valueOf(cuDecl.getMainTypeName());
+ if (!_enclosingTypename.equals(cuDeclName))
+ return;
+
+
+ TypeDeclaration typeDecl = cuDecl.types[0];
+
+ assertNotNull("TypeDeclaration should not be null.", typeDecl);
+
+ assertTrue("Membertypes of TypeDeclaration should be greater than 0.", typeDecl.memberTypes.length > 0);
+
+ TypeDeclaration [] members = typeDecl.memberTypes;
+ for (int idx = 0; idx < members.length; idx++)
+ {
+ TypeDeclaration decl = members[idx];
+ String typeName = String.valueOf(decl.name);
+
+ if (decl.isRole() && !decl.isInterface() && typeName.equals(TYPENAME))
+ {
+ RoleSmapGenerator rolefileSmapGenerator = new RoleSmapGenerator(decl);
+ rolefileSmapGenerator.addStratum("OTJ");
+ rolefileSmapGenerator.generate();
+ List actualStrata = rolefileSmapGenerator.getStrata();
+
+ assertEquals("Strata of type \"" + typeName + "\" should be equal.\n", expectedStrata.get(typeName).toString(), actualStrata.toString());
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest006.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest006.java
new file mode 100644
index 0000000..d208996
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest006.java
@@ -0,0 +1,271 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTJStratumGenerationTest006.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.FileInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.LineInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.RoleSmapGenerator;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.SmapStratum;
+
+/**
+ * @author ike
+ *
+ */
+public class OTJStratumGenerationTest006 extends AbstractSourceMapGeneratorTest
+{
+ private org.eclipse.jdt.core.ICompilationUnit _superTeam;
+ private org.eclipse.jdt.core.ICompilationUnit _subTeam;
+ private org.eclipse.jdt.core.ICompilationUnit _baseClass;
+ private String _enclosingTypename;
+
+
+ public OTJStratumGenerationTest006(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new Suite(OTJStratumGenerationTest006.class);
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("JSR-045");
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ _superTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "calloutOverride",
+ "SuperTeam.java");
+
+ _subTeam = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "calloutOverride",
+ "SubTeam.java");
+
+ _baseClass = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "calloutOverride",
+ "BaseClass.java");
+ }
+
+ public void testSmapGeneration1() throws JavaModelException
+ {
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename = "SuperTeam";
+
+ SmapStratum stratum_role1 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo_role1 = stratum_role1.getOrCreateFileInfo("SuperTeam.java", "calloutOverride/SuperTeam.java");
+ LineInfo lineInfo1_role1 = new LineInfo(1,1);
+ lineInfo1_role1.setRepeatCount(16);
+ LineInfo lineInfo1_role2 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo1_role3 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+ fileInfo_role1.addLineInfo(lineInfo1_role1);
+ fileInfo_role1.addLineInfo(lineInfo1_role2);
+ fileInfo_role1.addLineInfo(lineInfo1_role3);
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ stratum_role1.optimize();
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_baseClass, _superTeam, _subTeam});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration2()
+ {
+ SmapStratum stratum_role2 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+
+ FileInfo fileinfo = stratum_role2.getOrCreateFileInfo("Team.java", "org/objectteams/Team.java");
+ LineInfo lineInfo1 = new LineInfo(OT_CONFINED_GET_TEAM_LINE,17);
+ fileinfo.addLineInfo(lineInfo1);
+
+ FileInfo fileinfo2 = stratum_role2.getOrCreateFileInfo("SuperTeam.java", "calloutOverride/SuperTeam.java");
+ LineInfo lineInfo2 = new LineInfo(1,1);
+ lineInfo2.setRepeatCount(16);
+ LineInfo lineInfo3 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo4 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+ fileinfo2.addLineInfo(lineInfo2);
+ fileinfo2.addLineInfo(lineInfo3);
+ fileinfo2.addLineInfo(lineInfo4);
+
+ stratum_role2.optimize();
+
+ TYPENAME = "__OT__Confined";
+ _enclosingTypename = "SuperTeam";
+ List<SmapStratum> strata_role2 = new ArrayList<SmapStratum>();
+ strata_role2.add(stratum_role2);
+
+ expectedStrata.put(TYPENAME, strata_role2);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_baseClass, _superTeam, _subTeam});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration3() throws JavaModelException
+ {
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename = "SubTeam";
+
+ SmapStratum stratum_role1 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo1 = stratum_role1.getOrCreateFileInfo("SuperTeam.java", "calloutOverride/SuperTeam.java");
+ LineInfo lineInfo1 = new LineInfo(4,15);
+ LineInfo lineInfo2 = new LineInfo(8,18);
+ lineInfo2.setRepeatCount(2);
+ LineInfo lineInfo3 = new LineInfo(13,16);
+ lineInfo3.setRepeatCount(2);
+
+ fileInfo1.addLineInfo(lineInfo1);
+ fileInfo1.addLineInfo(lineInfo2);
+ fileInfo1.addLineInfo(lineInfo3);
+
+ FileInfo fileInfo2 = stratum_role1.getOrCreateFileInfo("SubTeam.java", "calloutOverride/SubTeam.java");
+ LineInfo lineInfo4 = new LineInfo(1,1);
+ lineInfo4.setRepeatCount(14);
+ LineInfo lineInfo7 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo8 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+ fileInfo2.addLineInfo(lineInfo4);
+ fileInfo2.addLineInfo(lineInfo7);
+ fileInfo2.addLineInfo(lineInfo8);
+
+ stratum_role1.optimize();
+
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_baseClass, _superTeam, _subTeam});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration4()
+ {
+ SmapStratum stratum_role2 = new SmapStratum(ISMAPConstants.OTJ_STRATUM_NAME);
+
+ FileInfo fileinfo = stratum_role2.getOrCreateFileInfo("Team.java", "org/objectteams/Team.java");
+ LineInfo lineInfo1 = new LineInfo(OT_CONFINED_GET_TEAM_LINE,16);
+ fileinfo.addLineInfo(lineInfo1);
+
+ FileInfo fileInfo2 = stratum_role2.getOrCreateFileInfo("SuperTeam.java", "calloutOverride/SuperTeam.java");
+ LineInfo lineInfo2 = new LineInfo(2,15);
+ fileInfo2.addLineInfo(lineInfo2);
+
+ FileInfo fileInfo3 = stratum_role2.getOrCreateFileInfo("SubTeam.java", "calloutOverride/SubTeam.java");
+ LineInfo lineInfo3 = new LineInfo(1,1);
+ lineInfo3.setRepeatCount(14);
+ LineInfo lineInfo5 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo6 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+ fileInfo3.addLineInfo(lineInfo3);
+ fileInfo3.addLineInfo(lineInfo5);
+ fileInfo3.addLineInfo(lineInfo6);
+
+ stratum_role2.optimize();
+
+ TYPENAME = "__OT__Confined";
+ _enclosingTypename = "SubTeam";
+ List<SmapStratum> strata_role2 = new ArrayList<SmapStratum>();
+ strata_role2.add(stratum_role2);
+
+ expectedStrata.put(TYPENAME, strata_role2);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[]{_baseClass, _superTeam, _subTeam});
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void callback(CompilationUnitDeclaration cuDecl)
+ {
+ String cuDeclName = String.valueOf(cuDecl.getMainTypeName());
+ if (!_enclosingTypename.equals(cuDeclName))
+ return;
+
+
+ TypeDeclaration typeDecl = cuDecl.types[0];
+
+ assertNotNull("TypeDeclaration should not be null.", typeDecl);
+
+ assertTrue("Membertypes of TypeDeclaration should be greater than 0.", typeDecl.memberTypes.length > 0);
+
+ TypeDeclaration [] members = typeDecl.memberTypes;
+ for (int idx = 0; idx < members.length; idx++)
+ {
+ TypeDeclaration decl = members[idx];
+ String typeName = String.valueOf(decl.name);
+
+ if (decl.isRole() && !decl.isInterface() && typeName.equals(TYPENAME))
+ {
+ RoleSmapGenerator rolefileSmapGenerator = new RoleSmapGenerator(decl);
+ rolefileSmapGenerator.addStratum("OTJ");
+ rolefileSmapGenerator.generate();
+ List actualStrata = rolefileSmapGenerator.getStrata();
+
+ assertEquals("Strata of type \"" + typeName + "\" should be equal.\n", expectedStrata.get(typeName).toString(), actualStrata.toString());
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest007.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest007.java
new file mode 100644
index 0000000..2549ea8
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/OTJStratumGenerationTest007.java
@@ -0,0 +1,280 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTJStratumGenerationTest007.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.FileInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.LineInfo;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.LineInfoReminder;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.RoleSmapGenerator;
+import org.eclipse.objectteams.otdt.internal.core.compiler.smap.SmapStratum;
+
+/**
+ * @author ike
+ *
+ */
+public class OTJStratumGenerationTest007 extends AbstractSourceMapGeneratorTest
+{
+ private org.eclipse.jdt.core.ICompilationUnit _teamA;
+
+ @SuppressWarnings("unused")
+ private org.eclipse.jdt.core.ICompilationUnit _tea1m2;
+
+ private org.eclipse.jdt.core.ICompilationUnit _teamB;
+
+ private org.eclipse.jdt.core.ICompilationUnit _baseClass;
+
+ private String _enclosingTypename;
+
+ private String _packagePath;
+
+ private boolean _buildPartially;
+
+ public OTJStratumGenerationTest007(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new Suite(OTJStratumGenerationTest007.class);
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("JSR-045");
+ super.setUpSuite();
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ _packagePath = "callin_after_before";
+
+ _teamA = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ _packagePath,
+ "TeamA.java");
+
+ _teamB = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ _packagePath,
+ "TeamB.java");
+
+ _baseClass = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ _packagePath,
+ "BaseClass.java");
+ }
+
+ public void testSmapGeneration1() throws JavaModelException
+ {
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename = "TeamA";
+ String enclTypeSourceName = _enclosingTypename + ".java";
+ _buildPartially = false;
+
+ SmapStratum stratum_role1 = new SmapStratum(
+ ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo_role1 = stratum_role1.getOrCreateFileInfo(
+ enclTypeSourceName, _packagePath + "/" + enclTypeSourceName);
+ LineInfo lineInfo1_role1 = new LineInfo(1, 1);
+ lineInfo1_role1.setRepeatCount(15);
+ LineInfo lineInfo1_role2 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo1_role3 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+
+ fileInfo_role1.addLineInfo(lineInfo1_role1);
+ fileInfo_role1.addLineInfo(lineInfo1_role2);
+ fileInfo_role1.addLineInfo(lineInfo1_role3);
+
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ stratum_role1.optimize();
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[] {
+ _baseClass, _teamA, _teamB });
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration2() throws JavaModelException
+ {
+ TYPENAME = "__OT__RoleA";
+ _enclosingTypename = "TeamA";
+ String enclTypeSourceName = _enclosingTypename + ".java";
+ _buildPartially = true;
+
+ SmapStratum stratum_role1 = new SmapStratum(
+ ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo_role1 = stratum_role1.getOrCreateFileInfo(
+ enclTypeSourceName, _packagePath + "/" + enclTypeSourceName);
+ fileInfo_role1.addLineInfo(new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER));
+
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[] {
+ _baseClass, _teamA, _teamB });
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testSmapGeneration3() throws JavaModelException
+ {
+ TYPENAME = "__OT__RoleB";
+ _enclosingTypename = "TeamB";
+ String enclTypeSourceName = _enclosingTypename + ".java";
+ _buildPartially = false;
+
+ SmapStratum stratum_role1 = new SmapStratum(
+ ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo_role1 = stratum_role1.getOrCreateFileInfo(
+ enclTypeSourceName, _packagePath + "/" + enclTypeSourceName);
+ LineInfo lineInfo1_role1 = new LineInfo(1, 1);
+ lineInfo1_role1.setRepeatCount(13);
+ LineInfo lineInfo1_role2 = new LineInfo(ISMAPConstants.STEP_INTO_LINENUMBER,ISMAPConstants.STEP_INTO_LINENUMBER);
+ LineInfo lineInfo1_role3 = new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER);
+
+ fileInfo_role1.addLineInfo(lineInfo1_role1);
+ fileInfo_role1.addLineInfo(lineInfo1_role2);
+ fileInfo_role1.addLineInfo(lineInfo1_role3);
+
+ stratum_role1.optimize();
+
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[] {
+ _baseClass, _teamA, _teamB });
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+
+ public void testSmapGeneration4() throws JavaModelException
+ {
+ TYPENAME = "__OT__RoleB";
+ _enclosingTypename = "TeamB";
+ String enclTypeSourceName = _enclosingTypename + ".java";
+ _buildPartially = true;
+
+ SmapStratum stratum_role1 = new SmapStratum(
+ ISMAPConstants.OTJ_STRATUM_NAME);
+ FileInfo fileInfo_role1 = stratum_role1.getOrCreateFileInfo(
+ enclTypeSourceName, _packagePath + "/" + enclTypeSourceName);
+ fileInfo_role1.addLineInfo(new LineInfo(ISMAPConstants.STEP_OVER_LINENUMBER,ISMAPConstants.STEP_OVER_LINENUMBER));
+
+ List<SmapStratum> strata_role1 = new ArrayList<SmapStratum>();
+ strata_role1.add(stratum_role1);
+
+ expectedStrata.put(TYPENAME, strata_role1);
+
+ try
+ {
+ parseAndCompile(new org.eclipse.jdt.core.ICompilationUnit[] {
+ _baseClass, _teamA, _teamB });
+ }
+ catch (JavaModelException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+ public void callback(CompilationUnitDeclaration cuDecl)
+ {
+ String cuDeclName = String.valueOf(cuDecl.getMainTypeName());
+ if (!_enclosingTypename.equals(cuDeclName))
+ return;
+
+ TypeDeclaration typeDecl = cuDecl.types[0];
+
+ assertNotNull("TypeDeclaration should not be null.", typeDecl);
+
+ assertTrue("Membertypes of TypeDeclaration should be greater than 0.",
+ typeDecl.memberTypes.length > 0);
+
+ TypeDeclaration[] members = typeDecl.memberTypes;
+ for (int idx = 0; idx < members.length; idx++)
+ {
+ TypeDeclaration decl = members[idx];
+ String typeName = String.valueOf(decl.name);
+
+ if (decl.isRole() && !decl.isInterface()
+ && typeName.equals(TYPENAME))
+ {
+ RoleSmapGenerator rolefileSmapGenerator = new RoleSmapGenerator(decl);
+ if (_buildPartially)
+ {
+ rolefileSmapGenerator.addStratum("OTJ");
+ SmapStratum stratum = (SmapStratum)rolefileSmapGenerator.getStrata().get(0);
+ rolefileSmapGenerator.generatePartialOTJSmap(stratum, new LineInfoReminder());
+ }
+ else
+ {
+ rolefileSmapGenerator.addStratum("OTJ");
+ rolefileSmapGenerator.generate();
+ }
+
+ List actualStrata = rolefileSmapGenerator.getStrata();
+
+ assertEquals("Strata of type \"" + typeName
+ + "\" should be equal.\n",
+ expectedStrata.get(typeName).toString(), actualStrata.toString());
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/Requestor.java b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/Requestor.java
new file mode 100644
index 0000000..ef9ac20
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/compiler/org/eclipse/objectteams/otdt/tests/compiler/smap/Requestor.java
@@ -0,0 +1,129 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: Requestor.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.compiler.smap;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.core.util.ClassFormatException;
+import org.eclipse.jdt.core.util.IClassFileReader;
+import org.eclipse.jdt.core.util.ILineNumberAttribute;
+import org.eclipse.jdt.core.util.IMethodInfo;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
+import org.eclipse.jdt.internal.core.util.ClassFileReader;
+
+// from org.eclipse.jdt.core.tests.compiler.regression.Requestor
+// added capability to check generated line numbers.
+public class Requestor extends Assert implements ICompilerRequestor {
+ public boolean hasErrors = false;
+ public String outputPath;
+ private boolean forceOutputGeneration;
+ public Hashtable expectedProblems = new Hashtable();
+ public String problemLog = "";
+ public ICompilerRequestor clientRequestor;
+ public boolean showCategory = false;
+ public boolean showWarningToken = false;
+ HashMap<String, int[]> lineNumbers = new HashMap<String, int[]>();
+
+
+public Requestor(boolean forceOutputGeneration, ICompilerRequestor clientRequestor, boolean showCategory, boolean showWarningToken, HashMap<String, int[]> lineNumbers) {
+ this.forceOutputGeneration = forceOutputGeneration;
+ this.clientRequestor = clientRequestor;
+ this.showCategory = showCategory;
+ this.showWarningToken = showWarningToken;
+ this.lineNumbers = lineNumbers;
+}
+public void acceptResult(CompilationResult compilationResult) {
+ this.hasErrors |= compilationResult.hasErrors();
+ this.problemLog += Util.getProblemLog(compilationResult, this.showCategory, this.showWarningToken);
+ outputClassFiles(compilationResult);
+ if (this.clientRequestor != null) {
+ this.clientRequestor.acceptResult(compilationResult);
+ }
+}
+protected void outputClassFiles(CompilationResult unitResult) {
+ if ((unitResult != null) && (!unitResult.hasErrors() || forceOutputGeneration)) {
+ ClassFile[]classFiles = unitResult.getClassFiles();
+ for (int i = 0, fileCount = classFiles.length; i < fileCount; i++) {
+ // retrieve the key and the corresponding classfile
+ ClassFile classFile = classFiles[i];
+ if (outputPath != null) {
+ String relativeName =
+ new String(classFile.fileName()).replace('/', File.separatorChar) + ".class";
+ try {
+ org.eclipse.jdt.internal.compiler.util.Util.writeToDisk(true, outputPath, relativeName, classFile);
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (this.lineNumbers != null) {
+ ClassFileReader cfr;
+ try {
+ cfr = new ClassFileReader(classFile.getBytes(), IClassFileReader.METHOD_INFOS|IClassFileReader.METHOD_BODIES);
+ } catch (ClassFormatException e) {
+ throw new AssertionFailedError("Can't read class file: "+e.getMessage());
+ }
+ for (IMethodInfo method : cfr.getMethodInfos()) {
+ String fullMethodDesignator = String.valueOf(
+ CharOperation.concatWith(
+ classFile.getCompoundName(),
+ CharOperation.concat(method.getName(), method.getDescriptor()),
+ '.'));
+ int[] expectedNumbers = this.lineNumbers.get(fullMethodDesignator);
+ if (expectedNumbers != null) {
+ this.lineNumbers.remove(fullMethodDesignator);
+ ILineNumberAttribute lineNumberAttribute = method.getCodeAttribute().getLineNumberAttribute();
+ int[][] table = lineNumberAttribute.getLineNumberTable();
+ Assert.assertEquals("wrong number of line numbers", expectedNumbers.length, table.length);
+ for (int n=0; n<expectedNumbers.length; n++)
+ Assert.assertEquals("wrong line numeber", expectedNumbers[n], table[n][1]);
+ }
+ }
+ }
+ }
+ }
+}
+public void checkAllLineNumbersSeen() {
+ if (this.lineNumbers != null) {
+ if (!this.lineNumbers.isEmpty()) {
+ String methods = "";
+ for (Map.Entry<String, int[]> entry : this.lineNumbers.entrySet()) {
+ System.out.print("Unmatched line numbers for method "+entry.getKey());
+ for(int l : entry.getValue())
+ System.out.print(" "+l);
+ System.out.println();
+ methods += " "+entry.getKey();
+ }
+ Assert.fail("Unmatched line numbers"+methods);
+ }
+ }
+}
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/formatter/org/eclipse/objectteams/otdt/core/tests/formatter/FormatterTests.java b/testplugins/org.eclipse.objectteams.otdt.tests/formatter/org/eclipse/objectteams/otdt/core/tests/formatter/FormatterTests.java
new file mode 100644
index 0000000..85303fd
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/formatter/org/eclipse/objectteams/otdt/core/tests/formatter/FormatterTests.java
@@ -0,0 +1,229 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: FormatterTests.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.core.tests.formatter;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.formatter.CodeFormatter;
+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
+
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter;
+import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions;
+import org.eclipse.objectteams.otdt.tests.AbstractJavaModelTests;
+import org.eclipse.text.edits.TextEdit;
+
+/**
+ * Test infra-structure copied from org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.
+ *
+ * @author stephan
+ */
+@SuppressWarnings("restriction")
+public class FormatterTests extends AbstractJavaModelTests {
+
+ public static final int UNKNOWN_KIND = 0;
+ public static final String IN = "_in";
+ public static final String OUT = "_out";
+ public static final boolean DEBUG = false;
+ private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+ private long time;
+
+ static {
+// TESTS_NUMBERS = new int[] { 620 } ;
+ }
+ public static Test suite() {
+ return buildModelTestSuite(FormatterTests.class);
+ }
+
+ public FormatterTests(String name) {
+ super(name);
+ }
+
+ /**
+ * Returns the OS path to the directory that contains this plugin.
+ */
+ protected String getPluginDirectoryPath() {
+ try {
+ URL platformURL = Platform.getBundle("org.eclispe.objectteams.otdt.tests").getEntry("/");
+ return new File(FileLocator.toFileURL(platformURL).getFile()).getAbsolutePath();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public String getSourceWorkspacePath() {
+ return getPluginDirectoryPath() + java.io.File.separator + "workspace";
+ }
+
+ private String runFormatter(CodeFormatter codeFormatter, String source, int kind, int indentationLevel, int offset, int length, String lineSeparator) {
+// long time = System.currentTimeMillis();
+ TextEdit edit = codeFormatter.format(kind, source, offset, length, indentationLevel, lineSeparator);//$NON-NLS-1$
+// System.out.println((System.currentTimeMillis() - time) + " ms");
+ if (edit == null) return null;
+// System.out.println(edit.getChildrenSize() + " edits");
+ String result = org.eclipse.jdt.internal.core.util.Util.editedString(source, edit);
+
+ if (length == source.length()) {
+// time = System.currentTimeMillis();
+ edit = codeFormatter.format(kind, result, 0, result.length(), indentationLevel, lineSeparator);//$NON-NLS-1$
+// System.out.println((System.currentTimeMillis() - time) + " ms");
+ if (edit == null) return null;
+// assertEquals("Should not have edits", 0, edit.getChildren().length);
+ final String result2 = org.eclipse.jdt.internal.core.util.Util.editedString(result, edit);
+ if (!result.equals(result2)) {
+ assertSourceEquals("Different reformatting", Util.convertToIndependantLineDelimiter(result), Util.convertToIndependantLineDelimiter(result2));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Create project and set the jar placeholder.
+ */
+ public void setUpSuite() throws Exception {
+ // ensure autobuilding is turned off
+ IWorkspaceDescription description = getWorkspace().getDescription();
+ if (description.isAutoBuilding()) {
+ description.setAutoBuilding(false);
+ getWorkspace().setDescription(description);
+ }
+ setUpJavaProject("Formatter", "1.5"); //$NON-NLS-1$ $NON-NLS-2$
+ if (DEBUG) {
+ this.time = System.currentTimeMillis();
+ }
+ }
+
+ /**
+ * Reset the jar placeholder and delete project.
+ */
+ public void tearDownSuite() throws Exception {
+ this.deleteProject("Formatter"); //$NON-NLS-1$
+ if (DEBUG) {
+ System.out.println("Time spent = " + (System.currentTimeMillis() - this.time));//$NON-NLS-1$
+ }
+ super.tearDown();
+ }
+
+ private String getIn(String compilationUnitName) {
+ assertNotNull(compilationUnitName);
+ int dotIndex = compilationUnitName.indexOf('.');
+ assertTrue(dotIndex != -1);
+ return compilationUnitName.substring(0, dotIndex) + IN + compilationUnitName.substring(dotIndex);
+ }
+
+ private String getOut(String compilationUnitName) {
+ assertNotNull(compilationUnitName);
+ int dotIndex = compilationUnitName.indexOf('.');
+ assertTrue(dotIndex != -1);
+ return compilationUnitName.substring(0, dotIndex) + OUT + compilationUnitName.substring(dotIndex);
+ }
+
+ private void assertLineEquals(String actualContents, String originalSource, String expectedContents, boolean checkNull) {
+ if (actualContents == null) {
+ assertTrue("actualContents is null", checkNull);
+ assertEquals(expectedContents, originalSource);
+ return;
+ }
+ assertSourceEquals("Different source", Util.convertToIndependantLineDelimiter(expectedContents), actualContents);
+ }
+
+ private void runTest(String packageName, String compilationUnitName) {
+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipse21Settings());
+ preferences.number_of_empty_lines_to_preserve = 0;
+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
+ runTest(codeFormatter, packageName, compilationUnitName, CodeFormatter.K_COMPILATION_UNIT, 0);
+ }
+
+ private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel) {
+ runTest(codeFormatter, packageName, compilationUnitName, kind, indentationLevel, false, 0, -1);
+ }
+ private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel, boolean checkNull, int offset, int length) {
+ runTest(codeFormatter, packageName, compilationUnitName, kind, indentationLevel, checkNull, offset, length, null);
+ }
+
+ private void runTest(CodeFormatter codeFormatter, String packageName, String compilationUnitName, int kind, int indentationLevel, boolean checkNull, int offset, int length, String lineSeparator) {
+ try {
+ ICompilationUnit sourceUnit = getCompilationUnit("Formatter" , "", packageName, getIn(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$
+ String s = sourceUnit.getSource();
+ assertNotNull(s);
+ ICompilationUnit outputUnit = getCompilationUnit("Formatter" , "", packageName, getOut(compilationUnitName)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull(outputUnit);
+ String result;
+ if (length == -1) {
+ result = runFormatter(codeFormatter, s, kind, indentationLevel, offset, s.length(), lineSeparator);
+ } else {
+ result = runFormatter(codeFormatter, s, kind, indentationLevel, offset, length, lineSeparator);
+ }
+ assertLineEquals(result, s, outputUnit.getSource(), checkNull);
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ String getSource(ASTNode astNode, char[] source) {
+ String result = new String(CharOperation.subarray(source, astNode.getStartPosition() + 1, astNode.getStartPosition() + astNode.getLength() - 1));
+ if (result.endsWith("\\n")) {
+ return result.substring(0, result.length() - 2) + LINE_SEPARATOR;
+ }
+ return result;
+ }
+
+ public void test001() {
+ runTest("test001", "T1.java");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void test002() {
+ runTest("test002", "T1.java");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void test003() {
+ runTest("test003", "T1.java");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void test004() {
+ runTest("test004", "T1.java");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void test005() {
+ runTest("test005", "T1.java");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void test006() {
+ runTest("test006", "T1.java");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void test007() {
+ runTest("test007", "Class1.java");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/AllTests.java
new file mode 100644
index 0000000..270f57f
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/AllTests.java
@@ -0,0 +1,44 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: AllTests.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.hierarchy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author anklam
+ *
+ * @version $Id: AllTests.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("All CompleteRoleHierarchy Tests");
+
+ //$JUnit-BEGIN$
+ suite.addTest(CompleteRoleHierarchyWithClasses.suite());
+ suite.addTest(OTTypeHierarchyTests.suite());
+ suite.addTest(ITypeIOTTypeTest.suite());
+ //$JUnit-END$
+
+ return suite;
+ }
+}
\ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/CompleteRoleHierarchyWithClasses.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/CompleteRoleHierarchyWithClasses.java
new file mode 100644
index 0000000..f67bda4
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/CompleteRoleHierarchyWithClasses.java
@@ -0,0 +1,560 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: CompleteRoleHierarchyWithClasses.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.hierarchy;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.IRoleType;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+/**
+ * @author jwloka
+ * @version $Id: CompleteRoleHierarchyWithClasses.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+/*
+ * The testdata setting looks like this:
+ *
+ * SuperSuperTeam
+ * R1 SuperClass
+ * /\ /\
+ * | |
+ * SuperTeam |
+ * R1------------------------------------------------> AClass
+ * /\ explicit inheritance /\
+ * | ~~~~~~~~~~~~~~~~~~~~ |'''''''''''''''''|
+ * ATeam | |
+ * R1 SubClass1 SubClass2
+ * /\ /\ /\
+ * |'''''''''''''''''''| |''''''''''''|'''''''''''''| |
+ * SubTeam1 SubTeam2 | | | |
+ * R1 R1------------------>SubSubClass11 SubSubClass12 |
+ * /\ | |
+ * |'''''''''''| | |
+ * SubSubTeam11 SubSubTeam12 | |
+ * R1 R1-----------------| |
+ * | |
+ * |---------------------------------------------------------------------|
+ *
+ * The focus role is ATeam.R1 .
+ */
+public class CompleteRoleHierarchyWithClasses extends FileBasedModelTest
+{
+ private IRoleType _focusRole;
+ private IRoleType _implSuperRole;
+ private IRoleType _implSuperSuperRole;
+ private IRoleType _implSubRole1;
+ private IRoleType _implSubRole2;
+ private IRoleType _implSubSubRole11;
+ private IRoleType _implSubSubRole12;
+ private IType _class;
+ private IType _superClass;
+ private IType _subClass1;
+ private IType _subClass2;
+ private IType _subSubClass11;
+ private IType _subSubClass12;
+ private IType _object;
+
+ private OTTypeHierarchy _hierarchy;
+
+
+ public CompleteRoleHierarchyWithClasses(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(CompleteRoleHierarchyWithClasses.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(CompleteRoleHierarchyWithClasses.class.getName());
+ return suite;
+ }
+
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ _focusRole =
+ getRole(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.inlined",
+ "ATeam",
+ "R1");
+
+ _hierarchy = new OTTypeHierarchy(_focusRole, _focusRole.getJavaProject(), true);
+ _hierarchy.refresh(new NullProgressMonitor());
+
+ _implSuperRole =
+ getRole(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.inlined",
+ "SuperTeam",
+ "R1");
+
+ _implSuperSuperRole =
+ getRole(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.inlined",
+ "SuperSuperTeam",
+ "R1");
+
+ _implSubRole1 =
+ getRole(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.inlined",
+ "SubTeam1",
+ "R1");
+
+ _implSubRole2 =
+ getRole(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.inlined",
+ "SubTeam2",
+ "R1");
+
+ _implSubSubRole11 =
+ getRole(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.inlined",
+ "SubSubTeam11",
+ "R1");
+
+ _implSubSubRole12 =
+ getRole(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.inlined",
+ "SubSubTeam12",
+ "R1");
+
+ _class =
+ getType(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.standard",
+ "AClass");
+
+ _superClass =
+ getType(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.standard",
+ "SuperClass");
+
+ _subClass1 =
+ getType(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.standard",
+ "SubClass1");
+
+ _subClass2 =
+ getType(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.standard",
+ "SubClass2");
+
+ _subSubClass11 =
+ getType(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.standard",
+ "SubSubClass11");
+
+ _subSubClass12 =
+ getType(getTestProjectDir(),
+ "complete_rolehierarchy_with_classes",
+ "test002.standard",
+ "SubSubClass12");
+
+ _object =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+
+ }
+
+ public void testContainment_implSuperRole()
+ {
+ assertTrue(_hierarchy.contains((IType)_implSuperRole.getCorrespondingJavaElement()));
+ }
+
+ public void testGetExplicitSuperclass_ofFocusRole() throws JavaModelException
+ {
+ assertEquals(_class, _hierarchy.getExplicitSuperclass((IType)_focusRole.getCorrespondingJavaElement()));
+ }
+
+
+ public void testGetExplicitSuperclass_ofImplSuperSuperRole() throws JavaModelException
+ {
+ assertEquals(_object, _hierarchy.getExplicitSuperclass((IType)_implSuperSuperRole.getCorrespondingJavaElement()));
+ }
+
+
+ public void testGetExplicitSuperclass_ofImplSuperRole() throws JavaModelException
+ {
+ assertEquals(_class, _hierarchy.getExplicitSuperclass((IType)_implSuperRole.getCorrespondingJavaElement()));
+ }
+
+
+ public void testGetExplicitSuperclass_ofImplSubRole1() throws JavaModelException
+ {
+ assertEquals(_class, _hierarchy.getExplicitSuperclass((IType)_implSubRole1.getCorrespondingJavaElement()));
+ }
+
+
+ public void testGetExplicitSuperclass_ofImplSubRole2() throws JavaModelException
+ {
+ assertEquals(_subSubClass11, _hierarchy.getExplicitSuperclass((IType)_implSubRole2.getCorrespondingJavaElement()));
+ }
+
+
+ public void testGetExplicitSuperclass_ofImplSubSubRole11() throws JavaModelException
+ {
+ assertEquals(_subClass2, _hierarchy.getExplicitSuperclass((IType)_implSubSubRole11.getCorrespondingJavaElement()));
+ }
+
+
+ public void testGetExplicitSuperclass_ofImplSubSubRole12() throws JavaModelException
+ {
+ assertEquals(_subClass1, _hierarchy.getExplicitSuperclass((IType)_implSubSubRole12.getCorrespondingJavaElement()));
+ }
+
+
+ public void testGetAllClasses()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_implSubRole1);
+ expectedList.add(_implSubRole2);
+ expectedList.add(_implSubSubRole11);
+ expectedList.add(_implSubSubRole12);
+ expectedList.add(_object);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_subClass1);
+ expectedList.add(_subClass2);
+ expectedList.add(_subSubClass11);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllClasses();
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllTypes()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_implSubRole1);
+ expectedList.add(_implSubRole2);
+ expectedList.add(_implSubSubRole11);
+ expectedList.add(_implSubSubRole12);
+ expectedList.add(_superClass);
+ expectedList.add(_object);
+ expectedList.add(_class);
+ expectedList.add(_subClass1);
+ expectedList.add(_subClass2);
+ expectedList.add(_subSubClass11);
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+
+ assertTrue(compareTypes(expected, _hierarchy.getAllTypes()));
+ }
+
+ public void testGetAllSuperclasses_ofFocusRole()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSuperclasses((IType)_focusRole.getCorrespondingJavaElement());
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_ofImplSuperSuperRole()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSuperclasses((IType)_implSuperSuperRole.getCorrespondingJavaElement());
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_ofImplSuperRole()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSuperclasses((IType)_implSuperRole.getCorrespondingJavaElement());
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_ofImplSubRole1()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSuperclasses((IType)_implSubRole1.getCorrespondingJavaElement());
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_ofImplSubRole2()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_subClass1);
+ expectedList.add(_subSubClass11);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSuperclasses((IType)_implSubRole2.getCorrespondingJavaElement());
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_ofImplSubSubRole11()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_implSubRole1);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_subClass2);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSuperclasses((IType)_implSubSubRole11.getCorrespondingJavaElement());
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_ofImplSubSubRole12()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_implSubRole1);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_subClass1);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSuperclasses((IType)_implSubSubRole12.getCorrespondingJavaElement());
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSupertypes_ofFocusRole()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_object);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSupertypes((IType)_focusRole.getCorrespondingJavaElement());
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSupertypes_ofImplSuperSuperRole()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSupertypes((IType)_implSuperSuperRole.getCorrespondingJavaElement());
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSupertypes_ofImplSuperRole()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSupertypes((IType)_implSuperRole.getCorrespondingJavaElement());
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSupertypes_ofImplSubRole1()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSupertypes((IType)_implSubRole1.getCorrespondingJavaElement());
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSupertypes_ofImplSubRole2()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_subClass1);
+ expectedList.add(_subSubClass11);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSupertypes((IType)_implSubRole2.getCorrespondingJavaElement());
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSupertypes_ofImplSubSubRole11()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_implSubRole1);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_subClass2);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSupertypes((IType)_implSubSubRole11.getCorrespondingJavaElement());
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSupertypes_ofImplSubSubRole12()
+ {
+ ArrayList<IType> expectedList = new ArrayList<IType>();
+ expectedList.add(_implSuperSuperRole);
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_implSubRole1);
+ expectedList.add(_superClass);
+ expectedList.add(_class);
+ expectedList.add(_subClass1);
+ expectedList.add(_object);
+
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+ IType[] actual = _hierarchy.getAllSupertypes((IType)_implSubSubRole12.getCorrespondingJavaElement());
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ // succeeds although hierarchy was not built for type.
+ public void testGetAllSubtypes_ofSubClass2()
+ {
+ ArrayList<IRoleType> expectedList = new ArrayList<IRoleType>();
+ expectedList.add(_implSubSubRole11);
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+
+ assertTrue(compareTypes(expected, _hierarchy.getAllSubtypes(_subClass2)));
+ }
+
+ // succeeds although hierarchy was not built for type.
+ public void testGetAllSubtypes_ofSubSubClass11()
+ {
+ ArrayList<IRoleType> expectedList = new ArrayList<IRoleType>();
+ expectedList.add(_implSubRole2);
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+
+ assertTrue(compareTypes(expected, _hierarchy.getAllSubtypes(_subSubClass11)));
+ }
+
+ // succeeds although hierarchy was not built for type.
+ public void testGetAllSubtypes_ofSubSubClass12()
+ {
+ IType[] expected = new IType[0];
+ assertTrue(compareTypes(expected, _hierarchy.getAllSubtypes(_subSubClass12)));
+ }
+
+ public void testGetAllSubtypes_ofImplSuperSuperRole()
+ {
+ ArrayList<IRoleType> expectedList = new ArrayList<IRoleType>();
+ expectedList.add(_implSuperRole);
+ expectedList.add(_focusRole);
+ expectedList.add(_implSubRole1);
+ expectedList.add(_implSubRole2);
+ expectedList.add(_implSubSubRole11);
+ expectedList.add(_implSubSubRole12);
+ IType[] expected = expectedList.toArray(new IType[expectedList.size()]);
+
+ assertTrue(compareTypes(expected, _hierarchy.getAllSubtypes((IType)_implSuperSuperRole.getCorrespondingJavaElement())));
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/FileBasedHierarchyTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/FileBasedHierarchyTest.java
new file mode 100644
index 0000000..a191e7c
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/FileBasedHierarchyTest.java
@@ -0,0 +1,58 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: FileBasedHierarchyTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.hierarchy;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+public class FileBasedHierarchyTest extends FileBasedModelTest
+{
+ protected OTTypeHierarchy _testObj;
+ protected IType _focusType;
+
+ public FileBasedHierarchyTest(String name)
+ {
+ super(name);
+ }
+
+ private OTTypeHierarchy createOTTypeHierarchy(IType focusType, boolean computeSubtypes) throws JavaModelException
+ {
+ OTTypeHierarchy hierarchy = new OTTypeHierarchy(focusType, focusType.getJavaProject(), computeSubtypes);
+ hierarchy.refresh(new NullProgressMonitor());
+ return hierarchy;
+ }
+
+ public OTTypeHierarchy createOTTypeHierarchy(IType focusType) throws JavaModelException
+ {
+ return createOTTypeHierarchy(focusType, true);
+ }
+
+ public OTTypeHierarchy createOTSuperTypeHierarchy(IType focusType) throws JavaModelException
+ {
+ return createOTTypeHierarchy(focusType, false);
+ }
+
+
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/ITypeIOTTypeTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/ITypeIOTTypeTest.java
new file mode 100644
index 0000000..00b9204
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/ITypeIOTTypeTest.java
@@ -0,0 +1,309 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: ITypeIOTTypeTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.hierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.IOTType;
+import org.eclipse.objectteams.otdt.core.IOTTypeHierarchy;
+import org.eclipse.objectteams.otdt.core.OTModelManager;
+import org.eclipse.objectteams.otdt.core.PhantomType;
+
+/**
+ * Testing OTTypeHiearchy with respect to IType vs. IOTType instances as input
+ * @author Carsten Pfeiffer (carp)
+ *
+ * $Id: ITypeIOTTypeTest.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class ITypeIOTTypeTest extends FileBasedHierarchyTest
+{
+ @SuppressWarnings("unused")
+ private IType _objectType;
+
+ private IType _MyTeam;
+ private IType _MySubTeam;
+ private IType _MyOtherSubTeam;
+
+ private IType _MyTeam_MyRole;
+ private IType _MySubTeam_MyRole; // phantom-type!
+ private IType _MyOtherSubTeam_MyRole;
+
+ private IOTType _OT_MyTeam;
+ private IOTType _OT_MySubTeam;
+ @SuppressWarnings("unused")
+ private IOTType _OT_MyOtherSubTeam;
+
+ private IOTType _OT_MyTeam_MyRole;
+ private IOTType _OT_MyOtherSubTeam_MyRole;
+
+ public ITypeIOTTypeTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(ITypeIOTTypeTest.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(ITypeIOTTypeTest.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "simple";
+
+ _objectType =
+ getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+
+ _MyTeam = getType(getTestProjectDir(), srcFolder, pkg, "MyTeam");
+ _MySubTeam = getType(getTestProjectDir(), srcFolder, pkg, "MySubTeam");
+ _MyOtherSubTeam = getType(getTestProjectDir(), srcFolder, pkg, "MyOtherSubTeam");
+
+ _MyTeam_MyRole = getRole(_MyTeam, "MyTeam.MyRole");
+ _MySubTeam_MyRole = new PhantomType(_MySubTeam, _MyTeam_MyRole);
+ _MyOtherSubTeam_MyRole = getRole(_MyOtherSubTeam, "MyOtherSubTeam.MyRole");
+
+ _OT_MyTeam = OTModelManager.getOTElement(_MyTeam);
+ _OT_MySubTeam = OTModelManager.getOTElement(_MySubTeam);
+ _OT_MyOtherSubTeam = OTModelManager.getOTElement(_MyOtherSubTeam);
+ _OT_MyTeam_MyRole = OTModelManager.getOTElement(_MyTeam_MyRole);
+ _OT_MyOtherSubTeam_MyRole = OTModelManager.getOTElement(_MyOtherSubTeam_MyRole);
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_MyTeam);
+ assertCreation(_MySubTeam);
+
+ assertCreation(_MyTeam_MyRole);
+ assertCreation(_MySubTeam_MyRole);
+
+ assertCreation(_OT_MyTeam);
+ assertCreation(_OT_MySubTeam);
+ assertCreation(_OT_MyTeam_MyRole);
+ }
+
+ public void testHierarchyCreation_equalFocusType() throws JavaModelException
+ {
+ IOTTypeHierarchy first = createOTTypeHierarchy(_MyTeam);
+ IOTTypeHierarchy second = createOTTypeHierarchy(_OT_MyTeam);
+
+ assertEquals(first.getFocusType(), second.getFocusType());
+ }
+
+ public void testGetOTSuperTypeHierarchy() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ ITypeHierarchy first = _testObj.getOTSuperTypeHierarchy(_MyTeam);
+ ITypeHierarchy second = _testObj.getOTSuperTypeHierarchy(_OT_MyTeam);
+
+ assertEquals(first, second);
+ }
+
+ public void testGetSubtypes() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ IType [] first = _testObj.getSubtypes(_MyTeam);
+ IType [] second = _testObj.getSubtypes(_OT_MyTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetAllSuperclasses() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MySubTeam);
+
+ IType [] first = _testObj.getAllSuperclasses(_MySubTeam);
+ IType [] second = _testObj.getAllSuperclasses(_OT_MySubTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ // TODO: actually use test data with interfaces
+ public void testGetAllSuperInterfaces() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ IType [] first = _testObj.getAllSuperInterfaces(_MyTeam);
+ IType [] second = _testObj.getAllSuperInterfaces(_OT_MyTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetAllSupertypes() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MySubTeam);
+
+ IType [] first = _testObj.getAllSupertypes(_MySubTeam);
+ IType [] second = _testObj.getAllSupertypes(_OT_MySubTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetAllSubtypes() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ IType [] first = _testObj.getAllSubtypes(_MyTeam);
+ IType [] second = _testObj.getAllSubtypes(_OT_MyTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetCachedFlags() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ int first = _testObj.getCachedFlags(_MyTeam);
+ int second = _testObj.getCachedFlags(_OT_MyTeam);
+
+ assertTrue(first == second);
+ }
+
+ public void testGetSubclasses() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ IType [] first = _testObj.getSubclasses(_MyTeam);
+ IType [] second = _testObj.getSubclasses(_OT_MyTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetSuperclass() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MySubTeam);
+
+ IType first = _testObj.getSuperclass(_MySubTeam);
+ IType second = _testObj.getSuperclass(_OT_MySubTeam);
+
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetSuperclasses() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MySubTeam);
+
+ IType [] first = _testObj.getSuperclasses(_MySubTeam);
+ IType [] second = _testObj.getSuperclasses(_OT_MySubTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ // TODO: actually use test data with interfaces
+ public void testGetSuperInterfaces() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ IType [] first = _testObj.getSuperInterfaces(_MyTeam);
+ IType [] second = _testObj.getSuperInterfaces(_OT_MyTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetSupertypes() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MySubTeam);
+
+ IType [] first = _testObj.getSupertypes(_MySubTeam);
+ IType [] second = _testObj.getSupertypes(_OT_MySubTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetTSuperTypes() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyOtherSubTeam_MyRole);
+
+ IType [] first = _testObj.getTSuperTypes(_MyOtherSubTeam_MyRole);
+ IType [] second = _testObj.getTSuperTypes(_OT_MyOtherSubTeam_MyRole);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetAllTSuperTypes() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyOtherSubTeam_MyRole);
+
+ IType [] first = _testObj.getAllTSuperTypes(_MyOtherSubTeam_MyRole);
+ IType [] second = _testObj.getAllTSuperTypes(_OT_MyOtherSubTeam_MyRole);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ public void testGetExplicitSuperclass() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MySubTeam);
+
+ IType first = _testObj.getExplicitSuperclass(_MySubTeam);
+ IType second = _testObj.getExplicitSuperclass(_OT_MySubTeam);
+
+ assertTrue(compareTypes(first, second));
+ }
+
+ // TODO: actually use test data with interfaces
+ public void testGetExtendingInterfaces() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ IType [] first = _testObj.getExtendingInterfaces(_MyTeam);
+ IType [] second = _testObj.getExtendingInterfaces(_OT_MyTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+
+ // TODO: actually use test data with interfaces
+ public void testGetImplementingClasses() throws JavaModelException
+ {
+ _testObj = createOTTypeHierarchy(_MyTeam);
+
+ IType [] first = _testObj.getImplementingClasses(_MyTeam);
+ IType [] second = _testObj.getImplementingClasses(_OT_MyTeam);
+
+ assertEquals(first.length, second.length);
+ assertTrue(compareTypes(first, second));
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/OTTypeHierarchyTests.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/OTTypeHierarchyTests.java
new file mode 100644
index 0000000..544f6ae
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/hierarchy/OTTypeHierarchyTests.java
@@ -0,0 +1,46 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTTypeHierarchyTests.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.hierarchy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTTypeHierarchyTests.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ */
+public class OTTypeHierarchyTests
+{
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("All OTTypeHierarchy Tests");
+
+ //$JUnit-BEGIN$
+ suite.addTest(org.eclipse.objectteams.otdt.tests.superhierarchy.AllTests.suite());
+ suite.addTest(org.eclipse.objectteams.otdt.tests.subhierarchy.AllTests.suite());
+ //$JUnit-END$
+
+ return suite;
+ }
+}
\ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/AllTests.java
new file mode 100644
index 0000000..9055e06
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/AllTests.java
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: AllTests.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Michael Krueger (mkr)
+ *
+ * @version $Id: AllTests.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("All OT-SubhierarchyTests");
+ //$JUnit-BEGIN$
+ suite.addTest(OTTypeHierarchyBuilderTest.suite());
+ suite.addTest(OTSubTypeHierarchyTest001.suite());
+ suite.addTest(OTSubTypeHierarchyTest002.suite());
+ suite.addTest(OTSubTypeHierarchyTest004.suite());
+ suite.addTest(OTSubTypeHierarchyTest006.suite());
+ suite.addTest(OTSubTypeHierarchyTest010.suite());
+ suite.addTest(OTSubTypeHierarchyTest011.suite());
+ suite.addTest(OTSubTypeHierarchyTest016.suite());
+ suite.addTest(OTSubTypeHierarchyTest017.suite());
+ suite.addTest(OTSubTypeHierarchyTest018.suite());
+ suite.addTest(OTSubTypeHierarchyTest019.suite());
+ //$JUnit-END$
+ return suite;
+ }
+}
\ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest001.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest001.java
new file mode 100644
index 0000000..85ba0f4
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest001.java
@@ -0,0 +1,411 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest001.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import java.util.HashMap;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.PhantomType;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSubTypeHierarchyTest001.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSubTypeHierarchyTest001 extends FileBasedHierarchyTest
+{
+
+ private IType _T1;
+ private IType _T2;
+ private IType _T3;
+ private IType _T4;
+ private IType _T5;
+ private IType _T6;
+ private IType _T7;
+ private IType _T8;
+
+ private IType _T1_R1;
+ private IType _T1_R2;
+
+ private IType _T2_R1;
+ private IType _T2_R2;
+
+ private IType _T3_R1;
+ private IType _T3_R2;
+
+ private IType _phantom_T4_R1;
+ private IType _T4_R2;
+
+ private IType _T5_R1;
+ private IType _T5_R2;
+ private IType _T5_R3;
+
+ private IType _T6_R1;
+ private IType _phantom_T6_R2;
+
+ private IType _phantom_T7_R1;
+ private IType _T7_R2;
+ private IType _T7_R3;
+
+ private IType _phantom_T8_R1;
+ private IType _T8_R2;
+
+ @SuppressWarnings("unused")
+ private IType _objectType;
+
+ public OTSubTypeHierarchyTest001(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest001.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest001.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test001";
+
+ _T1 = getType(getTestProjectDir(), srcFolder, pkg, "T1");
+ _T2 = getType(getTestProjectDir(), srcFolder, pkg, "T2");
+ _T3 = getType(getTestProjectDir(), srcFolder, pkg, "T3");
+ _T4 = getType(getTestProjectDir(), srcFolder, pkg, "T4");
+ _T5 = getType(getTestProjectDir(), srcFolder, pkg, "T5");
+ _T6 = getType(getTestProjectDir(), srcFolder, pkg, "T6");
+ _T7 = getType(getTestProjectDir(), srcFolder, pkg, "T7");
+ _T8 = getType(getTestProjectDir(), srcFolder, pkg, "T8");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+ _T1_R2 = getRole(_T1, "T1.R2");
+
+ _T2_R1 = getRole(_T2, "T2.R1");
+ _T2_R2 = getRole(_T2, "T2.R2");
+
+ _T3_R1 = getRole(_T3, "T3.R1");
+ _T3_R2 = getRole(_T3, "T3.R2");
+
+ _phantom_T4_R1 = new PhantomType(_T4, _T2_R1);
+ _T4_R2 = getRole(_T4, "T4.R2");
+
+ _T5_R1 = getRole(_T5, "T5.R1");
+ _T5_R2 = getRole(_T5, "T5.R2");
+ _T5_R3 = getRole(_T5, "T5.R3");
+
+ _T6_R1 = getRole(_T6, "T6.R1");
+ _phantom_T6_R2 = new PhantomType(_T6, _T2_R2);
+
+ _phantom_T7_R1 = new PhantomType(_T7, _T5_R1);
+ _T7_R2 = getRole(_T7, "T7.R2");
+ _T7_R3 = getRole(_T7, "T7.R3");
+
+ _phantom_T8_R1 = new PhantomType(_T8, _T6_R1);
+ _T8_R2 = getRole(_T8, "T8.R2");
+
+ _objectType = getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_T1);
+ assertCreation(_T2);
+ assertCreation(_T3);
+ assertCreation(_T4);
+ assertCreation(_T5);
+ assertCreation(_T6);
+ assertCreation(_T7);
+ assertCreation(_T8);
+
+ assertCreation(_T1_R1);
+ assertCreation(_T1_R2);
+
+ assertCreation(_T2_R1);
+ assertCreation(_T2_R2);
+
+ assertCreation(_T3_R1);
+ assertCreation(_T3_R2);
+
+ assertCreation(_phantom_T4_R1);
+ assertCreation(_T4_R2);
+
+ assertCreation(_T5_R1);
+ assertCreation(_T5_R2);
+ assertCreation(_T5_R3);
+
+ assertCreation(_T6_R1);
+ assertCreation(_phantom_T6_R2);
+
+ assertCreation(_phantom_T7_R1);
+ assertCreation(_T7_R2);
+ assertCreation(_T7_R3);
+
+ assertCreation(_phantom_T8_R1);
+ assertCreation(_T8_R2);
+ }
+
+ public void testGetAllSubtypes_T1_R1() throws JavaModelException
+ {
+ _focusType = _T1_R1;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {
+ _T2_R1, _T2_R2,
+ _T3_R1, _T3_R2,
+ _T4_R2,
+ _T5_R1, _T5_R2, _T5_R3,
+ _T6_R1,
+ _T7_R2, _T7_R3,
+ _T8_R2
+ };
+
+ IType [] actual = _testObj.getAllSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSubtypes_T1_R2() throws JavaModelException
+ {
+ _focusType = _T1_R2;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {
+ _T2_R2,
+ _T3_R2,
+ _T4_R2,
+ _T5_R2,
+ _T7_R2,
+ _T8_R2
+ };
+
+ IType [] actual = _testObj.getAllSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T2_R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {
+ _T4_R2,
+ _T2_R2,
+ _T3_R1,
+ _T5_R1,
+ _T6_R1
+ };
+
+ IType [] actual = _testObj.getSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSubclasses_T2_R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {
+ _T4_R2,
+ _T2_R2,
+ _T3_R1,
+ _T5_R1,
+ _T6_R1
+ };
+
+ IType [] actual = _testObj.getSubclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSubclasses_T5_R1() throws JavaModelException
+ {
+ _focusType = _T5_R1;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T5_R3, _T7_R3 };
+
+ IType [] actual = _testObj.getSubclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSubclasses_T6_R1() throws JavaModelException
+ {
+ _focusType = _T6_R1;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T8_R2,
+ _T2_R2 };
+
+ IType [] actual = _testObj.getSubclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubclasses_T6_R1_phantomMode() throws JavaModelException
+ {
+ _focusType = _T6_R1;
+ _testObj = createOTTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _phantom_T8_R1,
+ _phantom_T6_R2,
+ _T8_R2};
+
+ IType [] actual = _testObj.getSubclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubclasses_T6_R1_in_T2_R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T8_R2,
+ _T2_R2 };
+
+ IType [] actual = _testObj.getSubclasses(_T6_R1);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T6_R1() throws JavaModelException
+ {
+ _focusType = _T6_R1;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T8_R2,
+ _T2_R2 };
+
+ IType [] actual = _testObj.getSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T6_R1_phantomMode() throws JavaModelException
+ {
+ _focusType = _T6_R1;
+ _testObj = createOTTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _phantom_T6_R2,
+ _phantom_T8_R1,
+ _T8_R2 };
+ IType [] actual = _testObj.getSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_T6_R1_in_T2R1() throws JavaModelException
+ {
+ _focusType = (_T2_R1);
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T8_R2, _T2_R2 };
+ IType [] actual = _testObj.getAllSubtypes(_T6_R1);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testPhantomTypeEquality1() throws JavaModelException
+ {
+ PhantomType phantom1 = new PhantomType(_T6, _T2_R2);
+ PhantomType phantom2 = new PhantomType(_T6, _T2_R2);
+
+ assertEquals(phantom1.hashCode(), phantom2.hashCode());
+ assertTrue(phantom1.equals(phantom2));
+ }
+
+ public void testPhantomTypeHashability1() throws JavaModelException
+ {
+ PhantomType phantom1 = new PhantomType(_T6, _T2_R2);
+ PhantomType phantom2 = new PhantomType(_T6, _T2_R2);
+
+ HashMap<PhantomType, Double> map = new HashMap<PhantomType, Double>();
+ Double dummy = new Double(0.0);
+ map.put(phantom1, dummy);
+
+ Double expected = dummy;
+ Double actual = map.get(phantom2);
+
+ assertEquals(expected, actual);
+ }
+
+ public void testPhantomTypeEquality2() throws JavaModelException
+ {
+ PhantomType phantom1 = new PhantomType(_T6, _T2_R2);
+ PhantomType phantom2 = new PhantomType(_T6, _T2_R2);
+
+ PhantomType phantom11 = new PhantomType(phantom1, _T1_R1);
+ PhantomType phantom12 = new PhantomType(phantom2, _T1_R1);
+
+ assertEquals(phantom11.hashCode(), phantom12.hashCode());
+ assertTrue(phantom11.equals(phantom12));
+ }
+
+ public void testPhantomTypeHashability2() throws JavaModelException
+ {
+ PhantomType phantom1 = new PhantomType(_T6, _T2_R2);
+ PhantomType phantom2 = new PhantomType(_T6, _T2_R2);
+
+ PhantomType phantom11 = new PhantomType(phantom1, _T1_R1);
+ PhantomType phantom12 = new PhantomType(phantom2, _T1_R1);
+
+ HashMap<PhantomType, Double> map = new HashMap<PhantomType, Double>();
+ Double dummy = new Double(0.0);
+ map.put(phantom11, dummy);
+
+ Double expected = dummy;
+ Double actual = map.get(phantom12);
+ assertEquals(expected, actual);
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest002.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest002.java
new file mode 100644
index 0000000..4896b45
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest002.java
@@ -0,0 +1,144 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest002.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+/**
+ * @author Michael Krueger (mkr)
+ *
+ * $Id: OTSubTypeHierarchyTest002.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSubTypeHierarchyTest002 extends FileBasedModelTest {
+
+ private OTTypeHierarchy _testObj;
+
+ private IType _focusType;
+
+ private IType _T1_R1;
+
+ private IType _T2_R1;
+
+ private IType _T3_R1;
+
+ private IType _classA;
+
+ @SuppressWarnings("unused")
+ private IType _objectType;
+
+ private IType _T1;
+
+ private IType _T2;
+
+ private IType _T3;
+
+ public OTSubTypeHierarchyTest002(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest002.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest002.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test002";
+ _T1 = getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T1");
+
+ _T2 = getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T2");
+
+ _T3 = getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T3");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+
+ _T2_R1 = getRole(_T2, "T2.R1");
+
+ _T3_R1 = getRole(_T3, "T3.R1");
+
+ _classA = getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "ClassA");
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+ }
+
+ public void testGetAllSubtypes_T1_R1() throws JavaModelException
+ {
+ _focusType = _T1_R1;
+
+ _testObj = new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ _testObj.refresh(new NullProgressMonitor());
+
+ IType[] expected = new IType[] { _T2_R1, _T3_R1};
+
+ IType [] actual = _testObj.getAllSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_ClassA() throws JavaModelException
+ {
+ _focusType = _classA;
+
+ _testObj = new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ _testObj.refresh(new NullProgressMonitor());
+
+ IType[] expected = new IType[] { _T2_R1, _T3_R1};
+
+ IType [] actual = _testObj.getAllSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest004.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest004.java
new file mode 100644
index 0000000..3574c63
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest004.java
@@ -0,0 +1,189 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest004.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.TypeHelper;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSubTypeHierarchyTest004.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ */
+public class OTSubTypeHierarchyTest004 extends FileBasedHierarchyTest
+{
+
+ private ITypeHierarchy _testObj;
+ private IType _focusType;
+ @SuppressWarnings("unused")
+ private IType _objectType;
+ private IType _T20;
+ private IType _T21;
+
+ private IType _T20T10T00R0;
+ private IType _T20T10T00R1;
+ private IType _T21T10T00R1;
+ private IType _T21T10T00R2;
+ private IType _T21T11T00R0;
+ private IType _T21T11T00R1;
+ private IType _T21T11T00R2;
+
+
+ public OTSubTypeHierarchyTest004(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest004.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest004.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test004";
+
+ _T20 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T20");
+
+ _T21 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T21");
+
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+ _T20T10T00R0 = TypeHelper.findNestedRoleType(_T20, "T20.T10.T00.R0");
+ _T20T10T00R1 = TypeHelper.findNestedRoleType(_T20, "T20.T10.T00.R1");
+
+ _T21T10T00R1 = TypeHelper.findNestedRoleType(_T21, "T21.T10.T00.R1");
+ _T21T10T00R2 = TypeHelper.findNestedRoleType(_T21, "T21.T10.T00.R2");
+
+ _T21T11T00R0 = TypeHelper.findNestedRoleType(_T21, "T21.T11.T00.R0");
+ _T21T11T00R1 = TypeHelper.findNestedRoleType(_T21, "T21.T11.T00.R1");
+ _T21T11T00R2 = TypeHelper.findNestedRoleType(_T21, "T21.T11.T00.R2");
+ }
+
+
+ public void testCreation()
+ {
+ assertCreation(_T20);
+ assertCreation(_T21);
+
+ assertCreation(_T20T10T00R0);
+ assertCreation(_T20T10T00R1);
+
+ assertCreation(_T21T10T00R1);
+ assertCreation(_T21T10T00R2);
+
+ assertCreation(_T21T11T00R0);
+ assertCreation(_T21T11T00R1);
+ assertCreation(_T21T11T00R2);
+ }
+
+ public void testGetAllSubtypes_T20T10T00R0() throws JavaModelException
+ {
+ _focusType = _T20T10T00R0;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = { _T21T11T00R0, _T21T11T00R1, _T21T11T00R2 };
+ IType[] actual = _testObj.getAllSubtypes(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_T20T10T00R1() throws JavaModelException
+ {
+ _focusType = _T20T10T00R1;
+ OTTypeHierarchy hierarchy = new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] expected = { _T21T10T00R1, _T21T10T00R2, _T21T11T00R1, _T21T11T00R2 };
+ IType[] actual = hierarchy.getAllSubtypes(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T20T10T00R0() throws JavaModelException
+ {
+ _focusType = _T20T10T00R0;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = { _T21T11T00R0 };
+ IType[] actual = _testObj.getSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetTSuperTypes_T21T11T00R0() throws JavaModelException
+ {
+ _focusType = _T21T11T00R0;
+ OTTypeHierarchy hierarchy = new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), false);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] expected = { _T20T10T00R0 };
+ IType[] actual = hierarchy.getTSuperTypes(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetTSuperTypes_T21T11T00R1() throws JavaModelException
+ {
+ _focusType = _T21T11T00R1;
+ OTTypeHierarchy hierarchy = new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), false);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] expected = { _T21T10T00R1 };
+ IType[] actual = hierarchy.getTSuperTypes(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest006.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest006.java
new file mode 100644
index 0000000..c15387a
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest006.java
@@ -0,0 +1,225 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest006.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.PhantomType;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author Michael Kr?ger (mkr)
+ *
+ * $Id: OTSubTypeHierarchyTest006.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSubTypeHierarchyTest006 extends FileBasedHierarchyTest
+{
+ private IType _T1;
+ private IType _T2;
+ private IType _T3;
+
+ private IType _T1_R1;
+ private IType _T1_R2;
+
+ private IType _T2_R1;
+ private IType _phantom_T2_R2;
+
+ private IType _phantom_T3_R1;
+ private IType _T3_R2;
+
+ private IType _classA;
+ @SuppressWarnings("unused")
+ private IType _objectType;
+ private IType _MyTeam_MyRole;
+ private IType _MySubTeam_MyRole;
+ private IType _MyOtherSubTeam_MyRole;
+
+ private IType _MyTeam;
+ private IType _MySubTeam;
+ private IType _MyOtherSubTeam;
+
+ public OTSubTypeHierarchyTest006(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest006.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest006.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test006";
+
+ _T1 = getType(getTestProjectDir(), srcFolder, pkg, "T1");
+ _T2 = getType(getTestProjectDir(), srcFolder, pkg, "T2");
+ _T3 = getType(getTestProjectDir(), srcFolder, pkg, "T3");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+ _T1_R2 = getRole(_T1, "T1.R2");
+
+ _T2_R1 = getRole(_T2, "T2.R1");
+ _phantom_T2_R2 = new PhantomType(_T2, _T1_R2);
+
+ _phantom_T3_R1 = new PhantomType(_T3, _T2_R1);
+ _T3_R2 = getRole(_T3, "T3.R2");
+
+ _classA =
+ getType(getTestProjectDir(), srcFolder, pkg, "ClassA");
+
+ _objectType =
+ getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+
+ setupExtraStuff();
+ }
+
+ private void setupExtraStuff() throws JavaModelException
+ {
+ String srcFolder = "src";
+ String pkg = "simple";
+
+ _MyTeam = getType(getTestProjectDir(), srcFolder, pkg, "MyTeam");
+ _MySubTeam = getType(getTestProjectDir(), srcFolder, pkg, "MySubTeam");
+ _MyOtherSubTeam = getType(getTestProjectDir(), srcFolder, pkg, "MyOtherSubTeam");
+
+ _MyTeam_MyRole = getRole(_MyTeam, "MyTeam.MyRole");
+ _MySubTeam_MyRole = new PhantomType(_MySubTeam, _MyTeam_MyRole);
+ _MyOtherSubTeam_MyRole = getRole(_MyOtherSubTeam, "MyOtherSubTeam.MyRole");
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_T1);
+ assertCreation(_T2);
+ assertCreation(_T3);
+
+ assertCreation(_T1_R1);
+ assertCreation(_T1_R2);
+
+ assertCreation(_T2_R1);
+ assertCreation(_phantom_T2_R2);
+
+ assertCreation(_phantom_T3_R1);
+ assertCreation(_T3_R2);
+
+ assertCreation(_MyTeam);
+ assertCreation(_MySubTeam);
+
+ assertCreation(_MyTeam_MyRole);
+ assertCreation(_MySubTeam_MyRole);
+ }
+
+
+ public void testGetAllSubtypes_ClassA() throws JavaModelException
+ {
+ _focusType = _classA;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R1, _T2_R1, _T3_R2 };
+ IType [] actual = _testObj.getAllSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_MyTeam_MyRole_phantomMode() throws JavaModelException
+ {
+ _focusType = _MyTeam_MyRole;
+ _testObj = createOTTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] {
+ _MySubTeam_MyRole,
+ _MyOtherSubTeam_MyRole
+ };
+ IType [] actual = _testObj.getAllSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_ClassA_phantomMode() throws JavaModelException
+ {
+ _focusType = _classA;
+ _testObj = createOTTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _T1_R1,
+ _T2_R1,
+ _T3_R2,
+ _phantom_T3_R1 };
+ IType [] actual = _testObj.getAllSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_ClassA() throws JavaModelException
+ {
+ _focusType = _classA;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R1, _T2_R1 };
+ IType [] actual = _testObj.getSubtypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T2R1_in_ClassA() throws JavaModelException
+ {
+ _focusType = _classA;
+ _testObj = createOTTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T3_R2 };
+ IType [] actual = _testObj.getSubtypes(_T2_R1);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T2R1_in_ClassA_phantomMode() throws JavaModelException
+ {
+ _focusType = _classA;
+ _testObj = createOTTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _T3_R2, _phantom_T3_R1 };
+ IType [] actual = _testObj.getSubtypes(_T2_R1);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest010.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest010.java
new file mode 100644
index 0000000..cfe1259
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest010.java
@@ -0,0 +1,393 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest010.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+import org.eclipse.objectteams.otdt.core.TypeHelper;
+
+/**
+ * @author mkr
+ *
+ * $Id: OTSubTypeHierarchyTest010.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSubTypeHierarchyTest010 extends FileBasedModelTest
+{
+
+ private IType _focusType;
+ private IType _T1;
+ private IType _T2;
+ private IType _T3;
+ private IType _T1R1;
+ private IType _T2R1;
+ private IType _T3R1;
+ private IType _interfaceA;
+ private IType _objectType;
+
+
+ public OTSubTypeHierarchyTest010(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest010.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest010.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test010";
+
+ _T1 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T1");
+
+ _T2 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T2");
+
+ _T3 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T3");
+
+ _interfaceA =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "InterfaceA");
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+ _T1R1 = TypeHelper.findNestedRoleType(_T1, "T1.R1");
+ _T2R1 = TypeHelper.findNestedRoleType(_T2, "T2.R1");
+ _T3R1 = TypeHelper.findNestedRoleType(_T3, "T3.R1");
+
+ }
+
+
+ public void testCreation()
+ {
+ assertCreation(_T1R1);
+ assertCreation(_T2R1);
+ assertCreation(_T3R1);
+ assertCreation(_interfaceA);
+ }
+
+
+ public void testGetSubtypes_T1R1() throws JavaModelException
+ {
+ _focusType = _T1R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T2R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T2R1() throws JavaModelException
+ {
+ _focusType = _T2R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T3R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_interfaceA() throws JavaModelException
+ {
+ _focusType = _interfaceA;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T2R1, _T3R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSubtypes_T1R1() throws JavaModelException
+ {
+ _focusType = _T1R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getAllSubtypes(_focusType);
+ IType[] expected = new IType[] {
+ _T2R1,
+ _T3R1
+ };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSubtypes_T2R1() throws JavaModelException
+ {
+ _focusType = _T2R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getAllSubtypes(_focusType);
+ IType[] expected = new IType[] { _T3R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_interfaceA() throws JavaModelException
+ {
+ _focusType = _interfaceA;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getAllSubtypes(_focusType);
+ IType[] expected = new IType[] {
+ _T2R1,
+ _T3R1
+ };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetRootClasses_T1R1() throws JavaModelException
+ {
+ _focusType = _T1R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getRootClasses();
+ IType[] expected = new IType[] { _objectType };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetRootClasses_interfaceA() throws JavaModelException
+ {
+ _focusType = _interfaceA;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getRootClasses();
+ IType[] expected = new IType[] { _objectType };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetRootInterfaces_interfaceA() throws JavaModelException
+ {
+ _focusType = _interfaceA;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getRootInterfaces();
+ IType[] expected = new IType[] { _focusType };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetType_T1R1() throws JavaModelException
+ {
+ _focusType = _T1R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType actual = hierarchy.getType();
+ IType expected = _focusType;
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetImplementingClasses_interfaceA() throws JavaModelException
+ {
+ _focusType = _interfaceA;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getImplementingClasses(_focusType);
+ IType[] expected = new IType[] {
+ _T2R1,
+ _T3R1
+ };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllInterfaces_interfaceA() throws JavaModelException
+ {
+ _focusType = _interfaceA;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+
+ IType[] actual = hierarchy.getAllInterfaces();
+ IType[] expected = new IType[] { _interfaceA };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllClasses_T1R1() throws JavaModelException
+ {
+ _focusType = _T1R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getAllClasses();
+ IType[] expected = new IType[] {
+ _T1R1,
+ _T2R1,
+ _T3R1,
+ _objectType
+ };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetTSuperTypes_T1R1() throws JavaModelException
+ {
+ _focusType = _T1R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getTSuperTypes(_T3R1);
+ IType[] expected = new IType[] { _T2R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetExplicitSuperclass_T2R1_in_T2R1() throws JavaModelException
+ {
+ _focusType = _T2R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType actual = hierarchy.getExplicitSuperclass(_T2R1);
+ IType expected = _objectType;
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T3R1_in_T2R1() throws JavaModelException
+ {
+ _focusType = _T2R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType actual = hierarchy.getExplicitSuperclass(_T3R1);
+ IType expected = _objectType;
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetExplicitSuperclass_T1R1_in_T2R1() throws JavaModelException
+ {
+ _focusType = _T2R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType actual = hierarchy.getExplicitSuperclass(_T1R1);
+ IType expected = _objectType;
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest011.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest011.java
new file mode 100644
index 0000000..02dc26c
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest011.java
@@ -0,0 +1,177 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest011.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+import org.eclipse.objectteams.otdt.core.TypeHelper;
+
+/**
+ *
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSubTypeHierarchyTest011.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ */
+public class OTSubTypeHierarchyTest011 extends FileBasedModelTest {
+
+ @SuppressWarnings("unused")
+ private ITypeHierarchy _testObj;
+ private IType _focusType;
+ private IType _T10;
+ private IType _T21;
+ @SuppressWarnings("unused")
+ private IType _objectType;
+ private IType _T21T11T0R1;
+ private IType _T10T0R1;
+ private IType _T10T0R2;
+
+
+ public OTSubTypeHierarchyTest011(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest011.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest011.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test011";
+
+ _T10 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T10");
+
+ _T21 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T21");
+
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+ _T21T11T0R1 = TypeHelper.findNestedRoleType(_T21, "T21.T11.T0.R1");
+ _T10T0R1 = TypeHelper.findNestedRoleType(_T10, "T10.T0.R1");
+ _T10T0R2 = TypeHelper.findNestedRoleType(_T10, "T10.T0.R2");
+
+ }
+
+
+ public void testCreation()
+ {
+ assertCreation(_T10);
+ assertCreation(_T21);
+ assertCreation(_T21T11T0R1);
+ assertCreation(_T10T0R1);
+ assertCreation(_T10T0R2);
+ }
+
+
+ public void testGetSubtypes_T10T0R1() throws JavaModelException
+ {
+ _focusType = _T10T0R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T21T11T0R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T10T0R2() throws JavaModelException
+ {
+ _focusType = _T10T0R2;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] {
+ _T21T11T0R1,
+ _T10T0R1
+ };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_T10T0R1() throws JavaModelException
+ {
+ _focusType = _T10T0R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getAllSubtypes(_focusType);
+ IType[] expected = new IType[] { _T21T11T0R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSubtypes_T10T0R2() throws JavaModelException
+ {
+ _focusType = _T10T0R2;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getAllSubtypes(_focusType);
+ IType[] expected = new IType[] { _T10T0R1, _T21T11T0R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest016.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest016.java
new file mode 100644
index 0000000..c6ea7f5
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest016.java
@@ -0,0 +1,373 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest016.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+import org.eclipse.objectteams.otdt.core.TypeHelper;
+
+/**
+ *
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSubTypeHierarchyTest016.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ */
+public class OTSubTypeHierarchyTest016 extends FileBasedModelTest {
+
+ @SuppressWarnings("unused")
+ private ITypeHierarchy _testObj;
+ private IType _focusType;
+ private IType _C1;
+ private IType _I1;
+ private IType _T1;
+ private IType _T1R1;
+ private IType _T1R2;
+ private IType _T1R3;
+ private IType _T1R4;
+ private IType _T1R5;
+ private IType _T2;
+ private IType _T2R1;
+ private IType _T2R2;
+ private IType _T2R3;
+ private IType _T2R4;
+
+ @SuppressWarnings("unused")
+ private IType _objectType;
+
+
+ public OTSubTypeHierarchyTest016(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest016.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest016.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test016";
+
+ _C1 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "C1");
+
+ _I1 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "I1");
+
+ _T1 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T1");
+
+ _T2 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T2");
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+ _T1R1 = TypeHelper.findNestedRoleType(_T1, "T1.R1");
+ _T1R2 = TypeHelper.findNestedRoleType(_T1, "T1.R2");
+ _T1R3 = TypeHelper.findNestedRoleType(_T1, "T1.R3");
+ _T1R4 = TypeHelper.findNestedRoleType(_T1, "T1.R4");
+ _T1R5 = TypeHelper.findNestedRoleType(_T1, "T1.R5");
+ _T2R1 = TypeHelper.findNestedRoleType(_T2, "T2.R1");
+ _T2R2 = TypeHelper.findNestedRoleType(_T2, "T2.R2");
+ _T2R3 = TypeHelper.findNestedRoleType(_T2, "T2.R3");
+ _T2R4 = TypeHelper.findNestedRoleType(_T2, "T2.R4");
+
+ }
+
+
+ public void testCreation()
+ {
+ assertCreation(_C1);
+ assertCreation(_T1);
+ assertCreation(_T1R1);
+ assertCreation(_T1R2);
+ assertCreation(_T1R3);
+ assertCreation(_T1R4);
+ assertCreation(_T2);
+ assertCreation(_T2R1);
+ assertCreation(_T2R2);
+ assertCreation(_T2R3);
+ assertCreation(_T2R4);
+ }
+
+ public void testGetSubtypes_C1() throws JavaModelException
+ {
+ _focusType = _C1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T1R5 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSubtypes_T1R1() throws JavaModelException
+ {
+ _focusType = _T1R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T1R2, _T2R1 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T1R2() throws JavaModelException
+ {
+ _focusType = _T1R2;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T1R3, _T2R2 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_T1R3() throws JavaModelException
+ {
+ _focusType = _T1R3;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T1R4, _T2R3 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSubtypes_T1R4() throws JavaModelException
+ {
+ _focusType = _T1R4;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSubtypes(_focusType);
+ IType[] expected = new IType[] { _T2R4 };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetExplicitSuperclass_T1R2() throws JavaModelException
+ {
+ _focusType = _T1R2;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), false);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType actual = hierarchy.getExplicitSuperclass(_focusType);
+ IType expected = _T1R1;
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T1R3() throws JavaModelException
+ {
+ _focusType = _T1R3;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType actual = hierarchy.getExplicitSuperclass(_focusType);
+ IType expected = _T1R2;
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T1R4() throws JavaModelException
+ {
+ _focusType = _T1R4;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType actual = hierarchy.getExplicitSuperclass(_focusType);
+ IType expected = _T1R3;
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T1R5() throws JavaModelException
+ {
+ _focusType = _T1R5;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType actual = hierarchy.getExplicitSuperclass(_focusType);
+ IType expected = _C1;
+
+ String errorMsg = _focusType.getElementName()
+ + " extends "
+ + expected.getElementName()
+ + " not in OTTypeHierarchy!";
+
+ assertTrue(errorMsg, compareTypes(expected, actual));
+ }
+
+ public void testTypeHierarchy_GetSuperclass_T1R5() throws JavaModelException
+ {
+ _focusType = _T1R5;
+
+
+ ITypeHierarchy hierarchy = _focusType.newSupertypeHierarchy(new NullProgressMonitor());
+
+ IType actual = hierarchy.getSuperclass(_focusType);
+ IType expected = _C1;
+
+ String errorMsg = _focusType.getElementName()
+ + " extends "
+ + expected.getElementName()
+ + " not in TypeHierarchy!";
+
+ assertTrue(errorMsg, compareTypes(expected, actual));
+ }
+
+
+ public void testGetSuperInterfaces_T1R5() throws JavaModelException
+ {
+ _focusType = _T1R5;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getSuperInterfaces(_focusType);
+ IType[] expected = new IType[] { _I1 };
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetTSuperTypes_T2R1() throws JavaModelException
+ {
+ _focusType = _T2R1;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getTSuperTypes(_focusType);
+ IType[] expected = new IType[] {_T1R1 };
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetTSuperTypes_T2R2() throws JavaModelException
+ {
+ _focusType = _T2R2;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getTSuperTypes(_focusType);
+ IType[] expected = new IType[] {_T1R2 };
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetTSuperTypes_T2R3() throws JavaModelException
+ {
+ _focusType = _T2R3;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getTSuperTypes(_focusType);
+ IType[] expected = new IType[] {_T1R3 };
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetTSuperTypes_T2R4() throws JavaModelException
+ {
+ _focusType = _T2R4;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getTSuperTypes(_focusType);
+ IType[] expected = new IType[] {_T1R4 };
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest017.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest017.java
new file mode 100644
index 0000000..17f2ad3
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest017.java
@@ -0,0 +1,192 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest017.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.TypeHelper;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+/**
+ *
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSubTypeHierarchyTest017.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ */
+public class OTSubTypeHierarchyTest017 extends FileBasedModelTest {
+
+ private ITypeHierarchy _testObj;
+ @SuppressWarnings("unused")
+ private IType _focusType;
+ private IType _TA;
+ private IType _TB;
+ private IType _TC;
+ private IType _TD;
+ private IType _TE;
+
+ private IType _TA_R1;
+ private IType _TA_R2;
+ private IType _TA_R3;
+ private IType _TB_R1;
+ private IType _TB_R2;
+ private IType _TC_R2;
+ private IType _TC_R3;
+ private IType _TD_R1;
+ private IType _TE_R2;
+ private IType _TE_R3;
+
+
+
+ @SuppressWarnings("unused")
+ private IType _objectType;
+
+
+ public OTSubTypeHierarchyTest017(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest017.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest017.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test017";
+
+ _TA = getType(getTestProjectDir(), srcFolder, pkg, "TA");
+ _TB = getType(getTestProjectDir(), srcFolder, pkg, "TB");
+ _TC = getType(getTestProjectDir(), srcFolder, pkg, "TC");
+ _TD = getType(getTestProjectDir(), srcFolder, pkg, "TD");
+ _TE = getType(getTestProjectDir(), srcFolder, pkg, "TE");
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+ _TA_R1 = TypeHelper.findNestedRoleType(_TA, "TA.R1");
+ _TA_R2 = TypeHelper.findNestedRoleType(_TA, "TA.R2");
+ _TA_R3 = TypeHelper.findNestedRoleType(_TA, "TA.R3");
+ _TB_R1 = TypeHelper.findNestedRoleType(_TB, "TB.R1");
+ _TB_R2 = TypeHelper.findNestedRoleType(_TB, "TB.R2");
+ _TC_R2 = TypeHelper.findNestedRoleType(_TC, "TC.R2");
+ _TC_R3 = TypeHelper.findNestedRoleType(_TC, "TC.R3");
+ _TD_R1 = TypeHelper.findNestedRoleType(_TD, "TD.R1");
+ _TE_R2 = TypeHelper.findNestedRoleType(_TE, "TE.R2");
+ _TE_R3 = TypeHelper.findNestedRoleType(_TE, "TE.R3");
+
+ }
+
+ private void initHierarchy(IType focus, boolean computeSubtypes)
+ throws JavaModelException
+ {
+ _testObj = new OTTypeHierarchy(focus, focus.getJavaProject(), computeSubtypes);
+ _testObj.refresh(new NullProgressMonitor());
+ _focusType = focus;
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_TA);
+ assertCreation(_TB);
+ assertCreation(_TD);
+ assertCreation(_TE);
+
+ assertCreation(_TA_R1);
+ assertCreation(_TA_R2);
+ assertCreation(_TA_R3);
+
+ assertCreation(_TB_R1);
+ assertCreation(_TB_R2);
+
+ assertCreation(_TC_R2);
+ assertCreation(_TC_R3);
+
+ assertCreation(_TD_R1);
+
+ assertCreation(_TE_R2);
+ assertCreation(_TE_R3);
+ }
+
+ public void testGetSubtypes_TD_R1() throws JavaModelException
+ {
+ initHierarchy(_TA_R1, true);
+
+ IType[] expected = new IType[] { _TB_R2, _TE_R2 };
+ IType[] actual = _testObj.getSubtypes(_TD_R1);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_TD_R1() throws JavaModelException
+ {
+ initHierarchy(_TA_R1, true);
+
+ IType[] expected = new IType[] { _TA_R3, _TB_R2, _TE_R2, _TE_R3 };
+ IType[] actual = _testObj.getAllSubtypes(_TD_R1);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSubtypes_TB_R2() throws JavaModelException
+ {
+ initHierarchy(_TA_R1, true);
+
+ IType[] expected = new IType[] { _TA_R3, _TC_R2, _TC_R3, _TE_R2, _TE_R3};
+ IType[] actual = _testObj.getSubtypes(_TB_R2);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSubtypes_TB_R2() throws JavaModelException
+ {
+ initHierarchy(_TA_R1, true);
+
+ IType[] expected = new IType[] { _TA_R3, _TC_R2, _TC_R3, _TE_R2, _TE_R3 };
+ IType[] actual = _testObj.getAllSubtypes(_TB_R2);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest018.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest018.java
new file mode 100644
index 0000000..6cb1741
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest018.java
@@ -0,0 +1,166 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest018.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+import org.eclipse.objectteams.otdt.core.TypeHelper;
+
+/**
+ *
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSubTypeHierarchyTest018.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ */
+public class OTSubTypeHierarchyTest018 extends FileBasedModelTest {
+
+ private ITypeHierarchy _testObj;
+ @SuppressWarnings("unused")
+ private IType _focusType;
+ private IType _TA1;
+ private IType _TA2;
+ private IType _TA3;
+ private IType _TZ1;
+ private IType _TZ2;
+
+ private IType _TA1_TB1_R1;
+ private IType _TA2_TB1_R1;
+ private IType _TA2_TB2_R1;
+ private IType _TA2_TB2_R2;
+ private IType _TA3_TB2_R2;
+
+ private IType _TZ1_TX1;
+
+ private IType _TZ1_TX1_TB2_R2;
+ private IType _TZ1_TX2_TB2_R2;
+ private IType _TZ2_TX2_TB2_R1;
+
+
+ @SuppressWarnings("unused")
+ private IType _objectType;
+
+
+ public OTSubTypeHierarchyTest018(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest018.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest018.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test018";
+
+ _TA1 = getType(getTestProjectDir(), srcFolder, pkg, "TA1");
+ _TA2 = getType(getTestProjectDir(), srcFolder, pkg, "TA2");
+ _TA3 = getType(getTestProjectDir(), srcFolder, pkg, "TA3");
+ _TZ1 = getType(getTestProjectDir(), srcFolder, pkg, "TZ1");
+ _TZ2 = getType(getTestProjectDir(), srcFolder, pkg, "TZ2");
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+ _TA1_TB1_R1 = TypeHelper.findNestedRoleType(_TA1, "TA1.TB1.R1");
+ _TA2_TB1_R1 = TypeHelper.findNestedRoleType(_TA2, "TA2.TB1.R1");
+ _TA2_TB2_R1 = TypeHelper.findNestedRoleType(_TA2, "TA2.TB2.R1");
+ _TA2_TB2_R2 = TypeHelper.findNestedRoleType(_TA2, "TA2.TB2.R2");
+ _TA3_TB2_R2 = TypeHelper.findNestedRoleType(_TA3, "TA3.TB2.R2");
+ _TZ1_TX1 = TypeHelper.findNestedRoleType(_TZ1, "TZ1.TX1");
+ _TZ1_TX1_TB2_R2 = TypeHelper.findNestedRoleType(_TZ1, "TZ1.TX1.TB2.R2");
+ _TZ1_TX2_TB2_R2 = TypeHelper.findNestedRoleType(_TZ1, "TZ1.TX2.TB2.R2");
+ _TZ2_TX2_TB2_R1 = TypeHelper.findNestedRoleType(_TZ2, "TZ2.TX2.TB2.R1");
+
+
+ }
+
+ private void initHierarchy(IType focus, boolean computeSubtypes)
+ throws JavaModelException
+ {
+ _testObj = new OTTypeHierarchy(focus, focus.getJavaProject(), computeSubtypes);
+ _testObj.refresh(new NullProgressMonitor());
+ _focusType = focus;
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_TA1);
+ assertCreation(_TA2);
+ assertCreation(_TZ1);
+ assertCreation(_TZ2);
+
+ assertCreation(_TA1_TB1_R1);
+ assertCreation(_TA2_TB1_R1);
+ assertCreation(_TA2_TB2_R1);
+ assertCreation(_TA2_TB2_R2);
+ assertCreation(_TA3_TB2_R2);
+
+ assertCreation(_TZ1_TX1_TB2_R2);
+ assertCreation(_TZ1_TX2_TB2_R2);
+ assertCreation(_TZ2_TX2_TB2_R1);
+
+ assertCreation(_TZ1_TX1);
+ }
+
+
+ public void testGetAllSubtypes_TA1_TB1_R1() throws JavaModelException
+ {
+ initHierarchy(_TA1_TB1_R1, true);
+
+ IType[] expected = new IType[] { _TA2_TB1_R1,
+ _TA2_TB2_R1,
+ _TA2_TB2_R2,
+ _TA3_TB2_R2,
+ _TZ1_TX1_TB2_R2,
+ _TZ1_TX2_TB2_R2,
+ _TZ2_TX2_TB2_R1
+ };
+
+
+ IType[] actual = _testObj.getAllSubtypes(_TA1_TB1_R1);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest019.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest019.java
new file mode 100644
index 0000000..62820db
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTSubTypeHierarchyTest019.java
@@ -0,0 +1,154 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSubTypeHierarchyTest019.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+/**
+ * @author Michael Krueger (mkr)
+ *
+ * $Id: OTSubTypeHierarchyTest019.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSubTypeHierarchyTest019 extends FileBasedModelTest
+{
+
+ private OTTypeHierarchy _testObj;
+
+ private IType _focusType;
+
+ private IType _TA;
+ private IType _TB;
+ private IType _TC;
+
+ private IType _TB_R1;
+ private IType _TB_R2;
+ private IType _TB_R3;
+ private IType _TB_R4;
+ private IType _TB_R5;
+ private IType _TB_R6;
+ private IType _TB_R7;
+ private IType _TB_R8;
+ private IType _TB_R9;
+ private IType _TB_R10;
+ private IType _TB_R11;
+ private IType _TB_R12;
+ private IType _TB_R13;
+ private IType _TB_R14;
+ private IType _TB_R15;
+
+
+ public OTSubTypeHierarchyTest019(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSubTypeHierarchyTest019.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSubTypeHierarchyTest019.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test019";
+
+ _TA = getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "TA");
+
+ _TB = getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "TB");
+
+ _TC = getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "TC");
+
+ _TB_R1 = getRole(_TB, "TB.R1");
+ _TB_R2 = getRole(_TB, "TB.R2");
+ _TB_R3 = getRole(_TB, "TB.R3");
+ _TB_R4 = getRole(_TB, "TB.R4");
+ _TB_R5 = getRole(_TB, "TB.R5");
+ _TB_R6 = getRole(_TB, "TB.R6");
+ _TB_R7 = getRole(_TB, "TB.R7");
+ _TB_R8 = getRole(_TB, "TB.R8");
+ _TB_R9 = getRole(_TB, "TB.R9");
+ _TB_R10 = getRole(_TB, "TB.R10");
+ _TB_R11 = getRole(_TB, "TB.R11");
+ _TB_R12 = getRole(_TB, "TB.R12");
+ _TB_R13 = getRole(_TB, "TB.R13");
+ _TB_R14 = getRole(_TB, "TB.R14");
+ _TB_R15 = getRole(_TB, "TB.R15");
+
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_TA);
+ assertCreation(_TB);
+ assertCreation(_TC);
+
+ assertCreation(_TB_R1);
+ assertCreation(_TB_R2);
+ assertCreation(_TB_R3);
+ assertCreation(_TB_R4);
+ assertCreation(_TB_R5);
+ assertCreation(_TB_R6);
+ assertCreation(_TB_R7);
+ assertCreation(_TB_R8);
+ assertCreation(_TB_R9);
+ assertCreation(_TB_R10);
+ assertCreation(_TB_R11);
+ assertCreation(_TB_R12);
+ assertCreation(_TB_R13);
+ assertCreation(_TB_R14);
+ assertCreation(_TB_R15);
+ }
+
+ public void testOTTypeHiearchyCreation() throws JavaModelException
+ {
+ _focusType = _TB_R1;
+
+ _testObj = new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), true);
+ _testObj.refresh(new NullProgressMonitor());
+
+ assertTrue(true);
+ }
+}
+
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTTypeHierarchyBuilderTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTTypeHierarchyBuilderTest.java
new file mode 100644
index 0000000..7a072df
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/subhierarchy/OTTypeHierarchyBuilderTest.java
@@ -0,0 +1,161 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTTypeHierarchyBuilderTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.subhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchyBuilder;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+import org.eclipse.objectteams.otdt.core.TypeHelper;
+
+/**
+ *
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTTypeHierarchyBuilderTest.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ */
+public class OTTypeHierarchyBuilderTest extends FileBasedModelTest
+{
+
+ @SuppressWarnings("unused")
+ private ITypeHierarchy _testObj;
+ private IType _focusType;
+ @SuppressWarnings("unused")
+ private IType _objectType;
+ private IType _T20;
+ private IType _T21;
+
+ private IType _T20T10T00R0;
+ private IType _T20T10T00R1;
+ private IType _T21T10T00R1;
+ private IType _T21T10T00R2;
+ private IType _T21T11T00R0;
+ private IType _T21T11T00R1;
+ private IType _T21T11T00R2;
+
+
+ public OTTypeHierarchyBuilderTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTTypeHierarchyBuilderTest.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTTypeHierarchyBuilderTest.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test004";
+
+ _T20 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T20");
+
+ _T21 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T21");
+
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+ _T20T10T00R0 = TypeHelper.findNestedRoleType(_T20, "T20.T10.T00.R0");
+ _T20T10T00R1 = TypeHelper.findNestedRoleType(_T20, "T20.T10.T00.R1");
+
+ _T21T10T00R1 = TypeHelper.findNestedRoleType(_T21, "T21.T10.T00.R1");
+ _T21T10T00R2 = TypeHelper.findNestedRoleType(_T21, "T21.T10.T00.R2");
+
+ _T21T11T00R0 = TypeHelper.findNestedRoleType(_T21, "T21.T11.T00.R0");
+ _T21T11T00R1 = TypeHelper.findNestedRoleType(_T21, "T21.T11.T00.R1");
+ _T21T11T00R2 = TypeHelper.findNestedRoleType(_T21, "T21.T11.T00.R2");
+ }
+
+
+ public void testCreation()
+ {
+ assertCreation(_T20);
+ assertCreation(_T21);
+
+ assertCreation(_T20T10T00R0);
+ assertCreation(_T20T10T00R1);
+
+ assertCreation(_T21T10T00R1);
+ assertCreation(_T21T10T00R2);
+
+ assertCreation(_T21T11T00R0);
+ assertCreation(_T21T11T00R1);
+ assertCreation(_T21T11T00R2);
+ }
+
+ public void testGetResult_T20T10T00R0() throws JavaModelException
+ {
+ _focusType = _T20T10T00R0;
+ OTTypeHierarchy hierarchy = new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), false);
+ hierarchy.refresh(new NullProgressMonitor());
+ OTTypeHierarchyBuilder builder = new OTTypeHierarchyBuilder(hierarchy);
+
+ IType[] expected = { _T21T11T00R0, _T21T11T00R1, _T21T11T00R2 };
+
+ builder.build(true);
+ IType[] actual = hierarchy.getAllSubtypes(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetResult_T20T10T00R1() throws JavaModelException
+ {
+ _focusType = _T20T10T00R1;
+ OTTypeHierarchy hierarchy = new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), false);
+ hierarchy.refresh(new NullProgressMonitor());
+ OTTypeHierarchyBuilder builder = new OTTypeHierarchyBuilder(hierarchy);
+
+ IType[] expected = { _T21T10T00R1, _T21T10T00R2, _T21T11T00R1, _T21T11T00R2 };
+
+ builder.build(true);
+ IType[] actual = hierarchy.getAllSubtypes(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/AllTests.java
new file mode 100644
index 0000000..1e8115c
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/AllTests.java
@@ -0,0 +1,57 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: AllTests.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author anklam
+ *
+ * @version $Id: AllTests.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("All OT-SuperhierarchyTests");
+ //$JUnit-BEGIN$
+ suite.addTest(HierarchyResolverTestWithSrc003.suite());
+ suite.addTest(OrdinaryInterfaceHierarchyTests.suite());
+ suite.addTest(OrdinaryClassesHierarchyWithSubRolesTest.suite());
+
+ suite.addTest(OTSuperTypeHierarchyTest001.suite());
+ suite.addTest(OTSuperTypeHierarchyTest002.suite());
+ suite.addTest(OTSuperTypeHierarchyTest003.suite());
+ suite.addTest(OTSuperTypeHierarchyTest004.suite());
+ suite.addTest(OTSuperTypeHierarchyTest006.suite());
+ suite.addTest(OTSuperTypeHierarchyTest007.suite());
+ suite.addTest(OTSuperTypeHierarchyTest007_Stress.suite());
+ suite.addTest(OTSuperTypeHierarchyTest008.suite());
+ suite.addTest(OTSuperTypeHierarchyTest009.suite());
+ suite.addTest(OTSuperTypeHierarchyTest010.suite());
+ suite.addTest(OTSuperTypeHierarchyTest011.suite());
+ suite.addTest(OTSuperTypeHierarchyTest013.suite());
+ suite.addTest(OTSuperTypeHierarchyTest014.suite());
+ suite.addTest(OTSuperTypeHierarchyTest015.suite());
+ //$JUnit-END$
+ return suite;
+ }
+}
\ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/HierarchyResolverTestWithSrc003.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/HierarchyResolverTestWithSrc003.java
new file mode 100644
index 0000000..8f9f417
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/HierarchyResolverTestWithSrc003.java
@@ -0,0 +1,175 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: HierarchyResolverTestWithSrc003.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;
+import org.eclipse.objectteams.otdt.core.IRoleType;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+/**
+ * @author anklam
+ *
+ * @version $Id: HierarchyResolverTestWithSrc003.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+@SuppressWarnings("unused")
+public class HierarchyResolverTestWithSrc003 extends FileBasedModelTest {
+
+ private ITypeHierarchy _testObj;
+ private NullProgressMonitor _monitor;
+
+ private IType _focusType;
+
+ private IRoleType _T1_R1;
+ private IRoleType _T1_R2;
+
+ private IRoleType _T2_R2;
+
+ private IRoleType _T3_R1;
+ private IRoleType _T3_R2;
+
+ private IRoleType _T4_R1;
+ private IRoleType _T4_R2;
+ private IRoleType _T4_R3;
+
+ private IType _interfaceA;
+
+ private IType _objectType;
+
+ public HierarchyResolverTestWithSrc003(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(HierarchyResolverTestWithSrc003.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(HierarchyResolverTestWithSrc003.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ _monitor = new NullProgressMonitor();
+
+ String srcFolder = "src";
+ String pkg = "test003";
+
+ _T1_R1 =
+ getRole(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T1",
+ "R1");
+
+ _T1_R2 =
+ getRole(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T1",
+ "R2");
+
+ _T2_R2 =
+ getRole(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T2",
+ "R2");
+
+
+ _T3_R1 =
+ getRole(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T3",
+ "R1");
+
+ _T3_R2 =
+ getRole(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T3",
+ "R2");
+
+
+ _T4_R1 =
+ getRole(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T4",
+ "R1");
+
+ _T4_R2 =
+ getRole(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T4",
+ "R2");
+
+ _T4_R3 =
+ getRole(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T4",
+ "R3");
+
+ _interfaceA =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "InterfaceA");
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+ }
+
+
+ public void testGetSuperInterfacesFor_T2R2()
+ throws JavaModelException
+ {
+ _focusType = (IType)_T2_R2.getCorrespondingJavaElement();
+
+
+ ITypeHierarchy hierarchy = _focusType.newTypeHierarchy(_monitor);
+
+ IType[] expected = new IType[] { _interfaceA };
+
+ IType [] actual = ((TypeHierarchy)hierarchy).getSuperInterfaces(_focusType);
+ assertEquals(expected.length, actual.length);
+
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest001.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest001.java
new file mode 100644
index 0000000..9e8e2ff
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest001.java
@@ -0,0 +1,816 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSuperTypeHierarchyTest001.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.PhantomType;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSuperTypeHierarchyTest001.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSuperTypeHierarchyTest001 extends FileBasedHierarchyTest
+{
+
+ private IType _T1;
+ private IType _T2;
+ private IType _T3;
+ private IType _T4;
+ private IType _T5;
+ private IType _T6;
+ private IType _T7;
+ private IType _T8;
+
+ private IType _T1_R1;
+ private IType _T1_R2;
+
+ private IType _T2_R1;
+ private IType _T2_R2;
+
+ private IType _T3_R1;
+ private IType _T3_R2;
+
+ private IType _phantom_T4_R1;
+ private IType _T4_R2;
+
+ private IType _T5_R1;
+ private IType _T5_R2;
+ private IType _T5_R3;
+
+ private IType _T6_R1;
+ private IType _phantom_T6_R2;
+
+ private IType _phantom_T7_R1;
+ private IType _T7_R2;
+ private IType _T7_R3;
+
+ private IType _phantom_T8_R1;
+ private IType _T8_R2;
+
+ private IType _objectType;
+
+
+ public OTSuperTypeHierarchyTest001(String name)
+ {
+ super(name);
+ }
+
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSuperTypeHierarchyTest001.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSuperTypeHierarchyTest001.class.getName());
+ return suite;
+ }
+
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test001";
+
+ _T1 = getType(getTestProjectDir(), srcFolder, pkg, "T1");
+ _T2 = getType(getTestProjectDir(), srcFolder, pkg, "T2");
+ _T3 = getType(getTestProjectDir(), srcFolder, pkg, "T3");
+ _T4 = getType(getTestProjectDir(), srcFolder, pkg, "T4");
+ _T5 = getType(getTestProjectDir(), srcFolder, pkg, "T5");
+ _T6 = getType(getTestProjectDir(), srcFolder, pkg, "T6");
+ _T7 = getType(getTestProjectDir(), srcFolder, pkg, "T7");
+ _T8 = getType(getTestProjectDir(), srcFolder, pkg, "T8");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+ _T1_R2 = getRole(_T1, "T1.R2");
+
+ _T2_R1 = getRole(_T2, "T2.R1");
+ _T2_R2 = getRole(_T2, "T2.R2");
+
+ _T3_R1 = getRole(_T3, "T3.R1");
+ _T3_R2 = getRole(_T3, "T3.R2");
+
+ _phantom_T4_R1 = new PhantomType(_T4, _T2_R1);
+ _T4_R2 = getRole(_T4, "T4.R2");
+
+ _T5_R1 = getRole(_T5, "T5.R1");
+ _T5_R2 = getRole(_T5, "T5.R2");
+ _T5_R3 = getRole(_T5, "T5.R3");
+
+ _T6_R1 = getRole(_T6, "T6.R1");
+ _phantom_T6_R2 = new PhantomType(_T6, _T2_R2);
+
+ _phantom_T7_R1 = new PhantomType(_T7, _T5_R1);
+ _T7_R2 = getRole(_T7, "T7.R2");
+ _T7_R3 = getRole(_T7, "T7.R3");
+
+ _phantom_T8_R1 = new PhantomType(_T8, _T6_R1);
+ _T8_R2 = getRole(_T8, "T8.R2");
+
+ _objectType = getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+ }
+
+
+ public void testCreation()
+ {
+ assertCreation(_T1);
+ assertCreation(_T2);
+ assertCreation(_T3);
+ assertCreation(_T4);
+ assertCreation(_T5);
+ assertCreation(_T6);
+ assertCreation(_T7);
+ assertCreation(_T8);
+
+ assertCreation(_T1_R1);
+ assertCreation(_T1_R2);
+
+ assertCreation(_T2_R1);
+ assertCreation(_T2_R2);
+
+ assertCreation(_T3_R1);
+ assertCreation(_T3_R2);
+
+ assertCreation(_phantom_T4_R1);
+ assertCreation(_T4_R2);
+
+ assertCreation(_T5_R1);
+ assertCreation(_T5_R2);
+ assertCreation(_T5_R3);
+
+ assertCreation(_T6_R1);
+ assertCreation(_phantom_T6_R2);
+
+ assertCreation(_phantom_T7_R1);
+ assertCreation(_T7_R2);
+ assertCreation(_T7_R3);
+
+ assertCreation(_phantom_T8_R1);
+ assertCreation(_T8_R2);
+ }
+
+ public void testGetExplicitSuperclass_T8R2() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType expected = _T6_R1;
+ IType actual = _testObj.getExplicitSuperclass(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T8R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType expected = _phantom_T8_R1;
+ IType actual = _testObj.getExplicitSuperclass(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetTSuperTypes_T8R2() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T2_R2 };
+ IType[] actual = _testObj.getTSuperTypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetTSuperTypes_T8R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _phantom_T6_R2 };
+ IType[] actual = _testObj.getTSuperTypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllTSuperTypes_T8R2() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T2_R2,
+ _T1_R2
+ };
+
+ IType[] actual = _testObj.getAllTSuperTypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllTSuperTypes_T8R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _phantom_T6_R2,
+ _T2_R2,
+ _T1_R2
+ };
+
+ IType[] actual = _testObj.getAllTSuperTypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSuperclasses_T8R2() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T6_R1,
+ _T2_R2,
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSuperclasses_T8R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _phantom_T8_R1,
+ _phantom_T6_R2
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T8R2() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T6_R1,
+ _T2_R2,
+ _T2_R1,
+ _T1_R2,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T8R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T8_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _objectType,
+ _phantom_T8_R1,
+ _T6_R1,
+ _phantom_T6_R2,
+ _T2_R2,
+ _T2_R1,
+ _T1_R2,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSuperclasses_T6R1() throws JavaModelException
+ {
+ _focusType = _T6_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSuperclasses_T6R1_phantomMode() throws JavaModelException
+ {
+ _focusType = _T6_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T6R1() throws JavaModelException
+ {
+ _focusType = _T6_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSuperclasses_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T2_R1,
+ _T1_R2
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ _T1_R1,
+ _T1_R2
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T2R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T1R1() throws JavaModelException
+ {
+ _focusType = _T1_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T1R2() throws JavaModelException
+ {
+ _focusType = _T1_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSuperclasses_T7R3() throws JavaModelException
+ {
+ _focusType = _T7_R3;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T5_R1,
+ _T5_R3
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSuperclasses_T7R3_phantomMode() throws JavaModelException
+ {
+ _focusType = _T7_R3;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _phantom_T7_R1,
+ _T5_R3
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T7R3() throws JavaModelException
+ {
+ _focusType = _T7_R3;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T5_R1,
+ _T2_R1,
+ _T1_R1,
+ _T5_R3
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T7R3_phantomMode() throws JavaModelException
+ {
+ _focusType = _T7_R3;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _objectType,
+ _phantom_T7_R1,
+ _T5_R1,
+ _T2_R1,
+ _T1_R1,
+ _T5_R3
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T7R2() throws JavaModelException
+ {
+ _focusType = _T7_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T7_R3,
+ _T5_R1,
+ _T5_R3,
+ _T5_R2,
+ _T2_R2,
+ _T2_R1,
+ _T1_R2,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_T7_R2);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T7R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T7_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _objectType,
+ _T7_R3,
+ _phantom_T7_R1,
+ _T5_R1,
+ _T5_R3,
+ _T5_R2,
+ _T2_R2,
+ _T2_R1,
+ _T1_R2,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_T7_R2);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T7R3inT7R2() throws JavaModelException
+ {
+ _focusType = _T7_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T5_R1,
+ _T5_R3,
+ _T2_R1,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_T7_R3);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T2R1inT7R2() throws JavaModelException
+ {
+ _focusType = _T7_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_T2_R1);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T5R2() throws JavaModelException
+ {
+ _focusType = _T5_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T5_R3,
+ _T5_R1,
+ _T2_R2,
+ _T2_R1,
+ _T1_R1,
+ _T1_R2
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T5R3() throws JavaModelException
+ {
+ _focusType = _T5_R3;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+
+ IType[] expected = new IType[] { _objectType,
+ _T5_R1,
+ _T2_R1,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T5R1() throws JavaModelException
+ {
+ _focusType = _T5_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ _T1_R1
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSuperclasses_T4R2() throws JavaModelException
+ {
+ _focusType = _T4_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T2_R2,
+ _T2_R1
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetSuperclasses_T4R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T4_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _T2_R2,
+ _phantom_T4_R1
+ };
+
+ IType[] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T4R2() throws JavaModelException
+ {
+ _focusType = _T4_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R2,
+ _T2_R1,
+ _T1_R1,
+ _T1_R2
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperclasses_T4R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T4_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _objectType,
+ _phantom_T4_R1,
+ _T2_R2,
+ _T2_R1,
+ _T1_R1,
+ _T1_R2
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+
+ public void testGetAllSuperclasses_T3R2() throws JavaModelException
+ {
+ _focusType = _T3_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T3_R1,
+ _T2_R2,
+ _T2_R1,
+ _T1_R1,
+ _T1_R2
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T3R1() throws JavaModelException
+ {
+ _focusType = _T3_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ _T1_R1,
+ };
+
+ IType[] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllTSuperTypes_T5R1inT7R2() throws JavaModelException
+ {
+ _focusType = _T7_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T2_R1,
+ _T1_R1,
+ };
+
+ IType[] actual = _testObj.getAllTSuperTypes(_T5_R1);
+ assertEquals(expected.length, actual.length);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testToString_forNoException() throws JavaModelException
+ {
+ _focusType = _T5_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ try
+ {
+ _testObj.toString();
+ }
+ catch (Exception ex)
+ {
+ assertTrue(ex.getClass().toString() + " in OTTypeHierarchy.toString()", false);
+ }
+
+ assertTrue(true);
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest002.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest002.java
new file mode 100644
index 0000000..40b0e97
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest002.java
@@ -0,0 +1,203 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSuperTypeHierarchyTest002.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSuperTypeHierarchyTest002.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSuperTypeHierarchyTest002 extends FileBasedHierarchyTest
+{
+
+ private IType _T1;
+ private IType _T2;
+ private IType _T3;
+ private IType _T1_R1;
+ private IType _T2_R1;
+ private IType _T3_R1;
+ private IType _classA;
+ private IType _objectType;
+
+ public OTSuperTypeHierarchyTest002(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSuperTypeHierarchyTest002.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSuperTypeHierarchyTest002.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test002";
+
+ _T1 = getType(getTestProjectDir(), srcFolder, pkg, "T1");
+ _T2 = getType(getTestProjectDir(), srcFolder, pkg, "T2");
+ _T3 = getType(getTestProjectDir(), srcFolder, pkg, "T3");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+ _T2_R1 = getRole(_T2, "T2.R1");
+ _T3_R1 = getRole(_T3, "T3.R1");
+
+ _classA = getType(getTestProjectDir(), srcFolder, pkg, "ClassA");
+
+ _objectType = getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_T1);
+ assertCreation(_T2);
+ assertCreation(_T3);
+ assertCreation(_T1_R1);
+ assertCreation(_T2_R1);
+ assertCreation(_T3_R1);
+ assertCreation(_classA);
+ }
+
+ public void testGetAllSuperclasses_T3R1() throws JavaModelException
+ {
+ _focusType = _T3_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ _T1_R1,
+ _classA };
+
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T2R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T1_R1,
+ _classA };
+
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllClasses_T2R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T1_R1,
+ _T2_R1,
+ _classA };
+
+ IType [] actual = _testObj.getAllClasses();
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSuperclasses_T2R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R1,
+ _classA };
+
+ IType [] actual = _testObj.getSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T2R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType expected = _classA;
+
+ IType actual = _testObj.getExplicitSuperclass(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T3R1() throws JavaModelException
+ {
+ _focusType = _T3_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType expected = _classA;
+
+ IType actual = _testObj.getExplicitSuperclass(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T1R1() throws JavaModelException
+ {
+ _focusType = _T1_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType };
+ IType [] actual =_testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllTSuperTypes() throws JavaModelException
+ {
+ _focusType = _T3_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T2_R1,
+ _T1_R1 };
+ IType [] actual = _testObj.getAllTSuperTypes(_focusType);
+ assertEquals(expected.length, actual.length);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest003.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest003.java
new file mode 100644
index 0000000..a5cad29
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest003.java
@@ -0,0 +1,409 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSuperTypeHierarchyTest003.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.PhantomType;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author Michael Krueger (mkr)
+ * @version $Id: OTSuperTypeHierarchyTest003.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSuperTypeHierarchyTest003 extends FileBasedHierarchyTest
+{
+ private IType _T1;
+ private IType _T2;
+ private IType _T3;
+ private IType _T4;
+
+ private IType _T1_R1;
+ private IType _T1_R2;
+ private IType _phantom_T2_R1;
+ private IType _T2_R2;
+ private IType _T3_R1;
+ private IType _T3_R2;
+ private IType _T4_R1;
+ private IType _T4_R2;
+ private IType _T4_R3;
+
+ private IType _interfaceA;
+ private IType _objectType;
+
+ public OTSuperTypeHierarchyTest003(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSuperTypeHierarchyTest003.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSuperTypeHierarchyTest003.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test003";
+
+ _T1 = getType(getTestProjectDir(), srcFolder, pkg, "T1");
+ _T2 = getType(getTestProjectDir(), srcFolder, pkg, "T2");
+ _T3 = getType(getTestProjectDir(), srcFolder, pkg, "T3");
+ _T4 = getType(getTestProjectDir(), srcFolder, pkg, "T4");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+ _T1_R2 = getRole(_T1, "T1.R2");
+
+ _phantom_T2_R1 = new PhantomType(_T2, _T1_R1);
+ _T2_R2 = getRole(_T2, "T2.R2");
+
+ _T3_R1 = getRole(_T3, "T3.R1");
+ _T3_R2 = getRole(_T3, "T3.R2");
+
+ _T4_R1 = getRole(_T4, "T4.R1");
+ _T4_R2 = getRole(_T4, "T4.R2");
+ _T4_R3 = getRole(_T4, "T4.R3");
+
+ _interfaceA =
+ getType(getTestProjectDir(), srcFolder, pkg, "InterfaceA");
+
+ _objectType =
+ getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_T1);
+ assertCreation(_T2);
+ assertCreation(_T3);
+ assertCreation(_T4);
+
+ assertCreation(_T1_R1);
+ assertCreation(_T1_R2);
+
+ assertCreation(_phantom_T2_R1);
+ assertCreation(_T2_R2);
+
+ assertCreation(_T3_R1);
+ assertCreation(_T3_R2);
+
+ assertCreation(_T4_R1);
+ assertCreation(_T4_R2);
+ assertCreation(_T4_R3);
+ }
+
+ public void testGetSuperInterfaces_T4R1() throws JavaModelException
+ {
+ _focusType = _T4_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R1 };
+ IType [] actual = _testObj.getSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetSuperInterfaces_T4R1_phantomMode() throws JavaModelException
+ {
+ _focusType = _T4_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _phantom_T2_R1 };
+ IType [] actual = _testObj.getSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetSuperInterfaces_T4R2() throws JavaModelException
+ {
+ _focusType = _T4_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T2_R2, _interfaceA };
+ IType [] actual = _testObj.getSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetSuperInterfaces_T4R3() throws JavaModelException
+ {
+ _focusType = _T4_R3;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T4_R2 };
+ IType [] actual = _testObj.getSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetSuperInterfaces_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R2, _interfaceA };
+ IType [] actual = _testObj.getSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_T4R1() throws JavaModelException
+ {
+ _focusType = _T4_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R1 };
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_T4R2() throws JavaModelException
+ {
+ _focusType = _T4_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _interfaceA,
+ _T1_R2,
+ _T2_R2 };
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_T3R1() throws JavaModelException
+ {
+ _focusType = _T3_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R1 };
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_T3R2() throws JavaModelException
+ {
+ _focusType = _T3_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _interfaceA,
+ _T1_R2,
+ _T2_R2 };
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R2,
+ _interfaceA };
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_T1R2() throws JavaModelException
+ {
+ _focusType = _T1_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_T1R1() throws JavaModelException
+ {
+ _focusType = _T1_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_interfaceA() throws JavaModelException
+ {
+ _focusType = _interfaceA;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T4R1() throws JavaModelException
+ {
+ _focusType = _T4_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T4R2() throws JavaModelException
+ {
+ _focusType = _T4_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T3R1() throws JavaModelException
+ {
+ _focusType = _T3_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T3R2() throws JavaModelException
+ {
+ _focusType = _T3_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T1R1() throws JavaModelException
+ {
+ _focusType = _T1_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T1R2() throws JavaModelException
+ {
+ _focusType = _T1_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_interfaceA() throws JavaModelException
+ {
+ _focusType = _interfaceA;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {};
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfaces_T4R3() throws JavaModelException
+ {
+ _focusType = _T4_R3;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T4_R2,
+ _T2_R2,
+ _T1_R2,
+ _interfaceA };
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T4R3() throws JavaModelException
+ {
+ _focusType = _T4_R3;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType };
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue("Wrong Types", compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest004.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest004.java
new file mode 100644
index 0000000..426678c
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest004.java
@@ -0,0 +1,143 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSuperTypeHierarchyTest004.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.OTTypeHierarchy;
+import org.eclipse.objectteams.otdt.tests.otmodel.FileBasedModelTest;
+
+/**
+ *
+ * @author michael
+ * @version $Id: OTSuperTypeHierarchyTest004.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ */
+public class OTSuperTypeHierarchyTest004 extends FileBasedModelTest {
+
+ @SuppressWarnings("unused")
+ private ITypeHierarchy _testObj;
+ private IType _focusType;
+ private IType _T20;
+ private IType _T21;
+ private IType _objectType;
+ private IType _T20T10T00R0;
+ private IType _T20T10T00R1;
+ private IType _T21T10T00R1;
+ private IType _T21T10T00R2;
+ private IType _T21T11T00R0;
+ private IType _T21T11T00R1;
+ private IType _T21T11T00R2;
+
+
+
+ public OTSuperTypeHierarchyTest004(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSuperTypeHierarchyTest004.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSuperTypeHierarchyTest004.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test004";
+
+ _T20 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T20");
+
+ _T21 =
+ getType(getTestProjectDir(),
+ srcFolder,
+ pkg,
+ "T21");
+
+
+ _objectType =
+ getType(getTestProjectDir(),
+ "rt.jar",
+ "java.lang",
+ "Object");
+
+ _T20T10T00R0 = getRole(_T20, "T20.T10.T00.R0");
+ _T20T10T00R1 = getRole(_T20, "T20.T10.T00.R1");
+ _T21T10T00R1 = getRole(_T21, "T21.T10.T00.R1");
+ _T21T10T00R2 = getRole(_T21, "T21.T10.T00.R2");
+ _T21T11T00R0 = getRole(_T21, "T21.T11.T00.R0");
+ _T21T11T00R1 = getRole(_T21, "T21.T11.T00.R1");
+ _T21T11T00R2 = getRole(_T21, "T21.T11.T00.R2");
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_T20);
+ assertCreation(_T21);
+ assertCreation(_T20T10T00R0);
+ assertCreation(_T20T10T00R1);
+ assertCreation(_T21T10T00R1);
+ assertCreation(_T21T10T00R2);
+ assertCreation(_T21T11T00R0);
+ assertCreation(_T21T11T00R1);
+ assertCreation(_T21T11T00R2);
+ }
+
+ public void testGetAllSuperclasses_T21T11T00R2() throws JavaModelException
+ {
+ _focusType = _T21T11T00R2;
+
+ OTTypeHierarchy hierarchy =
+ new OTTypeHierarchy(_focusType, _focusType.getJavaProject(), false);
+ hierarchy.refresh(new NullProgressMonitor());
+
+ IType[] actual = hierarchy.getAllSuperclasses(_focusType);
+ IType[] expected = new IType[] { _objectType,
+ _T20T10T00R0,
+ _T20T10T00R1,
+ _T21T10T00R1,
+ _T21T10T00R2,
+ _T21T11T00R0,
+ _T21T11T00R1,
+ };
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest006.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest006.java
new file mode 100644
index 0000000..6d33bb8
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest006.java
@@ -0,0 +1,239 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSuperTypeHierarchyTest006.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.PhantomType;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author michael
+ * @version $Id: OTSuperTypeHierarchyTest006.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSuperTypeHierarchyTest006 extends FileBasedHierarchyTest
+{
+ private IType _T1;
+ private IType _T2;
+ private IType _T3;
+
+ private IType _T1_R1;
+ private IType _T1_R2;
+
+ private IType _T2_R1;
+ private IType _phantom_T2_R2;
+
+ private IType _phantom_T3_R1;
+ private IType _T3_R2;
+
+ private IType _classA;
+ private IType _objectType;
+
+ public OTSuperTypeHierarchyTest006(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSuperTypeHierarchyTest006.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSuperTypeHierarchyTest006.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test006";
+ _T1 = getType(getTestProjectDir(), srcFolder, pkg, "T1");
+ _T2 = getType(getTestProjectDir(), srcFolder, pkg, "T2");
+ _T3 = getType(getTestProjectDir(), srcFolder, pkg, "T3");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+ _T1_R2 = getRole(_T1, "T1.R2");
+
+ _T2_R1 = getRole(_T2, "T2.R1");
+ _phantom_T2_R2 = new PhantomType(_T2, _T1_R2);
+
+ _phantom_T3_R1 = new PhantomType(_T3, _T2_R1);
+ _T3_R2 = getRole(_T3, "T3.R2");
+
+ _classA =
+ getType(getTestProjectDir(), srcFolder, pkg, "ClassA");
+
+ _objectType =
+ getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+ }
+
+ public void testCreation()
+ {
+ assertCreation(_T1);
+ assertCreation(_T2);
+ assertCreation(_T3);
+
+ assertCreation(_T1_R1);
+ assertCreation(_T1_R2);
+
+ assertCreation(_T2_R1);
+ assertCreation(_phantom_T2_R2);
+
+ assertCreation(_phantom_T3_R1);
+ assertCreation(_T3_R2);
+ }
+
+ public void testGetAllSuperclasses_T1R1() throws JavaModelException
+ {
+ _focusType = _T1_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _classA };
+
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T2R2() throws JavaModelException
+ {
+ _focusType = _T1_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType };
+
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T2R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T1_R1,
+ _classA };
+
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T3R2() throws JavaModelException
+ {
+ _focusType = _T3_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ _T1_R1,
+ _T1_R2,
+ _classA };
+
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclasses_T3R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T3_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType[] expected = new IType[] { _objectType,
+ _T2_R1,
+ _T1_R1,
+ _T1_R2,
+ _phantom_T2_R2,
+ _phantom_T3_R1,
+ _classA };
+
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T3R2() throws JavaModelException
+ {
+ _focusType = _T3_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType expected = _T2_R1;
+ IType actual = _testObj.getExplicitSuperclass(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclass_T3R2_phantomMode() throws JavaModelException
+ {
+ _focusType = _T3_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+ _testObj.setPhantomMode(true);
+
+ IType expected = _phantom_T3_R1;
+ IType actual = _testObj.getExplicitSuperclass(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllTSuperTypes_T3R2() throws JavaModelException
+ {
+ _focusType = _T3_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R2 };
+
+ IType [] actual = _testObj.getAllTSuperTypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllTSuperTypes_T2R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R1 };
+ IType [] actual = _testObj.getAllTSuperTypes(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest007.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest007.java
new file mode 100644
index 0000000..f08f843
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest007.java
@@ -0,0 +1,267 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSuperTypeHierarchyTest007.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author Michael Krueger (michael)
+ * @version $Id: OTSuperTypeHierarchyTest007.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+public class OTSuperTypeHierarchyTest007 extends FileBasedHierarchyTest
+{
+ private IType _T1;
+ private IType _T2;
+
+ private IType _T1_R1;
+ private IType _T1_R2;
+
+ private IType _T2_R1;
+ private IType _T2_R2;
+
+ private IType _classA;
+ private IType _classB;
+
+ private IType _interfaceA;
+ private IType _interfaceB;
+ private IType _interfaceC;
+
+ private IType _objectType;
+
+ public OTSuperTypeHierarchyTest007(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSuperTypeHierarchyTest007.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSuperTypeHierarchyTest007.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test007";
+
+ _T1 = getType(getTestProjectDir(), srcFolder, pkg, "T1");
+ _T2 = getType(getTestProjectDir(), srcFolder, pkg, "T2");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+ _T1_R2 = getRole(_T1, "T1.R2");
+
+ _T2_R1 = getRole(_T2, "T2.R1");
+ _T2_R2 = getRole(_T2, "T2.R2");
+
+ _classA =
+ getType(getTestProjectDir(), srcFolder, pkg, "ClassA");
+ _classB =
+ getType(getTestProjectDir(), srcFolder, pkg, "ClassB");
+ _interfaceA =
+ getType(getTestProjectDir(), srcFolder, pkg, "InterfaceA");
+ _interfaceB =
+ getType(getTestProjectDir(), srcFolder, pkg, "InterfaceB");
+ _interfaceC =
+ getType(getTestProjectDir(), srcFolder, pkg, "InterfaceC");
+ _objectType =
+ getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+ }
+
+
+ public void testCreation()
+ {
+ assertCreation(_T1);
+ assertCreation(_T2);
+
+ assertCreation(_T1_R1);
+ assertCreation(_T1_R2);
+
+ assertCreation(_T2_R1);
+ assertCreation(_T2_R2);
+ }
+
+ public void testGetAllSuperclassesFor_T2R1() throws JavaModelException
+ {
+ _focusType = _T2_R1;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _classB,
+ _classA,
+ _T1_R1 };
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclassesFor_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType, _T1_R2 };
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+
+ public void testGetAllSuperInterfacesFor_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {
+ _interfaceA,
+ _interfaceB,
+ _interfaceC };
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSuperInterfaces_T1R2() throws JavaModelException
+ {
+ _focusType = _T1_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _interfaceA };
+ IType [] actual = _testObj.getSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclassesFor_interfaceB() throws JavaModelException
+ {
+ _focusType = _interfaceB;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[0];
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfacesFor_interfaceB() throws JavaModelException
+ {
+ _focusType = _interfaceB;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _interfaceA };
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperInterfacesFor_ClassA() throws JavaModelException
+ {
+ _focusType = _classA;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[0];
+ IType [] actual = _testObj.getAllSuperInterfaces(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetSuperInterfaces_interfaceB_In_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _interfaceA };
+ IType [] actual = _testObj.getSuperInterfaces(_interfaceB);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllSuperclassesFor_classB() throws JavaModelException
+ {
+ _focusType = _classB;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _objectType,
+ _classA };
+ IType [] actual = _testObj.getAllSuperclasses(_focusType);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetExplicitSuperclassFor_classB() throws JavaModelException
+ {
+ _focusType = _classB;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType expected = _classA;
+ IType actual = _testObj.getExplicitSuperclass(_focusType);
+
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetAllInterfaces_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] {
+ _interfaceA,
+ _interfaceB,
+ _interfaceC };
+ IType [] actual = _testObj.getAllInterfaces();
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+ public void testGetImplementingClasses_interfaceA_in_T2R2() throws JavaModelException
+ {
+ _focusType = _T2_R2;
+ _testObj = createOTSuperTypeHierarchy(_focusType);
+
+ IType[] expected = new IType[] { _T1_R2, _T2_R2 };
+ IType [] actual = _testObj.getImplementingClasses(_interfaceA);
+
+ assertEquals(expected.length, actual.length);
+ assertTrue(compareTypes(expected, actual));
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest007_Stress.java b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest007_Stress.java
new file mode 100644
index 0000000..a86309f
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/hierarchy/org/eclipse/objectteams/otdt/tests/superhierarchy/OTSuperTypeHierarchyTest007_Stress.java
@@ -0,0 +1,175 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
+ * for its Fraunhofer Institute and Computer Architecture and Software
+ * Technology (FIRST), Berlin, Germany and Technical University Berlin,
+ * Germany.
+ *
+ * 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: OTSuperTypeHierarchyTest007_Stress.java 23494 2010-02-05 23:06:44Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.tests.superhierarchy;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.tests.hierarchy.FileBasedHierarchyTest;
+
+/**
+ * @author Michael Krueger (michael)
+ * @version $Id: OTSuperTypeHierarchyTest007_Stress.java 23494 2010-02-05 23:06:44Z stephan $
+ */
+@SuppressWarnings("unused")
+public class OTSuperTypeHierarchyTest007_Stress extends FileBasedHierarchyTest
+{
+ private IType _T1;
+ private IType _T2;
+
+ private IType _T1_R1;
+ private IType _T1_R2;
+
+ private IType _T2_R1;
+ private IType _T2_R2;
+
+ private IType _classA;
+ private IType _classB;
+
+ private IType _interfaceA;
+ private IType _interfaceB;
+ private IType _interfaceC;
+
+ private IType _objectType;
+
+ public OTSuperTypeHierarchyTest007_Stress(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ if (true)
+ {
+ return new Suite(OTSuperTypeHierarchyTest007_Stress.class);
+ }
+ junit.framework.TestSuite suite =
+ new Suite(OTSuperTypeHierarchyTest007_Stress.class.getName());
+ return suite;
+ }
+
+ public void setUpSuite() throws Exception
+ {
+ setTestProjectDir("Hierarchy");
+ super.setUpSuite();
+
+ String srcFolder = "src";
+ String pkg = "test007";
+
+ _T1 = getType(getTestProjectDir(), srcFolder, pkg, "T1");
+ _T2 = getType(getTestProjectDir(), srcFolder, pkg, "T2");
+
+ _T1_R1 = getRole(_T1, "T1.R1");
+ _T1_R2 = getRole(_T1, "T1.R2");
+
+ _T2_R1 = getRole(_T2, "T2.R1");
+ _T2_R2 = getRole(_T2, "T2.R2");
+
+ _classA =
+ getType(getTestProjectDir(), srcFolder, pkg, "ClassA");
+ _classB =
+ getType(getTestProjectDir(), srcFolder, pkg, "ClassB");
+ _interfaceA =
+ getType(getTestProjectDir(), srcFolder, pkg, "InterfaceA");
+ _interfaceB =
+ getType(getTestProjectDir(), srcFolder, pkg, "InterfaceB");
+ _interfaceC =
+ getType(getTestProjectDir(), srcFolder, pkg, "InterfaceC");
+ _objectType =
+ getType(getTestProjectDir(), "rt.jar", "java.lang", "Object");
+
+ }
+
+ public void testGetAllSuperInterfacesFor_T2R2_Run001()
+ throws JavaModelException
+ {
+ runActualTestCase();
+ }
+
+ public void testGetAllSuperInterfacesFor_T2R2_Run002()
+ throws JavaModelException
+ {
+ runActualTestCase();
+ }
+
+ public void testGetAllSuperInterfacesFor_T2R2_Run003()
+ throws JavaModelException
+ {
+ runActualTestCase();
+ }
+
+ public void testGetAllSuperInterfacesFor_T2R2_Run004()
+ throws JavaModelException
+ {
+ runActualTestCase();
+ }