KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > launcher > JUnitLaunchConfigurationConstants


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.junit.launcher;
13
14 import org.eclipse.core.runtime.CoreException;
15
16 import org.eclipse.core.resources.ResourcesPlugin;
17
18 import org.eclipse.debug.core.ILaunchConfiguration;
19
20 import org.eclipse.jdt.core.IJavaProject;
21 import org.eclipse.jdt.core.JavaCore;
22
23 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
24
25 import org.eclipse.jdt.internal.junit.ui.JUnitPlugin;
26
27 /**
28  * Attribute keys used by the IJUnitLaunchConfiguration. Note that these constants are not API and
29  * might change in the future.
30  */

31 public class JUnitLaunchConfigurationConstants {
32
33     public static final String JavaDoc MODE_RUN_QUIETLY_MODE = "runQuietly"; //$NON-NLS-1$
34
public static final String JavaDoc ID_JUNIT_APPLICATION= "org.eclipse.jdt.junit.launchconfig"; //$NON-NLS-1$
35

36     public static final String JavaDoc ATTR_NO_DISPLAY = JUnitPlugin.PLUGIN_ID + ".NO_DISPLAY"; //$NON-NLS-1$
37

38
39     
40     public static final String JavaDoc ATTR_PORT= JUnitPlugin.PLUGIN_ID+".PORT"; //$NON-NLS-1$
41

42     /**
43      * The test method, or "" iff running the whole test type.
44      */

45     public static final String JavaDoc ATTR_TEST_METHOD_NAME= JUnitPlugin.PLUGIN_ID+".TESTNAME"; //$NON-NLS-1$
46

47     public static final String JavaDoc ATTR_KEEPRUNNING = JUnitPlugin.PLUGIN_ID+ ".KEEPRUNNING_ATTR"; //$NON-NLS-1$
48
/**
49      * The launch container, or "" iff running a single test type.
50      */

51     public static final String JavaDoc ATTR_TEST_CONTAINER= JUnitPlugin.PLUGIN_ID+".CONTAINER"; //$NON-NLS-1$
52

53     public static final String JavaDoc ATTR_FAILURES_NAMES= JUnitPlugin.PLUGIN_ID+".FAILURENAMES"; //$NON-NLS-1$
54

55     public static final String JavaDoc ATTR_TEST_RUNNER_KIND= JUnitPlugin.PLUGIN_ID+".TEST_KIND"; //$NON-NLS-1$
56

57     public static ITestKind getTestRunnerKind(ILaunchConfiguration launchConfiguration) {
58         try {
59             String JavaDoc loaderId = launchConfiguration.getAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_RUNNER_KIND, (String JavaDoc) null);
60             if (loaderId != null) {
61                 return TestKindRegistry.getDefault().getKind(loaderId);
62             }
63         } catch (CoreException e) {
64         }
65         return ITestKind.NULL;
66     }
67
68     public static IJavaProject getJavaProject(ILaunchConfiguration configuration) {
69         try {
70             String JavaDoc projectName= configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String JavaDoc) null);
71             if (projectName != null && projectName.length() > 0) {
72                 return JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName));
73             }
74         } catch (CoreException e) {
75         }
76         return null;
77     }
78     
79     
80 }
81
Popular Tags