Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-11-29 13:24:42 -0500
committerGerrit Code Review @ Eclipse.org2016-11-29 20:16:01 -0500
commitdccd99c84355703b57f00d027bbc402500187015 (patch)
tree5eb37592f13942657a730a173dea29e0e67f53ea
parent83bd6f7ed4b7af7d1880fcd93132d87571ab1e29 (diff)
downloadorg.eclipse.cdt-dccd99c84355703b57f00d027bbc402500187015.tar.gz
org.eclipse.cdt-dccd99c84355703b57f00d027bbc402500187015.tar.xz
org.eclipse.cdt-dccd99c84355703b57f00d027bbc402500187015.zip
Code cleanup
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java5
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java24
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/SizingTestPass.java40
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Main.java848
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/NewMain.java24
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/AccessibilityTestPass.java35
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/ExpectedStrings.java83
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/FocusTestPass.java16
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/IDialogTestPass.java24
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/VerifyDialog.java65
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpProviderTester.java302
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java114
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java45
13 files changed, 798 insertions, 827 deletions
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java
index 739772eb74..38850e9634 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestPluginLauncher.java
@@ -16,14 +16,13 @@ import java.net.URL;
* Helper class to launch a test
*/
public class TestPluginLauncher {
-
public static final String APP_NAME= "org.eclipse.jdt.ui.tests.app";
- public static void run(String location, Class testCase, String[] args) {
+ public static void run(String location, Class<?> testCase, String[] args) {
run(APP_NAME, location, testCase, args);
}
- public static void run(String application, String location, Class testCase, String[] args) {
+ public static void run(String application, String location, Class<?> testCase, String[] args) {
try {
String bootLocation= getBootLocation();
int nArgs= args.length;
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java
index 2ef312ffaa..ce612aeaf0 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/IDialogTestPass.java
@@ -10,46 +10,50 @@
*******************************************************************************/
package org.eclipse.cdt.core.testplugin.util;
-
import java.util.ArrayList;
-
/*
* Interface to describe a visual test pass for a dialog test.
*/
public interface IDialogTestPass {
- /*
+ /**
* @return String The title of the test pass.
*/
public String title();
- /*
+
+ /**
* @return String The description of the test pass.
*/
public String description();
- /*
+
+ /**
* @return String The label of the test pass to be used
* in a selection list. The return includes an '&'
* if a mnemonic is desired.
*/
public String label();
- /*
+
+ /**
* @return ArrayList A list of items to appear in a checklist.
* The items in the list must be Strings and should include an
* '&' if a mnemonic is desired.
*/
- public ArrayList checkListTexts();
- /*
+ public ArrayList<String> checkListTexts();
+
+ /**
* @return String[] Associated failure messages that correspond
* to the checklist items. The size of this array should be the
* same size as the checklist.
*/
public String[] failureTexts();
- /*
+
+ /**
* @return String The test that corresponds to the test pass to
* which the tester will respond with a 'yes' or 'no'.
*/
public String queryText();
- /*
+
+ /**
* @return int A unique number that identifies the test pass.
*/
public int getID();
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/SizingTestPass.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/SizingTestPass.java
index 7f2e76584b..ad22b29533 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/SizingTestPass.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/SizingTestPass.java
@@ -6,46 +6,36 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
+ * IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.testplugin.util;
import java.util.ArrayList;
/*
- * This test pass verifies visually the sizing of the dialog and its
- * widgets.
+ * This test pass verifies visually the sizing of the dialog and its widgets.
*/
class SizingTestPass implements IDialogTestPass {
private static final int CHECKLIST_SIZE = 5;
- /**
- * @see IDialogTestPass#title()
- */
@Override
public String title() {
return "Test Pass: Sizing and Display";
}
- /**
- * @see IDialogTestPass#description()
- */
+
@Override
public String description() {
return "Verify the sizing and display of the dialogs and widgets.";
}
- /**
- * @see IDialogTestPass#label()
- */
+
@Override
public String label() {
return "&Sizing and Display";
- }
- /**
- * @see IDialogTestPass#checkListTexts()
- */
+ }
+
@Override
- public ArrayList checkListTexts() {
- ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ public ArrayList<String> checkListTexts() {
+ ArrayList<String> list = new ArrayList<>(CHECKLIST_SIZE);
list.add("&1) the correct dialog displays.");
list.add("&2) the dialog is an appropriate size for the required resolution (1024x768).");
list.add("&3) the texts are correct and not cut off.");
@@ -53,11 +43,7 @@ class SizingTestPass implements IDialogTestPass {
list.add("&5) all the widgets are viewable and not cut off.");
return list;
}
- /**
- * @see IDialogTestPass#failureTexts()
- * Size of the return array must be the same size as the checkListTexts'
- * ArrayList.
- */
+
@Override
public String[] failureTexts() {
String[] failureText = new String[CHECKLIST_SIZE];
@@ -68,16 +54,12 @@ class SizingTestPass implements IDialogTestPass {
failureText[4] = "Some widgets are cut off.";
return failureText;
}
- /**
- * @see IDialogTestPass#queryText()
- */
+
@Override
public String queryText() {
return "Is the sizing and display of the dialog correct?";
}
- /**
- * @see IDialogTestPass#getID()
- */
+
@Override
public int getID() {
return VerifyDialog.TEST_SIZING;
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Main.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Main.java
index b77a27e338..d91744d84c 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Main.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Main.java
@@ -6,109 +6,107 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
+ * IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.testplugin;
-// copied from startup.jar. planned to be removed soon
-import java.net.*;
-import java.lang.reflect.*;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+
+// Copied from startup.jar. planned to be removed soon
+
/**
- * Startup class for Eclipse. Creates a class loader using
- * supplied URL of platform installation, loads and calls
- * the Eclipse Boot Loader. The startup arguments are as follows:
+ * Startup class for Eclipse. Creates a class loader using supplied URL of
+ * platform installation, loads and calls the Eclipse Boot Loader. The startup
+ * arguments are as follows:
* <dl>
- * <dd>
- * -application &lt;id&gt;: the identifier of the application to run
- * </dd>
- * <dd>
- * -boot &lt;location&gt;: the location, expressed as a URL, of the platform's boot.jar
- * </dd>
- * <dd>
- * -consolelog : enables log to the console. Handy when combined with -debug
- * </dd>
- * <dd>
- * -data &lt;location&gt;: sets the workspace location and the default location for projects
- * </dd>
- * <dd>
- * -debug [options file]: turns on debug mode for the platform and optionally specifies a location
- * for the .options file. This file indicates what debug points are available for a
- * plug-in and whether or not they are enabled. If a location is not specified, the platform searches
- * for the .options file under the install directory
- * </dd>
- * <dd>
- * -dev [entries]: turns on dev mode and optionally specifies comma-separated class path entries
- * which are added to the class path of each plug-in
- * </dd>
- * <dd>
- * -keyring &lt;location&gt;: the location of the authorization database on disk. This argument
- * has to be used together with the -password argument
- * </dd>
- * <dd>
- * -password &lt;passwd&gt;: the password for the authorization database
+ * <dd>-application &lt;id&gt;: the identifier of the application to run</dd>
+ * <dd>-boot &lt;location&gt;: the location, expressed as a URL, of the
+ * platform's boot.jar</dd>
+ * <dd>-consolelog : enables log to the console. Handy when combined with -debug
* </dd>
- * <dd>
- * -plugins &lt;location&gt;: The arg is a URL pointing to a file which specs the plugin
- * path for the platform. The file is in property file format where the keys are user-defined
- * names and the values are comma separated lists of either explicit paths to plugin.xml
- * files or directories containing plugins. (e.g., .../eclipse/plugins).
- * </dd>
- * <dd>
- * -ws &lt;window system&gt;: sets the window system value
+ * <dd>-data &lt;location&gt;: sets the workspace location and the default
+ * location for projects</dd>
+ * <dd>-debug [options file]: turns on debug mode for the platform and
+ * optionally specifies a location for the .options file. This file indicates
+ * what debug points are available for a plug-in and whether or not they are
+ * enabled. If a location is not specified, the platform searches for the
+ * .options file under the install directory</dd>
+ * <dd>-dev [entries]: turns on dev mode and optionally specifies
+ * comma-separated class path entries which are added to the class path of each
+ * plug-in</dd>
+ * <dd>-keyring &lt;location&gt;: the location of the authorization database on
+ * disk. This argument has to be used together with the -password argument</dd>
+ * <dd>-password &lt;passwd&gt;: the password for the authorization database
* </dd>
+ * <dd>-plugins &lt;location&gt;: The arg is a URL pointing to a file which
+ * specs the plugin path for the platform. The file is in property file format
+ * where the keys are user-defined names and the values are comma separated
+ * lists of either explicit paths to plugin.xml files or directories containing
+ * plugins. (e.g., .../eclipse/plugins).</dd>
+ * <dd>-ws &lt;window system&gt;: sets the window system value</dd>
* </dl>
*/
public class Main {
/**
* Indicates whether this instance is running in debug mode.
*/
- protected boolean debug = false;
-
+ protected boolean debug;
+
/**
* The location of the launcher to run.
*/
- protected String bootLocation = null;
-
+ protected String bootLocation;
+
/**
* The identifier of the application to run.
*/
protected String application;
-
+
/**
* The path for finding find plugins.
*/
protected URL pluginPathLocation;
-
+
/**
* The boot path location.
*/
protected String location;
-
+
/**
- * Indicates whether items for UNinstallation should be looked for.
+ * Indicates whether items for uninstallation should be looked for.
*/
protected boolean uninstall = false;
-
+
/**
* The item to be uninstalled.
*/
protected String uninstallCookie;
-
+
/**
* The class path entries.
*/
- protected String devClassPath = null;
-
+ protected String devClassPath;
+
/**
* Indicates whether this instance is running in development mode.
*/
- protected boolean inDevelopmentMode = false;
+ protected boolean inDevelopmentMode;
// static token describing how to take down the splash screen
- private static String endSplash = null;
-
+ private static String endSplash;
+
// constants
private static final String APPLICATION = "-application"; //$NON-NLS-1$
private static final String BOOT = "-boot"; //$NON-NLS-1$
@@ -120,7 +118,7 @@ public class Main {
private static final String BOOTLOADER = "org.eclipse.core.boot.BootLoader"; //$NON-NLS-1$
private static final String UPDATELOADER = "org.eclipse.core.internal.boot.LaunchInfo"; //$NON-NLS-1$
- // The project containing the boot loader code. This is used to construct
+ // The project containing the boot loader code. This is used to construct
// the correct class path for running in VAJ and VAME.
private static final String PROJECT_NAME = "Eclipse Core Boot"; //$NON-NLS-1$
@@ -143,387 +141,411 @@ public class Main {
}
}
-/**
- * Executes the launch.
- *
- * @return the result of performing the launch
- * @param args command-line arguments
- * @exception Exception thrown if a problem occurs during the launch
- */
-protected Object basicRun(String[] args) throws Exception {
- Class clazz = getBootLoader(bootLocation);
- Method method = clazz.getDeclaredMethod("run", new Class[] { String.class, URL.class, String.class, String[].class }); //$NON-NLS-1$
- try {
- return method.invoke(clazz, new Object[] { application, pluginPathLocation, location, args });
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof Error)
- throw (Error) e.getTargetException();
- throw e;
+ /**
+ * Executes the launch.
+ *
+ * @param args command-line arguments
+ * @return the result of performing the launch
+ * @exception Exception thrown if a problem occurs during the launch
+ */
+ protected Object basicRun(String[] args) throws Exception {
+ Class<?> clazz = getBootLoader(bootLocation);
+ Method method = clazz.getDeclaredMethod("run", //$NON-NLS-1$
+ new Class[] { String.class, URL.class, String.class, String[].class });
+ try {
+ return method.invoke(clazz, new Object[] { application, pluginPathLocation, location, args });
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof Error)
+ throw (Error) e.getTargetException();
+ throw e;
+ }
}
-}
-/**
- * Returns the result of converting a list of comma-separated tokens into an array
- *
- * @return the array of string tokens
- * @param prop the initial comma-separated string
- */
-private String[] getArrayFromList(String prop) {
- if (prop == null || prop.trim().isEmpty())
- return new String[0];
- Vector list = new Vector();
- StringTokenizer tokens = new StringTokenizer(prop, ","); //$NON-NLS-1$
- while (tokens.hasMoreTokens()) {
- String token = tokens.nextToken().trim();
- if (!token.isEmpty())
- list.addElement(token);
+ /**
+ * Returns the result of converting a list of comma-separated tokens into an array.
+ *
+ * @param prop the initial comma-separated string
+ * @return the array of string tokens
+ */
+ private String[] getArrayFromList(String prop) {
+ if (prop == null || prop.trim().isEmpty())
+ return new String[0];
+ List<String> list = new ArrayList<>();
+ StringTokenizer tokens = new StringTokenizer(prop, ","); //$NON-NLS-1$
+ while (tokens.hasMoreTokens()) {
+ String token = tokens.nextToken().trim();
+ if (!token.isEmpty())
+ list.add(token);
+ }
+ return list.toArray(new String[0]);
}
- return list.isEmpty() ? new String[0] : (String[]) list.toArray(new String[0]);
-}
-/**
- * Creates and returns a platform <code>BootLoader</code> which can be used to start
- * up and run the platform. The given base, if not <code>null</code>,
- * is the location of the boot loader code. If the value is <code>null</code>
- * then the boot loader is located relative to this class.
- *
- * @return the new boot loader
- * @param base the location of the boot loader
- */
-public Class getBootLoader(String base) throws Exception {
- URLClassLoader loader = new URLClassLoader(getBootPath(base), null);
- return loader.loadClass(BOOTLOADER);
-}
-/**
- * Returns the <code>URL</code>-based class path describing where the boot classes
- * are located when running in development mode.
- *
- * @return the url-based class path
- * @param base the base location
- * @exception MalformedURLException if a problem occurs computing the class path
- */
-protected URL[] getDevPath(URL base) throws MalformedURLException {
- URL url;
- String devBase = base.toExternalForm();
- if (!inDevelopmentMode) {
- url = new URL(devBase + "boot.jar"); //$NON-NLS-1$
- return new URL[] {url};
+
+ /**
+ * Creates and returns a platform <code>BootLoader</code> which can be used
+ * to start up and run the platform. The given base, if not
+ * <code>null</code>, is the location of the boot loader code. If the value
+ * is <code>null</code> then the boot loader is located relative to this
+ * class.
+ *
+ * @param base the location of the boot loader
+ * @return the new boot loader
+ */
+ public Class<?> getBootLoader(String base) throws Exception {
+ try (URLClassLoader loader = new URLClassLoader(getBootPath(base), null)) {
+ return loader.loadClass(BOOTLOADER);
+ }
}
- String[] locations = getArrayFromList(devClassPath);
- ArrayList result = new ArrayList(locations.length);
- for (int i = 0; i < locations.length; i++) {
- String spec = devBase + locations[i];
- char lastChar = spec.charAt(spec.length() - 1);
- if ((spec.endsWith(".jar") || (lastChar == '/' || lastChar == '\\'))) //$NON-NLS-1$
- url = new URL (spec);
- else
- url = new URL(spec + "/"); //$NON-NLS-1$
- //make sure URL exists before adding to path
+
+ /**
+ * Returns the <code>URL</code>-based class path describing where the boot
+ * classes are located when running in development mode.
+ *
+ * @param base the base location
+ * @return the url-based class path
+ * @exception MalformedURLException if a problem occurs computing the class path
+ */
+ protected URL[] getDevPath(URL base) throws MalformedURLException {
+ URL url;
+ String devBase = base.toExternalForm();
+ if (!inDevelopmentMode) {
+ url = new URL(devBase + "boot.jar"); //$NON-NLS-1$
+ return new URL[] { url };
+ }
+ String[] locations = getArrayFromList(devClassPath);
+ ArrayList<URL> result = new ArrayList<>(locations.length);
+ for (int i = 0; i < locations.length; i++) {
+ String spec = devBase + locations[i];
+ char lastChar = spec.charAt(spec.length() - 1);
+ if ((spec.endsWith(".jar") || (lastChar == '/' || lastChar == '\\'))) { //$NON-NLS-1$
+ url = new URL(spec);
+ } else {
+ url = new URL(spec + "/"); //$NON-NLS-1$
+ }
+ // make sure URL exists before adding to path
+ if (new java.io.File(url.getFile()).exists())
+ result.add(url);
+ }
+ url = new URL(devBase + "boot.jar"); //$NON-NLS-1$
if (new java.io.File(url.getFile()).exists())
result.add(url);
+ return result.toArray(new URL[result.size()]);
}
- url = new URL(devBase + "boot.jar"); //$NON-NLS-1$
- if (new java.io.File(url.getFile()).exists())
- result.add(url);
- return (URL[])result.toArray(new URL[result.size()]);
-}
-/**
- * Returns the <code>URL</code>-based class path describing where the boot classes are located.
- *
- * @return the url-based class path
- * @param base the base location
- * @exception MalformedURLException if a problem occurs computing the class path
- */
-protected URL[] getBootPath(String base) throws MalformedURLException {
- URL url = null;
- // if the given location is not null, assume it is correct and use it.
- if (base != null) {
- url = new URL(base);
- if (debug)
- System.out.println("Boot URL: " + url.toExternalForm()); //$NON-NLS-1$
- return new URL[] {url};
- }
- // Create a URL based on the location of this class' code.
- // strip off jar file and/or last directory to get
- // to the directory containing projects.
- URL[] result = null;
- url = getClass().getProtectionDomain().getCodeSource().getLocation();
- String path = url.getFile();
- if (path.endsWith(".jar")) //$NON-NLS-1$
- path = path.substring(0, path.lastIndexOf("/")); //$NON-NLS-1$
- else
- if (path.endsWith("/")) //$NON-NLS-1$
+ /**
+ * Returns the <code>URL</code>-based class path describing where the boot
+ * classes are located.
+ *
+ * @param base the base location
+ * @return the url-based class path
+ * @exception MalformedURLException if a problem occurs computing the class path
+ */
+ protected URL[] getBootPath(String base) throws MalformedURLException {
+ URL url = null;
+ // if the given location is not null, assume it is correct and use it.
+ if (base != null) {
+ url = new URL(base);
+ if (debug)
+ System.out.println("Boot URL: " + url.toExternalForm()); //$NON-NLS-1$
+ return new URL[] { url };
+ }
+ // Create a URL based on the location of this class' code.
+ // strip off jar file and/or last directory to get
+ // to the directory containing projects.
+ URL[] result = null;
+ url = getClass().getProtectionDomain().getCodeSource().getLocation();
+ String path = url.getFile();
+ if (path.endsWith(".jar")) //$NON-NLS-1$
+ path = path.substring(0, path.lastIndexOf("/")); //$NON-NLS-1$
+ else if (path.endsWith("/")) //$NON-NLS-1$
path = path.substring(0, path.length() - 1);
- if (inVAJ || inVAME) {
- int ix = path.lastIndexOf("/"); //$NON-NLS-1$
- path = path.substring(0, ix + 1);
- path = path + PROJECT_NAME + "/"; //$NON-NLS-1$
- url = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
- result = new URL[] {url};
- } else {
- path = searchForPlugins(path);
- path = searchForBoot(path);
- // add on any dev path elements
- url = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
- result = getDevPath(url);
- }
- if (debug) {
- System.out.println("Boot URL:"); //$NON-NLS-1$
- for (int i = 0; i < result.length; i++)
- System.out.println(" " + result[i].toExternalForm()); //$NON-NLS-1$
+ if (inVAJ || inVAME) {
+ int ix = path.lastIndexOf("/"); //$NON-NLS-1$
+ path = path.substring(0, ix + 1);
+ path = path + PROJECT_NAME + "/"; //$NON-NLS-1$
+ url = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
+ result = new URL[] { url };
+ } else {
+ path = searchForPlugins(path);
+ path = searchForBoot(path);
+ // add on any dev path elements
+ url = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
+ result = getDevPath(url);
+ }
+ if (debug) {
+ System.out.println("Boot URL:"); //$NON-NLS-1$
+ for (int i = 0; i < result.length; i++)
+ System.out.println(" " + result[i].toExternalForm()); //$NON-NLS-1$
+ }
+ return result;
}
- return result;
-}
-/**
- * Searches for a plugins root starting at a given location. If one is
- * found then this location is returned; otherwise an empty string is
- * returned.
- *
- * @return the location where plugins were found, or an empty string
- * @param start the location to begin searching at
- */
-protected String searchForPlugins(String start) {
- File path = new File(start);
- while (path != null) {
- File test = new File(path, "plugins"); //$NON-NLS-1$
- if (test.exists())
- return test.toString();
- path = path.getParentFile();
- path = (path == null || path.length() == 1) ? null : path;
- }
- return ""; //$NON-NLS-1$
-}
-/**
- * Searches for a boot directory starting at a given location. If one
- * is found then this location is returned; otherwise an empty string
- * is returned.
- *
- * @return the location where plugins were found, or an empty string
- * @param start the location to begin searching at
- */
-protected String searchForBoot(String start) {
- FileFilter filter = new FileFilter() {
- @Override
- public boolean accept(File candidate) {
- return candidate.getName().startsWith(PI_BOOT);
+ /**
+ * Searches for a plugins root starting at a given location. If one is found
+ * then this location is returned; otherwise an empty string is returned.
+ *
+ * @param start the location to begin searching at
+ * @return the location where plugins were found, or an empty string
+ */
+ protected String searchForPlugins(String start) {
+ File path = new File(start);
+ while (path != null) {
+ File test = new File(path, "plugins"); //$NON-NLS-1$
+ if (test.exists())
+ return test.toString();
+ path = path.getParentFile();
+ path = (path == null || path.length() == 1) ? null : path;
}
- };
- File[] boots = new File(start).listFiles(filter);
- String result = null;
- String maxVersion = null;
- for (int i = 0; i < boots.length; i++) {
- String name = boots[i].getName();
- int index = name.lastIndexOf('_');
- if (index == -1) {
- result = boots[i].getAbsolutePath();
- i = boots.length;
- } else {
- if (index > 0) {
- String version = name.substring(index + 1);
- if (maxVersion == null) {
- result = boots[i].getAbsolutePath();
- maxVersion = version;
- } else
- if (maxVersion.compareTo(version) == -1) {
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Searches for a boot directory starting at a given location. If one is
+ * found then this location is returned; otherwise an empty string is
+ * returned.
+ *
+ * @param start the location to begin searching at
+ * @return the location where plugins were found, or an empty string
+ */
+ protected String searchForBoot(String start) {
+ FileFilter filter = new FileFilter() {
+ @Override
+ public boolean accept(File candidate) {
+ return candidate.getName().startsWith(PI_BOOT);
+ }
+ };
+ File[] boots = new File(start).listFiles(filter);
+ String result = null;
+ String maxVersion = null;
+ for (int i = 0; i < boots.length; i++) {
+ String name = boots[i].getName();
+ int index = name.lastIndexOf('_');
+ if (index == -1) {
+ result = boots[i].getAbsolutePath();
+ i = boots.length;
+ } else {
+ if (index > 0) {
+ String version = name.substring(index + 1);
+ if (maxVersion == null) {
+ result = boots[i].getAbsolutePath();
+ maxVersion = version;
+ } else if (maxVersion.compareTo(version) == -1) {
result = boots[i].getAbsolutePath();
maxVersion = version;
- }
+ }
+ }
}
}
+ if (result == null)
+ throw new RuntimeException(
+ "Could not find bootstrap code. Check location of boot plug-in or specify -boot."); //$NON-NLS-1$
+ return result.replace(File.separatorChar, '/') + "/"; //$NON-NLS-1$
}
- if (result == null)
- throw new RuntimeException("Could not find bootstrap code. Check location of boot plug-in or specify -boot."); //$NON-NLS-1$
- return result.replace(File.separatorChar, '/') + "/"; //$NON-NLS-1$
-}
-/**
- * Returns the update loader for the given boot path.
- *
- * @return the update loader
- * @param base the boot path base
- * @exception Exception thrown is a problem occurs determining this loader
- */
-public Class getUpdateLoader(String base) throws Exception {
- URLClassLoader loader = new URLClassLoader(getBootPath(base), null);
- return loader.loadClass(UPDATELOADER);
-}
-/**
- * Runs the platform with the given arguments. The arguments must identify
- * an application to run (e.g., <code>-application com.example.application</code>).
- * After running the application <code>System.exit(N)</code> is executed.
- * The value of N is derived from the value returned from running the application.
- * If the application's return value is an <code>Integer</code>, N is this value.
- * In all other cases, N = 0.
- * <p>
- * Clients wishing to run the platform without a following <code>System.exit</code>
- * call should use <code>run()</code>.
- *
- * @see #run
- *
- * @param args the command line arguments
- */
-public static void main(String[] args) {
- Object result = null;
- try {
- result = new Main().run(args);
- } catch (Throwable e) {
- // try and take down the splash screen.
- endSplash();
- System.out.println("Exception launching the Eclipse Platform:"); //$NON-NLS-1$
- e.printStackTrace();
- }
- int exitCode = result instanceof Integer ? ((Integer) result).intValue() : 0;
- System.exit(exitCode);
-}
-/**
- * Tears down the currently-displayed splash screen.
- */
-public static void endSplash() {
- if (endSplash == null)
- return;
- try {
- Runtime.getRuntime().exec(endSplash);
- } catch (Exception e) {
- }
-}
-
-/**
- * Runs this launcher with the arguments specified in the given string.
- *
- * @param argString the arguments string
- * @exception Exception thrown if a problem occurs during launching
- */
-public static void main(String argString) throws Exception {
- Vector list = new Vector(5);
- for (StringTokenizer tokens = new StringTokenizer(argString, " "); tokens.hasMoreElements();) //$NON-NLS-1$
- list.addElement(tokens.nextElement());
- main((String[]) list.toArray(new String[list.size()]));
-}
-/**
- * Processes the command line arguments
- *
- * @return the arguments to pass through to the launched application
- * @param args the command line arguments
- */
-protected String[] processCommandLine(String[] args) throws Exception {
- int[] configArgs = new int[100];
- configArgs[0] = -1; // need to initialize the first element to something that could not be an index.
- int configArgIndex = 0;
- for (int i = 0; i < args.length; i++) {
- boolean found = false;
- // check for args without parameters (i.e., a flag arg)
- // check if debug should be enabled for the entire platform
- if (args[i].equalsIgnoreCase(DEBUG)) {
- debug = true;
- // passed thru this arg (i.e., do not set found = true
- continue;
- }
-
- // check if development mode should be enabled for the entire platform
- // If this is the last arg or there is a following arg (i.e., arg+1 has a leading -),
- // simply enable development mode. Otherwise, assume that that the following arg is
- // actually some additional development time class path entries. This will be processed below.
- if (args[i].equalsIgnoreCase(DEV) && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[i + 1].startsWith("-"))))) { //$NON-NLS-1$
- inDevelopmentMode = true;
- // do not mark the arg as found so it will be passed through
- continue;
+ /**
+ * Returns the update loader for the given boot path.
+ *
+ * @param base the boot path base
+ * @return the update loader
+ * @exception Exception thrown is a problem occurs determining this loader
+ */
+ public Class<?> getUpdateLoader(String base) throws MalformedURLException, IOException, ClassNotFoundException {
+ try (URLClassLoader loader = new URLClassLoader(getBootPath(base), null)) {
+ return loader.loadClass(UPDATELOADER);
}
+ }
- // done checking for args. Remember where an arg was found
- if (found) {
- configArgs[configArgIndex++] = i;
- continue;
- }
- // check for args with parameters. If we are at the last argument or if the next one
- // has a '-' as the first character, then we can't have an arg with a parm so continue.
- if (i == args.length - 1 || args[i + 1].startsWith("-")) //$NON-NLS-1$
- continue;
- String arg = args[++i];
-
- // look for the laucher to run
- if (args[i - 1].equalsIgnoreCase(BOOT)) {
- bootLocation = arg;
- found = true;
+ /**
+ * Runs the platform with the given arguments. The arguments must identify
+ * an application to run (e.g., <code>-application com.example.application</code>).
+ * After running the application <code>System.exit(N)</code> is executed.
+ * The value of N is derived from the value returned from running the application.
+ * If the application's return value is an <code>Integer</code>, N is this value.
+ * In all other cases, N = 0.
+ * <p>
+ * Clients wishing to run the platform without a following
+ * <code>System.exit</code> call should use <code>run()</code>.
+ *
+ * @param args the command line arguments
+ *
+ * @see #run
+ */
+ public static void main(String[] args) {
+ Object result = null;
+ try {
+ result = new Main().run(args);
+ } catch (Throwable e) {
+ // try and take down the splash screen.
+ endSplash();
+ System.out.println("Exception launching the Eclipse Platform:"); //$NON-NLS-1$
+ e.printStackTrace();
}
+ int exitCode = result instanceof Integer ? ((Integer) result).intValue() : 0;
+ System.exit(exitCode);
+ }
- // look for the development mode and class path entries.
- if (args[i - 1].equalsIgnoreCase(DEV)) {
- inDevelopmentMode = true;
- devClassPath = arg;
- continue;
+ /**
+ * Tears down the currently-displayed splash screen.
+ */
+ public static void endSplash() {
+ if (endSplash == null)
+ return;
+ try {
+ Runtime.getRuntime().exec(endSplash);
+ } catch (Exception e) {
}
+ }
- // look for the application to run
- if (args[i - 1].equalsIgnoreCase(APPLICATION)) {
- application = arg;
- found = true;
- }
+ /**
+ * Runs this launcher with the arguments specified in the given string.
+ *
+ * @param argString the arguments string
+ * @exception Exception thrown if a problem occurs during launching
+ */
+ public static void main(String argString) throws Exception {
+ Vector<Object> list = new Vector<Object>(5);
+ for (StringTokenizer tokens = new StringTokenizer(argString, " "); tokens.hasMoreElements();) //$NON-NLS-1$
+ list.addElement(tokens.nextElement());
+ main(list.toArray(new String[list.size()]));
+ }
- // look for token to use to end the splash screen
- if (args[i - 1].equalsIgnoreCase(ENDSPLASH)) {
- endSplash = arg;
- continue;
- }
+ /**
+ * Processes the command line arguments
+ *
+ * @param args the command line arguments
+ * @return the arguments to pass through to the launched application
+ */
+ protected String[] processCommandLine(String[] args) throws Exception {
+ int[] configArgs = new int[100];
+ configArgs[0] = -1; // need to initialize the first element to something
+ // that could not be an index.
+ int configArgIndex = 0;
+ for (int i = 0; i < args.length; i++) {
+ boolean found = false;
+ // check for args without parameters (i.e., a flag arg)
+ // check if debug should be enabled for the entire platform
+ if (args[i].equalsIgnoreCase(DEBUG)) {
+ debug = true;
+ // passed thru this arg (i.e., do not set found = true
+ continue;
+ }
- // look for items to uninstall
- if (args[i - 1].equalsIgnoreCase(UNINSTALL)) {
- uninstall = true;
- uninstallCookie = arg;
- found = true;
- }
+ // Check if development mode should be enabled for the entire platform.
+ // If this is the last arg or there is a following arg (i.e., arg+1
+ // has a leading -),
+ // simply enable development mode. Otherwise, assume that that the
+ // following arg is
+ // actually some additional development time class path entries.
+ // This will be processed below.
+ if (args[i].equalsIgnoreCase(DEV)
+ && ((i + 1 == args.length) || ((i + 1 < args.length) && (args[i + 1].startsWith("-"))))) { //$NON-NLS-1$
+ inDevelopmentMode = true;
+ // do not mark the arg as found so it will be passed through
+ continue;
+ }
+
+ // done checking for args. Remember where an arg was found
+ if (found) {
+ configArgs[configArgIndex++] = i;
+ continue;
+ }
+ // check for args with parameters. If we are at the last argument or
+ // if the next one
+ // has a '-' as the first character, then we can't have an arg with
+ // a parm so continue.
+ if (i == args.length - 1 || args[i + 1].startsWith("-")) //$NON-NLS-1$
+ continue;
+ String arg = args[++i];
- // done checking for args. Remember where an arg was found
- if (found) {
- configArgs[configArgIndex++] = i - 1;
- configArgs[configArgIndex++] = i;
+ // look for the laucher to run
+ if (args[i - 1].equalsIgnoreCase(BOOT)) {
+ bootLocation = arg;
+ found = true;
+ }
+
+ // look for the development mode and class path entries.
+ if (args[i - 1].equalsIgnoreCase(DEV)) {
+ inDevelopmentMode = true;
+ devClassPath = arg;
+ continue;
+ }
+
+ // look for the application to run
+ if (args[i - 1].equalsIgnoreCase(APPLICATION)) {
+ application = arg;
+ found = true;
+ }
+
+ // look for token to use to end the splash screen
+ if (args[i - 1].equalsIgnoreCase(ENDSPLASH)) {
+ endSplash = arg;
+ continue;
+ }
+
+ // look for items to uninstall
+ if (args[i - 1].equalsIgnoreCase(UNINSTALL)) {
+ uninstall = true;
+ uninstallCookie = arg;
+ found = true;
+ }
+
+ // done checking for args. Remember where an arg was found
+ if (found) {
+ configArgs[configArgIndex++] = i - 1;
+ configArgs[configArgIndex++] = i;
+ }
+ }
+ // remove all the arguments consumed by this argument parsing
+ if (configArgIndex == 0)
+ return args;
+ String[] passThruArgs = new String[args.length - configArgIndex];
+ configArgIndex = 0;
+ int j = 0;
+ for (int i = 0; i < args.length; i++) {
+ if (i == configArgs[configArgIndex])
+ configArgIndex++;
+ else
+ passThruArgs[j++] = args[i];
}
+ return passThruArgs;
}
- // remove all the arguments consumed by this argument parsing
- if (configArgIndex == 0)
- return args;
- String[] passThruArgs = new String[args.length - configArgIndex];
- configArgIndex = 0;
- int j = 0;
- for (int i = 0; i < args.length; i++) {
- if (i == configArgs[configArgIndex])
- configArgIndex++;
- else
- passThruArgs[j++] = args[i];
+
+ /**
+ * Runs the application to be launched.
+ *
+ * @return the return value from the launched application
+ * @param args the arguments to pass to the application
+ * @exception Exception thrown if a problem occurs during launching
+ */
+ public Object run(String[] args) throws Exception {
+ String[] passThruArgs = processCommandLine(args);
+ if (uninstall)
+ return updateRun(UNINSTALL, uninstallCookie, passThruArgs);
+ return basicRun(passThruArgs);
}
- return passThruArgs;
-}
-/**
- * Runs the application to be launched.
- *
- * @return the return value from the launched application
- * @param args the arguments to pass to the application
- * @exception thrown if a problem occurs during launching
- */
-public Object run(String[] args) throws Exception {
- String[] passThruArgs = processCommandLine(args);
- if (uninstall)
- return updateRun(UNINSTALL, uninstallCookie, passThruArgs);
- return basicRun(passThruArgs);
-}
-/**
- * Performs an update run.
- *
- * @return the return value from the update loader
- * @param flag flag to give to the update loader
- * @param value value to give to the update loader
- * @param args arguments to give to the update loader.
- * @exception Exception thrown if a problem occurs during execution
- */
-protected Object updateRun(String flag, String value, String[] args) throws Exception {
- Class clazz = getUpdateLoader(bootLocation);
- Method method = clazz.getDeclaredMethod("run", new Class[] { String.class, String.class, String.class, String[].class }); //$NON-NLS-1$
- try {
- return method.invoke(clazz, new Object[] { flag, value, location, args });
- } catch (InvocationTargetException e) {
- if (e.getTargetException() instanceof Error)
- throw (Error) e.getTargetException();
- throw e;
+
+ /**
+ * Performs an update run.
+ *
+ * @return the return value from the update loader
+ * @param flag
+ * flag to give to the update loader
+ * @param value
+ * value to give to the update loader
+ * @param args
+ * arguments to give to the update loader.
+ * @exception Exception
+ * thrown if a problem occurs during execution
+ */
+ protected Object updateRun(String flag, String value, String[] args) throws Exception {
+ Class<?> clazz = getUpdateLoader(bootLocation);
+ Method method = clazz.getDeclaredMethod("run", //$NON-NLS-1$
+ new Class[] { String.class, String.class, String.class, String[].class });
+ try {
+ return method.invoke(clazz, new Object[] { flag, value, location, args });
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof Error)
+ throw (Error) e.getTargetException();
+ throw e;
+ }
}
}
-}
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/NewMain.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/NewMain.java
index dec2b5858f..cbc0d3f85e 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/NewMain.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/NewMain.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
+ * IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.testplugin;
@@ -14,19 +14,19 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
-import java.util.Vector;
/**
* Application is responsible for calling core launch api
*/
-
public class NewMain extends Main {
private static final String DEFAULT_APPLICATION= "org.eclipse.ui.workbench"; //$NON-NLS-1$
-
-
- public NewMain(String application, String location, URL pluginPathLocation, String bootLocation, boolean debug) throws IOException {
+
+ public NewMain(String application, String location, URL pluginPathLocation, String bootLocation, boolean debug)
+ throws IOException {
this.application= application;
this.location= location;
this.pluginPathLocation= pluginPathLocation;
@@ -44,17 +44,17 @@ public class NewMain extends Main {
System.exit(0);
}
-
/**
- * Run this launcher with the arguments specified in the given string.
+ * Runs this launcher with the arguments specified in the given string.
* This is a short cut method for people running the launcher from
* a scrapbook (i.e., swip-and-doit facility).
*/
public static void main(String argString) throws Exception {
- Vector list= new Vector(5);
- for (StringTokenizer tokens= new StringTokenizer(argString, " "); tokens.hasMoreElements();) //$NON-NLS-1$
- list.addElement(tokens.nextElement());
- main((String[]) list.toArray(new String[list.size()]));
+ List<String> list= new ArrayList<>(5);
+ for (StringTokenizer tokens= new StringTokenizer(argString, " "); tokens.hasMoreElements();) { //$NON-NLS-1$
+ list.add((String) tokens.nextElement());
+ }
+ main(list.toArray(new String[list.size()]));
}
public static String getLocationFromProperties(String key) {
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/AccessibilityTestPass.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/AccessibilityTestPass.java
index 995ba4f87e..af6e4a957d 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/AccessibilityTestPass.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/AccessibilityTestPass.java
@@ -10,40 +10,29 @@
*******************************************************************************/
package org.eclipse.cdt.ui.testplugin.util;
-
import java.util.ArrayList;
-
public class AccessibilityTestPass implements IDialogTestPass {
private static final int CHECKLIST_SIZE = 5;
- /**
- * @see IDialogTestPass#title()
- */
@Override
public String title() {
return "Test Pass: Accessibility";
}
- /**
- * @see IDialogTestPass#description()
- */
+
@Override
public String description() {
return "Verify the accessibility of the dialogs.";
}
- /**
- * @see IDialogTestPass#label()
- */
+
@Override
public String label() {
return "&Accessibility";
}
- /**
- * @see IDialogTestPass#checkListTexts()
- */
+
@Override
- public ArrayList checkListTexts() {
- ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ public ArrayList<String> checkListTexts() {
+ ArrayList<String> list = new ArrayList<>(CHECKLIST_SIZE);
list.add("&1) all widgets are accessible by tabbing.");
list.add("&2) forwards and backwards tabbing is in a logical order");
list.add("&3) all the widgets with labels have an appropriate mnemonic.");
@@ -51,11 +40,7 @@ public class AccessibilityTestPass implements IDialogTestPass {
list.add("&5) selectable widgets can be selected using the spacebar.");
return list;
}
- /**
- * @see IDialogTestPass#failureTexts()
- * Size of the return array must be the same size as the checkListTexts'
- * ArrayList.
- */
+
@Override
public String[] failureTexts() {
String[] failureText = new String[CHECKLIST_SIZE];
@@ -66,16 +51,12 @@ public class AccessibilityTestPass implements IDialogTestPass {
failureText[4] = "Some widgets cannot be selected using the spacebar.";
return failureText;
}
- /**
- * @see IDialogTestPass#queryText()
- */
+
@Override
public String queryText() {
return "Is the accessibility of the dialog acceptable?";
}
- /**
- * @see IDialogTestPass#getID()
- */
+
@Override
public int getID() {
return VerifyDialog.TEST_ACCESS;
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/ExpectedStrings.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/ExpectedStrings.java
index acc8b69138..3b5a59c77d 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/ExpectedStrings.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/ExpectedStrings.java
@@ -19,12 +19,9 @@ import java.util.Stack;
* in a structure/list, it will maintain a list of unfound/extra strings.
*/
public class ExpectedStrings {
-
public String [] expStrings;
private boolean[] foundStrings;
- private Stack extraStrings; /* A stack of the unecpected strings we
- * recieved
- */
+ private Stack<String> extraStrings; // A stack of the unexpected strings we received
private boolean extra;
/**
@@ -32,75 +29,71 @@ public class ExpectedStrings {
*/
public ExpectedStrings() {
}
+
/**
- * Constructor for ExpectedStrings that accepts a list of strings that
- * we expect to get.
+ * Constructor for ExpectedStrings that accepts a list of strings that we expect to get.
*/
public ExpectedStrings(String[] values) {
- int x;
expStrings=new String[values.length];
- for (x=0;x<values.length;x++) {
- expStrings[x]=values[x];
+ for (int x = 0; x < values.length; x++) {
+ expStrings[x] = values[x];
}
foundStrings=new boolean[values.length];
- for (x=0;x<values.length;x++) {
- foundStrings[x]=false;
+ for (int x = 0; x < values.length; x++) {
+ foundStrings[x] = false;
}
- extraStrings=new Stack();
- extra=false;
+ extraStrings = new Stack<>();
+ extra = false;
}
public int foundString(String current) {
- int x;
- for (x=0;x<expStrings.length;x++) {
+ for (int x = 0; x < expStrings.length; x++) {
if (current.equals(expStrings[x])) {
- foundStrings[x]=true;
- return(0);
+ foundStrings[x] = true;
+ return 0;
}
}
- /* If we arrive here, the strings was not found, so this is
- * and extra string
- */
-
- extraStrings.push(current);
- extra=true;
- return(1);
+
+ // If we arrive here, the strings was not found, so this is and extra string.
+ extraStrings.push(current);
+ extra= true;
+ return 1;
}
+
public int getNum(String name) {
- int x;
- for (x=0;x<expStrings.length;x++) {
+ for (int x = 0; x < expStrings.length; x++) {
if (name.equals(expStrings[x]))
- return(x);
+ return x;
}
- return(-1);
+ return -1;
}
+
public boolean gotAll() {
- int x;
- for (x=0;x<expStrings.length;x++) {
- if (foundStrings[x]==false)
- return(false);
+ for (int x = 0; x < expStrings.length; x++) {
+ if (!foundStrings[x])
+ return false;
}
- return(true);
+ return true;
}
+
public boolean gotExtra() {
- return(extra);
+ return extra;
}
+
public String getMissingString() {
- int x;
- String missing = "Missing elements: ";
- for (x=0;x<expStrings.length;x++) {
- if (foundStrings[x]==false)
- missing+=expStrings[x];
- missing+=" ";
+ StringBuilder missing = new StringBuilder("Missing elements: ");
+ for (int x = 0; x < expStrings.length; x++) {
+ if (!foundStrings[x])
+ missing.append(expStrings[x]).append(" ");
}
- return(missing);
+ return missing.toString();
}
+
public String getExtraString() {
- String extra= "Extra elements: ";
+ StringBuilder extra = new StringBuilder("Extra elements: ");
while (!extraStrings.empty()) {
- extra+=extraStrings.pop();
- extra+=" ";
+ extra.append(extraStrings.pop()).append(" ");
}
- return(extra);
+ return extra.toString();
}
}
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/FocusTestPass.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/FocusTestPass.java
index a52bc0147c..d9c883cf7a 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/FocusTestPass.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/FocusTestPass.java
@@ -13,13 +13,11 @@ package org.eclipse.cdt.ui.testplugin.util;
import java.util.ArrayList;
/*
- * This test pass verifies the initial focus of a dialog
- * when it is given focus.
+ * This test pass verifies the initial focus of a dialog when it is given focus.
*/
public class FocusTestPass implements IDialogTestPass {
private static final int CHECKLIST_SIZE = 1;
-
/**
* @see IDialogTestPass#title()
*/
@@ -27,6 +25,7 @@ public class FocusTestPass implements IDialogTestPass {
public String title() {
return "Test Pass: Initial Focus";
}
+
/**
* @see IDialogTestPass#description()
*/
@@ -34,22 +33,25 @@ public class FocusTestPass implements IDialogTestPass {
public String description() {
return "Verify the initial focus of the dialogs.";
}
+
/**
* @see IDialogTestPass#label()
*/
@Override
public String label() {
return "&Initial Focus";
- }
+ }
+
/**
* @see IDialogTestPass#checkListTexts()
*/
@Override
- public ArrayList checkListTexts() {
- ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ public ArrayList<String> checkListTexts() {
+ ArrayList<String> list = new ArrayList<>(CHECKLIST_SIZE);
list.add("&1) the initial focus is appropriate.");
return list;
}
+
/**
* @see IDialogTestPass#failureTexts()
* Size of the return array must be the same size as the checkListTexts'
@@ -61,6 +63,7 @@ public class FocusTestPass implements IDialogTestPass {
failureText[0] = "The initial focus is inappropriate.";
return failureText;
}
+
/**
* @see IDialogTestPass#queryText()
*/
@@ -68,6 +71,7 @@ public class FocusTestPass implements IDialogTestPass {
public String queryText() {
return "Is the initial focus of the dialog correct?";
}
+
/**
* @see IDialogTestPass#getID()
*/
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/IDialogTestPass.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/IDialogTestPass.java
index 5d48349e0b..8169d8e17b 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/IDialogTestPass.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/IDialogTestPass.java
@@ -10,46 +10,50 @@
*******************************************************************************/
package org.eclipse.cdt.ui.testplugin.util;
-
import java.util.ArrayList;
-
/*
* Interface to describe a visual test pass for a dialog test.
*/
public interface IDialogTestPass {
- /*
+ /**
* @return String The title of the test pass.
*/
public String title();
- /*
+
+ /**
* @return String The description of the test pass.
*/
public String description();
- /*
+
+ /**
* @return String The label of the test pass to be used
* in a selection list. The return includes an '&'
* if a mnemonic is desired.
*/
public String label();
- /*
+
+ /**
* @return ArrayList A list of items to appear in a checklist.
* The items in the list must be Strings and should include an
* '&' if a mnemonic is desired.
*/
- public ArrayList checkListTexts();
- /*
+ public ArrayList<String> checkListTexts();
+
+ /**
* @return String[] Associated failure messages that correspond
* to the checklist items. The size of this array should be the
* same size as the checklist.
*/
public String[] failureTexts();
- /*
+
+ /**
* @return String The test that corresponds to the test pass to
* which the tester will respond with a 'yes' or 'no'.
*/
public String queryText();
- /*
+
+ /**
* @return int A unique number that identifies the test pass.
*/
public int getID();
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/VerifyDialog.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/VerifyDialog.java
index 3b6c671d64..d23f131fed 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/VerifyDialog.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/util/VerifyDialog.java
@@ -10,10 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.ui.testplugin.util;
-
import java.util.Iterator;
-
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
@@ -32,8 +30,7 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-
-/*
+/**
* This dialog is intended to verify a dialogs in a testing
* environment. The tester can test for sizing, initial focus,
* or accessibility.
@@ -41,7 +38,7 @@ import org.eclipse.swt.widgets.Shell;
public class VerifyDialog extends TitleAreaDialog {
private int SIZING_WIDTH = 400;
- static int TEST_TYPE;
+ static int TEST_TYPE;
public static final int TEST_SIZING = 0;
public static final int TEST_FOCUS = 1;
public static final int TEST_ACCESS = 2;
@@ -57,8 +54,8 @@ public class VerifyDialog extends TitleAreaDialog {
private Button _checkList[];
private String _failureText;
- /*
- * Create an instance of the verification dialog.
+ /**
+ * Creates an instance of the verification dialog.
*/
public VerifyDialog(Shell parent) {
super(parent);
@@ -71,26 +68,19 @@ public class VerifyDialog extends TitleAreaDialog {
_dialogTests[2] = new AccessibilityTestPass();
}
- /* (non-Javadoc)
- * Method declared on Window.
- */
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Dialog Verification");
setShellStyle(SWT.NONE);
}
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
+
@Override
protected void createButtonsForButtonBar(Composite parent) {
_yesButton = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
_noButton = createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
}
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
+
@Override
protected void buttonPressed(int buttonId) {
if (IDialogConstants.YES_ID == buttonId) {
@@ -103,15 +93,12 @@ public class VerifyDialog extends TitleAreaDialog {
handleFailure();
}
}
- /* (non-Javadoc)
- * Method declared on Dialog.
- */
+
@Override
protected Control createDialogArea(Composite parent) {
// top level composite
Composite parentComposite = (Composite)super.createDialogArea(parent);
-
// create a composite with standard margins and spacing
Composite composite = new Composite(parentComposite, SWT.NONE);
composite.setSize(SIZING_WIDTH, SWT.DEFAULT);
@@ -123,11 +110,9 @@ public class VerifyDialog extends TitleAreaDialog {
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
createTestSelectionGroup(composite);
createCheckListGroup(composite);
-
_queryLabel = new Label(composite, SWT.NONE);
_queryLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -206,16 +191,17 @@ public class VerifyDialog extends TitleAreaDialog {
}
_yesButton.setEnabled(enable);
}
- /*
+
+ /**
* Initializes the checklist, banner texts, and query label
*/
void initializeTest() {
IDialogTestPass test = _dialogTests[TEST_TYPE];
setTitle( test.title() );
setMessage( test.description() );
- Iterator iterator = test.checkListTexts().iterator();
+ Iterator<String> iterator = test.checkListTexts().iterator();
for (int i = 0; i < _checkList.length; i++) {
- if ( iterator.hasNext() ) {
+ if (iterator.hasNext()) {
_checkList[i].setText( iterator.next().toString() );
_checkList[i].setVisible(true);
_checkList[i].update();
@@ -227,21 +213,23 @@ public class VerifyDialog extends TitleAreaDialog {
}
_queryLabel.setText( test.queryText() );
}
+
public String getFailureText() {
return _failureText;
}
- /*
+
+ /**
* Can't open the verification dialog without a specified
* test dialog, this simply returns a failure and prevents
* opening. Should use open(Dialog) instead.
- *
*/
@Override
public int open() {
_failureText = "Testing dialog is required, use VerifyDialog::open(Dialog)";
return IDialogConstants.NO_ID;
}
- /*
+
+ /**
* Opens the verification dialog to test the specified dialog.
*/
public int open(Dialog testDialog) {
@@ -259,7 +247,8 @@ public class VerifyDialog extends TitleAreaDialog {
return super.open();
}
- /*
+
+ /**
* Opens the dialog to be verified.
*/
private void openNewTestDialog() {
@@ -278,7 +267,8 @@ public class VerifyDialog extends TitleAreaDialog {
});
_testDialog.open();
}
- /*
+
+ /**
* The test dialog failed, open the failure dialog.
*/
private void handleFailure() {
@@ -287,10 +277,10 @@ public class VerifyDialog extends TitleAreaDialog {
String label = test.label();
label = label.substring(0, label.indexOf("&")) +
label.substring(label.indexOf("&") + 1);
- text.append(label).
- append(" failed on the ").
- append(SWT.getPlatform()).
- append(" platform:\n");
+ text.append(label)
+ .append(" failed on the ")
+ .append(SWT.getPlatform())
+ .append(" platform:\n");
String failureMessages[] = test.failureTexts();
for (int i = 0; i < test.checkListTexts().size(); i++) {
@@ -300,7 +290,6 @@ public class VerifyDialog extends TitleAreaDialog {
}
FailureDialog dialog = new FailureDialog( getShell() );
dialog.create();
- //String temp = text.toString();
dialog.setText( text.toString() );
if (dialog.open() == IDialogConstants.OK_ID) {
_failureText = dialog.toString();
@@ -311,9 +300,9 @@ public class VerifyDialog extends TitleAreaDialog {
close();
}
}
- /*
- * In case the shell was closed by a means other than
- * the NO button.
+
+ /**
+ * In case the shell was closed by a means other than the NO button.
*/
@Override
protected void handleShellCloseEvent() {
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpProviderTester.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpProviderTester.java
index 3b556e806d..938b6823eb 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpProviderTester.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpProviderTester.java
@@ -4,12 +4,14 @@
* 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:
+ *
+ * Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.chelp;
+import static org.eclipse.cdt.ui.tests.chelp.CHelpTest.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -17,101 +19,101 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import junit.framework.Assert;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.IHelpResource;
+import org.junit.Assert;
-import org.eclipse.cdt.internal.ui.CHelpProviderManager;
-import org.eclipse.cdt.internal.ui.text.CHelpBookDescriptor;
-import org.eclipse.cdt.internal.ui.text.CHelpSettings;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.ICHelpBook;
import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.IRequiredInclude;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.help.IHelpResource;
+
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
+import org.eclipse.cdt.internal.ui.text.CHelpBookDescriptor;
+import org.eclipse.cdt.internal.ui.text.CHelpSettings;
/**
- *
+ *
*/
-public class CHelpProviderTester{
+public class CHelpProviderTester {
private static final String KEY_PROVIDER_ID = "providerID";
private static final String KEY_REQUESTED_NAME = "requestedName";
private static final String KEY_BOOK_TITLE = "bookTitle";
private static final String KEY_BOOK_TYPE = "bookType";
-
+
private Properties fProperties;
- private static CHelpProviderTester fDefaultInstance = null;
-
- private CHelpProviderTester(){
+ private static CHelpProviderTester fDefaultInstance;
+
+ private CHelpProviderTester() {
}
-
- public static CHelpProviderTester getDefault(){
- if(fDefaultInstance == null)
+
+ public static CHelpProviderTester getDefault() {
+ if (fDefaultInstance == null)
fDefaultInstance = new CHelpProviderTester();
return fDefaultInstance;
}
-
- private class CHelpBook implements ICHelpBook{
+
+ private class CHelpBook implements ICHelpBook {
private int fCHelpType;
private String fTitle;
-
- public CHelpBook(String providerID, int type){
+
+ public CHelpBook(String providerID, int type) {
fCHelpType = type;
- fTitle = generateBookTitle(providerID,type);
+ fTitle = generateBookTitle(providerID, type);
}
-
+
@Override
- public String getTitle(){
+ public String getTitle() {
return fTitle;
}
-
+
@Override
- public int getCHelpType(){
+ public int getCHelpType() {
return fCHelpType;
}
}
-
- private class CHelpResourceDescriptor implements ICHelpResourceDescriptor{
+
+ private class CHelpResourceDescriptor implements ICHelpResourceDescriptor {
ICHelpBook fBook;
String fString;
String fLabel;
String fHref;
IHelpResource fResources[];
-
- public CHelpResourceDescriptor(ICHelpBook helpBook, String string, String providerID){
+
+ public CHelpResourceDescriptor(ICHelpBook helpBook, String string, String providerID) {
fBook = helpBook;
fString = string;
fHref = string + helpBook.getTitle() + ".html";
fLabel = generateHelpString(helpBook, string, providerID);
fResources = new IHelpResource[1];
- fResources[0] = new IHelpResource(){
+ fResources[0] = new IHelpResource() {
@Override
- public String getHref(){
+ public String getHref() {
return fHref;
}
-
+
@Override
- public String getLabel(){
+ public String getLabel() {
return fLabel;
- }
+ }
};
}
-
+
@Override
- public ICHelpBook getCHelpBook(){
+ public ICHelpBook getCHelpBook() {
return fBook;
}
-
+
@Override
- public IHelpResource[] getHelpResources(){
+ public IHelpResource[] getHelpResources() {
return fResources;
}
}
private class FunctionSummary implements IFunctionSummary {
-
private String fName = "Name";
private String fReturnType = "ReturnType";
private String fPrototype = "Prototype";
@@ -120,231 +122,231 @@ public class CHelpProviderTester{
private IRequiredInclude[] incs = new IRequiredInclude[] { new RequiredInclude("dummy.h")};
private class RequiredInclude implements IRequiredInclude {
private String include;
-
+
public RequiredInclude (String file) {
include = file;
}
-
+
@Override
public String getIncludeName() {
return include;
}
-
+
@Override
public boolean isStandard() {
return true;
}
}
-
- public FunctionSummary(ICHelpBook helpBook, String string, String providerID){
+
+ public FunctionSummary(ICHelpBook helpBook, String string, String providerID) {
fName = string;
fSummary = generateHelpString(helpBook, string, providerID);
}
public class FunctionPrototypeSummary implements IFunctionPrototypeSummary {
@Override
- public String getName() { return fName; }
+ public String getName() {
+ return fName;
+ }
@Override
- public String getReturnType() { return fReturnType; }
+ public String getReturnType() {
+ return fReturnType;
+ }
@Override
- public String getArguments() { return fPrototype; }
+ public String getArguments() {
+ return fPrototype;
+ }
@Override
public String getPrototypeString(boolean namefirst) {
if (true == namefirst) {
return fName + " (" + fPrototype + ") " + fReturnType;
- }
- else {
+ } else {
return fReturnType + " " + fName + " (" + fPrototype + ")";
}
}
}
@Override
- public String getName() { return fName; }
+ public String getName() {
+ return fName;
+ }
@Override
- public String getNamespace() { return "dummy namespace"; }
+ public String getNamespace() {
+ return "dummy namespace";
+ }
@Override
- public String getDescription() { return fSummary; }
+ public String getDescription() {
+ return fSummary;
+ }
@Override
- public IFunctionPrototypeSummary getPrototype() { return new FunctionPrototypeSummary(); }
-
+ public IFunctionPrototypeSummary getPrototype() {
+ return new FunctionPrototypeSummary();
+ }
+
@Override
public IRequiredInclude[] getIncludes() {
- return incs;
+ return incs;
}
-
}
- private static String generateHelpString(ICHelpBook helpBook, String name, String providerID){
+ private static String generateHelpString(ICHelpBook helpBook, String name, String providerID) {
Properties props = new Properties();
props.setProperty(KEY_PROVIDER_ID, providerID);
props.setProperty(KEY_REQUESTED_NAME, name);
props.setProperty(KEY_BOOK_TITLE, helpBook.getTitle());
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- try{
- props.store(outputStream,null);
- }
- catch(Exception e){
+ try {
+ props.store(outputStream, null);
+ } catch (IOException e) {
+ fail(e);
}
return outputStream.toString();
}
-
- private static String generateBookTitle(String providerID, int bookType){
+
+ private static String generateBookTitle(String providerID, int bookType) {
Properties props = new Properties();
props.setProperty(KEY_PROVIDER_ID, providerID);
props.setProperty(KEY_BOOK_TYPE, String.valueOf(bookType));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- try{
- props.store(outputStream,null);
- }
- catch(Exception e){
+ try {
+ props.store(outputStream, null);
+ } catch (IOException e) {
+ fail(e);
}
return outputStream.toString();
}
- private CHelpProviderTester(String string) throws IOException{
+ private CHelpProviderTester(String string) {
fProperties = new Properties();
ByteArrayInputStream stream = new ByteArrayInputStream(string.getBytes());
-
- try{
+ try {
fProperties.load(stream);
- }catch(IOException e){
- //TODO: handle
- throw e;
+ } catch (IOException e) {
+ fail(e);
}
}
-
- private String getValueByKey(String key){
+
+ private String getValueByKey(String key) {
String val = fProperties.getProperty(key);
- if(val == null)
+ if (val == null)
val = ""; //$NON-NLS-1$
return val;
}
-
- private String getHelpProviderID(){
+
+ private String getHelpProviderID() {
return getValueByKey(KEY_PROVIDER_ID);
}
- private String getRequestedName(){
+ private String getRequestedName() {
return getValueByKey(KEY_REQUESTED_NAME);
}
- private String getBookTitle(){
+ private String getBookTitle() {
return getValueByKey(KEY_BOOK_TITLE);
}
-
- public boolean onlyTestInfoProvidersAvailable(){
- IConfigurationElement configElements[] = Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, CHelpSettings.CONTRIBUTION_EXTENSION);
+
+ public boolean onlyTestInfoProvidersAvailable() {
+ IConfigurationElement configElements[] = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ CUIPlugin.PLUGIN_ID, CHelpSettings.CONTRIBUTION_EXTENSION);
int numExts = 0;
- for(int i = 0; i < configElements.length; i++){
+ for (int i = 0; i < configElements.length; i++) {
String id = configElements[i].getAttribute("id");
- if(!id.startsWith(CHelpTest.TEST_EXTENSION_ID_PREFIX))
+ if (!id.startsWith(CHelpTest.TEST_EXTENSION_ID_PREFIX))
return false;
}
return true;
}
- public ICHelpResourceDescriptor[] generateHelpResources(ICHelpBook[] helpBooks, String name, String providerID){
+ public ICHelpResourceDescriptor[] generateHelpResources(ICHelpBook[] helpBooks, String name, String providerID) {
ICHelpResourceDescriptor des[] = new ICHelpResourceDescriptor[helpBooks.length];
- for(int i = 0; i < helpBooks.length; i++){
- des[i] = new CHelpResourceDescriptor(helpBooks[i],name,providerID);
+ for (int i = 0; i < helpBooks.length; i++) {
+ des[i] = new CHelpResourceDescriptor(helpBooks[i], name, providerID);
}
return des;
}
-
- public IFunctionSummary generateFunctionInfo(ICHelpBook[] helpBooks, String name, String providerID){
- if(helpBooks.length == 0)
+
+ public IFunctionSummary generateFunctionInfo(ICHelpBook[] helpBooks, String name, String providerID) {
+ if (helpBooks.length == 0)
return null;
- return new FunctionSummary(helpBooks[0],name,providerID);
+ return new FunctionSummary(helpBooks[0], name, providerID);
}
-
- public IFunctionSummary[] generateMatchingFunctions(ICHelpBook[] helpBooks, String prefix, String providerID){
+
+ public IFunctionSummary[] generateMatchingFunctions(ICHelpBook[] helpBooks, String prefix, String providerID) {
IFunctionSummary sum[] = new IFunctionSummary[helpBooks.length];
- for(int i = 0; i < helpBooks.length; i++){
- sum[i] = new FunctionSummary(helpBooks[i],prefix,providerID);
+ for (int i = 0; i < helpBooks.length; i++) {
+ sum[i] = new FunctionSummary(helpBooks[i], prefix, providerID);
}
return sum;
}
-
- public ICHelpBook[] generateCHelpBooks(final String providerID){
+
+ public ICHelpBook[] generateCHelpBooks(final String providerID) {
ICHelpBook books[] = new ICHelpBook[3];
- books[0] = new CHelpBook(providerID,ICHelpBook.HELP_TYPE_C);
- books[1] = new CHelpBook(providerID,ICHelpBook.HELP_TYPE_CPP);
- books[2] = new CHelpBook(providerID,ICHelpBook.HELP_TYPE_ASM);
+ books[0] = new CHelpBook(providerID, ICHelpBook.HELP_TYPE_C);
+ books[1] = new CHelpBook(providerID, ICHelpBook.HELP_TYPE_CPP);
+ books[2] = new CHelpBook(providerID, ICHelpBook.HELP_TYPE_ASM);
return books;
}
-
- private void checkResponse(CHelpProviderTester data[], ICHelpInvocationContext context, String name, boolean allBooksResponded){
+
+ private void checkResponse(CHelpProviderTester data[], ICHelpInvocationContext context, String name, boolean allBooksResponded) {
CHelpBookDescriptor bookDes[] = CHelpProviderManager.getDefault().getCHelpBookDescriptors(context);
- for(int i = 0; i < data.length; i++){
+ for (int i = 0; i < data.length; i++) {
CHelpProviderTester tester = data[i];
- Assert.assertTrue("the name passed to CHelpProvider (" + tester.getRequestedName() + ") differs prom tha name passed to manager (" + name + ")",name.equals(tester.getRequestedName()));
+ Assert.assertTrue("the name passed to CHelpProvider (" + tester.getRequestedName()
+ + ") differs prom tha name passed to manager (" + name + ")", name.equals(tester.getRequestedName()));
String bookTitle = tester.getBookTitle();
int j = 0;
- for(; j < bookDes.length; j++){
- if(bookTitle.equals(bookDes[j].getCHelpBook().getTitle())){
- Assert.assertTrue("provider was requested for help in disabled book",bookDes[j].isEnabled());
+ for (; j < bookDes.length; j++) {
+ if (bookTitle.equals(bookDes[j].getCHelpBook().getTitle())) {
+ Assert.assertTrue("provider was requested for help in disabled book", bookDes[j].isEnabled());
break;
}
}
- Assert.assertFalse("provider was requested for help in non-existent book",j == bookDes.length);
+ Assert.assertFalse("provider was requested for help in non-existent book", j == bookDes.length);
}
-
- if(allBooksResponded){
- for(int i = 0; i < bookDes.length; i++){
- if(bookDes[i].isEnabled()){
+
+ if (allBooksResponded) {
+ for (int i = 0; i < bookDes.length; i++) {
+ if (bookDes[i].isEnabled()) {
String bookTitle = bookDes[i].getCHelpBook().getTitle();
int j = 0;
- for(; j < data.length; j++){
- if(bookTitle.equals(data[j].getBookTitle()))
+ for (; j < data.length; j++) {
+ if (bookTitle.equals(data[j].getBookTitle()))
break;
}
- Assert.assertFalse("provider was not requested for help in enabled book",j == bookDes.length);
+ Assert.assertFalse("provider was not requested for help in enabled book", j == bookDes.length);
}
}
}
}
- public void checkHelpResources(ICHelpResourceDescriptor helpDescriptors[], ICHelpInvocationContext context, String name){
- if(helpDescriptors == null || helpDescriptors.length == 0)
+ public void checkHelpResources(ICHelpResourceDescriptor helpDescriptors[], ICHelpInvocationContext context,
+ String name) {
+ if (helpDescriptors == null || helpDescriptors.length == 0)
return;
- List dataList = new ArrayList(helpDescriptors.length);
- for(int i = 0; i < helpDescriptors.length; i++){
- try{
- dataList.add(new CHelpProviderTester(helpDescriptors[i].getHelpResources()[0].getLabel()));
- }catch(IOException e){
- Assert.fail("checkHelpResources failed to instantiate CHelpProviderTester, IOException occured: " + e.getMessage());
- }
+ List<CHelpProviderTester> dataList = new ArrayList<>(helpDescriptors.length);
+ for (int i = 0; i < helpDescriptors.length; i++) {
+ dataList.add(new CHelpProviderTester(helpDescriptors[i].getHelpResources()[0].getLabel()));
}
- if(dataList.size() > 0)
- checkResponse((CHelpProviderTester[])dataList.toArray(new CHelpProviderTester[dataList.size()]), context, name, true);
+ if (!dataList.isEmpty())
+ checkResponse(dataList.toArray(new CHelpProviderTester[dataList.size()]), context, name, true);
}
- public void checkMatchingFunctions(IFunctionSummary summaries[], ICHelpInvocationContext context, String name){
- if(summaries == null || summaries.length == 0)
+ public void checkMatchingFunctions(IFunctionSummary summaries[], ICHelpInvocationContext context, String name) {
+ if (summaries == null || summaries.length == 0)
return;
- List dataList = new ArrayList(summaries.length);
- for(int i = 0; i < summaries.length; i++){
- try{
- dataList.add(new CHelpProviderTester(summaries[i].getDescription()));
- }catch(IOException e){
- Assert.fail("checkMatchingFunctions failed to instantiate CHelpProviderTester, IOException occured: " + e.getMessage());
- }
+ List<CHelpProviderTester> dataList = new ArrayList<>(summaries.length);
+ for (int i = 0; i < summaries.length; i++) {
+ dataList.add(new CHelpProviderTester(summaries[i].getDescription()));
}
- if(dataList.size() > 0)
- checkResponse((CHelpProviderTester[])dataList.toArray(new CHelpProviderTester[dataList.size()]), context, name, true);
+ if (!dataList.isEmpty())
+ checkResponse(dataList.toArray(new CHelpProviderTester[dataList.size()]), context, name, true);
}
-
- public void checkFunctionInfo(IFunctionSummary summary, ICHelpInvocationContext context, String name){
- if(summary == null)
+
+ public void checkFunctionInfo(IFunctionSummary summary, ICHelpInvocationContext context, String name) {
+ if (summary == null)
return;
CHelpProviderTester data[] = new CHelpProviderTester[1];
- try{
- data[0] = new CHelpProviderTester(summary.getDescription());
- checkResponse(data, context, name, false);
- }catch(IOException e){
- Assert.fail("checkFunctionInfo failed to instantiate CHelpProviderTester, IOException occured: " + e.getMessage());
- }
-
+ data[0] = new CHelpProviderTester(summary.getDescription());
+ checkResponse(data, context, name, false);
}
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java
index b96af9bc7c..bb88e7211c 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java
@@ -10,14 +10,14 @@
*******************************************************************************/
package org.eclipse.cdt.ui.tests.chelp;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
+import org.junit.Assert;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICProject;
@@ -33,6 +33,10 @@ import org.eclipse.cdt.internal.ui.CHelpProviderManager;
import org.eclipse.cdt.internal.ui.text.CHelpBookDescriptor;
import org.eclipse.cdt.internal.ui.text.CHelpSettings;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
*
* CHelpProvider tests
@@ -49,15 +53,15 @@ public class CHelpTest extends TestCase {
private ICHelpInvocationContext fDefaultCHelpContext = null;
private ICHelpInvocationContext getDefaultCCHelpContext() throws CoreException{
- if(fDefaultCCHelpContext == null){
+ if (fDefaultCCHelpContext == null) {
final IProject project = getCCProject().getProject();
- fDefaultCCHelpContext = new ICHelpInvocationContext(){
+ fDefaultCCHelpContext = new ICHelpInvocationContext() {
@Override
- public IProject getProject(){
+ public IProject getProject() {
return project;
}
@Override
- public ITranslationUnit getTranslationUnit(){
+ public ITranslationUnit getTranslationUnit() {
return null;
}
};
@@ -66,15 +70,15 @@ public class CHelpTest extends TestCase {
}
private ICHelpInvocationContext getDefaultCHelpContext() throws CoreException{
- if(fDefaultCHelpContext == null){
+ if (fDefaultCHelpContext == null) {
final IProject project = getCProject().getProject();
- fDefaultCHelpContext = new ICHelpInvocationContext(){
+ fDefaultCHelpContext = new ICHelpInvocationContext() {
@Override
- public IProject getProject(){
+ public IProject getProject() {
return project;
}
@Override
- public ITranslationUnit getTranslationUnit(){
+ public ITranslationUnit getTranslationUnit() {
return null;
}
};
@@ -83,13 +87,13 @@ public class CHelpTest extends TestCase {
}
private ICProject getCProject() throws CoreException{
- if(fCProject == null)
+ if (fCProject == null)
fCProject = CProjectHelper.createCProject(C_PROJECT_NAME, BIN_DIR_NAME, IPDOMManager.ID_NO_INDEXER);
return fCProject;
}
private ICProject getCCProject() throws CoreException{
- if(fCCProject == null)
+ if (fCCProject == null)
fCCProject = CProjectHelper.createCCProject(CC_PROJECT_NAME, BIN_DIR_NAME, IPDOMManager.ID_NO_INDEXER);
return fCCProject;
}
@@ -110,14 +114,14 @@ public class CHelpTest extends TestCase {
super.tearDown();
}
- public void testCHelpProviderManagerGeneral(){
+ public void testCHelpProviderManagerGeneral() {
CHelpProviderManager mngr = CHelpProviderManager.getDefault();
- if(mngr == null)
+ if (mngr == null)
fail("manager not created"); //$NON-NLS-1$
- if(mngr != CHelpProviderManager.getDefault())
+ if (mngr != CHelpProviderManager.getDefault())
fail("getDefault returned an other instance of manager"); //$NON-NLS-1$
- try{
+ try {
ICHelpInvocationContext cContext = getDefaultCHelpContext();
ICHelpInvocationContext ccContext = getDefaultCCHelpContext();
@@ -133,116 +137,120 @@ public class CHelpTest extends TestCase {
IConfigurationElement configElements[] = Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, CHelpSettings.CONTRIBUTION_EXTENSION);
int numExts = 0;
- for(int i = 0; i < configElements.length; i++){
+ for (int i = 0; i < configElements.length; i++) {
String id = configElements[i].getAttribute("id"); //$NON-NLS-1$
if(id.startsWith(TEST_EXTENSION_ID_PREFIX))
numExts++;
}
assertTrue("number of provider instances created (" + CHelpTestInfoProvider.getNumProviders() + ") is not equal to number of extensions (" + numExts + ")",numExts == CHelpTestInfoProvider.getNumProviders()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }catch(CoreException e){
- fail("CoreException occured: " + e.getMessage()); //$NON-NLS-1$
+ } catch (CoreException e) {
+ fail(e);
}
}
- public void testGetMatchingFunctions(){
- if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
+ public void testGetMatchingFunctions() {
+ if (!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()) {
//this test assumes that only CHelpTestInfoProviders are available
return;
}
- try{
+ try {
ICHelpInvocationContext cContext = getDefaultCHelpContext();
ICHelpInvocationContext ccContext = getDefaultCCHelpContext();
String requestedName = "dummyName"; //$NON-NLS-1$
- IFunctionSummary summaries[] = CHelpProviderManager.getDefault().getMatchingFunctions(cContext,requestedName);
+ IFunctionSummary summaries[] = CHelpProviderManager.getDefault().getMatchingFunctions(cContext, requestedName);
CHelpProviderTester.getDefault().checkMatchingFunctions(summaries, cContext, requestedName);
- summaries = CHelpProviderManager.getDefault().getMatchingFunctions(ccContext,requestedName);
+ summaries = CHelpProviderManager.getDefault().getMatchingFunctions(ccContext, requestedName);
CHelpProviderTester.getDefault().checkMatchingFunctions(summaries, ccContext, requestedName);
- }
- catch(CoreException e){
- fail("CoreException occured: " + e.getMessage()); //$NON-NLS-1$
+ } catch (CoreException e) {
+ fail(e);
}
}
- public void testGetFunctionInfo(){
- if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
- //this test assumes that only CHelpTestInfoProviders are available
+ public void testGetFunctionInfo() {
+ if (!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()) {
+ // This test assumes that only CHelpTestInfoProviders are available.
return;
}
- try{
+ try {
ICHelpInvocationContext cContext = getDefaultCHelpContext();
ICHelpInvocationContext ccContext = getDefaultCCHelpContext();
String requestedName = "dummyName"; //$NON-NLS-1$
- IFunctionSummary summary = CHelpProviderManager.getDefault().getFunctionInfo(cContext,requestedName);
+ IFunctionSummary summary = CHelpProviderManager.getDefault().getFunctionInfo(cContext, requestedName);
CHelpProviderTester.getDefault().checkFunctionInfo(summary, cContext, requestedName);
- summary = CHelpProviderManager.getDefault().getFunctionInfo(ccContext,requestedName);
+ summary = CHelpProviderManager.getDefault().getFunctionInfo(ccContext, requestedName);
CHelpProviderTester.getDefault().checkFunctionInfo(summary, ccContext, requestedName);
- }
- catch(CoreException e){
+ } catch (CoreException e) {
fail("CoreException occured: " + e.getMessage()); //$NON-NLS-1$
}
}
- public void testGetHelpResources(){
- if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
+ public void testGetHelpResources() {
+ if (!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()) {
//this test assumes that only CHelpTestInfoProviders are available
return;
}
- try{
+ try {
ICHelpInvocationContext cContext = getDefaultCHelpContext();
ICHelpInvocationContext ccContext = getDefaultCCHelpContext();
String requestedName = "dummyName"; //$NON-NLS-1$
- ICHelpResourceDescriptor resourceDes[] = CHelpProviderManager.getDefault().getHelpResources(cContext,requestedName);
+ ICHelpResourceDescriptor resourceDes[] = CHelpProviderManager.getDefault().getHelpResources(cContext, requestedName);
CHelpProviderTester.getDefault().checkHelpResources(resourceDes, cContext, requestedName);
- resourceDes = CHelpProviderManager.getDefault().getHelpResources(ccContext,requestedName);
+ resourceDes = CHelpProviderManager.getDefault().getHelpResources(ccContext, requestedName);
CHelpProviderTester.getDefault().checkHelpResources(resourceDes, ccContext, requestedName);
- }
- catch(CoreException e){
+ } catch (CoreException e) {
fail("CoreException occured: " + e.getMessage()); //$NON-NLS-1$
}
}
- public void testCHelpBookDescriptors(){
+ public void testCHelpBookDescriptors() {
CHelpProviderManager mngr = CHelpProviderManager.getDefault();
- try{
+ try {
CHelpBookDescriptor ccBookDescriptors[] = mngr.getCHelpBookDescriptors(getDefaultCCHelpContext());
CHelpBookDescriptor cBookDescriptors[] = mngr.getCHelpBookDescriptors(getDefaultCHelpContext());
assertTrue("CC book descriptors length (" + ccBookDescriptors.length + ") is less than C book descriptors length (" + cBookDescriptors.length + ")", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ccBookDescriptors.length >= cBookDescriptors.length);
- for(int i = 0; i < cBookDescriptors.length; i++){
+ for (int i = 0; i < cBookDescriptors.length; i++) {
CHelpBookDescriptor curBookDes = cBookDescriptors[i];
assertTrue("book \"" + curBookDes.getCHelpBook().getTitle() + "\" of type HELP_TYPE_CPP in book descriptors for C project \"" + getDefaultCHelpContext().getProject().getName() + "\"", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
curBookDes.getCHelpBook().getCHelpType() != ICHelpBook.HELP_TYPE_CPP);
int j = 0;
- for(; j < ccBookDescriptors.length; j++){
- if(ccBookDescriptors[j].getCHelpBook().getTitle().equals(curBookDes.getCHelpBook().getTitle()))
+ for (; j < ccBookDescriptors.length; j++) {
+ if (ccBookDescriptors[j].getCHelpBook().getTitle().equals(curBookDes.getCHelpBook().getTitle()))
break;
}
- assertTrue("book \"" + curBookDes.getCHelpBook().getTitle() + "\" was not found in CC books",j < ccBookDescriptors.length); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("book \"" + curBookDes.getCHelpBook().getTitle() + "\" was not found in CC books", j < ccBookDescriptors.length); //$NON-NLS-1$ //$NON-NLS-2$
}
- for(int i = 0; i < ccBookDescriptors.length; i++){
+ for (int i = 0; i < ccBookDescriptors.length; i++) {
CHelpBookDescriptor curBookDes = ccBookDescriptors[i];
int j = 0;
- for(; j < cBookDescriptors.length; j++){
+ for (; j < cBookDescriptors.length; j++) {
if(cBookDescriptors[j].getCHelpBook().getTitle().equals(curBookDes.getCHelpBook().getTitle()))
break;
}
assertTrue("book \"" + curBookDes.getCHelpBook().getTitle() + "\" of type HELP_TYPE_C was not found in C books", //$NON-NLS-1$ //$NON-NLS-2$
j < cBookDescriptors.length || curBookDes.getCHelpBook().getCHelpType() == ICHelpBook.HELP_TYPE_CPP);
}
- }
- catch(CoreException e){
+ } catch (CoreException e) {
fail("CoreException occured: " + e.getMessage()); //$NON-NLS-1$
}
}
+
+ static void fail(Throwable t) {
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter);
+ printWriter.println(t);
+ t.printStackTrace(printWriter);
+ Assert.fail(stringWriter.toString());
+ }
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java
index 8ec2fe05a0..dfa4874e31 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java
@@ -10,7 +10,7 @@
**********************************************************************/
package org.eclipse.cdt.ui.tests.chelp;
-import junit.framework.Assert;
+import org.junit.Assert;
import org.eclipse.cdt.ui.ICHelpBook;
import org.eclipse.cdt.ui.ICHelpProvider;
@@ -19,15 +19,14 @@ import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
/**
- *
- * this class implements ICHelpProvider and provides test information
+ * This class implements ICHelpProvider and provides test information
*/
public class CHelpTestInfoProvider implements ICHelpProvider {
private static int fNumProviders = 0;
private static final String PROVIDER_ID_PREFIX = "TestInfoProvider_";
final private String fProviderID;
- private boolean fIsInitialized = false;
+ private boolean fIsInitialized;
private ICHelpBook fCHelpBooks[];
@@ -37,27 +36,21 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
*/
static boolean fgEnabled= false;
- public CHelpTestInfoProvider(){
+ public CHelpTestInfoProvider() {
fProviderID = PROVIDER_ID_PREFIX + fNumProviders++;
fCHelpBooks = CHelpProviderTester.getDefault().generateCHelpBooks(fProviderID);
}
- public static int getNumProviders(){
+ public static int getNumProviders() {
return fNumProviders;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.ICHelpProvider#initialize()
- */
@Override
public void initialize() {
- Assert.assertFalse("initialize is called several times",fIsInitialized);
+ Assert.assertFalse("initialize is called several times", fIsInitialized);
fIsInitialized = true;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.ICHelpProvider#getCHelpBooks()
- */
@Override
public ICHelpBook[] getCHelpBooks() {
if (!fgEnabled) {
@@ -67,22 +60,15 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
return fCHelpBooks;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.ICHelpProvider#getFunctionInfo(org.eclipse.cdt.ui.text.ICHelpInvocationContext, org.eclipse.cdt.ui.ICHelpBook[], java.lang.String)
- */
@Override
- public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context,
- ICHelpBook[] helpBooks, String name) {
+ public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
if (!fgEnabled) {
return null;
}
Assert.assertTrue("getFunctionInfo is called before completion contributor gets initialized",fIsInitialized);
- return CHelpProviderTester.getDefault().generateFunctionInfo(helpBooks,name,fProviderID);
+ return CHelpProviderTester.getDefault().generateFunctionInfo(helpBooks, name, fProviderID);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.ICHelpProvider#getMatchingFunctions(org.eclipse.cdt.ui.text.ICHelpInvocationContext, org.eclipse.cdt.ui.ICHelpBook[], java.lang.String)
- */
@Override
public IFunctionSummary[] getMatchingFunctions(
ICHelpInvocationContext context, ICHelpBook[] helpBooks,
@@ -90,21 +76,18 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
if (!fgEnabled) {
return new IFunctionSummary[0];
}
- Assert.assertTrue("getMatchingFunctions is called before completion contributor gets initialized",fIsInitialized);
+ Assert.assertTrue("getMatchingFunctions is called before completion contributor gets initialized", fIsInitialized);
return null; // TODO returning null until someone puts in a preference to control it.
- //return CHelpProviderTester.getDefault().generateMatchingFunctions(helpBooks,prefix,fProviderID);
+ //return CHelpProviderTester.getDefault().generateMatchingFunctions(helpBooks, prefix, fProviderID);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.ICHelpProvider#getHelpResources(org.eclipse.cdt.ui.text.ICHelpInvocationContext, org.eclipse.cdt.ui.ICHelpBook[], java.lang.String)
- */
@Override
- public ICHelpResourceDescriptor[] getHelpResources(
- ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
+ public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, ICHelpBook[] helpBooks,
+ String name) {
if (!fgEnabled) {
return new ICHelpResourceDescriptor[0];
}
- Assert.assertTrue("getHelpResources is called before completion contributor gets initialized",fIsInitialized);
- return CHelpProviderTester.getDefault().generateHelpResources(helpBooks,name,fProviderID);
+ Assert.assertTrue("getHelpResources is called before completion contributor gets initialized", fIsInitialized);
+ return CHelpProviderTester.getDefault().generateHelpResources(helpBooks, name, fProviderID);
}
}

Back to the top