Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2010-04-01 23:14:43 +0000
committerStephan Herrmann2010-04-01 23:14:43 +0000
commit0c152ef43e54ba1f27b4e54097615d0e774541fb (patch)
tree2fbe5fa3977779b759cde9f3a85c6cb0f1316ead /testplugins/org.eclipse.objectteams.otdt.debug.tests
parent02518472f92be6ea86eb5a7cf108c7d9ff95d23d (diff)
downloadorg.eclipse.objectteams-0c152ef43e54ba1f27b4e54097615d0e774541fb.tar.gz
org.eclipse.objectteams-0c152ef43e54ba1f27b4e54097615d0e774541fb.tar.xz
org.eclipse.objectteams-0c152ef43e54ba1f27b4e54097615d0e774541fb.zip
initial commit in accordance with CQ 3784
Diffstat (limited to 'testplugins/org.eclipse.objectteams.otdt.debug.tests')
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/.classpath8
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/.cvsignore1
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/.project28
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/.settings/org.eclipse.jdt.core.prefs52
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/META-INF/MANIFEST.MF30
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/build.properties15
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/scripts/buildTestSourceAttachmentJar.xml9
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/scripts/generateTests.xml13
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/AbstractOTDTDebugTest.java1456
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/AllTests.java116
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/ClassAttributeReader.java537
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/DebugTestsPlugin.java96
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/ManualDebugTestSuite.java102
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/OTProjectCreationDecorator.java291
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/Problem.java142
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/CopyInheritanceBreakpointTest.java192
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/JSR045Tests.java141
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/RoFiBreakpointTests.java96
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/SourceDebugExtensionTest.java79
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/StratumTests.java141
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/test.xml61
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/Breakpoints.java161
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/IBreakpoints.java14
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam.java12
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam2.java14
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam3.java14
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam.java9
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam3.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam3/R.java6
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/rofitests/RoFiTeam.java13
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/rofitests/RoFiTeam/RoFiRole.java7
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.debug.tests/testresources/dummy10
32 files changed, 3860 insertions, 0 deletions
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/.classpath b/testplugins/org.eclipse.objectteams.otdt.debug.tests/.classpath
new file mode 100644
index 000000000..da1d7bcd5
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/home/stephan/workspaces/otdt-helios/org.objectteams.runtime/otj/lib/jmangler/use/BCEL.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/.cvsignore b/testplugins/org.eclipse.objectteams.otdt.debug.tests/.cvsignore
new file mode 100644
index 000000000..092357e47
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/.project b/testplugins/org.eclipse.objectteams.otdt.debug.tests/.project
new file mode 100644
index 000000000..425547424
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.objectteams.otdt.debug.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.debug.tests/.settings/org.eclipse.jdt.core.prefs b/testplugins/org.eclipse.objectteams.otdt.debug.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..b19442463
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,52 @@
+#Thu Mar 08 22:53:25 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=ignore
+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.debug.tests/META-INF/MANIFEST.MF b/testplugins/org.eclipse.objectteams.otdt.debug.tests/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..c407dddc2
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OTDT DebugTest Plug-in
+Bundle-SymbolicName: org.eclipse.objectteams.otdt.debug.tests;singleton:=true
+Bundle-Version: 1.3.0
+Bundle-ClassPath: otdt-debugtests.jar,
+ BCEL.jar
+Bundle-Activator: org.eclipse.objectteams.otdt.debug.tests.DebugTestsPlugin
+Bundle-Vendor: Fraunhofer FIRST
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jdt.debug.tests,
+ org.eclipse.jdt.debug,
+ org.eclipse.jdt.debug.ui,
+ org.junit,
+ org.eclipse.jdt.launching,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.jdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.jface.text,
+ org.eclipse.ui.console,
+ org.eclipse.test.performance,
+ org.eclipse.objectteams.otdt.debug,
+ org.eclipse.objectteams.otdt,
+ org.eclipse.objectteams.otdt.debug.ui,
+ org.eclipse.objectteams.otdt.ui.tests
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.objectteams.otdt.debug.tests,
+ org.eclipse.objectteams.otdt.debug.tests.core
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/build.properties b/testplugins/org.eclipse.objectteams.otdt.debug.tests/build.properties
new file mode 100644
index 000000000..925883405
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/build.properties
@@ -0,0 +1,15 @@
+source.otdt-debugtests.jar = src/
+output.otdt-debugtests.jar = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ otdt-debugtests.jar,\
+ testjars/,\
+ testprograms/,\
+ testresources/,\
+ BCEL.jar,\
+ classfiles/,\
+ test.xml
+src.includes = build.properties,\
+ test.xml,\
+ .classpath,\
+ .project
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/scripts/buildTestSourceAttachmentJar.xml b/testplugins/org.eclipse.objectteams.otdt.debug.tests/scripts/buildTestSourceAttachmentJar.xml
new file mode 100644
index 000000000..d4ea7c7bc
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/scripts/buildTestSourceAttachmentJar.xml
@@ -0,0 +1,9 @@
+<project name="Build test source attachment jars" default="export" basedir="..">
+ <target name="export">
+ <jar
+ jarfile="./testresources/testJarWithOutRoot.jar"
+ basedir="testprograms"
+ includes="**"
+ />
+ </target>
+</project> \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/scripts/generateTests.xml b/testplugins/org.eclipse.objectteams.otdt.debug.tests/scripts/generateTests.xml
new file mode 100644
index 000000000..f29ebe679
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/scripts/generateTests.xml
@@ -0,0 +1,13 @@
+<project name="Generate Evaluation Tests" default="generateTests" basedir="..">
+ <target name="generateTests">
+ <java
+ classname="org.eclipse.jdt.debug.tests.eval.generator.TestGenerator"
+ fork="true"
+ failonerror="true"
+ dir="${basedir}/tests/org/eclipse/jdt/debug/tests/eval">
+ <classpath>
+ <pathelement path="${basedir}/bin"/>
+ </classpath>
+ </java>
+ </target>
+</project> \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/AbstractOTDTDebugTest.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/AbstractOTDTDebugTest.java
new file mode 100644
index 000000000..fb189c095
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/AbstractOTDTDebugTest.java
@@ -0,0 +1,1456 @@
+/**********************************************************************
+ * 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: AbstractOTDTDebugTest.java 23492 2010-02-05 22:57:56Z 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.debug.tests;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.ILineBreakpoint;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaModelMarker;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.debug.core.IJavaClassPrepareBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaDebugTarget;
+import org.eclipse.jdt.debug.core.IJavaExceptionBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaMethodBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaPatternBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaStratumLineBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaTargetPatternBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+import org.eclipse.jdt.debug.core.IJavaWatchpoint;
+import org.eclipse.jdt.debug.core.JDIDebugModel;
+import org.eclipse.jdt.debug.eval.EvaluationManager;
+import org.eclipse.jdt.debug.eval.IAstEvaluationEngine;
+import org.eclipse.jdt.debug.eval.IEvaluationListener;
+import org.eclipse.jdt.debug.eval.IEvaluationResult;
+import org.eclipse.jdt.debug.testplugin.DebugElementEventWaiter;
+import org.eclipse.jdt.debug.testplugin.DebugElementKindEventDetailWaiter;
+import org.eclipse.jdt.debug.testplugin.DebugElementKindEventWaiter;
+import org.eclipse.jdt.debug.testplugin.DebugEventWaiter;
+import org.eclipse.jdt.debug.tests.refactoring.MemberParser;
+import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
+import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.objectteams.otdt.core.ext.OTRuntimeClasspathProvider;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.objectteams.otdt.debug.ui.internal.actions.OTToggleBreakpointAdapter;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IHyperlink;
+import org.eclipse.ui.console.TextConsole;
+import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
+
+
+
+/**
+ * Tests for launch configurations
+ */
+public abstract class AbstractOTDTDebugTest extends TestCase implements IEvaluationListener {
+
+ public static final int DEFAULT_TIMEOUT = 30000;
+
+ public IEvaluationResult fEvaluationResult;
+
+ public static IJavaProject fJavaProject;
+
+ /**
+ * The last relevent event set - for example, that caused
+ * a thread to suspend
+ */
+ protected DebugEvent[] fEventSet;
+
+ public AbstractOTDTDebugTest(String name) {
+ super(name);
+ // set error dialog to non-blocking to avoid hanging the UI during test
+ ErrorDialog.AUTOMATED_MODE = true;
+ SafeRunnable.setIgnoreErrors(true);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+//{ObjectTeams replace ProjectCreationDecorator with own
+/* orig:
+ if (!ProjectCreationDecorator.isReady()) {
+ new TestSuite(ProjectCreationDecorator.class).run(new TestResult());
+ }
+ :giro */
+ if (!OTProjectCreationDecorator.isReady()) {
+ new TestSuite(OTProjectCreationDecorator.class).run(new TestResult());
+ }
+//ike+SH}
+ }
+
+//{ObjectTeams: get OS-Path for classfiles
+ protected IPath getAbsoluteOSClassFilePath(String typeName) throws Exception {
+ IResource project = getJavaProject().getResource();
+ IPath projectPath = project.getLocation();
+
+ IFile classfile = ((IProject) project).getFile(typeName+".class");
+ if (classfile!= null)
+ {
+// TODO(ike): Workaround, cause file.getAbsolutePath() return path without "src"
+ return new Path(projectPath.toOSString(),java.io.File.separator + "src" + java.io.File.separator + typeName + ".class");
+ }
+
+ return null;
+ }
+//ike}
+
+ /**
+ * Sets the last relevant event set
+ *
+ * @param set event set
+ */
+ protected void setEventSet(DebugEvent[] set) {
+ fEventSet = set;
+ }
+
+ /**
+ * Returns the last relevant event set
+ *
+ * @return event set
+ */
+ protected DebugEvent[] getEventSet() {
+ return fEventSet;
+ }
+
+ /**
+ * Returns the launch manager
+ *
+ * @return launch manager
+ */
+ protected ILaunchManager getLaunchManager() {
+ return DebugPlugin.getDefault().getLaunchManager();
+ }
+
+ /**
+ * Returns the breakpoint manager
+ *
+ * @return breakpoint manager
+ */
+ protected IBreakpointManager getBreakpointManager() {
+ return DebugPlugin.getDefault().getBreakpointManager();
+ }
+
+ /**
+ * Returns the 'DebugTests' project.
+ *
+ * @return the test project
+ */
+ protected IJavaProject getJavaProject() {
+ return getJavaProject("DebugTests");
+ }
+
+ /**
+ * Returns the Java project with the given name.
+ *
+ * @param name project name
+ * @return the Java project with the given name
+ */
+ protected IJavaProject getJavaProject(String name) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ return JavaCore.create(project);
+ }
+
+ /**
+ * Returns the source folder with the given name in the given project.
+ *
+ * @param project
+ * @param name source folder name
+ * @return package fragment root
+ */
+ protected IPackageFragmentRoot getPackageFragmentRoot(IJavaProject project, String name) {
+ IProject p = project.getProject();
+ return project.getPackageFragmentRoot(p.getFolder(name));
+ }
+
+ protected IHyperlink getHyperlink(int offset, IDocument doc) {
+ if (offset >= 0 && doc != null) {
+ Position[] positions = null;
+ try {
+ positions = doc.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
+ } catch (BadPositionCategoryException ex) {
+ // no links have been added
+ return null;
+ }
+ for (int i = 0; i < positions.length; i++) {
+ Position position = positions[i];
+ if (offset >= position.getOffset() && offset <= (position.getOffset() + position.getLength())) {
+ return ((ConsoleHyperlinkPosition)position).getHyperLink();
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Launches the given configuration and waits for an event. Returns the
+ * source of the event. If the event is not received, the launch is
+ * terminated and an exception is thrown.
+ *
+ * @param configuration the configuration to launch
+ * @param waiter the event waiter to use
+ * @return Object the source of the event
+ * @exception Exception if the event is never received.
+ */
+ protected Object launchAndWait(ILaunchConfiguration configuration, DebugEventWaiter waiter) throws CoreException {
+ return launchAndWait(configuration, waiter, true);
+ }
+
+ /**
+ * Launches the given configuration and waits for an event. Returns the
+ * source of the event. If the event is not received, the launch is
+ * terminated and an exception is thrown.
+ *
+ * @param configuration the configuration to launch
+ * @param waiter the event waiter to use
+ * @param register whether to register the launch
+ * @return Object the source of the event
+ * @exception Exception if the event is never received.
+ */
+ protected Object launchAndWait(ILaunchConfiguration configuration, DebugEventWaiter waiter, boolean register) throws CoreException {
+ ILaunch launch = configuration.launch(ILaunchManager.DEBUG_MODE, null, false, register);
+ Object suspendee= waiter.waitForEvent();
+ if (suspendee == null) {
+ System.out.println();
+ System.out.println("Test case: " + this.getName());
+ System.out.println("Never received event: " + waiter.getEventKindName());
+ if (launch.isTerminated()) {
+ System.out.println("Process exit value: " + launch.getProcesses()[0].getExitValue());
+ }
+ IConsole console = DebugUITools.getConsole(launch.getProcesses()[0]);
+ if (console instanceof TextConsole) {
+ TextConsole textConsole = (TextConsole)console;
+ String string = textConsole.getDocument().get();
+ System.out.println("Console output follows:");
+ System.out.println(string);
+ }
+ System.out.println();
+ try {
+ launch.terminate();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ fail("Program did not suspend, and unable to terminate launch.");
+ }
+ }
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend, launch terminated.", suspendee);
+ return suspendee;
+ }
+
+ /**
+ * Launches the type with the given name, and waits for a
+ * suspend event in that program. Returns the thread in which the suspend
+ * event occurred.
+ *
+ * @param mainTypeName the program to launch
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaThread launchAndSuspend(String mainTypeName) throws Exception {
+ ILaunchConfiguration config = getLaunchConfiguration(mainTypeName);
+ assertNotNull("Could not locate launch configuration for " + mainTypeName, config);
+ return launchAndSuspend(config);
+ }
+
+ /**
+ * Launches the given configuration in debug mode, and waits for a
+ * suspend event in that program. Returns the thread in which the suspend
+ * event occurred.
+ *
+ * @param config the configuration to launch
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaThread launchAndSuspend(ILaunchConfiguration config) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.SUSPEND, IJavaThread.class);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+ Object suspendee = launchAndWait(config, waiter);
+ return (IJavaThread)suspendee;
+ }
+
+ /**
+ * Launches the type with the given name, and waits for a breakpoint-caused
+ * suspend event in that program. Returns the thread in which the suspend
+ * event occurred.
+ *
+ * @param mainTypeName the program to launch
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaThread launchToBreakpoint(String mainTypeName) throws Exception {
+ return launchToBreakpoint(mainTypeName, true);
+ }
+
+ /**
+ * Launches the type with the given name, and waits for a breakpoint-caused
+ * suspend event in that program. Returns the thread in which the suspend
+ * event occurred.
+ *
+ * @param mainTypeName the program to launch
+ * @param register whether to register the launch
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaThread launchToBreakpoint(String mainTypeName, boolean register) throws Exception {
+ ILaunchConfiguration config = getLaunchConfiguration(mainTypeName);
+ assertNotNull("Could not locate launch configuration for " + mainTypeName, config);
+ return launchToBreakpoint(config, register);
+ }
+
+ /**
+ * Launches the given configuration in debug mode, and waits for a breakpoint-caused
+ * suspend event in that program. Returns the thread in which the suspend
+ * event occurred.
+ *
+ * @param config the configuration to launch
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaThread launchToBreakpoint(ILaunchConfiguration config) throws CoreException {
+ return launchToBreakpoint(config, true);
+ }
+
+ /**
+ * Launches the given configuration in debug mode, and waits for a breakpoint-caused
+ * suspend event in that program. Returns the thread in which the suspend
+ * event occurred.
+ *
+ * @param config the configuration to launch
+ * @param whether to register the launch
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaThread launchToBreakpoint(ILaunchConfiguration config, boolean register) throws CoreException {
+ DebugEventWaiter waiter= new DebugElementKindEventDetailWaiter(DebugEvent.SUSPEND, IJavaThread.class, DebugEvent.BREAKPOINT);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ Object suspendee= launchAndWait(config, waiter, register);
+ assertTrue("suspendee was not an IJavaThread", suspendee instanceof IJavaThread);
+ return (IJavaThread)suspendee;
+ }
+
+ /**
+ * Launches the type with the given name, and waits for a terminate
+ * event in that program. Returns the debug target in which the suspend
+ * event occurred.
+ *
+ * @param mainTypeName the program to launch
+ * @param timeout the number of milliseconds to wait for a terminate event
+ * @return debug target in which the terminate event occurred
+ */
+ protected IJavaDebugTarget launchAndTerminate(String mainTypeName) throws Exception {
+ ILaunchConfiguration config = getLaunchConfiguration(mainTypeName);
+ assertNotNull("Could not locate launch configuration for " + mainTypeName, config);
+ return launchAndTerminate(config, DEFAULT_TIMEOUT);
+ }
+
+ /**
+ * Launches the given configuration in debug mode, and waits for a terminate
+ * event in that program. Returns the debug target in which the terminate
+ * event occurred.
+ *
+ * @param config the configuration to launch
+ * @param timeout the number of milliseconds to wait for a terminate event
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaDebugTarget launchAndTerminate(ILaunchConfiguration config, int timeout) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.TERMINATE, IJavaDebugTarget.class);
+ waiter.setTimeout(timeout);
+
+ Object terminatee = launchAndWait(config, waiter);
+ assertNotNull("Program did not terminate.", terminatee);
+ assertTrue("terminatee is not an IJavaDebugTarget", terminatee instanceof IJavaDebugTarget);
+ IJavaDebugTarget debugTarget = (IJavaDebugTarget) terminatee;
+ assertTrue("debug target is not terminated", debugTarget.isTerminated() || debugTarget.isDisconnected());
+ return debugTarget;
+ }
+
+ /**
+ * Launches the type with the given name, and waits for a line breakpoint suspend
+ * event in that program. Returns the thread in which the suspend
+ * event occurred.
+ *
+ * @param mainTypeName the program to launch
+ * @param bp the breakpoint that should cause a suspend event
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaThread launchToLineBreakpoint(String mainTypeName, ILineBreakpoint bp) throws Exception {
+ ILaunchConfiguration config = getLaunchConfiguration(mainTypeName);
+ assertNotNull("Could not locate launch configuration for " + mainTypeName, config);
+ return launchToLineBreakpoint(config, bp);
+ }
+
+ /**
+ * Launches the given configuration in debug mode, and waits for a line breakpoint
+ * suspend event in that program. Returns the thread in which the suspend
+ * event occurred.
+ *
+ * @param config the configuration to launch
+ * @param bp the breakpoint that should cause a suspend event
+ * @return thread in which the first suspend event occurred
+ */
+ protected IJavaThread launchToLineBreakpoint(ILaunchConfiguration config, ILineBreakpoint bp) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventDetailWaiter(DebugEvent.SUSPEND, IJavaThread.class, DebugEvent.BREAKPOINT);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ Object suspendee= launchAndWait(config, waiter);
+ assertTrue("suspendee was not an IJavaThread", suspendee instanceof IJavaThread);
+ IJavaThread thread = (IJavaThread) suspendee;
+ IBreakpoint hit = getBreakpoint(thread);
+ assertNotNull("suspended, but not by breakpoint", hit);
+ assertTrue("hit un-registered breakpoint", bp.equals(hit));
+ assertTrue("suspended, but not by line breakpoint", hit instanceof ILineBreakpoint);
+ ILineBreakpoint breakpoint= (ILineBreakpoint) hit;
+ int lineNumber = breakpoint.getLineNumber();
+ int stackLine = thread.getTopStackFrame().getLineNumber();
+ assertTrue("line numbers of breakpoint and stack frame do not match", lineNumber == stackLine);
+
+ return thread;
+ }
+
+ /**
+ * Resumes the given thread, and waits for another breakpoint-caused suspend event.
+ * Returns the thread in which the suspend event occurs.
+ *
+ * @param thread thread to resume
+ * @return thread in which the first suspend event occurs
+ */
+ protected IJavaThread resume(IJavaThread thread) throws Exception {
+ return resume(thread, DEFAULT_TIMEOUT);
+ }
+
+ /**
+ * Resumes the given thread, and waits for another breakpoint-caused suspend event.
+ * Returns the thread in which the suspend event occurs.
+ *
+ * @param thread thread to resume
+ * @param timeout timeout in ms
+ * @return thread in which the first suspend event occurs
+ */
+ protected IJavaThread resume(IJavaThread thread, int timeout) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventDetailWaiter(DebugEvent.SUSPEND, IJavaThread.class, DebugEvent.BREAKPOINT);
+ waiter.setTimeout(timeout);
+
+ thread.resume();
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ return (IJavaThread)suspendee;
+ }
+
+ /**
+ * Resumes the given thread, and waits for a suspend event caused by the specified
+ * line breakpoint. Returns the thread in which the suspend event occurs.
+ *
+ * @param thread thread to resume
+ * @return thread in which the first suspend event occurs
+ */
+ protected IJavaThread resumeToLineBreakpoint(IJavaThread resumeThread, ILineBreakpoint bp) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventDetailWaiter(DebugEvent.SUSPEND, IJavaThread.class, DebugEvent.BREAKPOINT);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ resumeThread.resume();
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ assertTrue("suspendee was not an IJavaThread", suspendee instanceof IJavaThread);
+ IJavaThread thread = (IJavaThread) suspendee;
+ IBreakpoint hit = getBreakpoint(thread);
+ assertNotNull("suspended, but not by breakpoint", hit);
+ assertTrue("hit un-registered breakpoint", bp.equals(hit));
+ assertTrue("suspended, but not by line breakpoint", hit instanceof ILineBreakpoint);
+ ILineBreakpoint breakpoint= (ILineBreakpoint) hit;
+ int lineNumber = breakpoint.getLineNumber();
+ int stackLine = thread.getTopStackFrame().getLineNumber();
+ assertTrue("line numbers of breakpoint and stack frame do not match", lineNumber == stackLine);
+
+ return (IJavaThread)suspendee;
+ }
+
+ /**
+ * Resumes the given thread, and waits for the debug target
+ * to terminate (i.e. finish/exit the program).
+ *
+ * @param thread thread to resume
+ */
+ protected void exit(IJavaThread thread) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.TERMINATE, IProcess.class);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ thread.resume();
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not terminate.", suspendee);
+ }
+
+ /**
+ * Resumes the given thread, and waits the associated debug
+ * target to terminate.
+ *
+ * @param thread thread to resume
+ * @return the terminated debug target
+ */
+ protected IJavaDebugTarget resumeAndExit(IJavaThread thread) throws Exception {
+ DebugEventWaiter waiter= new DebugElementEventWaiter(DebugEvent.TERMINATE, thread.getDebugTarget());
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ thread.resume();
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not terminate.", suspendee);
+ IJavaDebugTarget target = (IJavaDebugTarget)suspendee;
+ assertTrue("program should have exited", target.isTerminated() || target.isDisconnected());
+ return target;
+ }
+
+ /**
+ * Returns the launch configuration for the given main type
+ *
+ * @param mainTypeName program to launch
+ * @see OTProjectCreationDecorator
+ */
+ protected ILaunchConfiguration getLaunchConfiguration(String mainTypeName) {
+ IFile file = getJavaProject().getProject().getFolder("launchConfigurations").getFile(mainTypeName + ".launch");
+ ILaunchConfiguration config = getLaunchManager().getLaunchConfiguration(file);
+ assertTrue("Could not find launch configuration for " + mainTypeName, config.exists());
+ return config;
+ }
+
+ protected IResource getBreakpointResource(String typeName) throws Exception {
+ IJavaElement element = getJavaProject().findElement(new Path(typeName + ".java"));
+ IResource resource = element.getCorrespondingResource();
+ if (resource == null) {
+ resource = getJavaProject().getProject();
+ }
+ return resource;
+ }
+
+ protected IResource getBreakpointResource(IType type) throws Exception {
+ if (type == null) {
+ return getJavaProject().getProject();
+ }
+ IResource resource = type.getResource();
+ if (resource == null) {
+ resource = getJavaProject().getProject();
+ }
+ return resource;
+ }
+
+ /**
+ * Creates and returns a line breakpoint at the given line number in the type with the
+ * given name.
+ *
+ * @param lineNumber line number
+ * @param typeName type name
+ */
+ protected IJavaLineBreakpoint createLineBreakpoint(int lineNumber, String typeName) throws Exception {
+ IType type = getType(typeName);
+ return createLineBreakpoint(type, lineNumber);
+ }
+
+ /**
+ *
+ * @param lineNumber
+ * @param root
+ * @param packageName
+ * @param cuName
+ * @param fullTargetName
+ * @return
+ */
+ protected IJavaLineBreakpoint createLineBreakpoint(int lineNumber, String root, String packageName, String cuName,
+ String fullTargetName) throws Exception{
+ IJavaProject javaProject = getJavaProject();
+ ICompilationUnit cunit = getCompilationUnit(javaProject, root, packageName, cuName);
+ assertNotNull("did not find requested Compilation Unit", cunit);
+ IType targetType = (IType)(new MemberParser()).getDeepest(cunit,fullTargetName);
+ assertNotNull("did not find requested type", targetType);
+ assertTrue("did not find type to install breakpoint in", targetType.exists());
+
+ return createLineBreakpoint(targetType, lineNumber);
+ }
+
+
+ /**
+ * Creates a line breakpoint in the given type (may be a top level non public type)
+ *
+ * @param lineNumber line number to create the breakpoint at
+ * @param packageName fully qualified package name containing the type, example "a.b.c"
+ * @param cuName simple name of compilation unit containing the type, example "Something.java"
+ * @param typeName $ qualified type name, example "Something" or "NonPublic" or "Something$Inner"
+ * @return line breakpoint
+ * @throws Exception
+ */
+ protected IJavaLineBreakpoint createLineBreakpoint(int lineNumber, String packageName, String cuName, String typeName) throws Exception {
+ IType type = getType(packageName, cuName, typeName);
+ return createLineBreakpoint(type, lineNumber);
+ }
+
+ /**
+ * Creates a line breakpoint in the given type at the given line number.
+ *
+ * @param type type in which to install the breakpoint
+ * @param lineNumber line number to install the breakpoint at
+ * @return line breakpoint
+ * @throws Exception
+ */
+ protected IJavaLineBreakpoint createLineBreakpoint(IType type, int lineNumber) throws Exception {
+ IMember member = null;
+ if (type != null) {
+ IJavaElement sourceElement = null;
+ String source = null;
+ if (type.isBinary()) {
+ IClassFile classFile = type.getClassFile();
+ source = classFile.getSource();
+ sourceElement = classFile;
+ } else {
+ ICompilationUnit unit = type.getCompilationUnit();
+ source = unit.getSource();
+ sourceElement = unit;
+ }
+ // translate line number to offset
+ if (source != null) {
+ Document document = new Document(source);
+ IRegion region = document.getLineInformation(lineNumber);
+ if (sourceElement instanceof ICompilationUnit) {
+ member = (IMember) ((ICompilationUnit)sourceElement).getElementAt(region.getOffset());
+ } else {
+ member = (IMember) ((IClassFile)sourceElement).getElementAt(region.getOffset());
+ }
+ }
+ }
+ Map map = getExtraBreakpointAttributes(member);
+//{ObjectTeams: special treatment for roles:
+ String typeName = OTToggleBreakpointAdapter.createQualifiedTypeName(type);
+/* orig:
+ return JDIDebugModel.createLineBreakpoint(getBreakpointResource(type), type.getFullyQualifiedName(), lineNumber, -1, -1, 0, true, map);
+ :giro */
+ return JDIDebugModel.createLineBreakpoint(getBreakpointResource(type), typeName, lineNumber, -1, -1, 0, true, map);
+// SH}
+ }
+
+ /**
+ * Returns the type in the test project based on the given name. The type name may refer to a
+ * top level non public type.
+ *
+ * @param packageName package name, example "a.b.c"
+ * @param cuName simple compilation unit name within the package, example "Something.java"
+ * @param typeName simple dot qualified type name, example "Something" or "NonPublic" or "Something.Inner"
+ * @return associated type or <code>null</code> if none
+ * @throws Exception
+ */
+ protected IType getType(String packageName, String cuName, String typeName) throws Exception {
+ IPackageFragment[] packageFragments = getJavaProject().getPackageFragments();
+ for (int i = 0; i < packageFragments.length; i++) {
+ IPackageFragment fragment = packageFragments[i];
+ if (fragment.getElementName().equals(packageName)) {
+ ICompilationUnit compilationUnit = fragment.getCompilationUnit(cuName);
+ String[] names = typeName.split("\\$");
+ IType type = compilationUnit.getType(names[0]);
+ for (int j = 1; j < names.length; j++) {
+ type = type.getType(names[j]);
+ }
+ if (type.exists()) {
+ return type;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates and returns a map of java element breakpoint attributes for a breakpoint on the
+ * given java element, or <code>null</code> if none
+ *
+ * @param element java element the breakpoint is associated with
+ * @return map of breakpoint attributes or <code>null</code>
+ * @throws Exception
+ */
+ protected Map getExtraBreakpointAttributes(IMember element) throws Exception {
+ if (element != null && element.exists()) {
+ Map map = new HashMap();
+ ISourceRange sourceRange = element.getSourceRange();
+ int start = sourceRange.getOffset();
+ int end = start + sourceRange.getLength();
+ IType type = null;
+ if (element instanceof IType) {
+ type = (IType) element;
+ } else {
+ type = element.getDeclaringType();
+ }
+ BreakpointUtils.addJavaBreakpointAttributesWithMemberDetails(map, type, start, end);
+ return map;
+ }
+ return null;
+ }
+
+ /**
+ * Creates and returns a line breakpoint at the given line number in the type with the
+ * given name and sets the specified condition on the breakpoint.
+ *
+ * @param lineNumber line number
+ * @param typeName type name
+ * @param condition condition
+ */
+ protected IJavaLineBreakpoint createConditionalLineBreakpoint(int lineNumber, String typeName, String condition, boolean suspendOnTrue) throws Exception {
+ IJavaLineBreakpoint bp = createLineBreakpoint(lineNumber, typeName);
+ bp.setCondition(condition);
+ bp.setConditionEnabled(true);
+ bp.setConditionSuspendOnTrue(suspendOnTrue);
+ return bp;
+ }
+
+ /**
+ * Creates and returns a pattern breakpoint at the given line number in the
+ * source file with the given name.
+ *
+ * @param lineNumber line number
+ * @param sourceName name of source file
+ * @param pattern the pattern of the class file name
+ */
+ protected IJavaPatternBreakpoint createPatternBreakpoint(int lineNumber, String sourceName, String pattern) throws Exception {
+ return JDIDebugModel.createPatternBreakpoint(getJavaProject().getProject(), sourceName, pattern, lineNumber, -1, -1, 0, true, null);
+ }
+
+ /**
+ * Creates and returns a target pattern breakpoint at the given line number in the
+ * source file with the given name.
+ *
+ * @param lineNumber line number
+ * @param sourceName name of source file
+ */
+ protected IJavaTargetPatternBreakpoint createTargetPatternBreakpoint(int lineNumber, String sourceName) throws Exception {
+ return JDIDebugModel.createTargetPatternBreakpoint(getJavaProject().getProject(), sourceName, lineNumber, -1, -1, 0, true, null);
+ }
+
+ /**
+ * Creates and returns a stratum breakpoint at the given line number in the
+ * source file with the given name.
+ *
+ * @param lineNumber line number
+ * @param sourceName name of source file
+ * @param stratum the stratum of the source file
+ */
+ protected IJavaStratumLineBreakpoint createStratumBreakpoint(int lineNumber, String sourceName, String stratum) throws Exception {
+ return JDIDebugModel.createStratumBreakpoint(getJavaProject().getProject(), stratum, sourceName, null, null, lineNumber, -1, -1, 0, true, null);
+ }
+
+ /**
+ * Creates and returns a method breakpoint
+ *
+ * @param typeNamePattern type name pattern
+ * @param methodName method name
+ * @param methodSignature method signature or <code>null</code>
+ * @param entry whether to break on entry
+ * @param exit whether to break on exit
+ */
+ protected IJavaMethodBreakpoint createMethodBreakpoint(String typeNamePattern, String methodName, String methodSignature, boolean entry, boolean exit) throws Exception {
+ IMethod method= null;
+ IResource resource = getJavaProject().getProject();
+ if (methodSignature != null && methodName != null) {
+ IType type = getType(typeNamePattern);
+ if (type != null ) {
+ resource = getBreakpointResource(type);
+ method = type.getMethod(methodName, Signature.getParameterTypes(methodSignature));
+ }
+ }
+ Map map = getExtraBreakpointAttributes(method);
+ return JDIDebugModel.createMethodBreakpoint(resource, typeNamePattern, methodName, methodSignature, entry, exit,false, -1, -1, -1, 0, true, map);
+ }
+
+ /**
+ * Creates a method breakpoint in a fully specified type (potentially non public).
+ *
+ * @param packageName package name containing type to install breakpoint in, example "a.b.c"
+ * @param cuName simple compilation unit name within package, example "Something.java"
+ * @param typeName $ qualified type name within compilation unit, example "Something" or
+ * "NonPublic" or "Something$Inner"
+ * @param methodName method or <code>null</code> for all methods
+ * @param methodSignature JLS method siganture or <code>null</code> for all methods with the given name
+ * @param entry whether to break on entry
+ * @param exit whether to break on exit
+ * @return method breakpoint
+ * @throws Exception
+ */
+ protected IJavaMethodBreakpoint createMethodBreakpoint(String packageName, String cuName, String typeName, String methodName, String methodSignature, boolean entry, boolean exit) throws Exception {
+ IType type = getType(packageName, cuName, typeName);
+ assertNotNull("did not find type to install breakpoint in", type);
+ IMethod method= null;
+ if (methodSignature != null && methodName != null) {
+ if (type != null ) {
+ method = type.getMethod(methodName, Signature.getParameterTypes(methodSignature));
+ }
+ }
+ Map map = getExtraBreakpointAttributes(method);
+ return JDIDebugModel.createMethodBreakpoint(getBreakpointResource(type), type.getFullyQualifiedName(), methodName, methodSignature, entry, exit,false, -1, -1, -1, 0, true, map);
+ }
+
+
+ /**
+ * Creates a MethodBreakPoint on the method specified at the given path.
+ * Syntax:
+ * Type$InnerType$MethodNameAndSignature$AnonymousTypeDeclarationNumber$FieldName
+ * eg:<code>
+ * public class Foo{
+ * class Inner
+ * {
+ * public void aMethod()
+ * {
+ * Object anon = new Object(){
+ * int anIntField;
+ * String anonTypeMethod() {return "an Example";}
+ * }
+ * }
+ * }
+ * }</code>
+ * Syntax to get the anonymous toString would be: Foo$Inner$aMethod()V$1$anonTypeMethod()QString
+ * so, createMethodBreakpoint(packageName, cuName, "Foo$Inner$aMethod()V$1$anonTypeMethod()QString",true,false);
+ */
+ protected IJavaMethodBreakpoint createMethodBreakpoint(String root, String packageName, String cuName,
+ String fullTargetName, boolean entry, boolean exit) throws Exception {
+
+ IJavaProject javaProject = getJavaProject();
+ ICompilationUnit cunit = getCompilationUnit(javaProject, root, packageName, cuName);
+ assertNotNull("did not find requested Compilation Unit", cunit);
+ IMethod targetMethod = (IMethod)(new MemberParser()).getDeepest(cunit,fullTargetName);
+ assertNotNull("did not find requested method", targetMethod);
+ assertTrue("Given method does not exist", targetMethod.exists());
+ IType methodParent = (IType)targetMethod.getParent();//safe - method's only parent = Type
+ assertNotNull("did not find type to install breakpoint in", methodParent);
+
+ Map map = getExtraBreakpointAttributes(targetMethod);
+ return JDIDebugModel.createMethodBreakpoint(getBreakpointResource(methodParent), methodParent.getFullyQualifiedName(),targetMethod.getElementName(), targetMethod.getSignature(), entry, exit,false, -1, -1, -1, 0, true, map);
+ }
+
+ /**
+ * @param cu the Compilation where the target resides
+ * @param target the fullname of the target, as per MemberParser syntax
+ * @return the requested Member
+ */
+ protected IMember getMember(ICompilationUnit cu, String target)
+ {
+ IMember toReturn = (new MemberParser()).getDeepest(cu,target);
+ return toReturn;
+ }
+ /**
+ * Creates and returns a class prepare breakpoint on the type with the given fully qualified name.
+ *
+ * @param typeName type on which to create the breakpoint
+ * @return breakpoint
+ * @throws Exception
+ */
+ protected IJavaClassPrepareBreakpoint createClassPrepareBreakpoint(String typeName) throws Exception {
+ return createClassPrepareBreakpoint(getType(typeName));
+ }
+
+ /**
+ * Creates and returns a class prepare breakpoint on the type with the given fully qualified name.
+ *
+ * @param typeName type on which to create the breakpoint
+ * @return breakpoint
+ * @throws Exception
+ */
+ protected IJavaClassPrepareBreakpoint createClassPrepareBreakpoint(String root,
+ String packageName, String cuName, String fullTargetName) throws Exception {
+ ICompilationUnit cunit = getCompilationUnit(getJavaProject(), root, packageName, cuName);
+ IType type = (IType)getMember(cunit,fullTargetName);
+ assertTrue("Target type not found", type.exists());
+ return createClassPrepareBreakpoint(type);
+ }
+
+ /**
+ * Creates a class prepare breakpoint in a fully specified type (potentially non public).
+ *
+ * @param packageName package name containing type to install breakpoint in, example "a.b.c"
+ * @param cuName simple compilation unit name within package, example "Something.java"
+ * @param typeName $ qualified type name within compilation unit, example "Something" or
+ * "NonPublic" or "Something$Inner"
+ */
+ protected IJavaClassPrepareBreakpoint createClassPrepareBreakpoint(String packageName, String cuName, String typeName) throws Exception {
+ return createClassPrepareBreakpoint(getType(packageName, cuName, typeName));
+ }
+
+ /**
+ * Creates a class prepare breakpoint for the given type
+ *
+ * @param type type
+ * @return class prepare breakpoint
+ * @throws Exception
+ */
+ protected IJavaClassPrepareBreakpoint createClassPrepareBreakpoint(IType type) throws Exception {
+ assertNotNull("type not specified for class prepare breakpoint", type);
+ int kind = IJavaClassPrepareBreakpoint.TYPE_CLASS;
+ if (type.isInterface()) {
+ kind = IJavaClassPrepareBreakpoint.TYPE_INTERFACE;
+ }
+ Map map = getExtraBreakpointAttributes(type);
+ return JDIDebugModel.createClassPrepareBreakpoint(getBreakpointResource(type), type.getFullyQualifiedName(), kind, -1, -1, true, map);
+ }
+
+ /**
+ * Returns the Java model type from the test project with the given name or <code>null</code>
+ * if none.
+ *
+ * @param typeName
+ * @return type or <code>null</code>
+ * @throws Exception
+ */
+ protected IType getType(String typeName) throws Exception {
+ return getJavaProject().findType(typeName);
+ }
+
+ /**
+ * Creates and returns a watchpoint
+ *
+ * @param typeNmae type name
+ * @param fieldName field name
+ * @param access whether to suspend on field access
+ * @param modification whether to suspend on field modification
+ */
+ protected IJavaWatchpoint createWatchpoint(String typeName, String fieldName, boolean access, boolean modification) throws Exception {
+ IType type = getType(typeName);
+ return createWatchpoint(type, fieldName, access, modification);
+ }
+
+ /**
+ * Creates and returns an exception breakpoint
+ *
+ * @param exName exception name
+ * @param caught whether to suspend in caught locations
+ * @param uncaught whether to suspend in uncaught locations
+ */
+ protected IJavaExceptionBreakpoint createExceptionBreakpoint(String exName, boolean caught, boolean uncaught) throws Exception {
+ IType type = getType(exName);
+ Map map = getExtraBreakpointAttributes(type);
+ return JDIDebugModel.createExceptionBreakpoint(getBreakpointResource(type),exName, caught, uncaught, false, true, map);
+ }
+
+ /**
+ * Creates and returns a watchpoint
+ *
+ * @param typeNmae type name
+ * @param fieldName field name
+ * @param access whether to suspend on field access
+ * @param modification whether to suspend on field modification
+ */
+/* protected IJavaWatchpoint createWatchpoint(String typeName, String fieldName, boolean access, boolean modification) throws Exception {
+ IType type = getType(typeName);
+ return createWatchpoint(type, fieldName, access, modification);
+ }*/
+
+
+ /**
+ * Creates a WatchPoint on the field specified at the given path.
+ * Will create watchpoints on fields within anonymous types, inner types,
+ * local (non-public) types, and public types.
+ * @param root
+ * @param packageName package name containing type to install breakpoint in, example "a.b.c"
+ * @param cuName simple compilation unit name within package, example "Something.java"
+ * @param fullTargetName - see below
+ * @param access whether to suspend on access
+ * @param modification whether to suspend on modification
+ * @return a watchpoint
+ * @throws Exception
+ * @throws CoreException
+ *
+ * @see
+ * </code>
+ * Syntax example:
+ * Type$InnerType$MethodNameAndSignature$AnonymousTypeDeclarationNumber$FieldName
+ * eg:<code>
+ * public class Foo{
+ * class Inner
+ * {
+ * public void aMethod()
+ * {
+ * Object anon = new Object(){
+ * int anIntField;
+ * String anonTypeMethod() {return "an Example";}
+ * }
+ * }
+ * }
+ * }</code>
+ * To get the anonymous toString, syntax of fullTargetName would be: <code>Foo$Inner$aMethod()V$1$anIntField</code>
+ */
+ protected IJavaWatchpoint createNestedTypeWatchPoint(String root, String packageName, String cuName,
+ String fullTargetName, boolean access, boolean modification) throws Exception, CoreException {
+
+ ICompilationUnit cunit = getCompilationUnit(getJavaProject(), root, packageName, cuName);
+ IField field = (IField)getMember(cunit,fullTargetName);
+ assertNotNull("Path to field is not valid", field);
+ assertTrue("Field is not valid", field.exists());
+ IType type = (IType)field.getParent();
+ return createWatchpoint(type, field.getElementName(), access, modification);
+ }
+
+
+ /**
+ * Creates a watchpoint in a fully specified type (potentially non public).
+ *
+ * @param packageName package name containing type to install breakpoint in, example "a.b.c"
+ * @param cuName simple compilation unit name within package, example "Something.java"
+ * @param typeName $ qualified type name within compilation unit, example "Something" or
+ * "NonPublic" or "Something$Inner"
+ * @param fieldName name of the field
+ * @param access whether to suspend on access
+ * @param modification whether to suspend on modification
+ */
+ protected IJavaWatchpoint createWatchpoint(String packageName, String cuName, String typeName, String fieldName, boolean access, boolean modification) throws Exception {
+ IType type = getType(packageName, cuName, typeName);
+ return createWatchpoint(type, fieldName, access, modification);
+ }
+
+ /**
+ * Creates a watchpoint on the specified field.
+ *
+ * @param type type containing the field
+ * @param fieldName name of the field
+ * @param access whether to suspend on access
+ * @param modification whether to suspend on modification
+ * @return watchpoint
+ * @throws Exception
+ */
+ protected IJavaWatchpoint createWatchpoint(IType type, String fieldName, boolean access, boolean modification) throws Exception, CoreException {
+ assertNotNull("type not specified for watchpoint", type);
+ IField field = type.getField(fieldName);
+ Map map = getExtraBreakpointAttributes(field);
+ IJavaWatchpoint wp = JDIDebugModel.createWatchpoint(getBreakpointResource(type), type.getFullyQualifiedName(), fieldName, -1, -1, -1, 0, true, map);
+ wp.setAccess(access);
+ wp.setModification(modification);
+ return wp;
+ }
+
+ /**
+ * Terminates the given thread and removes its launch
+ */
+ protected void terminateAndRemove(IJavaThread thread) {
+ if (thread != null) {
+ terminateAndRemove((IJavaDebugTarget)thread.getDebugTarget());
+ }
+ }
+
+ /**
+ * Terminates the given debug target and removes its launch.
+ *
+ * NOTE: all breakpoints are removed, all threads are resumed, and then
+ * the target is terminated. This avoids defunct processes on linux.
+ */
+ protected void terminateAndRemove(IJavaDebugTarget debugTarget) {
+ ILaunch launch = debugTarget.getLaunch();
+ if (debugTarget != null && !(debugTarget.isTerminated() || debugTarget.isDisconnected())) {
+ IPreferenceStore jdiUIPreferences = JDIDebugUIPlugin.getDefault().getPreferenceStore();
+ jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS, false);
+
+ DebugEventWaiter waiter = new DebugElementEventWaiter(DebugEvent.TERMINATE, debugTarget);
+ try {
+ removeAllBreakpoints();
+ IThread[] threads = debugTarget.getThreads();
+ for (int i = 0; i < threads.length; i++) {
+ IThread thread = threads[i];
+ try {
+ if (thread.isSuspended()) {
+ thread.resume();
+ }
+ } catch (CoreException e) {
+ }
+ }
+ debugTarget.getDebugTarget().terminate();
+ waiter.waitForEvent();
+ } catch (CoreException e) {
+ }
+ }
+ getLaunchManager().removeLaunch(launch);
+ // ensure event queue is flushed
+ DebugEventWaiter waiter = new DebugElementEventWaiter(DebugEvent.MODEL_SPECIFIC, this);
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(this, DebugEvent.MODEL_SPECIFIC)});
+ waiter.waitForEvent();
+ }
+
+ /**
+ * Deletes all existing breakpoints
+ */
+ protected void removeAllBreakpoints() {
+ IBreakpoint[] bps = getBreakpointManager().getBreakpoints();
+ try {
+ getBreakpointManager().removeBreakpoints(bps, true);
+ } catch (CoreException e) {
+ }
+ }
+
+ /**
+ * Returns the first breakpoint the given thread is suspended
+ * at, or <code>null</code> if none.
+ *
+ * @return the first breakpoint the given thread is suspended
+ * at, or <code>null</code> if none
+ */
+ protected IBreakpoint getBreakpoint(IThread thread) {
+ IBreakpoint[] bps = thread.getBreakpoints();
+ if (bps.length > 0) {
+ return bps[0];
+ }
+ return null;
+ }
+
+ /**
+ * Evaluates the given snippet in the context of the given stack frame and returns
+ * the result.
+ *
+ * @param snippet code snippet
+ * @param frame stack frame context
+ * @return evaluation result
+ */
+ protected IEvaluationResult evaluate(String snippet, IJavaStackFrame frame) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.SUSPEND, IJavaThread.class);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ IAstEvaluationEngine engine = EvaluationManager.newAstEvaluationEngine(getJavaProject(), (IJavaDebugTarget)frame.getDebugTarget());
+ engine.evaluate(snippet, frame, this, DebugEvent.EVALUATION, true);
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ engine.dispose();
+ return fEvaluationResult;
+ }
+
+ /**
+ * @see IEvaluationListener#evaluationComplete(IEvaluationResult)
+ */
+ public void evaluationComplete(IEvaluationResult result) {
+ fEvaluationResult = result;
+ }
+
+ /**
+ * Performs a step over in the given stack frame and returns when complete.
+ *
+ * @param frame stack frame to step in
+ */
+ protected IJavaThread stepOver(IJavaStackFrame frame) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventDetailWaiter(DebugEvent.SUSPEND, IJavaThread.class, DebugEvent.STEP_END);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ frame.stepOver();
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ return (IJavaThread) suspendee;
+ }
+
+ /**
+ * Performs a step into in the given stack frame and returns when complete.
+ *
+ * @param frame stack frame to step in
+ */
+ protected IJavaThread stepInto(IJavaStackFrame frame) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventDetailWaiter(DebugEvent.SUSPEND, IJavaThread.class, DebugEvent.STEP_END);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ frame.stepInto();
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ return (IJavaThread) suspendee;
+ }
+
+ /**
+ * Performs a step return in the given stack frame and returns when complete.
+ *
+ * @param frame stack frame to step return from
+ */
+ protected IJavaThread stepReturn(IJavaStackFrame frame) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventDetailWaiter(DebugEvent.SUSPEND, IJavaThread.class, DebugEvent.STEP_END);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ frame.stepReturn();
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ return (IJavaThread) suspendee;
+ }
+
+ /**
+ * Performs a step into with filters in the given stack frame and returns when
+ * complete.
+ *
+ * @param frame stack frame to step in
+ */
+ protected IJavaThread stepIntoWithFilters(IJavaStackFrame frame) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.SUSPEND, IJavaThread.class);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ // turn filters on
+ try {
+ DebugUITools.setUseStepFilters(true);
+ frame.stepInto();
+ } finally {
+ // turn filters off
+ DebugUITools.setUseStepFilters(false);
+ }
+
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ return (IJavaThread) suspendee;
+ }
+
+ /**
+ * Performs a step return with filters in the given stack frame and returns when
+ * complete.
+ *
+ * @param frame stack frame to step in
+ */
+ protected IJavaThread stepReturnWithFilters(IJavaStackFrame frame) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.SUSPEND, IJavaThread.class);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ // turn filters on
+ try {
+ DebugUITools.setUseStepFilters(true);
+ frame.stepReturn();
+ } finally {
+ // turn filters off
+ DebugUITools.setUseStepFilters(false);
+ }
+
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ return (IJavaThread) suspendee;
+ }
+
+ /**
+ * Performs a step over with filters in the given stack frame and returns when
+ * complete.
+ *
+ * @param frame stack frame to step in
+ */
+ protected IJavaThread stepOverWithFilters(IJavaStackFrame frame) throws Exception {
+ DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.SUSPEND, IJavaThread.class);
+ waiter.setTimeout(DEFAULT_TIMEOUT);
+
+ // turn filters on
+ try {
+ DebugUITools.setUseStepFilters(true);
+ frame.stepOver();
+ } finally {
+ // turn filters off
+ DebugUITools.setUseStepFilters(false);
+ }
+
+
+ Object suspendee= waiter.waitForEvent();
+ setEventSet(waiter.getEventSet());
+ assertNotNull("Program did not suspend.", suspendee);
+ return (IJavaThread) suspendee;
+ }
+
+ /**
+ * Returns the compilation unit with the given name.
+ *
+ * @param project the project containing the CU
+ * @param root the name of the source folder in the project
+ * @param pkg the name of the package (empty string for default package)
+ * @param name the name of the CU (ex. Something.java)
+ * @return compilation unit
+ */
+ protected ICompilationUnit getCompilationUnit(IJavaProject project, String root, String pkg, String name) {
+ IProject p = project.getProject();
+ IResource r = p.getFolder(root);
+ return project.getPackageFragmentRoot(r).getPackageFragment(pkg).getCompilationUnit(name);
+ }
+
+ /**
+ * Wait for builds to complete
+ */
+ public static void waitForBuild() {
+ boolean wasInterrupted = false;
+ do {
+ try {
+ Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ Platform.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD, null);
+ wasInterrupted = false;
+ } catch (OperationCanceledException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ wasInterrupted = true;
+ }
+ } while (wasInterrupted);
+ }
+
+
+ protected IJavaVariable findVariable(IJavaStackFrame frame, String name) throws DebugException {
+ IJavaVariable variable = frame.findVariable(name);
+ if (variable == null) {
+ // dump visible variables
+ IDebugModelPresentation presentation = DebugUIPlugin.getModelPresentation();
+ System.out.println("Could not find variable '" + name + "' in frame: " + presentation.getText(frame));
+ System.out.println("Visible variables are:");
+ IVariable[] variables = frame.getVariables();
+ for (int i = 0; i < variables.length; i++) {
+ IVariable variable2 = variables[i];
+ System.out.println("\t" + presentation.getText(variable2));
+ }
+ if (!frame.isStatic()) {
+ variables = frame.getThis().getVariables();
+ for (int i = 0; i < variables.length; i++) {
+ IVariable variable2 = variables[i];
+ System.out.println("\t" + presentation.getText(variable2));
+ }
+ }
+ }
+ return variable;
+ }
+
+ protected boolean isFileSystemCaseSensitive() {
+ return Platform.OS_MACOSX.equals(Platform.getOS()) ? false : new File("a").compareTo(new File("A")) != 0; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Creates a shared launch configuration for the type with the given name.
+ */
+ protected void createLaunchConfiguration(String mainTypeName) throws Exception {
+//{ObjectTeams: make launch type configurable:
+ createLaunchConfiguration(mainTypeName, IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
+ }
+ protected void createLaunchConfiguration(String mainTypeName, String launchType) throws Exception {
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(launchType);
+/*orig:
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
+ :giro */
+// SH}
+ ILaunchConfigurationWorkingCopy config = type.newInstance(getJavaProject().getProject().getFolder("launchConfigurations"), mainTypeName);
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainTypeName);
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, getJavaProject().getElementName());
+//{ObjectTeams: make it an OT/J launch:
+ if (OTDebugPlugin.OT_LAUNCH_CONFIGURATION_TYPE.equals(launchType)) {
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, OTRuntimeClasspathProvider.PROVIDER_ID);
+ config.setAttribute(OTDebugPlugin.OT_LAUNCH, true);
+ }
+// SH}
+ // use 'java' instead of 'javaw' to launch tests (javaw is problematic
+ // on JDK1.4.2)
+ Map map = new HashMap(1);
+ map.put(IJavaLaunchConfigurationConstants.ATTR_JAVA_COMMAND, "java");
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE_SPECIFIC_ATTRS_MAP, map);
+ config.doSave();
+ }
+
+ /**
+ * Return all problems with the specified element.
+ * From jdt.core.tests.builder.TestingEnvironment
+ */
+ public Problem[] getProblemsFor(IResource resource){
+ return getProblemsFor(resource, null);
+ }
+ /**
+ * Return all problems with the specified element.
+ * From jdt.core.tests.builder.TestingEnvironment
+ */
+ public Problem[] getProblemsFor(IResource resource, String additionalMarkerType){
+ try {
+ ArrayList problems = new ArrayList();
+ IMarker[] markers = resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
+ for (int i = 0; i < markers.length; i++)
+ problems.add(new Problem(markers[i]));
+
+ markers = resource.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
+ for (int i = 0; i < markers.length; i++)
+ problems.add(new Problem(markers[i]));
+
+ markers = resource.findMarkers(IJavaModelMarker.TASK_MARKER, true, IResource.DEPTH_INFINITE);
+ for (int i = 0; i < markers.length; i++)
+ problems.add(new Problem(markers[i]));
+
+ if (additionalMarkerType != null) {
+ markers = resource.findMarkers(additionalMarkerType, true, IResource.DEPTH_INFINITE);
+ for (int i = 0; i < markers.length; i++)
+ problems.add(new Problem(markers[i]));
+ }
+
+ Problem[] result = new Problem[problems.size()];
+ problems.toArray(result);
+ return result;
+ } catch(CoreException e){
+ // ignore
+ }
+ return new Problem[0];
+ }
+
+}
+
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/AllTests.java
new file mode 100644
index 000000000..153ddb490
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/AllTests.java
@@ -0,0 +1,116 @@
+/**********************************************************************
+ * 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 23492 2010-02-05 22:57:56Z 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.debug.tests;
+
+import java.util.Enumeration;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.debug.tests.ProjectCreationDecorator;
+import org.eclipse.objectteams.otdt.debug.tests.core.JSR045Tests;
+import org.eclipse.objectteams.otdt.debug.tests.core.SourceDebugExtensionTest;
+import org.eclipse.objectteams.otdt.debug.tests.core.StratumTests;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Tests for automatic testrun
+ */
+public class AllTests extends TestSuite
+{
+
+ /**
+ * Flag that indicates test are in progress
+ */
+ protected boolean fTesting = true;
+
+ /**
+ * Returns the suite. This is required to use the JUnit Launcher.
+ */
+ public static Test suite()
+ {
+ return new AllTests();
+ }
+
+ /**
+ * Construct the test suite.
+ * ADD TESTS HERE
+ */
+ public AllTests()
+ {
+ addTest(new TestSuite(OTProjectCreationDecorator.class));
+
+ addTest(new TestSuite(StratumTests.class));
+
+ addTest(new TestSuite(SourceDebugExtensionTest.class));
+
+ }
+
+ /**
+ * Runs the tests and collects their result in a TestResult. The debug tests
+ * cannot be run in the UI thread or the event waiter blocks the UI when a
+ * resource changes.
+ */
+ public void run(final TestResult result)
+ {
+ final Display display = Display.getCurrent();
+ Thread thread = null;
+ try
+ {
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ for (Enumeration e = tests(); e.hasMoreElements();)
+ {
+ if (result.shouldStop())
+ break;
+ Test test = (Test) e.nextElement();
+ runTest(test, result);
+ }
+ fTesting = false;
+ display.wake();
+ }
+ };
+ thread = new Thread(r);
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ while (fTesting)
+ {
+ try
+ {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/ClassAttributeReader.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/ClassAttributeReader.java
new file mode 100644
index 000000000..9bf88d996
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/ClassAttributeReader.java
@@ -0,0 +1,537 @@
+/**********************************************************************
+ * 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: ClassAttributeReader.java 23492 2010-02-05 22:57:56Z 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.debug.tests;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.IPath;
+
+import de.fub.bytecode.Repository;
+import de.fub.bytecode.classfile.Attribute;
+import de.fub.bytecode.classfile.ClassParser;
+import de.fub.bytecode.classfile.ConstantPool;
+import de.fub.bytecode.classfile.ConstantUtf8;
+import de.fub.bytecode.classfile.JavaClass;
+import de.fub.bytecode.classfile.Method;
+import de.fub.bytecode.classfile.Unknown;
+
+/**
+ * @author ike
+ *
+ * Read class file(s) and display its Attributes. Copied and modified from
+ * otlistclass.
+ *
+ * $Id: ClassAttributeReader.java 23492 2010-02-05 22:57:56Z stephan $
+ */
+public class ClassAttributeReader
+{
+
+ static boolean printCompilerAttributes = false;
+
+ private JavaClass _javaclass;
+
+ private Hashtable _classAttributes = new Hashtable();
+ private Hashtable _methodAttributes = new Hashtable();
+ private String _error;
+
+ public ClassAttributeReader(IPath classFilePath)
+ {
+ if ((_javaclass = Repository.lookupClass(classFilePath.toOSString())) == null)
+ try
+ {
+ _javaclass = new ClassParser(classFilePath.toOSString()).parse(); // May throw
+ readAndStoreAttributes();
+ }
+ catch (ClassFormatError e)
+ {
+ _error = e.getMessage();
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ _error = e.getMessage();
+ e.printStackTrace();
+ }
+ }
+
+ public String getError()
+ {
+ return _error;
+ }
+
+ public boolean isSDEAvailable()
+ {
+ return _classAttributes.containsKey("SourceDebugExtension");
+ }
+
+ public char[] getSDE()
+ {
+ String[] sdeAsString = (String[]) _classAttributes.get("SourceDebugExtension");
+ if (sdeAsString != null && sdeAsString[0] != null)
+ {
+ return sdeAsString[0].toCharArray();
+ }
+ return null;
+ }
+
+
+ public boolean isClassAttributeAvailable(String attributeName)
+ {
+ return _classAttributes.containsKey(attributeName);
+ }
+
+ public String[] getClassAttributeValues(String attributeName)
+ {
+ if (isClassAttributeAvailable(attributeName))
+ return (String[])_classAttributes.get(attributeName);
+ return null;
+ }
+
+ public void readAndStoreAttributes()
+ {
+ Attribute[] attributesAsArray = _javaclass.getAttributes();
+ ConstantPool cp = _javaclass.getConstantPool();
+ String class_name = _javaclass.getClassName();
+ Vector values;
+
+ for (int k = 0; k < attributesAsArray.length; k++)
+ {
+ Attribute actAttr = attributesAsArray[k];
+ Unknown attr = isOTAttribute(actAttr);
+
+ if (attr != null)
+ { //this is a callin attribute
+
+ String attrName = attr.getName();
+ byte[] indizes = attr.getBytes();
+ int count = combineTwoBytes(indizes, 0);
+ int numberOfEntries = 0;
+ String[] names;
+ values = new Vector();
+
+ if (attrName.equals("OTClassFlags"))
+ {
+ int classFlags = combineTwoBytes(indizes, 0);
+ String flagsString = "";
+ if ((classFlags & 1) != 0)
+ flagsString += "team ";
+ if ((classFlags & 2) != 0)
+ flagsString += "role";
+ if ((classFlags & 4) != 0)
+ flagsString += "role-local"; // relevant for the
+ // compiler only.
+ values.add(new String[]{flagsString});
+
+ }
+ else if (attrName.equals("CallinRoleBaseBindings"))
+ {
+ numberOfEntries = 2;
+ int i = 2;
+ while (i <= 2 * count * numberOfEntries)
+ {
+ names = new String[numberOfEntries];
+ i = scanStrings(names, indizes, i, cp);
+ String role_name = names[0];
+ String base_name = names[1];
+ values.add(new String[] { role_name, base_name });
+ }
+ }
+ else if (attrName.equals("CallinMethodMappings"))
+ {
+ numberOfEntries = 5;
+ int i = 2;
+ for (int n = 0; n < count; n++)
+ {
+ names = new String[numberOfEntries];
+ i = scanStrings(names, indizes, i, cp);
+ String wrapper_name = null;
+ String wrapper_signature = null;
+ int index = 0;
+ String binding_label = names[index++];
+ String role_method_name = names[index++];
+ String role_method_signature = names[index++];
+ String real_role_return = names[index++];
+ String binding_modifier = names[index++];
+
+ int base_len = combineTwoBytes(indizes, i);
+ i += 2;
+ names = new String[4];
+ for (int n_base = 0; n_base < base_len; n_base++)
+ {
+ i = scanStrings(names, indizes, i, cp);
+ String base_method_name = names[0];
+ String base_method_signature = names[1];
+ wrapper_name = names[2];
+ wrapper_signature = names[3];
+
+ values.add(new String[] { binding_label, role_method_name,
+ role_method_signature, real_role_return,
+ binding_modifier, base_method_name,
+ base_method_signature, wrapper_name,
+ wrapper_signature});
+ }
+ }
+ }
+ else if (attrName.equals("CalloutBoundFields"))
+ {
+ numberOfEntries = 2;
+ int i = 2;
+ for (int n = 0; n < count; n++)
+ {
+ names = new String[numberOfEntries];
+ i = scanStrings(names, indizes, i, cp);
+ String fieldName = names[0];
+ String fieldType = names[1];
+ int flags = combineTwoBytes(indizes, i);
+ String flagString = (flags & 1) == 1 ? "set " : "get ";
+ if ((flags & 2) != 0)
+ flagString = flagString + "static ";
+ i += 2;
+ values.add(new String[]{flagString, fieldType, fieldName});
+ }
+ }
+ else if (attrName.equals("InaccessibleBaseMethods"))
+ {
+ numberOfEntries = 3;
+ int i = 2;
+ while (i <= 2 * count * numberOfEntries)
+ {
+ names = new String[numberOfEntries];
+ i = scanStrings(names, indizes, i, cp);
+ String base_class = names[0];
+ String base_method = names[1];
+ String base_signature = names[2];
+ values.add(new String[]{base_class, base_method, base_signature});
+ }
+ }
+ else if (attrName.equals("ReferencedTeams"))
+ {
+ numberOfEntries = 1;
+ int i = 2;
+ while (i <= 2 * count * numberOfEntries)
+ {
+ names = new String[numberOfEntries];
+ i = scanStrings(names, indizes, i, cp);
+ String referenced_team = names[0];
+ values.add(new String[]{referenced_team});
+ }
+
+ }
+ else if (attrName.equals("BaseClassTags"))
+ {
+ numberOfEntries = 2;
+ String baseClass = "";
+ int tag = 0;
+ HashMap tagMap = new HashMap();
+
+ int i = 2;
+ while (i <= 2 * count * numberOfEntries)
+ {
+ for (int j = 0; j < numberOfEntries; j++)
+ {
+ int nextIndex = combineTwoBytes(indizes, i);
+ if (j == 0)
+ {
+ ConstantUtf8 cons = (ConstantUtf8) cp
+ .getConstant(nextIndex);
+ baseClass = cons.getBytes();
+ }
+ else if (j == 1)
+ {
+ tag = nextIndex;
+ }
+ i += 2;
+ }
+ tagMap.put(baseClass, new Integer(tag));
+
+ values.add(new String[]{class_name, baseClass, String.valueOf(tag)});
+ }
+ }
+ else if (attrName.equals("PlayedBy"))
+ {
+ names = new String[1];
+ scanStrings(names, indizes, 0, cp);
+ String base_class_name = names[0];
+ values.add(new String[]{base_class_name});
+
+ }
+ else if (attrName.equals("OTCompilerVersion"))
+ {
+ int encodedVersion = combineTwoBytes(indizes, 0);
+ int major = encodedVersion >>> 9;
+ int minor = (encodedVersion >>> 5) & 0xF;
+ int revision = encodedVersion & 0x1F;
+ values.add(new String[]{String.valueOf(major), String.valueOf(minor), String.valueOf(revision)});
+
+ }
+ else if (attrName.equals("CallinPrecedence"))
+ {
+ List precedenceList = new LinkedList();
+ numberOfEntries = 1;
+ int i = 2;
+ while (i <= 2 * count * numberOfEntries)
+ {
+ names = new String[numberOfEntries];
+ i = scanStrings(names, indizes, i, cp);
+ String binding_label = names[0];
+ precedenceList.add(binding_label);
+ }
+ values.add(new String[]{precedenceList.toString()});
+ } // ==== Following: attributes relevant for the compiler only:
+ // ====
+ else if (attrName.equals("RoleFiles"))
+ {
+ numberOfEntries = 1;
+ int i = 2;
+ while (i <= 2 * count * numberOfEntries)
+ {
+ names = new String[numberOfEntries];
+ i = scanStrings(names, indizes, i, cp);
+ String roleFile = names[0];
+ values.add(new String[]{roleFile});
+ }
+ }
+ else if (attrName.equals("CalloutMethodMappings"))
+ {
+ numberOfEntries = 2;
+ int i = 2;
+ for (int n = 0; n < count; n++)
+ {
+ names = new String[numberOfEntries];
+ i = scanStrings(names, indizes, i, cp);
+ int index = 0;
+ String role_method_name = names[index++];
+ String role_method_signature = names[index++];
+
+ values.add(new String[]{role_method_name, role_method_signature});
+ }
+ }
+ else if (attrName.equals("SourceDebugExtension"))
+ {
+ String smap = new String();
+ for (int idx = 0; idx < indizes.length; idx++)
+ {
+ smap += String.valueOf((char) indizes[idx]);
+ }
+ values.add(new String[]{smap});
+ }
+
+ _classAttributes.put(attrName, values);
+ }
+
+ }
+
+ Method[] possibleRoleMethods = _javaclass.getMethods();
+
+ for (int i = 0; i < possibleRoleMethods.length; i++)
+ {
+ Method meth = possibleRoleMethods[i];
+ Attribute[] attrsMethod = meth.getAttributes();
+ String method_name = meth.getName();
+ //TODO(ike): handle and store attributes of methodes also
+// scanMethodOTAttributes(attrsMethod, class_name, method_name, cp);
+ }
+ }
+
+ Unknown isOTAttribute(Attribute attr)
+ {
+ if (attr instanceof Unknown)
+ {
+ Unknown unknown = (Unknown) attr;
+ String attrName = unknown.getName();
+ if (attrName.equals("CallinRoleBaseBindings")
+ || attrName.equals("CallinMethodMappings")
+ || attrName.equals("CallinParamMappings")
+ || attrName.equals("CallinFlags")
+ || attrName.equals("CalloutBoundFields")
+ || attrName.equals("WrappedRoleSignature")
+ || attrName.equals("WrappedBaseSignature")
+ || attrName.equals("InaccessibleBaseMethods")
+ || attrName.equals("ReferencedTeams")
+ || attrName.equals("BaseClassTags")
+ || attrName.equals("PlayedBy")
+ || attrName.equals("Modifiers")
+ || attrName.equals("OTCompilerVersion")
+ || attrName.equals("OTClassFlags")
+ || attrName.equals("CallinPrecedence")
+ || attrName.equals("SourceDebugExtension"))
+ {
+ return unknown;
+ }
+ if (printCompilerAttributes)
+ {
+ if (attrName.equals("RoleFiles")
+ || attrName.equals("CalloutMethodMappings")
+ || attrName.equals("Modifiers")
+ || attrName.equals("CopyInheritanceSrc"))
+ {
+ return unknown;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * combines two int's representing the higher and the lower part of a two
+ * byte number.
+ *
+ * @param first
+ * the first (higer?) byte
+ * @param second
+ * the second (lower?) byte
+ * @return the combined number
+ */
+ int combineTwoBytes(byte[] indizes, int start)
+ {
+ int first = indizes[start];
+ int second = indizes[start + 1];
+ int twoBytes = 0;
+
+ twoBytes = twoBytes | (first & 0xff);
+ twoBytes = twoBytes << 8;
+ twoBytes = twoBytes | (second & 0xff);
+ return twoBytes;
+ }
+
+ /**
+ * Read some strings from a byte array.
+ *
+ * @param entries
+ * Result array to be provided by caller.
+ * @param indizes
+ * buffer of read bytes to be provided by caller, consists if
+ * indizes into the constant pool
+ * @param i
+ * current index into indizes
+ * @param cp
+ * the pool.
+ * @result updated value of <tt>i</tt>.
+ */
+ int scanStrings(String[] entries, byte[] indizes, int i, ConstantPool cp)
+ {
+ for (int j = 0; j < entries.length; j++)
+ {
+ int nextIndex = combineTwoBytes(indizes, i);
+ ConstantUtf8 cons = (ConstantUtf8) cp.getConstant(nextIndex);
+ String content = cons.getBytes();
+ entries[j] = content;
+ i += 2;
+ }
+ return i;
+ }
+
+ void scanMethodOTAttributes(Attribute[] attributes, String class_name,
+ String method_name, ConstantPool cp)
+ {
+ Vector methodAttributesValues = new Vector();
+ boolean ot_attribute_found = false;
+ for (int k = 0; k < attributes.length; k++)
+ {
+ Attribute actAttr = attributes[k];
+ Unknown attr = isOTAttribute(actAttr);
+
+ if (attr != null)
+ { //this is an OT attribute
+ if (ot_attribute_found == false)
+ {
+ System.out.println();
+ System.out.println("--- in method '" + method_name
+ + "': ---");
+ ot_attribute_found = true;
+ }
+ String attrName = attr.getName();
+ if (attrName.equals("CallinParamMappings"))
+ {
+ System.out.println("CallinParamMappings:");
+ byte[] indizes = attr.getBytes();
+ int[] positions = null;
+ if (indizes == null)
+ throw new RuntimeException("Unexpected null attr");
+ int count = combineTwoBytes(indizes, 0);
+ positions = new int[count];
+ int p = 2;
+ for (int i = 0; i < count; i++, p += 2)
+ {
+ positions[i] = combineTwoBytes(indizes, p);
+ System.out.println("\t" + i + " <- " + positions[i]);
+ }
+
+ }
+ else if (attrName.equals("WrappedRoleSignature"))
+ {
+ System.out.println("WrappedRoleSignature:");
+ byte[] indizes = attr.getBytes();
+ String[] names = new String[1];
+ scanStrings(names, indizes, 0, cp);
+ String role_signature = names[0];
+ System.out.println("\t" + role_signature);
+ }
+ else if (attrName.equals("WrappedBaseSignature"))
+ {
+ System.out.println("WrappedBaseSignature:");
+ byte[] indizes = attr.getBytes();
+ String[] names = new String[1];
+ scanStrings(names, indizes, 0, cp);
+ String base_signature = names[0];
+ System.out.println("\t" + base_signature);
+ }
+ else if (attrName.equals("CallinFlags"))
+ {
+ System.out.print("CallinFlags: ");
+ byte[] bytes = attr.getBytes();
+ int flags = combineTwoBytes(bytes, 0);
+ if ((flags & 1) != 0)
+ System.out.print("OVERRIDE ");
+ if ((flags & 2) != 0)
+ System.out.print("WRAPPER ");
+ if ((flags & 4) != 0)
+ System.out.print("REPLACE ");
+ System.out.println();
+ } // ==== Following: attributes relevant for the compiler only:
+ // ====
+ else if (attrName.equals("Modifiers"))
+ {
+ System.out.print("Modifiers: 0x");
+ byte[] bytes = attr.getBytes();
+ int flags = combineTwoBytes(bytes, 0);
+ System.out.println(Integer.toHexString(flags));
+ }
+ else if (attrName.equals("CopyInheritanceSrc"))
+ {
+ System.out.println("CopyInheritanceSrc:");
+ byte[] indizes = attr.getBytes();
+ String[] names = new String[1];
+ scanStrings(names, indizes, 0, cp);
+ String src_name = names[0];
+ System.out.println("\t" + src_name);
+ }
+
+ }
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/DebugTestsPlugin.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/DebugTestsPlugin.java
new file mode 100644
index 000000000..61195e69f
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/DebugTestsPlugin.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: DebugTestsPlugin.java 23492 2010-02-05 22:57:56Z 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.debug.tests;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.plugin.*;
+import org.osgi.framework.BundleContext;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class DebugTestsPlugin extends AbstractUIPlugin {
+ //The shared instance.
+ private static DebugTestsPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public DebugTestsPlugin() {
+ super();
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static DebugTestsPlugin getDefault() {
+ return plugin;
+ }
+
+ protected String getPluginID()
+ {
+ return "org.eclispe.objectteams.otdt.debug.tests";
+ }
+
+ /**
+ * Returns the OS path to the directory that contains this plugin and adds a subpath if wanted.
+ *
+ */
+ protected File getPluginDirectoryPath(IPath test_src_dir)
+ {
+ try
+ {
+ URL platformURL = Platform
+ .getBundle(getPluginID())
+ .getEntry("/");
+ if (test_src_dir != null)
+ platformURL = new URL(platformURL, test_src_dir.toString());
+
+ return new File(Platform.asLocalURL(platformURL).getFile());
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/ManualDebugTestSuite.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/ManualDebugTestSuite.java
new file mode 100644
index 000000000..bf8b4341d
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/ManualDebugTestSuite.java
@@ -0,0 +1,102 @@
+/**********************************************************************
+ * 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: ManualDebugTestSuite.java 23492 2010-02-05 22:57:56Z 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.debug.tests;
+
+import java.util.Enumeration;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.eclipse.jdt.debug.tests.ProjectCreationDecorator;
+import org.eclipse.objectteams.otdt.debug.tests.core.JSR045Tests;
+import org.eclipse.objectteams.otdt.debug.tests.core.SourceDebugExtensionTest;
+import org.eclipse.objectteams.otdt.debug.tests.core.StratumTests;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Tests that are to be run manually by the debug team, in addition to
+ * automated tests.
+ */
+public class ManualDebugTestSuite extends TestSuite {
+
+ /**
+ * Flag that indicates test are in progress
+ */
+ protected boolean fTesting = true;
+
+ /**
+ * Returns the suite. This is required to
+ * use the JUnit Launcher.
+ */
+ public static Test suite() {
+ return new ManualDebugTestSuite();
+ }
+
+ /**
+ * Construct the test suite.
+ */
+ public ManualDebugTestSuite() {
+ addTest(new TestSuite(OTProjectCreationDecorator.class));
+
+ addTest(new TestSuite(StratumTests.class));
+
+ }
+
+ /**
+ * Runs the tests and collects their result in a TestResult.
+ * The debug tests cannot be run in the UI thread or the event
+ * waiter blocks the UI when a resource changes.
+ */
+ public void run(final TestResult result) {
+ final Display display = Display.getCurrent();
+ Thread thread = null;
+ try {
+ Runnable r = new Runnable() {
+ public void run() {
+ for (Enumeration e= tests(); e.hasMoreElements(); ) {
+ if (result.shouldStop() )
+ break;
+ Test test= (Test)e.nextElement();
+ runTest(test, result);
+ }
+ fTesting = false;
+ display.wake();
+ }
+ };
+ thread = new Thread(r);
+ thread.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ while (fTesting) {
+ try {
+ if (!display.readAndDispatch())
+ display.sleep();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
+
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/OTProjectCreationDecorator.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/OTProjectCreationDecorator.java
new file mode 100644
index 000000000..88f53df56
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/OTProjectCreationDecorator.java
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Fraunhofer FIRST - Initial API and implementation
+ * Technical University Berlin - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.objectteams.otdt.debug.tests;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.debug.core.JDIDebugModel;
+import org.eclipse.jdt.debug.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
+import org.eclipse.objectteams.otdt.debug.OTDebugPlugin;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+
+public class OTProjectCreationDecorator extends AbstractOTDTDebugTest {
+
+ public static boolean fgReady = false;
+
+ /**
+ * Constructor
+ * @param name
+ */
+ public OTProjectCreationDecorator(String name) {
+ super(name);
+ fgReady = true;
+ }
+
+ public static boolean isReady() {
+ return fgReady;
+ }
+
+// public void testTurnOffAutobuild() throws Exception {
+// IWorkspace workspace = ResourcesPlugin.getWorkspace();
+// IWorkspaceDescription description = workspace.getDescription();
+// workspace.isAutoBuilding();
+// description.setAutoBuilding(false);
+// workspace.setDescription(description);
+// assertFalse(workspace.isAutoBuilding());
+// }
+
+ public void testPerspectiveSwtich() {
+ DebugUIPlugin.getStandardDisplay().syncExec(new Runnable() {
+ public void run() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IPerspectiveDescriptor descriptor = workbench.getPerspectiveRegistry().findPerspectiveWithId(IDebugUIConstants.ID_DEBUG_PERSPECTIVE);
+ IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
+ activePage.setPerspective(descriptor);
+ // hide variables and breakpoints view to reduce simaltaneous conflicting requests on debug targets
+ IViewReference ref = activePage.findViewReference(IDebugUIConstants.ID_VARIABLE_VIEW);
+ activePage.hideView(ref);
+ ref = activePage.findViewReference(IDebugUIConstants.ID_BREAKPOINT_VIEW);
+ activePage.hideView(ref);
+ }
+ });
+ }
+
+ public void testProjectCreation() throws Exception {
+ // delete any pre-existing project
+ IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject("DebugTests");
+ if (pro.exists()) {
+ pro.delete(true, true, null);
+ }
+ IWorkspaceDescription wsDescription = ResourcesPlugin.getWorkspace().getDescription();
+ wsDescription.setAutoBuilding(false);
+ ResourcesPlugin.getWorkspace().setDescription(wsDescription);
+
+ // create & configure project and import source
+ fJavaProject = org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper.createOTJavaProject("DebugTests", "bin");
+ fJavaProject.setOption(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.IGNORE);
+ fJavaProject.setOption(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
+ fJavaProject.setOption(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ fJavaProject.setOption(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
+ IPackageFragmentRoot src = JavaProjectHelper.addSourceContainer(fJavaProject, "src");
+
+//{ObjectTeams: rootfile-path is now org.eclipse.objectteams.otdt.debug.tests + "testprograms"
+ File root = DebugTestsPlugin.getDefault().getPluginDirectoryPath(JavaProjectHelper.TEST_SRC_DIR);
+//ike}
+ JavaProjectHelper.importFilesFromDirectory(root, src.getPath(), null);
+
+ // import classfiles
+ root = DebugTestsPlugin.getDefault().getPluginDirectoryPath(new Path("classfiles"));
+ JavaProjectHelper.importFilesFromDirectory(root, src.getPath(), null);
+
+ // add rt.jar
+ IVMInstall vm = JavaRuntime.getDefaultVMInstall();
+ assertNotNull("No default JRE", vm);
+ JavaProjectHelper.addContainerEntry(fJavaProject, new Path(JavaRuntime.JRE_CONTAINER));
+//{ObjectTeams: add otre.jar:
+ JavaProjectHelper.addContainerEntry(fJavaProject, OTREContainer.OTRE_CONTAINER_PATH);
+// SH}
+ pro = fJavaProject.getProject();
+
+ // all set up, can start auto-building now:
+ wsDescription.setAutoBuilding(true);
+ ResourcesPlugin.getWorkspace().setDescription(wsDescription);
+
+ // create launch configuration folder
+
+ IFolder folder = pro.getFolder("launchConfigurations");
+ if (folder.exists()) {
+ folder.delete(true, null);
+ }
+ folder.create(true, true, null);
+
+ // delete any existing launch configs
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ for (int i = 0; i < configs.length; i++) {
+ configs[i].delete();
+ }
+
+ // this one used by StratumTests:
+ createLaunchConfiguration("Breakpoints");
+//{ObjectTeams: own tests:
+ createLaunchConfiguration("rofitests.RoFiTeam", OTDebugPlugin.OT_LAUNCH_CONFIGURATION_TYPE);
+ createLaunchConfiguration("copyinheritancetests.SubTeam", OTDebugPlugin.OT_LAUNCH_CONFIGURATION_TYPE);
+ createLaunchConfiguration("copyinheritancetests.SubTeam2", OTDebugPlugin.OT_LAUNCH_CONFIGURATION_TYPE);
+ createLaunchConfiguration("copyinheritancetests.SubTeam3", OTDebugPlugin.OT_LAUNCH_CONFIGURATION_TYPE);
+// SH}
+ }
+
+ /**
+ * Create a project with non-default, mulitple output locations.
+ *
+ * @throws Exception
+ */
+ public void _testMultipleOutputProjectCreation() throws Exception {
+ // delete any pre-existing project
+ IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject("MultiOutput");
+ if (pro.exists()) {
+ pro.delete(true, true, null);
+ }
+ // create project with two src folders and output locations
+ IJavaProject project = org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper.createOTJavaProject("MultiOutput", (String)null);
+ JavaProjectHelper.addSourceContainer(project, "src1", "bin1");
+ JavaProjectHelper.addSourceContainer(project, "src2", "bin2");
+
+ // add rt.jar
+ IVMInstall vm = JavaRuntime.getDefaultVMInstall();
+ assertNotNull("No default JRE", vm);
+ JavaProjectHelper.addContainerEntry(project, new Path(JavaRuntime.JRE_CONTAINER));
+ }
+
+ /**
+ * Set up preferences that need to be changed for the tests
+ */
+ public void _testSetPreferences() {
+ IPreferenceStore debugUIPreferences = DebugUIPlugin.getDefault().getPreferenceStore();
+ // Don't prompt for perspective switching
+ debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_SWITCH_PERSPECTIVE_ON_SUSPEND, MessageDialogWithToggle.ALWAYS);
+ debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_SWITCH_TO_PERSPECTIVE, MessageDialogWithToggle.ALWAYS);
+ debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE, MessageDialogWithToggle.NEVER);
+ debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_WAIT_FOR_BUILD, MessageDialogWithToggle.ALWAYS);
+ debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, MessageDialogWithToggle.ALWAYS);
+ debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH, MessageDialogWithToggle.NEVER);
+
+ String property = System.getProperty("debug.workbenchActivation");
+ if (property != null && property.equals("off")) {
+ debugUIPreferences.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, false);
+ debugUIPreferences.setValue(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, false);
+ debugUIPreferences.setValue(IInternalDebugUIConstants.PREF_ACTIVATE_DEBUG_VIEW, false);
+ debugUIPreferences.setValue(IDebugUIConstants.PREF_ACTIVATE_WORKBENCH, false);
+ }
+
+ IPreferenceStore jdiUIPreferences = JDIDebugUIPlugin.getDefault().getPreferenceStore();
+ // Turn off suspend on uncaught exceptions
+ jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS, false);
+ jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_SUSPEND_ON_COMPILATION_ERRORS, false);
+ // Don't warn about HCR failures
+ jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_ALERT_HCR_FAILED, false);
+ jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_ALERT_HCR_NOT_SUPPORTED, false);
+ jdiUIPreferences.setValue(IJDIPreferencesConstants.PREF_ALERT_OBSOLETE_METHODS, false);
+ // Set the timeout preference to a high value, to avoid timeouts while
+ // testing
+ JDIDebugModel.getPreferences().setDefault(JDIDebugModel.PREF_REQUEST_TIMEOUT, 10000);
+ // turn off monitor information
+ jdiUIPreferences.setValue(IJavaDebugUIConstants.PREF_SHOW_MONITOR_THREAD_INFO, false);
+ }
+
+ public void testBuild() throws Exception {
+ // force a full build and wait
+ ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ waitForBuild();
+ }
+
+// public void testTurnOnAutoBuild() throws Exception {
+// // turn on autobuild again.
+// IWorkspace workspace = ResourcesPlugin.getWorkspace();
+// IWorkspaceDescription description = workspace.getDescription();
+// workspace.isAutoBuilding();
+// description.setAutoBuilding(true);
+// workspace.setDescription(description);
+// assertTrue(workspace.isAutoBuilding());
+// }
+
+ /**
+ * test if builds completed successfully and output directory contains class
+ * files.
+ */
+ public void _testOutputFolderNotEmpty() throws Exception {
+ waitForBuild();
+ IPath outputLocation = fJavaProject.getOutputLocation();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ IResource resource = root.findMember(outputLocation);
+ assertNotNull("Project output location is null", resource);
+ assertTrue("Project output location does not exist", resource.exists());
+ assertTrue("Project output is not a folder", (resource.getType() == IResource.FOLDER));
+ IFolder folder = (IFolder) resource;
+ IResource[] children = folder.members();
+ assertTrue("output folder is empty", children.length > 0);
+ }
+
+// public void testForUnexpectedErrorsInProject() throws Exception {
+// waitForBuild();
+// IProject project = fJavaProject.getProject();
+// IMarker[] markers = project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+// int errors = 0;
+// for (int i = 0; i < markers.length; i++) {
+// IMarker marker = markers[i];
+// Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
+// IResource resource = marker.getResource();
+//
+// System.out.println(resource.getName());
+//
+// if (severity != null && severity.intValue() >= IMarker.SEVERITY_ERROR) {
+// errors++;
+// }
+// }
+// assertTrue("Unexpected compile errors in project. Expected 1, found " + markers.length, errors == 1);
+// }
+
+ public void _testClassFilesGenerated() throws Exception {
+ waitForBuild();
+ IPath outputLocation = fJavaProject.getOutputLocation();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ IFolder folder = (IFolder) root.findMember(outputLocation);
+ IResource[] children = folder.members();
+ int classFiles = 0;
+ for (int i = 0; i < children.length; i++) {
+ IResource child = children[i];
+ if (child.getType() == IResource.FILE) {
+ IFile file = (IFile) child;
+ String fileExtension = file.getFileExtension();
+ if (fileExtension.equals("class")) {
+ classFiles++;
+ }
+ }
+ }
+ assertTrue("No class files exist", (classFiles > 0));
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/Problem.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/Problem.java
new file mode 100644
index 000000000..7bd88e7e6
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/Problem.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.objectteams.otdt.debug.tests;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaModelMarker;
+
+// from org.eclipse.jdt.core.tests.builder
+public class Problem implements Comparable {
+ private String location;
+ private String message;
+ private IPath resourcePath;
+ private int start = -1, end = -1, categoryId = -1;
+ private String sourceId;
+ private int severity = IMarker.SEVERITY_ERROR;
+
+ public Problem(String location, String message, IPath resourcePath, int start, int end, int categoryId, int severity) {
+ this.location = location;
+ this.message = message;
+ this.resourcePath = resourcePath;
+ this.start = start;
+ this.end = end;
+ this.categoryId = categoryId;
+ this.severity = severity;
+// if ((start > 0 || end > 0) && categoryId <= 0) {
+// System.out.print("is categoryId properly set ? new Problem(\"" + location + "\", \"" + message + "\", \"" + resourcePath + "\"");
+// System.out.print(", " + start + ", " + end + ", " + categoryId);
+// System.out.println(")");
+// }
+ }
+
+ public Problem(IMarker marker){
+ this.location = marker.getAttribute(IMarker.LOCATION, ""); //$NON-NLS-1$
+ this.message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
+ this.resourcePath = marker.getResource().getFullPath();
+ this.start = marker.getAttribute(IMarker.CHAR_START, -1);
+ this.end = marker.getAttribute(IMarker.CHAR_END, -1);
+ this.categoryId = marker.getAttribute(IJavaModelMarker.CATEGORY_ID, -1);
+ this.sourceId = marker.getAttribute(IMarker.SOURCE_ID, "missing");
+ this.severity = marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ }
+ public int getCategoryId() {
+ return this.categoryId;
+ }
+
+/**
+ * Return the IMarker.SOURCE_ID attribute of the underlying marker if any.
+ * Value null denotes a problem created from explicit structural attributes
+ * (instead of using a source marker). Value "missing" denotes that the marker
+ * used to initialize the problem had no IMarker.SOURCE_ID attribute.
+ * @return the IMarker.SOURCE_ID attribute of the underlying marker if any
+ */
+public String getSourceId() {
+ return this.sourceId;
+}
+ /**
+ * Gets the location.
+ * @return Returns a String
+ */
+ public String getLocation() {
+ return this.location;
+ }
+ /**
+ * Gets the message.
+ * @return Returns a String
+ */
+ public String getMessage() {
+ return this.message;
+ }
+ /**
+ * Gets the resourcePath.
+ * @return Returns a IPath
+ */
+ public IPath getResourcePath() {
+ return this.resourcePath;
+ }
+
+public int getSeverity() {
+ return this.severity;
+}
+
+ public int getStart() {
+ return this.start;
+ }
+
+ public int getEnd() {
+ return this.end;
+ }
+
+ public String toString(){
+// ignore locations since the builder no longer finds exact Java elements
+// return "Problem : " + message + " [ resource : <" + resourcePath + "> location <"+ location + "> ]";
+ return
+ "Problem : "
+ + this.message
+ + " [ resource : <"
+ + this.resourcePath
+ + ">"
+ + (" range : <" + this.start + "," + this.end + ">")
+ + (" category : <" + this.categoryId + ">")
+ + (" severity : <" + this.severity + ">")
+ + "]";
+ }
+
+ public boolean equals(Object o){
+ if(o instanceof Problem){
+ return toString().equals(o.toString());
+ }
+ return false;
+ }
+
+ public int compareTo(Object o) {
+ if(o instanceof Problem){
+ Problem problem = (Problem) o;
+ /* Replace initial implementation with toString() comparison otherwise the problems order may change
+ * when different VM are used (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=213570)...
+ if (!(this.getLocation().equals(problem.getLocation()))) {
+ return this.getLocation().compareTo(problem.getLocation());
+ }
+ if (this.getStart() < problem.getStart()) {
+ return -1;
+ }
+ if (this.getEnd() < problem.getEnd()) {
+ return -1;
+ }
+ return this.getMessage().compareTo(problem.getMessage());
+ */
+ return toString().compareTo(problem.toString());
+ }
+ return -1;
+ }
+}
+
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/CopyInheritanceBreakpointTest.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/CopyInheritanceBreakpointTest.java
new file mode 100644
index 000000000..9c5152bcb
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/CopyInheritanceBreakpointTest.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: CopyInheritanceBreakpointTest.java 23492 2010-02-05 22:57:56Z 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.debug.tests.core;
+
+import junit.framework.AssertionFailedError;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jdt.debug.core.IJavaReferenceType;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.TextConsole;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.debug.tests.AbstractOTDTDebugTest;
+import org.eclipse.objectteams.otdt.debug.tests.Problem;
+
+public class CopyInheritanceBreakpointTest extends AbstractOTDTDebugTest {
+
+ public CopyInheritanceBreakpointTest(String name) {
+ super(name);
+ }
+
+ public void testBreakInPhantomRoleMethod() throws Exception {
+ // set breakpoint in this type:
+ String breakTeamName = "copyinheritancetests.SuperTeam";
+ // launch this type:
+ String launchTypeName = "copyinheritancetests.SubTeam";
+ // expect this type at the top stack frame:
+ String breakTypeName = "copyinheritancetests.SubTeam$__OT__R";
+ // expect this source file to be found via SMAP:
+ String sourceFile = "SuperTeam.java";
+
+ createLineBreakpoint(6, breakTeamName); // sysout within roleMethod1
+
+ IJavaThread thread= null;
+ try {
+ waitForBuild();
+ expectNoErrors("DebugTests");
+
+ thread= launchToBreakpoint(launchTypeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+
+ IJavaReferenceType type = ((IJavaStackFrame)thread.getTopStackFrame()).getReferenceType();
+ assertEquals("Stopped in wrong type", breakTypeName, type.getName());
+
+ String methodName = ((IJavaStackFrame)thread.getTopStackFrame()).getMethodName();
+ assertEquals("Stopped in wrong method", "roleMethod1", methodName);
+
+ String sourceName = ((IJavaStackFrame)thread.getTopStackFrame()).getSourceName(ISMAPConstants.OTJ_STRATUM_NAME);
+ assertEquals("Lookup gave wrong source name", sourceFile, sourceName);
+
+ } catch (AssertionFailedError fail) {
+ if (thread != null) {
+ IConsole console = DebugUITools.getConsole(thread.getLaunch().getProcesses()[0]);
+ if (console instanceof TextConsole) {
+ TextConsole textConsole = (TextConsole)console;
+ String string = textConsole.getDocument().get();
+ System.out.println("Console output follows:");
+ System.out.println(string);
+ }
+ System.out.println();
+ }
+ throw fail;
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ public void testBreakInRoleMethod() throws Exception {
+ // set breakpoint in this type:
+ String breakTeamName = "copyinheritancetests.SuperTeam";
+ // launch this type:
+ String launchTypeName = "copyinheritancetests.SubTeam2";
+ // expect this type at the top stack frame:
+ String breakTypeName = "copyinheritancetests.SubTeam2$__OT__R";
+ // expect this source file to be found via SMAP:
+ String sourceFile = "SuperTeam.java";
+
+ createLineBreakpoint(6, breakTeamName); // sysout with roleMethod1
+
+ IJavaThread thread= null;
+ try {
+ waitForBuild();
+ expectNoErrors("DebugTests");
+
+ thread= launchToBreakpoint(launchTypeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+
+ IJavaReferenceType type = ((IJavaStackFrame)thread.getTopStackFrame()).getReferenceType();
+ assertEquals("Stopped in wrong type", breakTypeName, type.getName());
+
+ String methodName = ((IJavaStackFrame)thread.getTopStackFrame()).getMethodName();
+ assertEquals("Stopped in wrong method", "roleMethod1", methodName);
+
+ String sourceName = ((IJavaStackFrame)thread.getTopStackFrame()).getSourceName(ISMAPConstants.OTJ_STRATUM_NAME);
+ assertEquals("Lookup gave wrong source name", sourceFile, sourceName);
+
+ } catch (AssertionFailedError fail) {
+ if (thread != null) {
+ IConsole console = DebugUITools.getConsole(thread.getLaunch().getProcesses()[0]);
+ if (console instanceof TextConsole) {
+ TextConsole textConsole = (TextConsole)console;
+ String string = textConsole.getDocument().get();
+ System.out.println("Console output follows:");
+ System.out.println(string);
+ }
+ System.out.println();
+ }
+ throw fail;
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ public void testBreakInRoleFileMethod() throws Exception {
+ // set breakpoint in this type:
+ String breakRoleName = "copyinheritancetests.SuperTeam3.R";
+ // launch this type:
+ String launchTypeName = "copyinheritancetests.SubTeam3";
+ // expect this type at the top stack frame:
+ String breakTypeName = "copyinheritancetests.SubTeam3$__OT__R";
+ // expect this source file to be found via SMAP:
+ String sourceFile = "R.java";
+
+ createLineBreakpoint(4, breakRoleName); // sysout within roleMethod1
+
+ IJavaThread thread= null;
+ try {
+ waitForBuild();
+ expectNoErrors("DebugTests");
+
+ thread= launchToBreakpoint(launchTypeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+
+ IJavaReferenceType type = ((IJavaStackFrame)thread.getTopStackFrame()).getReferenceType();
+ assertEquals("Stopped in wrong type", breakTypeName, type.getName());
+
+ String methodName = ((IJavaStackFrame)thread.getTopStackFrame()).getMethodName();
+ assertEquals("Stopped in wrong method", "roleMethod1", methodName);
+
+ String sourceName = ((IJavaStackFrame)thread.getTopStackFrame()).getSourceName(ISMAPConstants.OTJ_STRATUM_NAME);
+ assertEquals("Lookup gave wrong source name", sourceFile, sourceName);
+
+ } catch (AssertionFailedError fail) {
+ if (thread != null) {
+ IConsole console = DebugUITools.getConsole(thread.getLaunch().getProcesses()[0]);
+ if (console instanceof TextConsole) {
+ TextConsole textConsole = (TextConsole)console;
+ String string = textConsole.getDocument().get();
+ System.out.println("Console output follows:");
+ System.out.println(string);
+ }
+ System.out.println();
+ }
+ throw fail;
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ void expectNoErrors(String projectName) {
+ Problem[] problems = getProblemsFor(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName));
+ if (problems != null && problems.length > 0) {
+ for (Problem problem : problems) {
+ System.out.println(problem.toString());
+ }
+ fail("Should not have compile errors");
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/JSR045Tests.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/JSR045Tests.java
new file mode 100644
index 000000000..e512faf11
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/JSR045Tests.java
@@ -0,0 +1,141 @@
+/**********************************************************************
+ * 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: JSR045Tests.java 23492 2010-02-05 22:57:56Z 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.debug.tests.core;
+
+import org.eclipse.jdt.debug.core.IJavaClassType;
+import org.eclipse.jdt.debug.core.IJavaDebugTarget;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.objectteams.otdt.debug.tests.AbstractOTDTDebugTest;
+
+/**
+ * Tests strata.
+ */
+public class JSR045Tests extends AbstractOTDTDebugTest {
+
+ public JSR045Tests(String name) {
+ super(name);
+ }
+
+ /**
+ * Test available strata on a type.
+ *
+ * @throws Exception
+ */
+ public void testAvailableStrata() throws Exception {
+ String typeName = "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaClassType type = ((IJavaStackFrame)thread.getTopStackFrame()).getDeclaringType();
+ String[] strata = type.getAvailableStrata();
+ assertEquals("Wrong number of available strata", 1, strata.length);
+ assertEquals("Wrong strata", "Java", strata[0]);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ /**
+ * Test default stratum on a type.
+ *
+ * @throws Exception
+ */
+ public void testDefaultStratum() throws Exception {
+ String typeName = "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaClassType type = ((IJavaStackFrame)thread.getTopStackFrame()).getDeclaringType();
+ String stratum = type.getDefaultStratum();
+ assertEquals("Wrong strata", "Java", stratum);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ /**
+ * Test set / get default stratum on a java debug target.
+ *
+ * @throws Exception
+ */
+ public void testSetGetDefaultStratum() throws Exception {
+ String typeName = "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaDebugTarget debugTarget= (IJavaDebugTarget)thread.getDebugTarget();
+ String stratum= debugTarget.getDefaultStratum();
+ assertNull("Default strata should be 'null'", stratum);
+ debugTarget.setDefaultStratum("strataTest");
+ stratum= debugTarget.getDefaultStratum();
+ assertEquals("Wrong strata", "strataTest", stratum);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ public void testGetLineInStratum() throws Exception {
+ String typeName= "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaStackFrame stackFrame= (IJavaStackFrame)thread.getTopStackFrame();
+ int lineNumber= stackFrame.getLineNumber("Java");
+ assertEquals("Wrong line number", 81, lineNumber);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ public void testGetSourceNameInStratum() throws Exception {
+ String typeName= "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaStackFrame stackFrame= (IJavaStackFrame)thread.getTopStackFrame();
+ String sourceName= stackFrame.getSourceName("Java");
+ assertEquals("Wrong source name", "Breakpoints.java", sourceName);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/RoFiBreakpointTests.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/RoFiBreakpointTests.java
new file mode 100644
index 000000000..9931d1b68
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/RoFiBreakpointTests.java
@@ -0,0 +1,96 @@
+/**********************************************************************
+ * This file is part of "Object Teams Development Tooling"-Software
+ *
+ * Copyright 2008 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: RoFiBreakpointTests.java 23485 2010-02-05 22:00:22Z stephan $
+ *
+ * Please visit http://www.eclipse.org/objectteams for updates and contact.
+ *
+ * Contributors:
+ * Technical University Berlin - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.objectteams.otdt.debug.tests.core;
+
+import org.eclipse.jdt.debug.core.IJavaReferenceType;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.objectteams.otdt.core.compiler.ISMAPConstants;
+import org.eclipse.objectteams.otdt.debug.tests.AbstractOTDTDebugTest;
+
+public class RoFiBreakpointTests extends AbstractOTDTDebugTest {
+
+ public RoFiBreakpointTests(String name) {
+ super(name);
+ }
+
+
+
+ /**
+ * Test breaking in a team method
+ *
+ * @throws Exception
+ */
+ public void testBreakInTeamMethod1() throws Exception {
+ String typeName = "rofitests.RoFiTeam";
+ createLineBreakpoint(6, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaReferenceType type = ((IJavaStackFrame)thread.getTopStackFrame()).getReferenceType();
+ assertEquals("Stopped in wrong type", typeName, type.getName());
+ String methodName = ((IJavaStackFrame)thread.getTopStackFrame()).getMethodName();
+ assertEquals("Stopped in wrong method", "doit", methodName);
+
+ assertEquals("Wrong source name", "RoFiTeam.java", ((IJavaStackFrame)thread.getTopStackFrame()).getSourceName(ISMAPConstants.OTJ_STRATUM_NAME));
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+
+ /**
+ * Test breaking in a method of a role file.
+ *
+ * @throws Exception
+ */
+ public void testBreakInRoFiMethod1() throws Exception {
+ String typeName = "rofitests.RoFiTeam";
+ String roleName = "rofitests.RoFiTeam.RoFiRole";
+ String roleBinaryName = "rofitests.RoFiTeam$__OT__RoFiRole";
+ createLineBreakpoint(5, roleName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaReferenceType type = ((IJavaStackFrame)thread.getTopStackFrame()).getReferenceType();
+ assertEquals("Stopped in wrong type", roleBinaryName, type.getName());
+ String methodName = ((IJavaStackFrame)thread.getTopStackFrame()).getMethodName();
+ assertEquals("Stopped in wrong method", "doRolish", methodName);
+
+
+ assertEquals("Wrong source name", "RoFiRole.java", ((IJavaStackFrame)thread.getTopStackFrame()).getSourceName(ISMAPConstants.OTJ_STRATUM_NAME));
+// IPackageFragmentRoot root = getPackageFragmentRoot(getJavaProject(), "src");
+// IJavaSourceLocation location = new PackageFragmentRootSourceLocation(root);
+// String[] javaSourcePaths = type.getSourcePaths("java");
+// String[] otjSourcePaths = type.getSourcePaths(ISMAPConstants.OTJ_STRATUM_NAME);
+// System.out.println("j:"+javaSourcePaths.length+", otj:"+otjSourcePaths.length);
+//
+// ICompilationUnit cu = (ICompilationUnit) location.findSourceElement(otjSourcePaths[0]);
+// assertNotNull("CU should not be null", cu);
+// assertTrue("CU should exist", cu.exists());
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/SourceDebugExtensionTest.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/SourceDebugExtensionTest.java
new file mode 100644
index 000000000..224544ccb
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/SourceDebugExtensionTest.java
@@ -0,0 +1,79 @@
+/**********************************************************************
+ * 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: SourceDebugExtensionTest.java 23492 2010-02-05 22:57:56Z 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.debug.tests.core;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.objectteams.otdt.debug.tests.AbstractOTDTDebugTest;
+import org.eclipse.objectteams.otdt.debug.tests.ClassAttributeReader;
+
+/**
+ * @author ike
+ *
+ * Tests the availability and correctness of SDE in a given classfile.
+ * $Id: SourceDebugExtensionTest.java 23492 2010-02-05 22:57:56Z stephan $
+ */
+public class SourceDebugExtensionTest extends AbstractOTDTDebugTest
+{
+
+ public SourceDebugExtensionTest(String name)
+ {
+ super(name);
+ }
+
+ public void testSDEAbsenceForSimpleClass() throws Exception
+ {
+ ClassAttributeReader reader = getAttributeReader("SimpleClass");
+ assertNotNull("An error occurs while creating ClassAttributeReader", reader);
+ assertFalse("SDE should be absent.", reader.isSDEAvailable());
+ }
+
+ public void testSDEAbsenceForSimpleTeam() throws Exception
+ {
+ ClassAttributeReader reader = getAttributeReader("SimpleTeam");
+ assertNotNull("An error occurs while creating ClassAttributeReader", reader);
+ assertFalse("SDE should be absent.", reader.isSDEAvailable());
+ }
+
+ public void testSDEAbsenceForSimpleTeam2() throws Exception
+ {
+ ClassAttributeReader reader = getAttributeReader("SimpleTeam2");
+ assertNotNull("An error occurs while creating ClassAttributeReader", reader);
+ assertFalse("SDE should be absent.", reader.isSDEAvailable());
+ }
+
+ public void testSDEExistenceForSimpleSDEClass() throws Exception
+ {
+ ClassAttributeReader reader = getAttributeReader("SimpleSDEClass");
+ assertNotNull("An error occurs while creating ClassAttributeReader", reader);
+ assertTrue("SDE should exist.", reader.isSDEAvailable());
+ }
+
+ private ClassAttributeReader getAttributeReader(String classname) throws Exception
+ {
+ IPath classFilePath = getAbsoluteOSClassFilePath(classname);
+ ClassAttributeReader classReader = new ClassAttributeReader(classFilePath);
+ if (classReader.getError() != null)
+ return null;
+
+ return classReader;
+ }
+
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/StratumTests.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/StratumTests.java
new file mode 100644
index 000000000..e49822711
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/src/org/eclipse/objectteams/otdt/debug/tests/core/StratumTests.java
@@ -0,0 +1,141 @@
+/**********************************************************************
+ * 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: StratumTests.java 23492 2010-02-05 22:57:56Z 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.debug.tests.core;
+
+import org.eclipse.jdt.debug.core.IJavaDebugTarget;
+import org.eclipse.jdt.debug.core.IJavaReferenceType;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.objectteams.otdt.debug.tests.AbstractOTDTDebugTest;
+
+/**
+ * Tests strata.
+ */
+public class StratumTests extends AbstractOTDTDebugTest {
+
+ public StratumTests(String name) {
+ super(name);
+ }
+
+ /**
+ * Test available strata on a type.
+ *
+ * @throws Exception
+ */
+ public void testAvailableStrata() throws Exception {
+ String typeName = "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaReferenceType type = ((IJavaStackFrame)thread.getTopStackFrame()).getReferenceType();
+ String[] strata = type.getAvailableStrata();
+ assertEquals("Wrong number of available strata", 1, strata.length);
+ assertEquals("Wrong strata", "Java", strata[0]);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ /**
+ * Test default stratum on a type.
+ *
+ * @throws Exception
+ */
+ public void testDefaultStratum() throws Exception {
+ String typeName = "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaReferenceType type = ((IJavaStackFrame)thread.getTopStackFrame()).getReferenceType();
+ String stratum = type.getDefaultStratum();
+ assertEquals("Wrong strata", "Java", stratum);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ /**
+ * Test set / get default stratum on a java debug target.
+ *
+ * @throws Exception
+ */
+ public void testSetGetDefaultStratum() throws Exception {
+ String typeName = "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaDebugTarget debugTarget= (IJavaDebugTarget)thread.getDebugTarget();
+ String stratum= debugTarget.getDefaultStratum();
+ assertNull("Default strata should be 'null'", stratum);
+ debugTarget.setDefaultStratum("strataTest");
+ stratum= debugTarget.getDefaultStratum();
+ assertEquals("Wrong strata", "strataTest", stratum);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ public void testGetLineInStratum() throws Exception {
+ String typeName= "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaStackFrame stackFrame= (IJavaStackFrame)thread.getTopStackFrame();
+ int lineNumber= stackFrame.getLineNumber("Java");
+ assertEquals("Wrong line number", 81, lineNumber);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+
+ public void testGetSourceNameInStratum() throws Exception {
+ String typeName= "Breakpoints";
+ createLineBreakpoint(81, typeName);
+
+ IJavaThread thread= null;
+ try {
+ thread= launchToBreakpoint(typeName);
+ assertNotNull("Breakpoint not hit within timeout period", thread);
+ IJavaStackFrame stackFrame= (IJavaStackFrame)thread.getTopStackFrame();
+ String sourceName= stackFrame.getSourceName("Java");
+ assertEquals("Wrong source name", "Breakpoints.java", sourceName);
+ } finally {
+ terminateAndRemove(thread);
+ removeAllBreakpoints();
+ }
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/test.xml b/testplugins/org.eclipse.objectteams.otdt.debug.tests/test.xml
new file mode 100644
index 000000000..8d44a6d57
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/test.xml
@@ -0,0 +1,61 @@
+<project name="testsuite" default="run" basedir=".">
+
+ <property name="otdt-tests-workspace" value="${test.eclipseDir}/otdt-tests-workspace"/>
+
+ <!-- sets the properties eclipseTest-home, and library-file -->
+ <property name="plugin-name" value="org.eclipse.objectteams.otdt.debug.tests"/>
+
+ <!-- library.xml need these properties-->
+ <property name="eclipse-home" value="${test.eclipseDir}"/>
+ <property name="test.target" value="performance"/>
+
+ <property name="library-file" value="${test.eclipseDir}/plugins/${org.eclipse.test}/library.xml"/>
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp/>
+ <delete quiet="true">
+ <fileset dir="${test.eclipseDir}" includes="org.eclipse.objectteams.otdt.debug.tests.AllTests.xml,${plugin-name}.${file-id}.xml"/>
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="suite">
+ <property name="otdt-debug-folder"
+ value="${otdt-tests-workspace}/otdt-debug-folder"/>
+ <delete dir="${otdt-debug-folder}" quiet="true"/>
+ <ant target="ui-test" antfile="${library-file}" dir="${test.eclipseDir}">
+ <property name="data-dir" value="${otdt-debug-folder}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname"
+ value="org.eclipse.objectteams.otdt.debug.tests.AllTests"/>
+ </ant>
+ </target>
+
+ <target name="checkOS">
+ <condition property="os.isWindows">
+ <os family="windows"/>
+ </condition>
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- after all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,suite,cleanup">
+<!--
+ <ant target="collect" antfile="${library-file}" dir="${test.eclipseDir}">
+ <property name="includes" value="org.eclipse.objectteams.otdt.debug.tests.AllTests.xml"/>
+ <property name="output-file" value="${plugin-name}.${file-id}.xml"/>
+ </ant>
+-->
+ </target>
+
+</project>
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/Breakpoints.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/Breakpoints.java
new file mode 100644
index 000000000..113239e25
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/Breakpoints.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+import java.util.*;
+
+
+public class Breakpoints implements IBreakpoints {
+ static {
+ new Vector(1);
+ System.out.println("Initializer");
+ }
+
+ public class InnerBreakpoints {
+ public void innerInstanceMethod() {
+ System.out.println("inner instance");
+ }
+ }
+
+ Enumeration myNamedEnumerate(final Object array[]) {
+ final int count[] = {0}; // final reference to mutable array
+ class E implements Enumeration {
+ public boolean hasMoreElements(){
+ return count[0] < array.length;
+ }
+ public Object nextElement(){
+ return array[count[0]++];
+ }
+ }
+ return new E();
+ }
+
+ Enumeration myAnonymousEnumerate(final Object array[]) {
+ return new Enumeration() {
+ int count = 0;
+ public boolean hasMoreElements(){
+ return count < array.length;
+ }
+ public Object nextElement(){
+ return array[count++];
+ }
+ };
+ }
+
+ public static void main (String[] args) {
+ threading();
+ Breakpoints bp= new Breakpoints();
+ bp.instanceMethod();
+ bp.instanceMethod2();
+
+ }
+
+public class InnerRunnable implements Runnable {
+ public void run() {
+ System.out.println("Threading");
+ }
+ }
+ public static boolean threading() {
+ try {
+ Thread runner = new Thread(new Breakpoints().new InnerRunnable(), "BreakpointsThread");
+ runner.setPriority(Thread.MIN_PRIORITY);
+ runner.start();
+ runner.join();
+ } catch (InterruptedException ie) {
+ }
+ return false;
+ }
+
+ public Breakpoints() {
+ super();
+ System.out.println("Constructor");
+ }
+ public void instanceMethod() {
+ if (true) {
+ System.out.println("If");
+ } else {
+ System.out.println("Can't get here");
+ }
+ if (false) {
+ System.out.println("Can't get here");
+ } else {
+ System.out.println("Else");
+ }
+
+ int i;
+ for (i= 0; i < 3; i++) {
+ System.out.println("for");
+ }
+
+ while (i < 6) {
+ System.out.println("while");
+ i++;
+ }
+
+ {
+ System.out.println("block");
+ }
+ }
+
+ public void instanceMethod2() {
+ int count= 0;
+ do {
+ System.out.println("dowhile");
+ count++;
+ } while (count < 5);
+
+
+ try {
+ Vector v= new Vector(1);
+ v.firstElement();
+ } catch (NoSuchElementException nsee) {
+ System.out.println("catch block");
+ } finally {
+ System.out.println("finally after catch");
+
+ }
+ try {
+ new Vector(1);
+ System.out.println("try");
+ } catch (NoSuchElementException nsee) {
+ } finally {
+ System.out.println("finally after try");
+
+ }
+ switch (count) {
+ case 5:
+ System.out.println("switch");
+ break;
+ }
+ switch (count) {
+ case 3:
+ break;
+ default:
+ System.out.println("switch default");
+ }
+
+
+ Object lock= new Object();
+ synchronized (lock) {
+ System.out.println("synchronized");
+ }
+
+ InnerBreakpoints ibp= new InnerBreakpoints();
+ ibp.innerInstanceMethod();
+
+ String[] array= {"1", "2", "3"};
+ Enumeration myNamed= myNamedEnumerate(array);
+ myNamed.hasMoreElements();
+
+ Enumeration myAnonymous= myAnonymousEnumerate(array);
+ myAnonymous.hasMoreElements();
+
+ ibp.innerInstanceMethod();
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/IBreakpoints.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/IBreakpoints.java
new file mode 100644
index 000000000..cfb676af3
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/IBreakpoints.java
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+public interface IBreakpoints {
+ public abstract void instanceMethod();
+ }
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam.java
new file mode 100644
index 000000000..5d9273940
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam.java
@@ -0,0 +1,12 @@
+package copyinheritancetests;
+
+public team class SubTeam extends SuperTeam {
+ void test() {
+ R r = new R();
+ r.roleMethod1();
+ System.out.println("finished");
+ }
+ public static void main(String [] args) {
+ new SubTeam().test();
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam2.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam2.java
new file mode 100644
index 000000000..9b4053895
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam2.java
@@ -0,0 +1,14 @@
+package copyinheritancetests;
+
+public team class SubTeam2 extends SuperTeam {
+ @Override
+ protected class R { /* empty */ }
+ void test() {
+ R r = new R();
+ r.roleMethod1();
+ System.out.println("finished");
+ }
+ public static void main(String [] args) {
+ new SubTeam2().test();
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam3.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam3.java
new file mode 100644
index 000000000..259481451
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SubTeam3.java
@@ -0,0 +1,14 @@
+package copyinheritancetests;
+
+public team class SubTeam3 extends SuperTeam3 {
+ @Override
+ protected class R { /* empty */ }
+ void test() {
+ R r = new R();
+ r.roleMethod1();
+ System.out.println("finished");
+ }
+ public static void main(String [] args) {
+ new SubTeam3().test();
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam.java
new file mode 100644
index 000000000..a141d5bf8
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam.java
@@ -0,0 +1,9 @@
+package copyinheritancetests;
+
+public team class SuperTeam {
+ protected class R {
+ protected void roleMethod1() {
+ System.out.println("roleMethod1");
+ }
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam3.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam3.java
new file mode 100644
index 000000000..8a951b7e5
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam3.java
@@ -0,0 +1,4 @@
+package copyinheritancetests;
+
+public team class SuperTeam3 {
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam3/R.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam3/R.java
new file mode 100644
index 000000000..47eff23e2
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/copyinheritancetests/SuperTeam3/R.java
@@ -0,0 +1,6 @@
+team package copyinheritancetests.SuperTeam3;
+protected class R {
+ protected void roleMethod1() {
+ System.out.println("roleMethod1");
+ }
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/rofitests/RoFiTeam.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/rofitests/RoFiTeam.java
new file mode 100644
index 000000000..cc13bdd15
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/rofitests/RoFiTeam.java
@@ -0,0 +1,13 @@
+package rofitests;
+
+public team class RoFiTeam {
+ void doit() {
+ System.out.println("doit");
+ RoFiRole rfr = new RoFiRole();
+ rfr.doRolish();
+ }
+ public static void main(String[] args) {
+ RoFiTeam rft = new RoFiTeam();
+ rft.doit();
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/rofitests/RoFiTeam/RoFiRole.java b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/rofitests/RoFiTeam/RoFiRole.java
new file mode 100644
index 000000000..65625910e
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testprograms/rofitests/RoFiTeam/RoFiRole.java
@@ -0,0 +1,7 @@
+team package rofitests.RoFiTeam;
+
+protected class RoFiRole {
+ protected void doRolish() {
+ System.out.println("role stuff");
+ }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.debug.tests/testresources/dummy1 b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testresources/dummy1
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.debug.tests/testresources/dummy1

Back to the top