Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErich Gamma2002-09-03 10:40:28 +0000
committerErich Gamma2002-09-03 10:40:28 +0000
commit8c738bc4e2025baab47b4d5c29d34d31dd93fd6e (patch)
tree5160ffbf1988ec98a2a64d5e555add75ba0149e9
parent35eb26c6e8be916f6fc14da617b9756b225f74b8 (diff)
downloadeclipse.jdt.ui-Branch21.tar.gz
eclipse.jdt.ui-Branch21.tar.xz
eclipse.jdt.ui-Branch21.zip
initial checkingBranch21
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java36
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitBaseLaunchConfiguration.java108
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfiguration.java6
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchShortcut.java1
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitMainTab.java176
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/runner/RemoteTestRunner.java5
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java20
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java36
8 files changed, 259 insertions, 129 deletions
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java
index cb8c9b58bc..15fb67657a 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java
@@ -104,22 +104,7 @@ public class TestSearchEngine {
if (elements.length > 0) {
IRunnableWithProgress runnable= new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InterruptedException {
- int nElements= elements.length;
- pm.beginTask(JUnitMessages.getString("TestSearchEngine.message.searching"), nElements); //$NON-NLS-1$
- try {
- for (int i= 0; i < nElements; i++) {
- try {
- collectTypes(elements[i], new SubProgressMonitor(pm, 1), result);
- } catch (JavaModelException e) {
- JUnitPlugin.log(e.getStatus());
- }
- if (pm.isCanceled()) {
- throw new InterruptedException();
- }
- }
- } finally {
- pm.done();
- }
+ doFindTests(elements, result, pm);
}
};
context.run(true, true, runnable);
@@ -127,6 +112,25 @@ public class TestSearchEngine {
return (IType[]) result.toArray(new IType[result.size()]) ;
}
+ public static void doFindTests(Object[] elements, Set result, IProgressMonitor pm) throws InterruptedException {
+ int nElements= elements.length;
+ pm.beginTask(JUnitMessages.getString("TestSearchEngine.message.searching"), nElements); //$NON-NLS-1$
+ try {
+ for (int i= 0; i < nElements; i++) {
+ try {
+ collectTypes(elements[i], new SubProgressMonitor(pm, 1), result);
+ } catch (JavaModelException e) {
+ JUnitPlugin.log(e.getStatus());
+ }
+ if (pm.isCanceled()) {
+ throw new InterruptedException();
+ }
+ }
+ } finally {
+ pm.done();
+ }
+ }
+
private static void collectTypes(Object element, IProgressMonitor pm, Set result) throws JavaModelException/*, InvocationTargetException*/ {
element= computeScope(element);
while((element instanceof IJavaElement) && !(element instanceof ICompilationUnit) && (element instanceof ISourceReference)) {
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitBaseLaunchConfiguration.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitBaseLaunchConfiguration.java
index 17f06adc6d..e498a2f0cd 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitBaseLaunchConfiguration.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitBaseLaunchConfiguration.java
@@ -7,36 +7,33 @@ package org.eclipse.jdt.internal.junit.launcher;
import java.io.File;
import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.ISourceLocator;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.internal.junit.ui.JUnitMessages;
import org.eclipse.jdt.internal.junit.ui.JUnitPlugin;
import org.eclipse.jdt.internal.junit.util.SocketUtil;
+import org.eclipse.jdt.internal.junit.util.TestSearchEngine;
import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
import org.eclipse.jdt.launching.ExecutionArguments;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMRunner;
import org.eclipse.jdt.launching.VMRunnerConfiguration;
-import org.eclipse.jdt.launching.sourcelookup.JavaSourceLocator;
/**
* Abstract launch configuration delegate for a JUnit test.
@@ -46,6 +43,7 @@ public abstract class JUnitBaseLaunchConfiguration extends AbstractJavaLaunchCon
public static final String PORT_ATTR= JUnitPlugin.PLUGIN_ID+".PORT"; //$NON-NLS-1$
public static final String TESTTYPE_ATTR= JUnitPlugin.PLUGIN_ID+".TESTTYPE"; //$NON-NLS-1$
public static final String ATTR_KEEPRUNNING = JUnitPlugin.PLUGIN_ID+ ".KEEPRUNNING_ATTR"; //$NON-NLS-1$
+ public static final String LAUNCH_CONTAINER_ATTR= JUnitPlugin.PLUGIN_ID+".APPLICATION_NAME";
/**
* @see ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String)
*/
@@ -55,12 +53,24 @@ public abstract class JUnitBaseLaunchConfiguration extends AbstractJavaLaunchCon
if ((javaProject == null) || !javaProject.exists()) {
abort(JUnitMessages.getString("JUnitBaseLaunchConfiguration.error.invalidproject"), null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT); //$NON-NLS-1$
}
- IType testType = getTestType(configuration, javaProject);
+ IType[] testTypes = getTestTypes(configuration, javaProject, pm);
IVMInstall install= getVMInstall(configuration);
IVMRunner runner = install.getVMRunner(mode);
if (runner == null) {
abort(MessageFormat.format(JUnitMessages.getString("JUnitBaseLaunchConfiguration.error.novmrunner"), new String[]{install.getId()}), null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST); //$NON-NLS-1$
}
+
+ int port= SocketUtil.findUnusedLocalPort("", 5000, 15000); //$NON-NLS-1$
+ VMRunnerConfiguration runConfig= launchTypes(configuration, mode, testTypes, port);
+ setDefaultSourceLocator(launch, configuration);
+
+ launch.setAttribute(PORT_ATTR, Integer.toString(port));
+ launch.setAttribute(TESTTYPE_ATTR, testTypes[0].getHandleIdentifier());
+ runner.run(runConfig, launch, pm);
+ }
+
+ protected VMRunnerConfiguration launchTypes(ILaunchConfiguration configuration,
+ String mode, IType[] tests, int port) throws CoreException {
File workingDir = verifyWorkingDirectory(configuration);
String workingDirName = null;
if (workingDir != null)
@@ -69,48 +79,58 @@ public abstract class JUnitBaseLaunchConfiguration extends AbstractJavaLaunchCon
// Program & VM args
String vmArgs= getVMArguments(configuration);
ExecutionArguments execArgs = new ExecutionArguments(vmArgs, ""); //$NON-NLS-1$
-
- // Create VM config
- IType types[]= { testType };
- int port= SocketUtil.findUnusedLocalPort("", 5000, 15000); //$NON-NLS-1$
-
- VMRunnerConfiguration runConfig= createVMRunner(configuration, types, port, mode);
+
+ VMRunnerConfiguration runConfig= createVMRunner(configuration, tests, port, mode);
runConfig.setVMArguments(execArgs.getVMArgumentsArray());
runConfig.setWorkingDirectory(workingDirName);
-
+
String[] bootpath = getBootpath(configuration);
runConfig.setBootClassPath(bootpath);
-
-
- // set default source locator if none specified
- String id= configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
- if (id == null) {
- ISourceLocator sourceLocator = new JavaSourceLocator(javaProject);
- launch.setSourceLocator(sourceLocator);
- }
-
- launch.setAttribute(PORT_ATTR, Integer.toString(port));
- launch.setAttribute(TESTTYPE_ATTR, testType.getHandleIdentifier());
- runner.run(runConfig, launch, pm);
+ return runConfig;
}
- public IType getTestType(ILaunchConfiguration configuration, IJavaProject javaProject) throws CoreException {
- // test type
+ public IType[] getTestTypes(ILaunchConfiguration configuration, IJavaProject javaProject, IProgressMonitor pm) throws CoreException {
String testTypeName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null);
+
if ((testTypeName == null) || (testTypeName.trim().length() < 1)) {
abort("No test type specified", null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE); //$NON-NLS-1$
}
- IType testType = null;
+
+ String containerHandle = configuration.getAttribute(LAUNCH_CONTAINER_ATTR, "");
+ if (containerHandle.length() == 0) {
+ return findSingleTest(javaProject, testTypeName);
+ }
+ else
+ return findTestsInContainer(javaProject, containerHandle, pm);
+ }
+
+ private IType[] findTestsInContainer(IJavaProject javaProject, String containerHandle, IProgressMonitor pm) {
+ IJavaElement container= JavaCore.create(containerHandle);
+ IType[] types= new IType[0];
+ Set result= new HashSet();
+ try {
+ TestSearchEngine.doFindTests(new Object[]{container}, result, pm);
+ } catch (InterruptedException e) {
+ }
+ for (int i= 0; i < types.length; i++) {
+ System.out.println(types[i]);
+ }
+ return (IType[]) result.toArray(new IType[result.size()]) ;
+ }
+
+
+ public IType[] findSingleTest(IJavaProject javaProject, String testName) throws CoreException {
+ IType type = null;
try {
- testType = findType(javaProject, testTypeName);
+ type = findType(javaProject, testName);
} catch (JavaModelException jme) {
abort("Test type does not exist", null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE); //$NON-NLS-1$
}
- if (testType == null) {
+ if (type == null) {
abort("Test type does not exist", null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE); //$NON-NLS-1$
}
- return testType;
- }
+ return new IType[]{type};
+ }
/**
* Throws a core exception with the given message and optional
@@ -129,27 +149,7 @@ public abstract class JUnitBaseLaunchConfiguration extends AbstractJavaLaunchCon
* Find the specified (fully-qualified) type name in the specified java project.
*/
private IType findType(IJavaProject javaProject, String mainTypeName) throws JavaModelException {
- String pathStr= mainTypeName.replace('.', '/') + ".java"; //$NON-NLS-1$
- IJavaElement javaElement= javaProject.findElement(new Path(pathStr));
- if (javaElement == null) {
- // try to find it as inner type
- String qualifier= Signature.getQualifier(mainTypeName);
- if (qualifier.length() > 0) {
- IType type= findType(javaProject, qualifier); // recursive!
- if (type != null) {
- IType res= type.getType(Signature.getSimpleName(mainTypeName));
- if (res.exists()) {
- return res;
- }
- }
- }
- } else if (javaElement.getElementType() == IJavaElement.COMPILATION_UNIT) {
- String simpleName= Signature.getSimpleName(mainTypeName);
- return ((ICompilationUnit) javaElement).getType(simpleName);
- } else if (javaElement.getElementType() == IJavaElement.CLASS_FILE) {
- return ((IClassFile) javaElement).getType();
- }
- return null;
+ return javaProject.findType(mainTypeName);
}
/**
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfiguration.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfiguration.java
index 65cc40e25b..cfcc17f253 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfiguration.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfiguration.java
@@ -33,18 +33,18 @@ public class JUnitLaunchConfiguration extends JUnitBaseLaunchConfiguration {
* In addition it adds the port for the RemoteTestRunner as an argument
*/
protected VMRunnerConfiguration createVMRunner(ILaunchConfiguration configuration, IType[] testTypes, int port, String runMode) throws CoreException {
- String[] classPath= createClassPath(configuration, testTypes[0]);
+ String[] classPath= createClassPath(configuration);
VMRunnerConfiguration vmConfig= new VMRunnerConfiguration("org.eclipse.jdt.internal.junit.runner.RemoteTestRunner", classPath); //$NON-NLS-1$
Vector argv= new Vector(10);
argv.add("-port"); //$NON-NLS-1$
argv.add(Integer.toString(port));
//argv("-debugging");
- argv.add("-classNames"); //$NON-NLS-1$
if (keepAlive(configuration) && runMode.equals(ILaunchManager.DEBUG_MODE))
argv.add(0, "-keepalive"); //$NON-NLS-1$
+ argv.add("-classNames"); //$NON-NLS-1$
for (int i= 0; i < testTypes.length; i++)
argv.add(testTypes[i].getFullyQualifiedName());
@@ -54,7 +54,7 @@ public class JUnitLaunchConfiguration extends JUnitBaseLaunchConfiguration {
return vmConfig;
}
- private String[] createClassPath(ILaunchConfiguration configuration, IType type) throws CoreException {
+ private String[] createClassPath(ILaunchConfiguration configuration) throws CoreException {
URL url= JUnitPlugin.getDefault().getDescriptor().getInstallURL();
String[] cp= getClasspath(configuration);
boolean inDevelopmentMode= BootLoader.inDevelopmentMode();
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchShortcut.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchShortcut.java
index 7cf9fce1c0..5b8505acc5 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchShortcut.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchShortcut.java
@@ -118,6 +118,7 @@ public class JUnitLaunchShortcut implements ILaunchShortcut {
try {
ILaunchConfiguration config = findLaunchConfiguration(type, mode);
if (config != null) {
+ DebugUITools.saveAndBuildBeforeLaunch();
config.launch(mode, null);
}
} catch (CoreException e) {
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitMainTab.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitMainTab.java
index 8f2874086f..a15649ff91 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitMainTab.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/JUnitMainTab.java
@@ -35,6 +35,7 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -62,7 +63,15 @@ public class JUnitMainTab extends JUnitLaunchConfigurationTab {
private Label fTestLabel;
private Text fTestText;
private Button fSearchButton;
- private final Image fTestIcon= createImage("obj16/test.gif"); //$NON-NLS-1$
+ private final Image fTestIcon= createImage("obj16/test.gif");
+
+ private Text fContainerText;
+
+ private Button fContainerSearchButton;
+
+ private Button fTestContainerRadioButton;
+
+ private Button fTestRadioButton; //$NON-NLS-1$
/**
* @see ILaunchConfigurationTab#createControl(TabItem)
@@ -74,42 +83,82 @@ public class JUnitMainTab extends JUnitLaunchConfigurationTab {
GridLayout topLayout = new GridLayout();
topLayout.numColumns= 2;
comp.setLayout(topLayout);
- GridData gd;
new Label(comp, SWT.NONE);
- fProjLabel = new Label(comp, SWT.NONE);
- fProjLabel.setText(JUnitMessages.getString("JUnitMainTab.label.project")); //$NON-NLS-1$
- gd= new GridData();
+ createProjectGroup(comp);
+ createTestSelectionGroup(comp);
+ createTestContainerSelectionGroup(comp);
+ createKeepAliveGroup(comp);
+ }
+
+ private void createTestContainerSelectionGroup(Composite comp) {
+ GridData gd;
+ fTestContainerRadioButton= new Button(comp, SWT.RADIO | SWT.LEFT);
+ fTestContainerRadioButton.setText("All Tests in Container:");
+ gd = new GridData();
gd.horizontalSpan = 2;
- fProjLabel.setLayoutData(gd);
-
- fProjText= new Text(comp, SWT.SINGLE | SWT.BORDER);
+ fTestContainerRadioButton.setLayoutData(gd);
+ fTestContainerRadioButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ testModeChanged();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ testModeChanged();
+ }
+ });
+ fContainerText = new Text(comp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
- fProjText.setLayoutData(gd);
- fProjText.addModifyListener(new ModifyListener() {
+ gd.horizontalIndent= 20;
+ fContainerText.setLayoutData(gd);
+ fContainerText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
updateLaunchConfigurationDialog();
}
});
- fProjButton = new Button(comp, SWT.PUSH);
- fProjButton.setText(JUnitMessages.getString("JUnitMainTab.label.browse")); //$NON-NLS-1$
- fProjButton.addSelectionListener(new SelectionAdapter() {
+ fContainerSearchButton = new Button(comp, SWT.PUSH);
+ fContainerSearchButton.setText(JUnitMessages.getString("JUnitMainTab.label.search")); //$NON-NLS-1$
+ fContainerSearchButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
- handleProjectButtonSelected();
+ handleContainerSearchButtonSelected();
}
});
- setButtonGridData(fProjButton);
-
- fTestLabel = new Label(comp, SWT.NONE);
- fTestLabel.setText(JUnitMessages.getString("JUnitMainTab.label.test")); //$NON-NLS-1$
+ setButtonGridData(fContainerSearchButton);
+ }
+
+ private void handleContainerSearchButtonSelected() {
+ }
+
+ public void createKeepAliveGroup(Composite comp) {
+ GridData gd;
+ fKeepRunning = new Button(comp, SWT.CHECK);
+ fKeepRunning.setText(JUnitMessages.getString("JUnitMainTab.label.keeprunning")); //$NON-NLS-1$
+ gd= new GridData();
+ gd.horizontalAlignment= GridData.FILL;
+ gd.horizontalSpan= 2;
+ fKeepRunning.setLayoutData(gd);
+ }
+
+ public void createTestSelectionGroup(Composite comp) {
+ GridData gd;
+ fTestRadioButton= new Button(comp, SWT.RADIO | SWT.LEFT);
+ fTestRadioButton.setText(JUnitMessages.getString("JUnitMainTab.label.test"));
gd = new GridData();
gd.horizontalSpan = 2;
- fTestLabel.setLayoutData(gd);
+ fTestRadioButton.setLayoutData(gd);
+ fTestRadioButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ testModeChanged();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ testModeChanged();
+ }
+ });
fTestText = new Text(comp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalIndent= 20;
fTestText.setLayoutData(gd);
fTestText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
@@ -125,13 +174,33 @@ public class JUnitMainTab extends JUnitLaunchConfigurationTab {
}
});
setButtonGridData(fSearchButton);
-
- fKeepRunning = new Button(comp, SWT.CHECK);
- fKeepRunning.setText(JUnitMessages.getString("JUnitMainTab.label.keeprunning")); //$NON-NLS-1$
+ }
+
+ public void createProjectGroup(Composite comp) {
+ GridData gd;
+ fProjLabel = new Label(comp, SWT.NONE);
+ fProjLabel.setText(JUnitMessages.getString("JUnitMainTab.label.project")); //$NON-NLS-1$
gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.horizontalSpan= 2;
- fKeepRunning.setLayoutData(gd);
+ gd.horizontalSpan = 2;
+ fProjLabel.setLayoutData(gd);
+
+ fProjText= new Text(comp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fProjText.setLayoutData(gd);
+ fProjText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ fProjButton = new Button(comp, SWT.PUSH);
+ fProjButton.setText(JUnitMessages.getString("JUnitMainTab.label.browse")); //$NON-NLS-1$
+ fProjButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ handleProjectButtonSelected();
+ }
+ });
+ setButtonGridData(fProjButton);
}
protected static Image createImage(String path) {
@@ -151,6 +220,7 @@ public class JUnitMainTab extends JUnitLaunchConfigurationTab {
public void initializeFrom(ILaunchConfiguration config) {
updateProjectFromConfig(config);
updateTestTypeFromConfig(config);
+ updateTestContainerFromConfig(config);
updateKeepRunning(config);
}
@@ -174,13 +244,39 @@ public class JUnitMainTab extends JUnitLaunchConfigurationTab {
protected void updateTestTypeFromConfig(ILaunchConfiguration config) {
String testTypeName= ""; //$NON-NLS-1$
+ String containerHandle= "";
try {
testTypeName = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, ""); //$NON-NLS-1$
+ containerHandle = config.getAttribute(JUnitBaseLaunchConfiguration.LAUNCH_CONTAINER_ATTR, ""); //$NON-NLS-1$
} catch (CoreException ce) {
}
- fTestText.setText(testTypeName);
+ if (containerHandle.length() == 0) {
+ fTestRadioButton.setSelection(true);
+ fTestContainerRadioButton.setSelection(false);
+ fContainerText.setText("");
+ fTestText.setText(testTypeName);
+ setEnableSingleTestGroup(true);
+ setEnableContainerTestGroup(false);
+ }
}
+ protected void updateTestContainerFromConfig(ILaunchConfiguration config) {
+ String testTypeName= ""; //$NON-NLS-1$
+ String containerHandle= "";
+ try {
+ testTypeName = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, ""); //$NON-NLS-1$
+ containerHandle = config.getAttribute(JUnitBaseLaunchConfiguration.LAUNCH_CONTAINER_ATTR, ""); //$NON-NLS-1$
+ } catch (CoreException ce) {
+ }
+ if (containerHandle.length() > 0) {
+ fTestContainerRadioButton.setSelection(true);
+ fTestRadioButton.setSelection(false);
+ fContainerText.setText(testTypeName);
+ fTestText.setText("");
+ setEnableSingleTestGroup(false);
+ setEnableContainerTestGroup(true);
+ }
+ }
/**
* @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
*/
@@ -309,16 +405,17 @@ public class JUnitMainTab extends JUnitLaunchConfigurationTab {
setErrorMessage(null);
setMessage(null);
- String name = fProjText.getText().trim();
- if (name.length() > 0) {
- if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
+ String projectName = fProjText.getText().trim();
+ if (projectName.length() > 0) {
+ if (!ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).exists()) {
setErrorMessage(JUnitMessages.getString("JUnitMainTab.error.projectnotexists")); //$NON-NLS-1$
return false;
}
}
- name = fTestText.getText().trim();
- if (name.length() == 0) {
+ String testName = fTestText.getText().trim();
+ String containerName = fContainerText.getText().trim();
+ if (testName.length() == 0 && containerName.length() == 0) {
setErrorMessage(JUnitMessages.getString("JUnitMainTab.error.testnotdefined")); //$NON-NLS-1$
return false;
}
@@ -326,6 +423,23 @@ public class JUnitMainTab extends JUnitLaunchConfigurationTab {
return true;
}
+ private void testModeChanged() {
+ boolean isSingleTestMode= fTestRadioButton.getSelection();
+ setEnableSingleTestGroup(isSingleTestMode);
+ setEnableContainerTestGroup(!isSingleTestMode);
+ }
+
+ private void setEnableContainerTestGroup(boolean enabled) {
+ fContainerSearchButton.setEnabled(enabled);
+ fContainerText.setEnabled(enabled);
+ }
+
+
+ private void setEnableSingleTestGroup(boolean enabled) {
+ fSearchButton.setEnabled(enabled);
+ fTestText.setEnabled(enabled);
+ }
+
/**
* @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
*/
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/runner/RemoteTestRunner.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/runner/RemoteTestRunner.java
index a5463711c9..36551e03e9 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/runner/RemoteTestRunner.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/runner/RemoteTestRunner.java
@@ -317,7 +317,10 @@ public class RemoteTestRunner implements TestListener {
long startTime= System.currentTimeMillis();
if (fDebugMode)
System.out.println("start send tree"); //$NON-NLS-1$
- sendTree(suites[0]);
+ for (int i= 0; i < suites.length; i++) {
+ sendTree(suites[i]);
+ }
+
if (fDebugMode)
System.out.println("done send tree"+(System.currentTimeMillis()-startTime)); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
index 5199b8b271..dd3e0c0630 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
@@ -121,9 +121,9 @@ public class TestRunnerViewPart extends ViewPart implements ITestRunListener, IP
*/
private boolean fIsDisposed= false;
/**
- * The launched test type
+ * The launched project
*/
- private IType fTestType;
+ private IJavaProject fTestProject;
/**
* The launcher that has started the test
*/
@@ -448,8 +448,8 @@ public class TestRunnerViewPart extends ViewPart implements ITestRunListener, IP
});
}
- public void startTestRunListening(IType type, int port, ILaunch launch) {
- fTestType= type;
+ public void startTestRunListening(IJavaElement type, int port, ILaunch launch) {
+ fTestProject= type.getJavaProject();
fLaunchMode= launch.getLaunchMode();
aboutToLaunch();
@@ -459,9 +459,13 @@ public class TestRunnerViewPart extends ViewPart implements ITestRunListener, IP
fTestRunnerClient= new RemoteTestRunnerClient();
fTestRunnerClient.startListening(this, port);
fLastLaunch= launch;
- String title= JUnitMessages.getFormattedString("TestRunnerViewPart.title", fTestType.getElementName()); //$NON-NLS-1$
+ String title= JUnitMessages.getFormattedString("TestRunnerViewPart.title", type.getElementName()); //$NON-NLS-1$
setTitle(title);
- setTitleToolTip(fTestType.getFullyQualifiedName());
+ if (type instanceof IType)
+ setTitleToolTip(((IType)type).getFullyQualifiedName());
+ else
+ setTitleToolTip(type.getElementName());
+
}
private void aboutToLaunch() {
@@ -515,7 +519,7 @@ public class TestRunnerViewPart extends ViewPart implements ITestRunListener, IP
private void postAsyncRunnable(Runnable r) {
if (!isDisposed())
- getDisplay().asyncExec(r);
+ getDisplay().syncExec(r);
}
private void aboutToStart() {
@@ -809,7 +813,7 @@ public class TestRunnerViewPart extends ViewPart implements ITestRunListener, IP
}
public IJavaProject getLaunchedProject() {
- return fTestType.getJavaProject();
+ return fTestProject;
}
protected static Image createImage(String path) {
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java
index cb8c9b58bc..15fb67657a 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java
@@ -104,22 +104,7 @@ public class TestSearchEngine {
if (elements.length > 0) {
IRunnableWithProgress runnable= new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InterruptedException {
- int nElements= elements.length;
- pm.beginTask(JUnitMessages.getString("TestSearchEngine.message.searching"), nElements); //$NON-NLS-1$
- try {
- for (int i= 0; i < nElements; i++) {
- try {
- collectTypes(elements[i], new SubProgressMonitor(pm, 1), result);
- } catch (JavaModelException e) {
- JUnitPlugin.log(e.getStatus());
- }
- if (pm.isCanceled()) {
- throw new InterruptedException();
- }
- }
- } finally {
- pm.done();
- }
+ doFindTests(elements, result, pm);
}
};
context.run(true, true, runnable);
@@ -127,6 +112,25 @@ public class TestSearchEngine {
return (IType[]) result.toArray(new IType[result.size()]) ;
}
+ public static void doFindTests(Object[] elements, Set result, IProgressMonitor pm) throws InterruptedException {
+ int nElements= elements.length;
+ pm.beginTask(JUnitMessages.getString("TestSearchEngine.message.searching"), nElements); //$NON-NLS-1$
+ try {
+ for (int i= 0; i < nElements; i++) {
+ try {
+ collectTypes(elements[i], new SubProgressMonitor(pm, 1), result);
+ } catch (JavaModelException e) {
+ JUnitPlugin.log(e.getStatus());
+ }
+ if (pm.isCanceled()) {
+ throw new InterruptedException();
+ }
+ }
+ } finally {
+ pm.done();
+ }
+ }
+
private static void collectTypes(Object element, IProgressMonitor pm, Set result) throws JavaModelException/*, InvocationTargetException*/ {
element= computeScope(element);
while((element instanceof IJavaElement) && !(element instanceof ICompilationUnit) && (element instanceof ISourceReference)) {

Back to the top