diff options
author | Mike Rennie | 2013-07-31 16:44:16 +0000 |
---|---|---|
committer | Mike Rennie | 2013-07-31 16:44:16 +0000 |
commit | d975f27f12707ae6598994c5e3c6bd5e271d46c4 (patch) | |
tree | c7d1b2b1a202e19c0c2ccaaff959f4dd25286f0d /org.eclipse.debug.tests | |
parent | 4fcde1ffaf34791bd406d47ce72d17e2801432a3 (diff) | |
download | eclipse.platform.debug-d975f27f12707ae6598994c5e3c6bd5e271d46c4.tar.gz eclipse.platform.debug-d975f27f12707ae6598994c5e3c6bd5e271d46c4.tar.xz eclipse.platform.debug-d975f27f12707ae6598994c5e3c6bd5e271d46c4.zip |
Bug 352626 - Move platform debug to Java 1.6 BREE
Diffstat (limited to 'org.eclipse.debug.tests')
56 files changed, 1674 insertions, 1345 deletions
diff --git a/org.eclipse.debug.tests/.classpath b/org.eclipse.debug.tests/.classpath index 2fbb7a23e..ad32c83a7 100644 --- a/org.eclipse.debug.tests/.classpath +++ b/org.eclipse.debug.tests/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/org.eclipse.debug.tests/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.debug.tests/.settings/org.eclipse.jdt.core.prefs index 5d7a22fe3..caf704038 100644 --- a/org.eclipse.debug.tests/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.debug.tests/.settings/org.eclipse.jdt.core.prefs @@ -14,17 +14,17 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonN org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning @@ -33,9 +33,9 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=error org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore @@ -53,10 +53,10 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public @@ -65,7 +65,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore @@ -81,8 +81,8 @@ org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=error org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore @@ -91,18 +91,18 @@ org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=error org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=error org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning @@ -119,9 +119,9 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=error org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,HIGH,HIGH org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,EXPERIMENTAL,CONTEXTLAUNCHING diff --git a/org.eclipse.debug.tests/META-INF/MANIFEST.MF b/org.eclipse.debug.tests/META-INF/MANIFEST.MF index 02801facd..54d5bec36 100644 --- a/org.eclipse.debug.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.debug.tests/META-INF/MANIFEST.MF @@ -7,14 +7,14 @@ Bundle-Activator: org.eclipse.debug.tests.TestsPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", - org.eclipse.debug.ui;bundle-version="[3.6.0,4.0.0)", + org.eclipse.debug.ui;bundle-version="[3.10.0,4.0.0)", org.junit, org.eclipse.core.filesystem;bundle-version="[1.3.0,2.0.0)", org.eclipse.test.performance;bundle-version="3.6.0", org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)", - org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)" + org.eclipse.debug.core;bundle-version="[3.9.0,4.0.0)" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %providerName Export-Package: org.eclipe.debug.tests.launching, org.eclipe.debug.tests.view.memory, diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java index 3330c2872..c43a0ccc6 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/ArgumentParsingTests.java @@ -35,41 +35,41 @@ import org.eclipse.osgi.service.environment.Constants; * {@link org.eclipse.debug.core.DebugPlugin#renderArguments(String[], int[])}. */ public class ArgumentParsingTests extends TestCase { - + private void execute1Arg(String cmdLine) throws Exception { execute1Arg(cmdLine, cmdLine); } - + private void execute1Arg(String cmdLine, String argParsed) throws Exception { execute1Arg(cmdLine, argParsed, cmdLine); } - + private void execute1Arg(String cmdLine, String argParsed, String rendered) throws Exception { execute("a " + cmdLine + " b", new String[] { "a", argParsed, "b" }, "a " + rendered + " b"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ } - + private static void execute(String commandLine, String[] expectedArgs) throws Exception { execute(commandLine, expectedArgs, commandLine); } - + private static void execute(String commandLine, String[] expectedArgs, String expectedRendered) throws Exception { String[] arguments = DebugPlugin.parseArguments(commandLine); assertEquals("unexpected parseArguments result;", //$NON-NLS-1$ Arrays.asList(expectedArgs).toString(), Arrays.asList(arguments).toString()); - + runCommandLine(commandLine, arguments); - + String rendered = DebugPlugin.renderArguments(arguments, null); assertEquals("unexpected renderArguments result;", expectedRendered, rendered); //$NON-NLS-1$ - + if (!commandLine.equals(rendered)) { String[] arguments2 = DebugPlugin.parseArguments(rendered); assertEquals("parsing rendered command line doesn't yield original arguments;", //$NON-NLS-1$ Arrays.asList(expectedArgs).toString(), Arrays.asList(arguments2).toString()); } - + } private static void runCommandLine(String commandLine, String[] arguments) throws IOException, @@ -80,20 +80,20 @@ public class ArgumentParsingTests extends TestCase { } classPathUrl = FileLocator.toFileURL(classPathUrl); File classPathFile = URIUtil.toFile(URIUtil.toURI(classPathUrl)); - + String[] execArgs= new String[arguments.length + 4]; execArgs[0] = new Path(System.getProperty("java.home")).append("bin/java").toOSString(); //$NON-NLS-1$ //$NON-NLS-2$ execArgs[1] = "-cp"; //$NON-NLS-1$ execArgs[2]= classPathFile.getAbsolutePath(); execArgs[3]= ArgumentsPrinter.class.getName(); System.arraycopy(arguments, 0, execArgs, 4, arguments.length); - - ArrayList resultArgs = runCommandLine(execArgs); - + + ArrayList<String> resultArgs = runCommandLine(execArgs); + assertEquals("unexpected exec result;", //$NON-NLS-1$ Arrays.asList(arguments).toString(), resultArgs.toString()); - + if (! Platform.getOS().equals(Constants.OS_WIN32)) { execArgs = new String[] { "sh", "-c", execArgs[0] + " " + execArgs[1] + " " + execArgs[2] + " " + execArgs[3] + " " + commandLine }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ resultArgs = runCommandLine(execArgs); @@ -103,20 +103,20 @@ public class ArgumentParsingTests extends TestCase { } } - private static ArrayList runCommandLine(String[] execArgs) + private static ArrayList<String> runCommandLine(String[] execArgs) throws CoreException, IOException { execArgs = quoteWindowsArgs(execArgs); Process process = DebugPlugin.exec(execArgs, null); BufferedReader procOut = new BufferedReader(new InputStreamReader(process.getInputStream())); - - ArrayList procArgs= new ArrayList(); + + ArrayList<String> procArgs = new ArrayList<String>(); String procArg; while ((procArg = procOut.readLine()) != null) { procArgs.add(procArg); } return procArgs; } - + private static String[] quoteWindowsArgs(String[] cmdLine) { // see https://bugs.eclipse.org/387504#c13 , workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6511002 if (Platform.getOS().equals(Constants.OS_WIN32)) { @@ -128,8 +128,8 @@ public class ArgumentParsingTests extends TestCase { } return cmdLine; } - - + + private static boolean needsQuoting(String s) { int len = s.length(); if (len == 0) { @@ -139,6 +139,8 @@ public class ArgumentParsingTests extends TestCase { switch (s.charAt(i)) { case ' ': case '\t': case '\\': case '"': return true; + default: + break; } } return false; @@ -152,7 +154,7 @@ public class ArgumentParsingTests extends TestCase { s = s.replaceAll("([\\\\]*)\\z", "$1$1"); //$NON-NLS-1$ //$NON-NLS-2$ return "\"" + s + "\""; //$NON-NLS-1$ //$NON-NLS-2$ } - + // -- tests: public void testEmpty() throws Exception { @@ -177,7 +179,7 @@ public class ArgumentParsingTests extends TestCase { Arrays.fill(args, "a"); //$NON-NLS-1$ execute(buf.toString(), args, buf.toString().trim()); } - + public void testEscape() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("\\1"); //$NON-NLS-1$ @@ -185,15 +187,15 @@ public class ArgumentParsingTests extends TestCase { execute1Arg("\\1", "1", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } - + public void testEscapeDoubleQuote1() throws Exception { execute1Arg("\\\"", "\"", "\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - + public void testEscapeDoubleQuote2() throws Exception { execute1Arg("arg=\\\"bla\\\"", "arg=\"bla\"", "arg=\\\"bla\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - + public void testDoubleQuoted1() throws Exception { execute1Arg("\"1 2\"", "1 2"); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -201,7 +203,7 @@ public class ArgumentParsingTests extends TestCase { public void testDoubleQuoted2() throws Exception { execute1Arg("\"1\"", "1", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - + public void testDoubleQuoted3() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { // execute1Arg("\"\"", "", "\"\""); // would be correct, but ProcessImpl is buggy on Windows JDKs @@ -210,7 +212,7 @@ public class ArgumentParsingTests extends TestCase { execute1Arg("\"\"", "", "\"\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } - + public void testDoubleQuoted4() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("\"\"\"\"", "\"", "\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -218,11 +220,11 @@ public class ArgumentParsingTests extends TestCase { execute1Arg("\"\"\"\"", "", "\"\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } - + public void testDoubleQuoted5() throws Exception { execute1Arg("ab\"cd\"ef\"gh\"", "abcdefgh", "abcdefgh"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - + public void testDoubleQuotedWithSpace1() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("\"\"\"1\"\" 2\"", "\"1\" 2", "\"\\\"1\\\" 2\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -230,11 +232,11 @@ public class ArgumentParsingTests extends TestCase { execute1Arg("\"\"\"1\"\" 2\"", "1 2", "\"1 2\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } - + public void testDoubleQuotedWithSpace2() throws Exception { execute1Arg("\"\\\"1\\\" 2\"", "\"1\" 2"); //$NON-NLS-1$ //$NON-NLS-2$ } - + public void testSingleQuoted1() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("'1 2'", new String[] { "'1", "2'" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -242,7 +244,7 @@ public class ArgumentParsingTests extends TestCase { execute("'1 2'", new String[] { "1 2" }, "\"1 2\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } - + public void testSingleQuoted2() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("'1'", "'1'", "'1'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -250,11 +252,11 @@ public class ArgumentParsingTests extends TestCase { execute1Arg("'1'", "1", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } - + public void testWindows1() throws Exception { execute("\"a b c\" d e", new String[] { "a b c", "d", "e" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } - + public void testWindows2() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("\"ab\\\"c\" \"\\\\\" d", new String[] { "ab\"c", "\\", "d" }, "ab\\\"c \\ d"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ @@ -262,7 +264,7 @@ public class ArgumentParsingTests extends TestCase { execute("\"ab\\\"c\" \"\\\\\" d", new String[] { "ab\"c", "\\", "d" }, "ab\\\"c \\\\ d"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } } - + public void testWindows3() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("a\\\\\\b d\"e f\"g h", new String[] { "a\\\\\\b", "de fg", "h" }, "a\\\\\\b \"de fg\" h"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ @@ -270,11 +272,11 @@ public class ArgumentParsingTests extends TestCase { execute("a\\\\\\b d\"e f\"g h", new String[] { "a\\b", "de fg", "h" }, "a\\\\b \"de fg\" h"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } } - + public void testWindows4() throws Exception { execute("a\\\\\\\"b c d", new String[] { "a\\\"b", "c", "d" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } - + public void testWindows5() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("a\\\\\\\\\"b c\" d e", new String[] { "a\\\\b c", "d", "e" }, "\"a\\\\b c\" d e"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ @@ -282,7 +284,7 @@ public class ArgumentParsingTests extends TestCase { execute("a\\\\\\\\\"b c\" d e", new String[] { "a\\\\b c", "d", "e" }, "\"a\\\\\\\\b c\" d e"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } } - + public void testAllInOne() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("1 \"\" 2 \" \" 3 \\\" 4 \"a b\" 5 \\\"bla\\\" 6 \"ab\"cd 7 ef\"gh\" 8 i\"\"j 9 \"x\\\"y\\\\\" 10 z\\\\z 11 \"two-quotes:\"\"\"\"\" 12 \"g\"\"h\" 13 \"\"\"a\"\" b\"", //$NON-NLS-1$ @@ -294,5 +296,5 @@ public class ArgumentParsingTests extends TestCase { "1 \"\" 2 \" \" 3 \\\" 4 \"a b\" 5 \\\"bla\\\" 6 abcd 7 efgh 8 ij 9 x\\\"y\\\\ 10 z\\\\z 11 two-quotes: 12 gh 13 \"a b\""); //$NON-NLS-1$ } } - + } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileStore.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileStore.java index 283c461fc..d3f42a73b 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileStore.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileStore.java @@ -36,24 +36,25 @@ import org.eclipse.core.runtime.Status; * Implementation of an in memory file store to test launch configurations on EFS */ public class DebugFileStore extends FileStore { - + /** * Output steam for writing a file */ class DebugOutputStream extends ByteArrayOutputStream { - + /* (non-Javadoc) * @see java.io.ByteArrayOutputStream#close() */ + @Override public void close() throws IOException { super.close(); DebugFileSystem.getDefault().setContents(toURI(), toByteArray()); } - + } - + private final URI uri; - + public DebugFileStore(URI id) { uri = id; } @@ -61,9 +62,10 @@ public class DebugFileStore extends FileStore { /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#childNames(int, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public String[] childNames(int options, IProgressMonitor monitor) throws CoreException { URI[] uris = DebugFileSystem.getDefault().getFileURIs(); - List children = new ArrayList(); + List<String> children = new ArrayList<String>(); IPath me = getPath(); for (int i = 0; i < uris.length; i++) { URI id = uris[i]; @@ -74,12 +76,13 @@ public class DebugFileStore extends FileStore { } } } - return (String[]) children.toArray(new String[children.size()]); + return children.toArray(new String[children.size()]); } /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#fetchInfo(int, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { byte[] contents = DebugFileSystem.getDefault().getContents(toURI()); FileInfo info = new FileInfo(); @@ -102,6 +105,7 @@ public class DebugFileStore extends FileStore { /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#getChild(java.lang.String) */ + @Override public IFileStore getChild(String name) { try { return new DebugFileStore(new URI(getFileSystem().getScheme(), getPath().append(name).toString(), null)); @@ -113,6 +117,7 @@ public class DebugFileStore extends FileStore { /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#getName() */ + @Override public String getName() { IPath path = getPath(); if (path.segmentCount() > 0) { @@ -133,6 +138,7 @@ public class DebugFileStore extends FileStore { /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#getParent() */ + @Override public IFileStore getParent() { IPath path = getPath(); if (path.segmentCount() > 0) { @@ -147,6 +153,7 @@ public class DebugFileStore extends FileStore { /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#openInputStream(int, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException { byte[] contents = DebugFileSystem.getDefault().getContents(toURI()); if (contents != null) { @@ -155,17 +162,19 @@ public class DebugFileStore extends FileStore { throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jdt.debug.tests", //$NON-NLS-1$ "File does not exist: " + toURI())); //$NON-NLS-1$ } - + /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException { return new DebugOutputStream(); } - + /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#mkdir(int, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException { IFileInfo info = fetchInfo(); if (info.exists()) { @@ -192,6 +201,7 @@ public class DebugFileStore extends FileStore { /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#toURI() */ + @Override public URI toURI() { return uri; } @@ -199,6 +209,7 @@ public class DebugFileStore extends FileStore { /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileStore#delete(int, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void delete(int options, IProgressMonitor monitor) throws CoreException { DebugFileSystem.getDefault().delete(toURI()); } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileSystem.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileSystem.java index 7ec08bf71..3c876f687 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileSystem.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/DebugFileSystem.java @@ -23,18 +23,18 @@ import org.eclipse.core.runtime.Path; * A simple in memory file system to test launch configurations in EFS */ public class DebugFileSystem extends FileSystem { - + /** * represents a directory */ public static final byte[] DIRECTORY_BYTES = new byte[] {1, 2, 3, 4}; - + private static DebugFileSystem system; - + /** * Keys URIs to file stores for existing files */ - private final Map files = new HashMap(); + private final Map<URI, byte[]> files = new HashMap<URI, byte[]>(); /** * Constructs the singleton @@ -46,50 +46,53 @@ public class DebugFileSystem extends FileSystem { setContents(new URI("debug", Path.ROOT.toString(), null), DIRECTORY_BYTES); //$NON-NLS-1$ } catch (URISyntaxException e) {} } - + /** * Returns the Debug files system. - * + * * @return file system */ static DebugFileSystem getDefault() { return system; } - + /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileSystem#getStore(java.net.URI) */ + @Override public IFileStore getStore(URI uri) { return new DebugFileStore(uri); } - + /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileSystem#canDelete() */ + @Override public boolean canDelete() { return true; } - + /* (non-Javadoc) * @see org.eclipse.core.filesystem.provider.FileSystem#canWrite() */ + @Override public boolean canWrite() { return true; } - + /** * Returns whether contents of the file or <code>null</code> if none. - * + * * @param uri * @return bytes or <code>null</code> */ public byte[] getContents(URI uri) { - return (byte[]) files.get(uri); + return files.get(uri); } - + /** * Deletes the file. - * + * * @param uri */ public void delete(URI uri) { @@ -98,21 +101,21 @@ public class DebugFileSystem extends FileSystem { /** * Sets the content of the given file. - * + * * @param uri * @param bytes */ public void setContents(URI uri, byte[] bytes) { files.put(uri, bytes); } - + /** * Returns URIs of all existing files. - * + * * @return */ public URI[] getFileURIs() { - return (URI[])files.keySet().toArray(new URI[files.size()]); + return files.keySet().toArray(new URI[files.size()]); } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java index 167667c3e..707ac8465 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchConfigurationTests.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -61,23 +61,24 @@ import org.eclipse.ui.PlatformUI; /** * Tests for launch configurations */ +@SuppressWarnings("deprecation") public class LaunchConfigurationTests extends AbstractLaunchTest implements ILaunchConfigurationListener { - + /** * Identifier of test launch configuration type extension */ public static final String ID_TEST_LAUNCH_TYPE = "org.eclipse.debug.tests.launch.type"; //$NON-NLS-1$ - + /** * The from/to handles during rename operations */ protected ILaunchConfiguration fFrom; protected ILaunchConfiguration fTo; - + protected Object fLock = new Object(); protected ILaunchConfiguration fAdded; protected ILaunchConfiguration fRemoved; - + /** * Class to hold resource description infos * @since 3.9.0 @@ -90,16 +91,17 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau String path; Integer type; } - + class Listener implements ILaunchConfigurationListener { - - private final List addedList = new ArrayList(); - private final List removedList = new ArrayList(); - private final List changedList = new ArrayList(); + + private final List<ILaunchConfiguration> addedList = new ArrayList<ILaunchConfiguration>(); + private final List<ILaunchConfiguration> removedList = new ArrayList<ILaunchConfiguration>(); + private final List<ILaunchConfiguration> changedList = new ArrayList<ILaunchConfiguration>(); /* (non-Javadoc) * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void launchConfigurationAdded(ILaunchConfiguration configuration) { addedList.add(configuration); } @@ -107,6 +109,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /* (non-Javadoc) * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void launchConfigurationChanged(ILaunchConfiguration configuration) { changedList.add(configuration); } @@ -114,27 +117,30 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /* (non-Javadoc) * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void launchConfigurationRemoved(ILaunchConfiguration configuration) { removedList.add(configuration); } - - public List getAdded() { + + public List<ILaunchConfiguration> getAdded() { return addedList; } - public List getChanged() { + + public List<ILaunchConfiguration> getChanged() { return changedList; } - public List getRemoved() { + + public List<ILaunchConfiguration> getRemoved() { return removedList; } - + } - + /** * Returns the given input stream's contents as a character array. * If a length is specified (i.e. if length != -1), this represents the number of bytes in the stream. * Note the specified stream is not closed in this method - * @param stream the stream to get convert to the char array + * @param stream the stream to get convert to the char array * @return the given input stream's contents as a character array. * @throws IOException if a problem occurred reading the stream. */ @@ -157,7 +163,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau byteBuffer.flip(); return charsetDecoder.decode(byteBuffer).array(); } - + /** * Returns the given input stream as a byte array * @param stream the stream to get as a byte array @@ -206,8 +212,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } } return contents; - } - + } + /** * Constructor * @param name @@ -215,17 +221,17 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau public LaunchConfigurationTests(String name) { super(name); } - + /** * Returns a scratch project for launch configurations - * + * * @return */ protected IProject getProject() throws CoreException { return TestsPlugin.createProject("LaunchConfigurationTests"); //$NON-NLS-1$ } - - /** + + /** * Creates and returns a new launch config the given name, local * or shared, with 4 attributes: * - String1 = "String1" @@ -245,8 +251,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$ return wc; } - - /** + + /** * Creates and returns a new launch configuration with the given name, local * or shared, with no attributes */ @@ -255,8 +261,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name); assertEquals("Should have no attributes", 0, wc.getAttributes().size()); //$NON-NLS-1$ return wc; - } - + } + /** * Returns whether the given handle is contained in the specified * array of handles. @@ -269,11 +275,11 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } return false; } - + /** * Creates a local working copy configuration, sets some attributes, * and saves the working copy, and retrieves the attributes. - * + * * @throws CoreException */ public void testCreateLocalConfiguration() throws CoreException { @@ -282,40 +288,40 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfiguration handle = wc.doSave(); File file = location.toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - + // retrieve attributes assertEquals("String1 should be String1", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertEquals("Int1 should be 1", handle.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$//$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$//$NON-NLS-2$ - + // ensure new handle is the index ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$ - + // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ } - + /** * Creates a local working copy configuration and tests its name. - * + * * @throws CoreException */ public void testLocalName() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "localName"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes - assertEquals("Wrong name", handle.getName(), "localName"); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Wrong name", handle.getName(), "localName"); //$NON-NLS-1$ //$NON-NLS-2$ // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ - } - + } + /** * Creates a shared working copy configuration and tests is name. */ @@ -323,15 +329,15 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "sharedName"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes - assertEquals("Wrong name", handle.getName(), "sharedName"); //$NON-NLS-1$ //$NON-NLS-2$ - + assertEquals("Wrong name", handle.getName(), "sharedName"); //$NON-NLS-1$ //$NON-NLS-2$ + // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ - } - + } + /** * Ensures that a launch configuration returns a complete attribute map * @throws CoreException @@ -343,7 +349,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau File file = location.toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - Map attributes = handle.getAttributes(); + Map<?, ?> attributes = handle.getAttributes(); // retrieve attributes assertEquals("String1 should be String1", "String1", attributes.get("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals("Int1 should be 1", new Integer(1), attributes.get("Int1")); //$NON-NLS-1$ //$NON-NLS-2$ @@ -353,15 +359,15 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ - } - + } + /** * Ensures that set attributes works * @throws CoreException */ public void testSetAttributes() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$ - Map map = new HashMap(); + Map<String, Object> map = new HashMap<String, Object>(); map.put("ATTR1", "ONE"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("ATTR2", "TWO"); //$NON-NLS-1$ //$NON-NLS-2$ wc.setAttributes(map); @@ -370,7 +376,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau File file = location.toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - Map attributes = handle.getAttributes(); + Map<?, ?> attributes = handle.getAttributes(); assertEquals("should have two attributes", 2, attributes.size()); //$NON-NLS-1$ // retrieve attributes assertEquals("ATTR1 should be ONE", "ONE", attributes.get("ATTR1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -379,8 +385,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ - } - + } + /** * Ensures that set attributes to <code>null</code> works * @throws CoreException @@ -393,13 +399,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau File file = location.toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - Map attributes = handle.getAttributes(); + Map<?, ?> attributes = handle.getAttributes(); assertEquals("should have no attributes", 0, attributes.size()); //$NON-NLS-1$ // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ } - + /** * Creates a local working copy configuration, sets some attributes, * and saves the working copy, and retrieves the attributes. @@ -412,17 +418,17 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfiguration handle = wc.doSave(); File file = location.toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + // ensure new handle is the index ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$ - + ILaunchConfigurationWorkingCopy softCopy = handle.copy("CopyOf" + handle.getName()); //$NON-NLS-1$ assertNull("Original in copy should be null", softCopy.getOriginal()); //$NON-NLS-1$ ILaunchConfiguration hardCopy = softCopy.doSave(); @@ -432,16 +438,16 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertTrue("Int1 should be 1", hardCopy.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", hardCopy.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !hardCopy.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + assertTrue("Original should still exist", handle.exists()); //$NON-NLS-1$ - + // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ hardCopy.delete(); assertTrue("Config should not exist after deletion", !hardCopy.exists()); //$NON-NLS-1$ } - + /** * Create a config and save it twice, ensuring it only * ends up in the index once. @@ -453,32 +459,32 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfiguration handle = wc.doSave(); File file = location.toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + // ensure new handle is the index ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$ - + String name = wc.getName(); wc.rename("newName"); //$NON-NLS-1$ wc.rename(name); assertTrue("Should be dirty", wc.isDirty()); //$NON-NLS-1$ wc.doSave(); - + ILaunchConfiguration[] newConfigs = getLaunchManager().getLaunchConfigurations(); assertTrue("Should be the same number of configs", newConfigs.length == configs.length); //$NON-NLS-1$ - + // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ - + } - + /** * Creates a local working copy configuration, sets some attributes, * and saves the working copy, and retrieves the attributes. Deletes @@ -490,22 +496,22 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfiguration handle = wc.doSave(); File file = wc.getLocation().toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - - // delete - handle.delete(); + + // delete + handle.delete(); assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$ - + // ensure handle is not in the index ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should not exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$ - } - + } + /** * Creates a local working copy configuration, sets some attributes, * and saves the working copy, and retrieves the attributes. Renames @@ -519,13 +525,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfiguration handle = wc.doSave(); File file = location.toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + // rename wc = handle.getWorkingCopy(); wc.rename("config-2-rename"); //$NON-NLS-1$ @@ -535,7 +541,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$ assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$ assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$ - + // retrieve new attributes assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ @@ -546,12 +552,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$ assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$ - + // cleanup newHandle.delete(); assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$ - } - + } + /** * Moves a local configuration to a shared location * @throws CoreException @@ -593,8 +599,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau // cleanup newHandle.delete(); assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$ - } - + } + /** * Moves a local configuration to a shared location * @throws CoreException @@ -636,8 +642,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau // cleanup newHandle.delete(); assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$ - } - + } + /** * Creates a shared working copy configuration, sets some attributes, * and saves the working copy, and retrieves the attributes. @@ -647,22 +653,22 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + // ensure new handle is in the index ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$ - + // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ - } - + } + /** * Creates a shared working copy configuration, sets some attributes, * and saves the working copy, and retrieves the attributes. @@ -673,36 +679,36 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2Copy"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + // ensure new handle is in the index ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$ - - // copy + + // copy ILaunchConfigurationWorkingCopy softCopy = handle.copy("CopyOf" + handle.getName()); //$NON-NLS-1$ ILaunchConfiguration hardCopy = softCopy.doSave(); - + // retrieve attributes assertTrue("String1 should be String1", hardCopy.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", hardCopy.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", hardCopy.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !hardCopy.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + assertTrue("Original should still exist", handle.exists()); //$NON-NLS-1$ - + // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ hardCopy.delete(); assertTrue("Config should not exist after deletion", !hardCopy.exists()); //$NON-NLS-1$ - } - + } + /** * Creates a shared working copy configuration, sets some attributes, @@ -714,22 +720,22 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2delete"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - - // delete - handle.delete(); + + // delete + handle.delete(); assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$ - + // ensure handle is not in the index ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should not exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$ - } - + } + /** * Creates a shared working copy configuration, sets some attributes, * and saves the working copy, and retrieves the attributes. Renames @@ -741,13 +747,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2rename"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + // rename wc = handle.getWorkingCopy(); wc.rename("shared-2-rename"); //$NON-NLS-1$ @@ -757,7 +763,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$ assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$ assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$ - + // retrieve new attributes assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ @@ -768,12 +774,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$ assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$ - + // cleanup newHandle.delete(); assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$ } - + /** * Closes all editors in the active workbench page. */ @@ -781,8 +787,8 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); activeWorkbenchWindow.getActivePage().closeAllEditors(false); } - - /** + + /** * Creates a few configs, closes the project and re-opens the * project to ensure the config index is persisted properly * @throws CoreException @@ -790,24 +796,24 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau public void testPersistIndex() throws CoreException { // close all editors before closing project: @see bug 204023 closeAllEditors(); - + ILaunchConfigurationWorkingCopy wc1 = newConfiguration(null, "persist1local"); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy wc2 = newConfiguration(getProject(), "persist2shared"); //$NON-NLS-1$ ILaunchConfiguration lc1 = wc1.doSave(); ILaunchConfiguration lc2 = wc2.doSave(); - + IProject project = getProject(); ILaunchConfiguration[] before = getLaunchManager().getLaunchConfigurations(); assertTrue("config should be in index", existsIn(before, lc1)); //$NON-NLS-1$ assertTrue("config should be in index", existsIn(before, lc2)); //$NON-NLS-1$ - + project.close(null); ILaunchConfiguration[] during = getLaunchManager().getLaunchConfigurations(); boolean local = true; for (int i = 0; i < during.length; i++) { // must be local, or not from the closed project local = local && (during[i].isLocal() || !during[i].getFile().getProject().equals(project)); - } + } project.open(null); assertTrue("Should only be local configs when closed", local); //$NON-NLS-1$ ILaunchConfiguration[] after = getLaunchManager().getLaunchConfigurations(); @@ -821,14 +827,15 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertTrue("Config should not exist after deletion", !lc1.exists()); //$NON-NLS-1$ lc2.delete(); assertTrue("Config should not exist after deletion", !lc2.exists()); //$NON-NLS-1$ - - - } - - + + + } + + /** * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationAdded(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void launchConfigurationAdded(ILaunchConfiguration configuration) { fFrom = getLaunchManager().getMovedFrom(configuration); synchronized (fLock) { @@ -840,12 +847,14 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void launchConfigurationChanged(ILaunchConfiguration configuration) { } /** * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void launchConfigurationRemoved(ILaunchConfiguration configuration) { fTo = getLaunchManager().getMovedTo(configuration); synchronized (fLock) { @@ -857,15 +866,15 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau protected void addConfigListener() { getLaunchManager().addLaunchConfigurationListener(this); } - + protected void removeConfigListener() { getLaunchManager().removeLaunchConfigurationListener(this); } - + /** * Ensures that a removal notification is sent for a shared config in a project * that is deleted. - * + * * @throws Exception */ public void testDeleteProjectWithSharedConfig() throws Exception { @@ -877,11 +886,11 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau project.open(null); assertTrue("project should be open", project.isOpen()); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy wc = newConfiguration(project, "ToBeDeleted"); //$NON-NLS-1$ - + addConfigListener(); ILaunchConfiguration configuration = wc.doSave(); assertEquals(configuration, fAdded); - + synchronized (fLock) { fRemoved = null; project.delete(true, false, null); @@ -897,10 +906,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau removeConfigListener(); } } - + /** * Tests a nested working copy. - * + * * @throws CoreException */ public void testNestedWorkingCopyLocalConfiguration() throws CoreException { @@ -909,33 +918,33 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfiguration handle = wc.doSave(); File file = location.toFile(); assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$ - + // retrieve attributes assertEquals("String1 should be String1", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertEquals("Int1 should be 1", handle.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + // ensure new handle is the index ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$ - + // get a working copy wc = handle.getWorkingCopy(); ILaunchConfigurationWorkingCopy nested = wc.getWorkingCopy(); - + // verify nested is same as original assertEquals("String1 should be String1", nested.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertEquals("Int1 should be 1", nested.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", nested.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean2 should be false", !nested.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + // change an attribute in the nested working copy nested.setAttribute("String1", "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$ assertEquals("Wrong attribute value", nested.getAttribute("String1", "Missing"), "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertEquals("Wrong attribute value", wc.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertEquals("Wrong attribute value", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - + // save back to parent ILaunchConfigurationWorkingCopy parent = nested.getParent(); assertEquals("Wrong parent", wc, parent); //$NON-NLS-1$ @@ -943,84 +952,84 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau nested.doSave(); assertEquals("Wrong attribute value", wc.getAttribute("String1", "Missing"), "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ assertEquals("Wrong attribute value", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - + // check originals assertEquals("Wrong original config" , handle, wc.getOriginal()); //$NON-NLS-1$ assertEquals("Wrong original config" , handle, nested.getOriginal()); //$NON-NLS-1$ - + // cleanup handle.delete(); assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$ - } - + } + /** * Creates a configuration in an EFS linked folder. Deletes configuration directly. - * + * * @throws CoreException * @throws URISyntaxException - */ + */ public void testCreateDeleteEFS() throws CoreException, URISyntaxException { IFileSystem fileSystem = EFS.getFileSystem("debug"); //$NON-NLS-1$ assertNotNull("Missing debug EFS", fileSystem); //$NON-NLS-1$ - + // create folder in EFS IFolder folder = getProject().getFolder("efs"); //$NON-NLS-1$ folder.createLink(new URI("debug", Path.ROOT.toString(), null), 0, null); //$NON-NLS-1$ - + // create configuration ILaunchConfigurationWorkingCopy wc = newConfiguration(folder, "efsConfig"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ + // delete configuration handle.delete(); assertTrue("Configuration should not exist", !handle.exists()); //$NON-NLS-1$ - + // cleanup folder.delete(IResource.NONE, null); } - + /** * Creates a configuration in an EFS linked folder. Deletes the folder to ensure the * configuration is also deleted. - * + * * @throws CoreException * @throws URISyntaxException */ public void testCreateDeleteEFSLink() throws CoreException, URISyntaxException { IFileSystem fileSystem = EFS.getFileSystem("debug"); //$NON-NLS-1$ assertNotNull("Missing debug EFS", fileSystem); //$NON-NLS-1$ - + // create folder in EFS IFolder folder = getProject().getFolder("efs2"); //$NON-NLS-1$ folder.createLink(new URI("debug", Path.ROOT.toString(), null), 0, null); //$NON-NLS-1$ - + // create configuration ILaunchConfigurationWorkingCopy wc = newConfiguration(folder, "efsConfig"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ + // cleanup folder.delete(IResource.NONE, null); assertTrue("Configuration should not exist", !handle.exists()); //$NON-NLS-1$ - } - + } + /** * Test that renaming a project with a linked EFS folder containing a shared * launch configuration is properly updated. - * + * * @throws Exception */ public void testEFSProjectRename() throws Exception { @@ -1031,33 +1040,33 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } // create project IProject project = TestsPlugin.createProject("RenameEFS"); //$NON-NLS-1$ - + IFileSystem fileSystem = EFS.getFileSystem("debug"); //$NON-NLS-1$ assertNotNull("Missing debug EFS", fileSystem); //$NON-NLS-1$ - + // create folder in EFS IFolder folder = project.getFolder("efs2"); //$NON-NLS-1$ folder.createLink(new URI("debug", Path.ROOT.toString(), null), 0, null); //$NON-NLS-1$ - + // create configuration ILaunchConfigurationWorkingCopy wc = newConfiguration(folder, "efsConfig"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ + // rename project IProjectDescription description = project.getDescription(); description.setName("SFEemaneR"); // reverse name //$NON-NLS-1$ project.move(description, IResource.SHALLOW, null); - + // original configuration should no longer exist - handle out of date assertTrue("Configuration should not exist", !handle.exists()); //$NON-NLS-1$ - + // get the new handle project = ResourcesPlugin.getWorkspace().getRoot().getProject("SFEemaneR"); //$NON-NLS-1$ assertTrue("Project should exist", project.exists()); //$NON-NLS-1$ @@ -1065,25 +1074,25 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertTrue("launch config file should exist", file.exists()); //$NON-NLS-1$ handle = getLaunchManager().getLaunchConfiguration(file); assertTrue("launch config should exist", handle.exists()); //$NON-NLS-1$ - + // retrieve attributes assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ - + assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$ + // validate shared location assertEquals("Shared location should be updated", file, handle.getFile()); //$NON-NLS-1$ - + // cleanup project.delete(IResource.NONE, null); assertTrue("Configuration should not exist", !handle.exists()); //$NON-NLS-1$ - + } - + /** * Tests launch configuration import. - * + * * @throws Exception */ public void testImport() throws Exception { @@ -1091,7 +1100,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "Import4"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$ - + File dir = TestsPlugin.getDefault().getFileInPlugin(new Path("test-import")); //$NON-NLS-1$ assertTrue("Import directory does not exist", dir.exists()); //$NON-NLS-1$ LaunchManager manager = (LaunchManager) getLaunchManager(); @@ -1102,6 +1111,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau // import manager.importConfigurations(dir.listFiles( new FileFilter() { + @Override public boolean accept(File file) { return file.isFile() && file.getName().endsWith( @@ -1109,17 +1119,17 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } }), null); - + // should be one removed - List removed = listener.getRemoved(); + List<ILaunchConfiguration> removed = listener.getRemoved(); assertEquals("Should be one removed config", 1, removed.size()); //$NON-NLS-1$ assertTrue("Import4 should be removed", removed.contains(handle)); //$NON-NLS-1$ - + // should be 5 added - List added = listener.getAdded(); + List<?> added = listener.getAdded(); assertEquals("Should be 5 added configs", 5, added.size()); //$NON-NLS-1$ - Set names = new HashSet(); - Iterator iterator = added.iterator(); + Set<String> names = new HashSet<String>(); + Iterator<?> iterator = added.iterator(); while (iterator.hasNext()) { ILaunchConfiguration lc = (ILaunchConfiguration) iterator.next(); names.add(lc.getName()); @@ -1129,20 +1139,20 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertTrue("Missing Name", names.contains("Import3")); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Missing Name", names.contains("Import4")); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Missing Name", names.contains("Import5")); //$NON-NLS-1$ //$NON-NLS-2$ - + // should be one changed - List changed = listener.getChanged(); + List<ILaunchConfiguration> changed = listener.getChanged(); assertEquals("Should be 1 changed config", 1, changed.size()); //$NON-NLS-1$ - assertEquals("Wrong changed config", "Import4", ((ILaunchConfiguration) changed.get(0)).getName()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Wrong changed config", "Import4", changed.get(0).getName()); //$NON-NLS-1$ //$NON-NLS-2$ } finally { manager.removeLaunchConfigurationListener(listener); } - + } - + /** * Tests the location of a local working copy. - * + * * @throws CoreException */ public void testWorkingCopyGetLocation() throws CoreException { @@ -1150,7 +1160,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau IPath location = workingCopy.getLocation(); assertEquals("Wrong path for local working copy", LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.append("test-get-location.launch"), location); //$NON-NLS-1$ //$NON-NLS-2$ } - + /** * Tests that the framework adds time stamps to launch objects. */ @@ -1167,15 +1177,15 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } } } - + /** * Tests that attributes in a nested map are persisted in alphabetical order. - * + * * @throws CoreException */ public void testMapAttributePersistence() throws CoreException, IOException { ILaunchConfigurationWorkingCopy c1 = newEmptyConfiguration(getProject(), "testMapAttributes1"); //$NON-NLS-1$ - HashMap map = new HashMap(); + HashMap<String, String> map = new HashMap<String, String>(); map.put("Z", "z-value"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("Y", "y-value"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("X", "x-value"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1204,9 +1214,9 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau map.put("A", "a-value"); //$NON-NLS-1$ //$NON-NLS-2$ c1.setAttribute("Map-Attribute", map); //$NON-NLS-1$ c1.doSave(); - + ILaunchConfigurationWorkingCopy c2 = newEmptyConfiguration(getProject(), "testMapAttributes2"); //$NON-NLS-1$ - map = new HashMap(); + map = new HashMap<String, String>(); map.put("A", "a-value"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("Z", "z-value"); //$NON-NLS-1$ //$NON-NLS-2$ map.put("B", "b-value"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1235,7 +1245,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau map.put("N", "n-value"); //$NON-NLS-1$ //$NON-NLS-2$ c2.setAttribute("Map-Attribute", map); //$NON-NLS-1$ c2.doSave(); - + // file contents should be the same char[] chars1 = getInputStreamAsCharArray(c1.getFile().getContents()); char[] chars2 = getInputStreamAsCharArray(c2.getFile().getContents()); @@ -1243,17 +1253,17 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau for (int i = 0; i < chars2.length; i++) { assertEquals("Should be the same character", chars1[i], chars2[i]); //$NON-NLS-1$ } - + } /** * Tests that attributes in a nested set are persisted in alphabetical order. - * + * * @throws CoreException */ public void testSetAttributePersistence() throws CoreException, IOException { ILaunchConfigurationWorkingCopy c1 = newEmptyConfiguration(getProject(), "testSetAttributes1"); //$NON-NLS-1$ - Set set = new HashSet(); + Set<String> set = new HashSet<String>(); set.add("z-value"); //$NON-NLS-1$ set.add("y-value"); //$NON-NLS-1$ set.add("x-value"); //$NON-NLS-1$ @@ -1282,9 +1292,9 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau set.add("a-value"); //$NON-NLS-1$ c1.setAttribute("Set-Attribute", set); //$NON-NLS-1$ c1.doSave(); - + ILaunchConfigurationWorkingCopy c2 = newEmptyConfiguration(getProject(), "testSetAttributes2"); //$NON-NLS-1$ - set = new HashSet(); + set = new HashSet<String>(); set.add("a-value"); //$NON-NLS-1$ set.add("z-value"); //$NON-NLS-1$ set.add("b-value"); //$NON-NLS-1$ @@ -1313,7 +1323,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau set.add("n-value"); //$NON-NLS-1$ c2.setAttribute("Set-Attribute", set); //$NON-NLS-1$ c2.doSave(); - + // file contents should be the same char[] chars1 = getInputStreamAsCharArray(c1.getFile().getContents()); char[] chars2 = getInputStreamAsCharArray(c2.getFile().getContents()); @@ -1321,13 +1331,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau for (int i = 0; i < chars2.length; i++) { assertEquals("Should be the same character", chars1[i], chars2[i]); //$NON-NLS-1$ } - + } - + /** * Ensures that client does not attempt to nest configurations in a sub directory when * using local metadata location. See bug 275741. - * + * * @throws CoreException */ public void testIllegalFileSepCharName() { @@ -1339,12 +1349,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } assertTrue("Should be an illegal argument - cannot nest local configurations", false); //$NON-NLS-1$ } - + /** * Ensures that client can nest configurations in a sub directory when * using a workspace location. See bug 275741. For behavior compatibility * a client should be able to use a slash in the configuration name. - * + * * @throws CoreException */ public void testLegalFileSepCharName() { @@ -1353,11 +1363,11 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } catch (CoreException e) { assertTrue("Should *not* be an illegal argument - can nest shared cofigurations", false); //$NON-NLS-1$ } - } - + } + /** * Test that an illegal name with '<' causes an exception - * + * * @throws CoreException */ public void testIllegalCharName() { @@ -1368,11 +1378,11 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau return; } assertTrue("Should be an illegal argument - illegal character used in name", false); //$NON-NLS-1$ - } - + } + /** * Test that moving and renaming a shared configuration at the same time works. - * + * * @throws CoreException */ public void testRenameAndMoveShared() throws CoreException { @@ -1384,19 +1394,19 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau ILaunchConfigurationWorkingCopy wc = newConfiguration(f1, "start-here"); //$NON-NLS-1$ ILaunchConfiguration orig = wc.doSave(); wc = orig.getWorkingCopy(); - + wc.setContainer(f2); wc.rename("end-here"); //$NON-NLS-1$ ILaunchConfiguration next = wc.doSave(); - + assertFalse("Original should not exist", orig.exists()); //$NON-NLS-1$ assertTrue("Renamed and moved config should exist", next.exists()); //$NON-NLS-1$ - + } - + /** * Test support for a URL in the 'icon' part of the launchConfigurationTypeImages extension point - * + * * Bug 381175 - [patch] launchConfigurationTypeImage to support platform: style icons * @throws Exception */ @@ -1405,7 +1415,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertNotNull("The image descriptior type.image.1 must exist", descriptor); //$NON-NLS-1$ assertNotSame("The image descriptor is not type.image.1", ImageDescriptor.getMissingImageDescriptor(), descriptor); //$NON-NLS-1$ } - + /** * Test support for a declared launch configuration type image * @throws Exception @@ -1415,10 +1425,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau assertNotNull("The image descriptior type.image.2 must exist", descriptor); //$NON-NLS-1$ assertNotSame("The image descriptor is not type.image.2", ImageDescriptor.getMissingImageDescriptor(), descriptor); //$NON-NLS-1$ } - + /** * Tests that we can get a project handle from a project name - * + * * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395441 * @throws Exception * @since 3.9.0 @@ -1437,10 +1447,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau lc.delete(); } } - + /** * Tests that we cannot get a project handle from a bogus project name - * + * * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395441 * @throws Exception * @since 3.9.0 @@ -1458,10 +1468,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau lc.delete(); } } - + /** * Tests that we cannot get a project handle from a bogus project name - * + * * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395441 * @throws Exception * @since 3.9.0 @@ -1487,7 +1497,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Tests that we can get a project handle from an absolute project name - * + * * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395441 * @throws Exception * @since 3.9.0 @@ -1505,19 +1515,19 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau lc.delete(); } } - + /** * Proxy to set resource paths, allowing invalid resource paths to be set * @param resources * @since 3.9.0 */ protected void setResourceMappings(ILaunchConfigurationWorkingCopy config, ResourceItem[] resources) { - List/*<String>*/ paths = null; - List/*<String>*/ types = null; + List/* <String> */<String> paths = null; + List/* <String> */<String> types = null; int size = resources.length; if(resources != null && size > 0) { - paths = new ArrayList(size); - types = new ArrayList(size); + paths = new ArrayList<String>(size); + types = new ArrayList<String>(size); for(int i = 0; i < size; i++) { paths.add(resources[i].path); types.add(resources[i].type.toString()); diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchFavoriteTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchFavoriteTests.java index 485e8dec4..8b5989ccf 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchFavoriteTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchFavoriteTests.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -22,13 +22,13 @@ import org.eclipse.debug.ui.IDebugUIConstants; /** * Test the launch history favorites get updated properly as configurations as * modified. - * + * * @since 3.6 */ public class LaunchFavoriteTests extends AbstractLaunchTest { - + /** - * Configuration to use for the test. One is created for each test during + * Configuration to use for the test. One is created for each test during * setup and deleted during tear down. */ private ILaunchConfiguration fConfig; @@ -40,7 +40,7 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { public LaunchFavoriteTests(String name) { super(name); } - + /** * Returns the run launch history * @return @@ -48,7 +48,7 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { private LaunchHistory getRunLaunchHistory() { return getLaunchConfigurationManager().getLaunchHistory(IDebugUIConstants.ID_RUN_LAUNCH_GROUP); } - + /** * Returns the debug launch history * @return @@ -56,10 +56,11 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { private LaunchHistory getDebugLaunchHistory() { return getLaunchConfigurationManager().getLaunchHistory(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP); } - + /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); // clear the favorites @@ -67,10 +68,11 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { getDebugLaunchHistory().setFavorites(new ILaunchConfiguration[0]); fConfig = getLaunchConfiguration(getName()); } - + /* (non-Javadoc) * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { super.tearDown(); // delete the configuration used during this test @@ -79,40 +81,40 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { configuration.delete(); } } - + /** * Returns the new/initial launch configuration to use for this test. - * + * * @return */ private ILaunchConfiguration getLaunchConfiguration() { return fConfig; } - + /** * Makes the configuration a favorite in the specified group. - * + * * @param config configuration to make a favorite - may be a working copy already * @param groupId group to add it to * @return working copy after making it a favorite - * + * * @throws CoreException */ private ILaunchConfigurationWorkingCopy addFavorite(ILaunchConfiguration config, String groupId) throws CoreException { ILaunchConfigurationWorkingCopy wc = getWorkingCopy(config); - List list = config.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null); + List<String> list = config.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List<String>) null); if (list == null) { - list = new ArrayList(); + list = new ArrayList<String>(); } list.add(groupId); wc.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, list); return wc; } - + /** * Removes the favorite group from the configuration's favorites attribute. Returns * the resulting working copy. - * + * * @param config configuration to remove favorite attribute from, may already be a working copy * @param groupId group to remove * @return working copy after removing favorite @@ -120,7 +122,7 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { */ private ILaunchConfigurationWorkingCopy removeFavorite(ILaunchConfiguration config, String groupId) throws CoreException { ILaunchConfigurationWorkingCopy wc = getWorkingCopy(config); - List list = config.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List)null); + List<String> list = config.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List<String>) null); if (list != null) { if (list.remove(groupId)) { if (list.isEmpty()) { @@ -131,7 +133,7 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { } return wc; } - + private ILaunchConfigurationWorkingCopy getWorkingCopy(ILaunchConfiguration config) throws CoreException { ILaunchConfigurationWorkingCopy wc = null; if (config.isWorkingCopy()) { @@ -141,15 +143,15 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { } return wc; } - + /** - * Returns whether the launch history contains the given configuration as a favorite and is + * Returns whether the launch history contains the given configuration as a favorite and is * the expected size. - * + * * @param history launch history * @param configuration launch configuration * @param size expected size of favorites or -1 if unknown - * @return whether the launch history contains the given configuration as a favorite and is + * @return whether the launch history contains the given configuration as a favorite and is * the expected size */ private boolean containsFavorite(LaunchHistory history, ILaunchConfiguration configuration, int size) { @@ -165,10 +167,10 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { } return false; } - + /** * Tests that a configuration becoming a favorite appears in the favorites. - * + * * @throws CoreException */ public void testBecomeFavorite() throws CoreException { @@ -178,10 +180,10 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { assertTrue("Missing from debug favorites", containsFavorite(getDebugLaunchHistory(), saved, 1)); //$NON-NLS-1$ assertTrue("Missing from run favorites", containsFavorite(getRunLaunchHistory(), saved, 1)); //$NON-NLS-1$ } - + /** * Tests that a when a favorite is no longer a favorite, it gets removed from the favorites. - * + * * @throws CoreException */ public void testUnFavorite() throws CoreException { @@ -192,10 +194,10 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { assertFalse("Should not be a debug favorite", containsFavorite(getDebugLaunchHistory(), saved, 0)); //$NON-NLS-1$ assertFalse("Should not be a run favorite", containsFavorite(getRunLaunchHistory(), saved, 0)); //$NON-NLS-1$ } - + /** * When a configuration is deleted, it should no longer be in the list. - * + * * @throws CoreException */ public void testDeleteConfiguration() throws CoreException { @@ -205,10 +207,10 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { assertFalse("Should not be a debug favorite", containsFavorite(getDebugLaunchHistory(), configuration, 0)); //$NON-NLS-1$ assertFalse("Should not be a run favorite", containsFavorite(getRunLaunchHistory(), configuration, 0)); //$NON-NLS-1$ } - + /** * When a favorite is renamed, it should still be in the list, with the new name. - * + * * @throws CoreException */ public void testRenameFavorite() throws CoreException { @@ -221,10 +223,10 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { assertTrue("Missing from run favorites", containsFavorite(getRunLaunchHistory(), saved, 1)); //$NON-NLS-1$ saved.delete(); } - + /** * Renaming a configuration and making it a favorite at the same time - should appear in the list. - * + * * @throws CoreException */ public void testRenameBecomeFavorite() throws CoreException { @@ -238,10 +240,10 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { assertTrue("Missing from run favorites", containsFavorite(getRunLaunchHistory(), saved, 1)); //$NON-NLS-1$ saved.delete(); } - + /** * Renaming a configuration and removing its favorite status should remove it from the list. - * + * * @throws CoreException */ public void testRenameUnFavorite() throws CoreException { diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java index e841160b3..10cd892f7 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java @@ -15,11 +15,12 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.internal.core.LaunchManager; /** - * + * * Variety of tests for the {@link org.eclipse.debug.internal.core.LaunchManager} - * + * * @since 3.6 */ +@SuppressWarnings("deprecation") public class LaunchManagerTests extends AbstractLaunchTest { /** @@ -38,7 +39,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { String name = getLaunchManager().generateLaunchConfigurationName(configname); assertTrue("the name nust be '" + configname + "'", name.equals(configname)); //$NON-NLS-1$ //$NON-NLS-2$ } - + /** * Tests generating a launch configuration name with an unsupported char using * the deprecated method @@ -48,7 +49,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname); assertEquals("config name should be '" + configname + "'", configname, name); //$NON-NLS-1$ //$NON-NLS-2$ } - + /** * Tests that a valid name is accepted as is. */ @@ -57,7 +58,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { String name = getLaunchManager().generateLaunchConfigurationName(configname); assertEquals("Should be the same as the seed", configname, name); //$NON-NLS-1$ } - + /** * Tests generating a launch configuration name using a name that is an OS reserved * name. Win 32 test only. @@ -69,7 +70,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { assertEquals("config name should be 'aux'", configname, name); //$NON-NLS-1$ } } - + /** * Tests generating a configuration name that contains an invalid character */ @@ -78,9 +79,9 @@ public class LaunchManagerTests extends AbstractLaunchTest { String name = getLaunchManager().generateLaunchConfigurationName(configname); assertEquals("config name should be 'config_name'", "config_name", name); //$NON-NLS-1$ //$NON-NLS-2$ } - + /** - * Tests generating a name that conflicts with an OS reserved name. This test is for windows only as there + * Tests generating a name that conflicts with an OS reserved name. This test is for windows only as there * are no reserved names on other OS's. */ public void testGenerateConflictingName() { @@ -90,7 +91,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { assertEquals("config name should be 'launch_configuration'", "launch_configuration", name); //$NON-NLS-1$ //$NON-NLS-2$ } } - + /** * Tests generating a configuration name that contains an invalid character and where there * is another config with the replaced name already @@ -105,10 +106,10 @@ public class LaunchManagerTests extends AbstractLaunchTest { ILaunchConfiguration config = getLaunchConfiguration("config_name"); //$NON-NLS-1$ config.delete(); } - + /** - * Tests generating a name that conflicts with an OS reserved name and that - * there is a config with the replaced name already. This test is for windows only as there + * Tests generating a name that conflicts with an OS reserved name and that + * there is a config with the replaced name already. This test is for windows only as there * are no reserved names on other OS's. */ public void testGenerateBadNameConflict() throws Exception { @@ -123,7 +124,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { config.delete(); } } - + /** * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness */ @@ -136,7 +137,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { fail("the config name should not have thrown an exception during validation"); //$NON-NLS-1$ } } - + /** * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness */ @@ -150,7 +151,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { } fail("the config name should have thrown an exception during validation"); //$NON-NLS-1$ } - + /** * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness */ @@ -166,7 +167,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { fail("the config name should have thrown an exception during validation"); //$NON-NLS-1$ } } - + /** * Tests that generating a configuration name when there exists a configuration with that name * already properly updates a '(N)' counter at the end @@ -188,7 +189,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { config.delete(); } } - + /** * Tests that removing an accelerator properly removes it without affecting the base string (readable) value */ diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/TestLaunchDelegate.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/TestLaunchDelegate.java index 54994d369..df62ebd8c 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/TestLaunchDelegate.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/TestLaunchDelegate.java @@ -24,6 +24,7 @@ public class TestLaunchDelegate extends LaunchConfigurationDelegate { /* (non-Javadoc) * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { // do nothing } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/DynamicRenderingBindings.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/DynamicRenderingBindings.java index 648b97674..527ba3665 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/DynamicRenderingBindings.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/DynamicRenderingBindings.java @@ -37,21 +37,24 @@ public class DynamicRenderingBindings extends AbstractMemoryRenderingBindingsPro /** * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getRenderingTypes(org.eclipse.debug.core.model.IMemoryBlock) */ - public IMemoryRenderingType[] getRenderingTypes(IMemoryBlock block) { + @Override + public IMemoryRenderingType[] getRenderingTypes(IMemoryBlock block) { return new IMemoryRenderingType[]{getPrimaryRenderingType(block)}; } /** * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getDefaultRenderingTypes(org.eclipse.debug.core.model.IMemoryBlock) */ - public IMemoryRenderingType[] getDefaultRenderingTypes(IMemoryBlock block) { + @Override + public IMemoryRenderingType[] getDefaultRenderingTypes(IMemoryBlock block) { return new IMemoryRenderingType[]{getPrimaryRenderingType(block)}; } /** * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getPrimaryRenderingType(org.eclipse.debug.core.model.IMemoryBlock) */ - public IMemoryRenderingType getPrimaryRenderingType(IMemoryBlock block) { + @Override + public IMemoryRenderingType getPrimaryRenderingType(IMemoryBlock block) { return DebugUITools.getMemoryRenderingManager().getRenderingType(fId); } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlock.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlock.java index 994f4a158..4c5e84082 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlock.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryBlock.java @@ -25,6 +25,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.debug.core.model.IMemoryBlock#getStartAddress() */ + @Override public long getStartAddress() { return 0; } @@ -32,6 +33,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.debug.core.model.IMemoryBlock#getLength() */ + @Override public long getLength() { return 100; } @@ -39,6 +41,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.debug.core.model.IMemoryBlock#getBytes() */ + @Override public byte[] getBytes() throws DebugException { byte[] bytes = new byte[(int)getLength()]; for (int i = 0; i < bytes.length; i++) { @@ -50,6 +53,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.debug.core.model.IMemoryBlock#supportsValueModification() */ + @Override public boolean supportsValueModification() { return false; } @@ -57,6 +61,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.debug.core.model.IMemoryBlock#setValue(long, byte[]) */ + @Override public void setValue(long offset, byte[] bytes) throws DebugException { } @@ -64,6 +69,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() */ + @Override public String getModelIdentifier() { return "no.debugger"; //$NON-NLS-1$ } @@ -71,6 +77,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() */ + @Override public IDebugTarget getDebugTarget() { return null; } @@ -78,6 +85,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() */ + @Override public ILaunch getLaunch() { return null; } @@ -85,6 +93,7 @@ public class MemoryBlock implements IMemoryBlock { /** * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ + @Override public Object getAdapter(Class adapter) { return null; } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryRenderingTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryRenderingTests.java index 8c7a9f2ca..6e5816bf1 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryRenderingTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/MemoryRenderingTests.java @@ -118,6 +118,7 @@ public class MemoryRenderingTests extends TestCase { public void testBindingChangeNotification() { final boolean[] changed = new boolean[1]; IMemoryRenderingBindingsListener listener = new IMemoryRenderingBindingsListener() { + @Override public void memoryRenderingBindingsChanged() { changed[0] = true; } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/RenderingTypeDelegate.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/RenderingTypeDelegate.java index b4f9a70be..1b0f41bd1 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/RenderingTypeDelegate.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/view/memory/RenderingTypeDelegate.java @@ -24,6 +24,7 @@ public class RenderingTypeDelegate implements IMemoryRenderingTypeDelegate { /** * @see org.eclipse.debug.ui.memory.IMemoryRenderingTypeDelegate#createRendering(java.lang.String) */ + @Override public IMemoryRendering createRendering(String id) throws CoreException { return null; } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/CheckTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/CheckTests.java index 9cc09fec0..8ac3e964d 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/CheckTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/CheckTests.java @@ -45,7 +45,8 @@ abstract public class CheckTests extends TestCase { /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); @@ -63,7 +64,8 @@ abstract public class CheckTests extends TestCase { /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); @@ -76,7 +78,8 @@ abstract public class CheckTests extends TestCase { } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ChildrenUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ChildrenUpdateTests.java index 9c85204e0..db5a43710 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ChildrenUpdateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ChildrenUpdateTests.java @@ -45,129 +45,184 @@ public class ChildrenUpdateTests extends TestCase { /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider#getViewer() */ + @Override protected IInternalTreeModelViewer getViewer() { return new IInternalTreeModelViewer(){ + @Override public void setSelection(ISelection selection) {} + @Override public void removeSelectionChangedListener(ISelectionChangedListener listener) {} + @Override public void addSelectionChangedListener(ISelectionChangedListener listener) {} + @Override public void updateViewer(IModelDelta delta) {} + @Override public void setSelection(ISelection selection, boolean reveal, boolean force) {} + @Override public void clearSelectionQuiet() {} + @Override public boolean trySelection(ISelection selection, boolean reveal, boolean force) { return true; } + @Override public void setInput(Object object) {} + @Override public void setAutoExpandLevel(int level) {} + @Override public boolean saveElementState(TreePath path, ModelDelta delta, int flags) { return true; } + @Override public void removeStateUpdateListener(IStateUpdateListener listener) {} + @Override public void removeViewerUpdateListener(IViewerUpdateListener listener) {} + @Override public void removeModelChangedListener(IModelChangedListener listener) {} + @Override public void removeLabelUpdateListener(ILabelUpdateListener listener) {} - public void addViewerUpdateListener(IViewerUpdateListener listener) {} - public void addStateUpdateListener(IStateUpdateListener listener) {} - public void addModelChangedListener(IModelChangedListener listener) {} - public void addLabelUpdateListener(ILabelUpdateListener listener) {} - public void update(Object element) {} - public void setHasChildren(Object elementOrTreePath, boolean hasChildren) {} - public void setExpandedState(Object elementOrTreePath, boolean expanded) {} - public void setChildCount(Object elementOrTreePath, int count) {} - public void reveal(TreePath path, int index) {} - public void replace(Object parentOrTreePath, int index, Object element) {} - public void remove(Object parentOrTreePath, int index) {} - public void remove(Object elementOrTreePath) {} - public void refresh() {} - public void refresh(Object element) {} + @Override + public void addViewerUpdateListener(IViewerUpdateListener listener) {} + @Override + public void addStateUpdateListener(IStateUpdateListener listener) {} + @Override + public void addModelChangedListener(IModelChangedListener listener) {} + @Override + public void addLabelUpdateListener(ILabelUpdateListener listener) {} + @Override + public void update(Object element) {} + @Override + public void setHasChildren(Object elementOrTreePath, boolean hasChildren) {} + @Override + public void setExpandedState(Object elementOrTreePath, boolean expanded) {} + @Override + public void setChildCount(Object elementOrTreePath, int count) {} + @Override + public void reveal(TreePath path, int index) {} + @Override + public void replace(Object parentOrTreePath, int index, Object element) {} + @Override + public void remove(Object parentOrTreePath, int index) {} + @Override + public void remove(Object elementOrTreePath) {} + @Override + public void refresh() {} + @Override + public void refresh(Object element) {} + @Override public ISelection getSelection() { return null; } + @Override public IPresentationContext getPresentationContext() { return null; } + @Override public Object getInput() { return null; } + @Override public ViewerLabel getElementLabel(TreePath path, String columnId) { return null; } + @Override public Display getDisplay() { return DebugUIPlugin.getStandardDisplay(); } + @Override public int getAutoExpandLevel() { return 0; } + @Override public boolean overrideSelection(ISelection current, ISelection candidate) { return false; } + @Override public void insert(Object parentOrTreePath, Object element, int position) { } + @Override public TreePath getTopElementPath() { return null; } + @Override public ViewerFilter[] getFilters() { return null; } + @Override public void addFilter(ViewerFilter filter) {} + @Override public void setFilters(ViewerFilter[] filters) {} + @Override public boolean getExpandedState(Object elementOrTreePath) { return false; } + @Override public Object getChildElement(TreePath path, int index) { return null; } - public boolean getHasChildren(Object elementOrTreePath) { + @Override + public boolean getHasChildren(Object elementOrTreePath) { return false; } + @Override public int getChildCount(TreePath path) { return 0; } + @Override public int findElementIndex(TreePath parentPath, Object element) { return 0; } + @Override public void expandToLevel(Object elementOrTreePath, int level) { } + @Override public void autoExpand(TreePath elementPath) { } - public boolean getElementChildrenRealized(TreePath parentPath) { + @Override + public boolean getElementChildrenRealized(TreePath parentPath) { return false; } - public boolean getElementChecked(TreePath path) { + @Override + public boolean getElementChecked(TreePath path) { return false; } - public boolean getElementGrayed(TreePath path) { + @Override + public boolean getElementGrayed(TreePath path) { return false; } - public void setElementChecked(TreePath path, boolean checked, boolean grayed) { + @Override + public void setElementChecked(TreePath path, boolean checked, boolean grayed) { } - public TreePath[] getElementPaths(Object element) { + @Override + public TreePath[] getElementPaths(Object element) { return null; } - public void setElementData(TreePath path, int numColumns, String[] labels, ImageDescriptor[] images, + @Override + public void setElementData(TreePath path, int numColumns, String[] labels, ImageDescriptor[] images, FontData[] fontDatas, RGB[] foregrounds, RGB[] backgrounds) { } - public String[] getVisibleColumns() { + @Override + public String[] getVisibleColumns() { return null; } }; diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ColumnPresentationTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ColumnPresentationTests.java index b8f406e75..62f7593e1 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ColumnPresentationTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ColumnPresentationTests.java @@ -52,6 +52,7 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat /** * @throws java.lang.Exception */ + @Override protected void setUp() throws Exception { createViewer(); } @@ -59,6 +60,7 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat /** * @throws java.lang.Exception */ + @Override protected void tearDown() throws Exception { destroyViewer(); } @@ -70,11 +72,13 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat fShell.setLayout(new FillLayout()); fViewer = new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ fViewer.getTree().addControlListener(new ControlListener() { - public void controlResized(ControlEvent e) { + @Override + public void controlResized(ControlEvent e) { fResized = true; } - public void controlMoved(ControlEvent e) { + @Override + public void controlMoved(ControlEvent e) { } }); fListener = new TestModelUpdatesListener(fViewer, false, false); @@ -118,14 +122,17 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat this.columnIds = columnIds; } + @Override public void init(IPresentationContext context) { fContext = context; } + @Override public void dispose() { fContext = null; } + @Override public ImageDescriptor getImageDescriptor(String id) { return null; } @@ -134,14 +141,17 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat return fContext; } + @Override public String[] getAvailableColumns() { return columnIds; } + @Override public String[] getInitialColumns() { return columnIds; } + @Override public String getHeader(String id) { if (Arrays.asList(columnIds).indexOf(id) != -1) { return id; @@ -149,10 +159,12 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat return null; } + @Override public String getId() { return "MyColumnPresentationID"; //$NON-NLS-1$ } + @Override public boolean isOptional() { return true; } @@ -171,6 +183,7 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat Arrays.fill(repliedWidths, -2); } + @Override public int getInitialColumnWidth(String id, int treeWidgetWidth, String[] visibleColumnIds) { for (int i = 0; i < columnIds.length; i++) { @@ -194,6 +207,7 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat return -1; } + @Override public String getId() { return "MyColumnPresentation2ID"; //$NON-NLS-1$ } @@ -206,6 +220,7 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat colPresenation = cp1; } + @Override public IColumnPresentation createColumnPresentation( IPresentationContext context, Object element) { if (colPresenation != null) { @@ -214,6 +229,7 @@ public class ColumnPresentationTests extends TestCase implements ITestModelUpdat return null; } + @Override public String getColumnPresentationId(IPresentationContext context, Object element) { if (colPresenation != null) { diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ContentTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ContentTests.java index d2dff371a..387879a47 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ContentTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ContentTests.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation * IBM Corporation - clean-up @@ -25,6 +25,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.ITreeModelViewer; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.jface.viewers.TreePath; import org.eclipse.swt.layout.FillLayout; @@ -33,18 +34,18 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; /** - * Tests that verify that the viewer property retrieves all the content + * Tests that verify that the viewer property retrieves all the content * from the model. - * + * * @since 3.6 */ abstract public class ContentTests extends TestCase implements ITestModelUpdatesListenerConstants { - + Display fDisplay; Shell fShell; ITreeModelViewer fViewer; TestModelUpdatesListener fListener; - + public ContentTests(String name) { super(name); } @@ -52,28 +53,30 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); fShell.setLayout(new FillLayout()); fViewer = createViewer(fDisplay, fShell); - + fListener = new TestModelUpdatesListener(fViewer, true, true); fShell.open (); } abstract protected IInternalTreeModelViewer createViewer(Display display, Shell shell); - + /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); - + // Close the shell and exit. fShell.close(); while (!fShell.isDisposed()) { @@ -83,50 +86,51 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { throw new ExecutionException("Test failed: " + t.getMessage() + "\n fListener = " + fListener.toString(), t); //$NON-NLS-1$ //$NON-NLS-2$ } } - + public void testSimpleSingleLevel() throws InterruptedException { // Create the model with test data TestModel model = TestModel.simpleSingleLevel(); // Make sure that all elements are expanded fViewer.setAutoExpandLevel(-1); - + // Create the agent which forces the tree to populate //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + // Create the listener which determines when the view is finished updating. - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true); - + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true); + // Set the viewer input (and trigger updates). fViewer.setInput(model.getRootElement()); - + // Wait for the updates to complete. while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + model.validateData(fViewer, TreePath.EMPTY); - + assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) ); } public void testSimpleMultiLevel() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleMultiLevel(); fViewer.setAutoExpandLevel(-1); - - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true); - + + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true); + fViewer.setInput(model.getRootElement()); while (!fListener.isFinished()) { @@ -136,22 +140,23 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates } model.validateData(fViewer, TreePath.EMPTY); - + assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 3) ); } - + /** - * Modified test model that optionally captures (i.e. doesn't compete) - * udpates after filling in their data. + * Modified test model that optionally captures (i.e. doesn't compete) + * udpates after filling in their data. */ class TestModelWithCapturedUpdates extends TestModel { - + boolean fCaptureLabelUpdates = false; boolean fCaptureChildrenUpdates = false; - - List fCapturedUpdates = Collections.synchronizedList(new ArrayList()); - - public void update(IChildrenUpdate[] updates) { + + List<IViewerUpdate> fCapturedUpdates = Collections.synchronizedList(new ArrayList<IViewerUpdate>()); + + @Override + public void update(IChildrenUpdate[] updates) { for (int i = 0; i < updates.length; i++) { TestElement element = (TestElement)updates[i].getElement(); int endOffset = updates[i].getOffset() + updates[i].getLength(); @@ -167,13 +172,14 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates } } } - - public void update(ILabelUpdate[] updates) { + + @Override + public void update(ILabelUpdate[] updates) { for (int i = 0; i < updates.length; i++) { TestElement element = (TestElement)updates[i].getElement(); updates[i].setLabel(element.getLabel(), 0); - if (updates[i] instanceof ICheckUpdate && - Boolean.TRUE.equals(updates[i].getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK))) + if (updates[i] instanceof ICheckUpdate && + Boolean.TRUE.equals(updates[i].getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK))) { ((ICheckUpdate)updates[i]).setChecked(element.getChecked(), element.getGrayed()); } @@ -182,19 +188,19 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates } else { updates[i].done(); } - } - } + } + } } - + /** - * Test to make sure that label provider cancels stale updates and doesn't + * Test to make sure that label provider cancels stale updates and doesn't * use data from stale updates to populate the viewer.<br> * See bug 210027 */ public void testLabelUpdatesCompletedOutOfSequence1() throws InterruptedException { TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates(); model.fCaptureLabelUpdates = true; - + model.setRoot(new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$ new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$ new TestElement(model, "2", new TestElement[0]), //$NON-NLS-1$ @@ -208,28 +214,28 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates Thread.sleep(0); } } - List firstUpdates = model.fCapturedUpdates; - model.fCapturedUpdates = new ArrayList(2); - -// // Change the model and run another update set. + List<IViewerUpdate> firstUpdates = model.fCapturedUpdates; + model.fCapturedUpdates = new ArrayList<IViewerUpdate>(2); + +// // Change the model and run another update set. model.getElement(model.findElement("1")).setLabelAppendix(" - changed"); //$NON-NLS-1$ //$NON-NLS-2$ model.getElement(model.findElement("2")).setLabelAppendix(" - changed"); //$NON-NLS-1$ //$NON-NLS-2$ - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (model.fCapturedUpdates.size() < model.getRootElement().fChildren.length) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + // Complete the second set of children updates for (int i = 0; i < model.fCapturedUpdates.size(); i++) { ((ILabelUpdate)model.fCapturedUpdates.get(i)).done(); } - + // Then complete the first set. for (int i = 0; i < firstUpdates.size(); i++) { - ILabelUpdate capturedUpdate = (ILabelUpdate)firstUpdates.get(i); + ILabelUpdate capturedUpdate = (ILabelUpdate)firstUpdates.get(i); assertTrue(capturedUpdate.isCanceled()); capturedUpdate.done(); } @@ -239,23 +245,23 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates Thread.sleep(0); } } - + // Check viewer data model.validateData(fViewer, TreePath.EMPTY); } /** - * Test to make sure that label provider cancels stale updates and doesn't + * Test to make sure that label provider cancels stale updates and doesn't * use data from stale updates to populate the viewer.<br> - * This version of the test changes the elements in the view, and not just - * the elements' labels. In this case, the view should still cancel stale - * updates.<br> + * This version of the test changes the elements in the view, and not just + * the elements' labels. In this case, the view should still cancel stale + * updates.<br> * See bug 210027 */ public void testLabelUpdatesCompletedOutOfSequence2() throws InterruptedException { TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates(); model.fCaptureLabelUpdates = true; - + model.setRoot(new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$ new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$ new TestElement(model, "2", new TestElement[0]), //$NON-NLS-1$ @@ -269,30 +275,30 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates Thread.sleep(0); } } - List firstUpdates = model.fCapturedUpdates; - model.fCapturedUpdates = new ArrayList(2); - - // Change the model and run another update set. + List<IViewerUpdate> firstUpdates = model.fCapturedUpdates; + model.fCapturedUpdates = new ArrayList<IViewerUpdate>(2); + + // Change the model and run another update set. model.setElementChildren(TreePath.EMPTY, new TestElement[] { new TestElement(model, "1-new", new TestElement[0]), //$NON-NLS-1$ new TestElement(model, "2-new", new TestElement[0]), //$NON-NLS-1$ }); - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (model.fCapturedUpdates.size() < model.getRootElement().fChildren.length) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + // Complete the second set of children updates for (int i = 0; i < model.fCapturedUpdates.size(); i++) { ((ILabelUpdate)model.fCapturedUpdates.get(i)).done(); } - + // Then complete the first set. for (int i = 0; i < firstUpdates.size(); i++) { - ILabelUpdate capturedUpdate = (ILabelUpdate)firstUpdates.get(i); + ILabelUpdate capturedUpdate = (ILabelUpdate)firstUpdates.get(i); assertTrue(capturedUpdate.isCanceled()); capturedUpdate.done(); } @@ -302,24 +308,24 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates Thread.sleep(0); } } - + // Check viewer data model.validateData(fViewer, TreePath.EMPTY); } /** - * Test to make sure that content provider cancels stale updates and doesn't + * Test to make sure that content provider cancels stale updates and doesn't * use data from stale updates to populate the viewer.<br> - * Note: this test is disabled because currently the viewer will not issue + * Note: this test is disabled because currently the viewer will not issue * a new update for an until the previous update is completed. This is even - * if the previous update is canceled. If this behavior is changed at some + * if the previous update is canceled. If this behavior is changed at some * point, then this test should be re-enabled.<br> * See bug 210027 */ public void _x_testChildrenUpdatesCompletedOutOfSequence() throws InterruptedException { TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates(); model.fCaptureChildrenUpdates = true; - + model.setRoot(new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$ new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$ new TestElement(model, "2", new TestElement[0]), //$NON-NLS-1$ @@ -333,27 +339,27 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates Thread.sleep(0); } } - IChildrenUpdate[] firstUpdates = (IChildrenUpdate[])model.fCapturedUpdates.toArray(new IChildrenUpdate[0]); + IChildrenUpdate[] firstUpdates = model.fCapturedUpdates.toArray(new IChildrenUpdate[0]); model.fCapturedUpdates.clear(); - - // Change the model and run another update set. + + // Change the model and run another update set. model.setElementChildren(TreePath.EMPTY, new TestElement[] { new TestElement(model, "1-new", new TestElement[0]), //$NON-NLS-1$ new TestElement(model, "2-new", new TestElement[0]), //$NON-NLS-1$ }); - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (!areCapturedChildrenUpdatesComplete(model.fCapturedUpdates, model.getRootElement().fChildren.length)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + // Complete the second set of children updates for (int i = 0; i < model.fCapturedUpdates.size(); i++) { ((IChildrenUpdate)model.fCapturedUpdates.get(i)).done(); } - + // Then complete the first set. for (int i = 0; i < firstUpdates.length; i++) { firstUpdates[i].done(); @@ -364,17 +370,17 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates Thread.sleep(0); } } - + // Check viewer data model.validateData(fViewer, TreePath.EMPTY); } - - private boolean areCapturedChildrenUpdatesComplete(List capturedUpdates, int childCount) { - List expectedChildren = new ArrayList(); + + private boolean areCapturedChildrenUpdatesComplete(List<IViewerUpdate> capturedUpdates, int childCount) { + List<Integer> expectedChildren = new ArrayList<Integer>(); for (int i = 0; i < childCount; i++) { expectedChildren.add(new Integer(i)); } - IChildrenUpdate[] updates = (IChildrenUpdate[])capturedUpdates.toArray(new IChildrenUpdate[0]); + IChildrenUpdate[] updates = capturedUpdates.toArray(new IChildrenUpdate[0]); for (int i = 0; i < updates.length; i++) { for (int j = 0; j < updates[i].getLength(); j++) { expectedChildren.remove( new Integer(updates[i].getOffset() + j) ); diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java index 93fac0a2c..d183c0ff5 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation * IBM Corporation - clean-up @@ -31,15 +31,15 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; /** - * Tests to verify that the viewer property retrieves and processes the - * model deltas generated by the test model. + * Tests to verify that the viewer property retrieves and processes the + * model deltas generated by the test model. */ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesListenerConstants { Display fDisplay; Shell fShell; ITreeModelViewer fViewer; TestModelUpdatesListener fListener; - + public DeltaTests(String name) { super(name); } @@ -47,29 +47,31 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); - + fShell.setLayout(new FillLayout()); fViewer = createViewer(fDisplay, fShell); - + fListener = new TestModelUpdatesListener(fViewer, false, false); fShell.open (); } abstract protected IInternalTreeModelViewer createViewer(Display display, Shell shell); - + /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); - + // Close the shell and exit. fShell.close(); while (!fShell.isDisposed()) { @@ -79,22 +81,23 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { throw new ExecutionException("Test failed: " + t.getMessage() + "\n fListener = " + fListener.toString(), t); //$NON-NLS-1$ //$NON-NLS-2$ } } - + public void testUpdateLabel() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -104,13 +107,13 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model TestElement element = model.getRootElement().getChildren()[0]; TreePath elementPath = new TreePath(new Object[] { element }); ModelDelta delta = model.appendElementLabel(elementPath, "-modified"); //$NON-NLS-1$ - - fListener.reset(elementPath, element, -1, true, false); + + fListener.reset(elementPath, element, -1, true, false); model.postDelta(delta); while (!fListener.isFinished(LABEL_COMPLETE | MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -122,12 +125,12 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi public void testRefreshStruct() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -137,7 +140,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model TestElement element = model.getRootElement().getChildren()[0]; TreePath elementPath = new TreePath(new Object[] { element }); @@ -147,8 +150,8 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi new TestElement(model, "1.3 - new", new TestElement[0]), //$NON-NLS-1$ }; ModelDelta delta = model.setElementChildren(elementPath, newChildren); - - fListener.reset(elementPath, element, -1, true, false); + + fListener.reset(elementPath, element, -1, true, false); model.postDelta(delta); while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { @@ -160,12 +163,12 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi public void testRefreshStruct2() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleMultiLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -202,10 +205,10 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi }), }) }); - + TestElement element = model.getRootElement(); fListener.reset(TreePath.EMPTY, element, -1, false, false); - + model.postDelta(new ModelDelta(element, IModelDelta.CONTENT)); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -217,20 +220,20 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi public void testRefreshCoalesceStruct() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + // Create a single level model and add a single child to each element. TestModel model = TestModel.simpleSingleLevel(); - TestElement[] rootChildren = model.getRootElement().getChildren(); + TestElement[] rootChildren = model.getRootElement().getChildren(); for (int i = 0; i < rootChildren.length; i++) { model.setElementChildren( - new TreePath(new Object[] { rootChildren[i]} ), + new TreePath(new Object[] { rootChildren[i]} ), new TestElement[] { new TestElement(model, i + ".1", new TestElement[0]) }); //$NON-NLS-1$ } - + fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -240,7 +243,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } } model.validateData(fViewer, TreePath.EMPTY); - + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE)) { @@ -248,36 +251,36 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi Thread.sleep(0); } } - + model.validateData(fViewer, TreePath.EMPTY); assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) ); } - - + + public void testInsert() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); - + while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model TestElement element = new TestElement(model, "7", new TestElement[0]); //$NON-NLS-1$ TreePath elementPath = new TreePath(new Object[] { element }); ModelDelta delta = model.insertElementChild(TreePath.EMPTY, 6, element); - + // Insert causes the update of element's data, label and children. // TODO: update of element's data after insert seems redundant // but it's probably not a big inefficiency @@ -295,14 +298,14 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } model.validateData(fViewer, TreePath.EMPTY); } - + /** * This test checks that insert and select delta flags are processed in correct order: * insert then select. */ public void testInsertAndSelect() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -311,15 +314,15 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); - + while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - - model.validateData(fViewer, TreePath.EMPTY); - + + model.validateData(fViewer, TreePath.EMPTY); + // Update the model // Insert two new elements at once TestElement element0 = new TestElement(model, "00", new TestElement[] {}); //$NON-NLS-1$ @@ -328,7 +331,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi TreePath elementPath1 = new TreePath(new Object[] { element1 }); ModelDelta rootDelta = model.insertElementChild(TreePath.EMPTY, 0, element0); rootDelta = model.insertElementChild(rootDelta, TreePath.EMPTY, 1, element1); - + // Set the select flag on the first added node. ModelDelta delta0 = rootDelta.getChildDelta(element0); delta0.setFlags(delta0.getFlags() | IModelDelta.SELECT); @@ -338,7 +341,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi fListener.addHasChildrenUpdate(elementPath1); fListener.addLabelUpdate(elementPath0); fListener.addLabelUpdate(elementPath1); - + // TODO: list full set of expected updates. fListener.setFailOnRedundantUpdates(false); @@ -348,34 +351,34 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi Thread.sleep(0); } } - + model.validateData(fViewer, TreePath.EMPTY); } /** * This test checks that insert and remove deltas are processed in correct order: - * remove deltas are processed first then insert deltas. + * remove deltas are processed first then insert deltas. */ public void testInsertAndRemove() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); fViewer.setInput(model.getRootElement()); - + while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - - model.validateData(fViewer, TreePath.EMPTY); - + + model.validateData(fViewer, TreePath.EMPTY); + // Update the model // Remove one element then insert a new one IModelDelta removeDelta = model.removeElementChild(TreePath.EMPTY, 3).getChildDeltas()[0]; - + // Insert new elements at once TestElement element = new TestElement(model, "00", new TestElement[] {}); //$NON-NLS-1$ TreePath elementPath = new TreePath(new Object[] { element }); @@ -385,12 +388,12 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi ModelDelta combinedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE, 0, model.getRootElement().getChildren().length); combinedDelta.addNode(insertDelta.getElement(), insertDelta.getIndex(), insertDelta.getFlags(), insertDelta.getChildCount()); combinedDelta.addNode(removeDelta.getElement(), removeDelta.getIndex(), removeDelta.getFlags(), removeDelta.getChildCount()); - + // Set the select flag on the first added node. fListener.reset(); fListener.addHasChildrenUpdate(elementPath); fListener.addLabelUpdate(elementPath); - + // TODO: list full set of expected updates. fListener.setFailOnRedundantUpdates(false); @@ -400,19 +403,19 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi Thread.sleep(0); } } - + model.validateData(fViewer, TreePath.EMPTY); } - + public void testAddElement() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -422,14 +425,14 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model TestElement element = new TestElement(model, "7", new TestElement[0]); //$NON-NLS-1$ TreePath elementPath = new TreePath(new Object[] { element }); ModelDelta delta = model.addElementChild(TreePath.EMPTY, null, 6, element); - + // Add causes the update of parent child count and element's children. - fListener.reset(elementPath, element, -1, true, false); + fListener.reset(elementPath, element, -1, true, false); fListener.addChildreUpdate(TreePath.EMPTY, 6); // TODO: redundant updates on add! fListener.setFailOnRedundantUpdates(false); @@ -442,17 +445,17 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi model.validateData(fViewer, TreePath.EMPTY); } - // This test currently fails. When (if) bug 311442 gets address we should re-enable it. + // This test currently fails. When (if) bug 311442 gets address we should re-enable it. public void _x_testAddUnexpandedElement() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleMultiLevel(); // Turn off auto-expansion fViewer.setAutoExpandLevel(0); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -468,7 +471,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi model.addElementChild(parentPath, rootDelta, 1, new TestElement(model, "1.2", new TestElement[0])); //$NON-NLS-1$ model.addElementChild(parentPath, rootDelta, 2, new TestElement(model, "1.3", new TestElement[0])); //$NON-NLS-1$ model.addElementChild(parentPath, rootDelta, 3, new TestElement(model, "1.4", new TestElement[0])); //$NON-NLS-1$ - + // Add causes the update of parent child count and element's children. fListener.reset(); fListener.setFailOnRedundantUpdates(false); @@ -487,14 +490,14 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi model.getElementDelta(rootDelta, model.findElement("1.2"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$ model.getElementDelta(rootDelta, model.findElement("1.3"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$ model.getElementDelta(rootDelta, model.findElement("1.4"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$ - + model.postDelta(rootDelta); while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | ALL_UPDATES_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + fListener.reset(parentPath, model.getElement(parentPath), 1, false, true); ((IInternalTreeModelViewer)fViewer).expandToLevel(parentPath, 1); @@ -509,14 +512,14 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi public void _x_testRefreshUnexpandedElementsChildren() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleMultiLevel(); // Turn off auto-expansion fViewer.setAutoExpandLevel(0); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -539,7 +542,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi // Collapse back element "2" ((IInternalTreeModelViewer)fViewer).setExpandedState(parentPath, false); - + // Update the children of element "2". fListener.reset(); fListener.addUpdates((IInternalTreeModelViewer)fViewer, TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE); @@ -547,7 +550,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi model.getElementDelta(rootDelta, model.findElement("2.1"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$ model.getElementDelta(rootDelta, model.findElement("2.2"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$ model.getElementDelta(rootDelta, model.findElement("2.3"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$ - + model.postDelta(rootDelta); while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | ALL_UPDATES_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -568,15 +571,15 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi model.validateData(fViewer, parentPath, true); } - + public void testRemove() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -586,13 +589,13 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model ModelDelta delta = model.removeElementChild(TreePath.EMPTY, 5); - + // Remove delta should generate no new updates, but we still need to wait for the event to // be processed. - fListener.reset(); + fListener.reset(); model.postDelta(delta); while (!fListener.isFinished(MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -601,10 +604,10 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } model.validateData(fViewer, TreePath.EMPTY); } - + public void testExpandAndSelect() throws InterruptedException { TestModel model = TestModel.simpleMultiLevel(); - + // Create the listener fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); @@ -619,8 +622,8 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi // Create the delta fListener.reset(); - // TODO Investigate: there seem to be unnecessary updates being issued - // by the viewer. These include the updates that are commented out: + // TODO Investigate: there seem to be unnecessary updates being issued + // by the viewer. These include the updates that are commented out: // For now disable checking for extra updates. fListener.setFailOnRedundantUpdates(false); TestElement element = model.getRootElement(); @@ -637,7 +640,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi TreePath path_root_3_3 = path_root_3.createChildPath(element.getChildren()[2]); fListener.addHasChildrenUpdate(path_root_3_3); fListener.addLabelUpdate(path_root_3_3); - //TODO unnecessary update: fListener.addChildreUpdate(path1, 1); + //TODO unnecessary update: fListener.addChildreUpdate(path1, 1); fListener.addChildreUpdate(path_root_3, 2); element = element.getChildren()[1]; TreePath path_root_3_2 = path_root_3.createChildPath(element); @@ -651,7 +654,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi fListener.addLabelUpdate(path_root_3_2_3); // TODO unnecessary update: fListener.addChildreCountUpdate(path2); fListener.addChildreUpdate(path_root_3_2, 0); - // TODO unnecessary update: fListener.addChildreUpdate(path2, 1); + // TODO unnecessary update: fListener.addChildreUpdate(path2, 1); fListener.addChildreUpdate(path_root_3_2, 2); element = element.getChildren()[1]; TreePath path_root_3_2_2 = path_root_3_2.createChildPath(element); @@ -660,12 +663,12 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi fListener.addHasChildrenUpdate(path_root_3_2_2); // Validate the expansion state BEFORE posting the delta. - - IInternalTreeModelViewer contentProviderViewer = (IInternalTreeModelViewer)fViewer; + + IInternalTreeModelViewer contentProviderViewer = (IInternalTreeModelViewer)fViewer; assertFalse(contentProviderViewer.getExpandedState(path_root_3)); assertFalse(contentProviderViewer.getExpandedState(path_root_3_2)); assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2)); - + model.postDelta(deltaRoot); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -678,11 +681,11 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi assertTrue(contentProviderViewer.getExpandedState(path_root_3)); assertTrue(contentProviderViewer.getExpandedState(path_root_3_2)); assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2)); - + // Verify selection ISelection selection = fViewer.getSelection(); if (selection instanceof ITreeSelection) { - List selectionPathsList = Arrays.asList( ((ITreeSelection)selection).getPaths() ); + List<TreePath> selectionPathsList = Arrays.asList(((ITreeSelection) selection).getPaths()); assertTrue(selectionPathsList.contains(path_root_3_2_2)); } else { fail("Not a tree selection"); //$NON-NLS-1$ @@ -694,7 +697,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi */ public void testExpandAndSelect_simple() throws InterruptedException { TestModel model = TestModel.simpleMultiLevel(); - + // Create the listener fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); @@ -709,8 +712,8 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi // Create the delta fListener.reset(); - // TODO Investigate: there seem to be unnecessary updates being issued - // by the viewer. These include the updates that are commented out: + // TODO Investigate: there seem to be unnecessary updates being issued + // by the viewer. These include the updates that are commented out: // For now disable checking for extra updates. fListener.setFailOnRedundantUpdates(false); TestElement element = model.getRootElement(); @@ -722,10 +725,10 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi delta.addNode(element, 2, IModelDelta.SELECT | IModelDelta.EXPAND, element.fChildren.length); // Validate the expansion state BEFORE posting the delta. - - IInternalTreeModelViewer contentProviderViewer = (IInternalTreeModelViewer)fViewer; + + IInternalTreeModelViewer contentProviderViewer = (IInternalTreeModelViewer)fViewer; assertFalse(contentProviderViewer.getExpandedState(path_root_3)); - + model.postDelta(deltaRoot); while (true) { if (fListener.isFinished(MODEL_CHANGED_COMPLETE)) { @@ -741,11 +744,11 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi // Validate the expansion state AFTER posting the delta. assertTrue(contentProviderViewer.getExpandedState(path_root_3)); - + // Verify selection ISelection selection = fViewer.getSelection(); if (selection instanceof ITreeSelection) { - List selectionPathsList = Arrays.asList( ((ITreeSelection)selection).getPaths() ); + List<TreePath> selectionPathsList = Arrays.asList(((ITreeSelection) selection).getPaths()); assertTrue(selectionPathsList.contains(path_root_3)); } else { fail("Not a tree selection"); //$NON-NLS-1$ @@ -754,12 +757,12 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi public void testCompositeModelRefreshStruct() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.compositeMultiLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - // TODO: redundant updates on install deltas + // TODO: redundant updates on install deltas fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. @@ -782,8 +785,8 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi }; ModelDelta delta = m4.setElementChildren(m4_2_1Path, newChildren); - - fListener.reset(m4_2_1Path, m4_2_1, -1, true, false); + + fListener.reset(m4_2_1Path, m4_2_1, -1, true, false); model.postDelta(delta); while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { @@ -798,7 +801,7 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi fViewer.setAutoExpandLevel(-1); // Create the listener - // TODO: redundant updates on install deltas + // TODO: redundant updates on install deltas fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. @@ -809,32 +812,32 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } } model.validateData(fViewer, TreePath.EMPTY, true); - + TreePath m3_1Path = model.findElement("m3.1"); //$NON-NLS-1$ TestElement m3_1 = model.getElement(m3_1Path); TestModel m3 = m3_1.getModel(); TestElement m3_1_new = new TestElement(m3, "m3.1-new", new TestElement[0]); //$NON-NLS-1$ TreePath m3_1_newPath = m3_1Path.createChildPath(m3_1_new); ModelDelta delta = m3.addElementChild(m3_1Path, null, 0, m3_1_new); - - fListener.reset(m3_1_newPath, m3_1_new, -1, true, false); + + fListener.reset(m3_1_newPath, m3_1_new, -1, true, false); fListener.addChildreUpdate(m3_1Path, 0); fListener.setFailOnRedundantUpdates(false); - + m3.postDelta(delta); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + model.validateData(fViewer, TreePath.EMPTY); } - + public void testBug292322() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -844,13 +847,13 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi } } model.validateData(fViewer, TreePath.EMPTY, true); - + // Update the model: remove one child of an un-expanded element, then // make sure that the number of children is correct. TreePath parentPath = model.findElement("2"); //$NON-NLS-1$ TestElement parentElement = model.getElement(parentPath); ModelDelta delta = model.removeElementChild(parentPath, 0); - + // Update the viewer fListener.reset(parentPath, parentElement, 0, false, false); //fListener.addChildreCountUpdate(parentPath); @@ -864,10 +867,10 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi // Validate the viewer data. model.validateData(fViewer, TreePath.EMPTY, true); - // Update the model: remove the remaining children and make sure that + // Update the model: remove the remaining children and make sure that // the element children are updated to false. model.removeElementChild(parentPath, 0); - + // Update the viewer fListener.reset(parentPath, parentElement, 0, false, false); model.postDelta(delta); @@ -880,10 +883,10 @@ abstract public class DeltaTests extends TestCase implements ITestModelUpdatesLi // Validate the viewer data. model.validateData(fViewer, TreePath.EMPTY, true); - // Update the model: remove the remaining children and make sure that + // Update the model: remove the remaining children and make sure that // the element children are updated to false. model.removeElementChild(parentPath, 0); - + // Update the viewer fListener.reset(parentPath, parentElement, 0, false, false); model.postDelta(delta); diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTests.java index 52308e2d1..9cd850cd2 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTests.java @@ -52,7 +52,8 @@ abstract public class FilterTests extends TestCase implements ITestModelUpdatesL /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); @@ -70,7 +71,8 @@ abstract public class FilterTests extends TestCase implements ITestModelUpdatesL /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); @@ -83,7 +85,8 @@ abstract public class FilterTests extends TestCase implements ITestModelUpdatesL } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { @@ -104,7 +107,8 @@ abstract public class FilterTests extends TestCase implements ITestModelUpdatesL } - public boolean select(Viewer viewer, Object parentElement, Object element) { + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof TestElement) { TestElement te = (TestElement)element; return !fPattern.matcher(te.getLabel()).find(); @@ -122,7 +126,8 @@ abstract public class FilterTests extends TestCase implements ITestModelUpdatesL fParentElement = parentElement; } - public boolean isApplicable(ITreeModelViewer viewer, Object parentElement) { + @Override + public boolean isApplicable(ITreeModelViewer viewer, Object parentElement) { if (fParentElement != null) { return fParentElement.equals(parentElement); } @@ -130,7 +135,8 @@ abstract public class FilterTests extends TestCase implements ITestModelUpdatesL return true; } - public boolean select(Viewer viewer, Object parentElement, Object element) { + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof TestElement) { TestElement te = (TestElement)element; return !fPattern.matcher(te.getLabel()).find(); diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTransformTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTransformTests.java index afe51e13c..07f1151c3 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTransformTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/FilterTransformTests.java @@ -45,6 +45,7 @@ public class FilterTransformTests extends TestCase { * and elements 0, 2, 3, 6, 7 are filtered. Elements * 1, 4, 5 are visible. */ + @Override protected void setUp() throws Exception { super.setUp(); transform = new FilterTransform(); diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerCheckTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerCheckTests.java index b2f3db69a..79472fb34 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerCheckTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerCheckTests.java @@ -27,7 +27,8 @@ public class JFaceViewerCheckTests extends CheckTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.CHECK, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerContentTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerContentTests.java index 68e860470..fcd8dfe66 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerContentTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerContentTests.java @@ -27,7 +27,8 @@ public class JFaceViewerContentTests extends ContentTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerDeltaTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerDeltaTests.java index 8853315a0..d606f6097 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerDeltaTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerDeltaTests.java @@ -27,13 +27,15 @@ public class JFaceViewerDeltaTests extends DeltaTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ } /** * TODO: remove this method when bug 292322 gets fixed in TreeViewer */ - public void testBug292322() { + @Override + public void testBug292322() { } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerFilterTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerFilterTests.java index 654d97b9f..ac9a7c598 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerFilterTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerFilterTests.java @@ -27,7 +27,8 @@ public class JFaceViewerFilterTests extends FilterTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.MULTI, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerLazyTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerLazyTests.java index b511a32d3..9347e274e 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerLazyTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerLazyTests.java @@ -26,7 +26,8 @@ public class JFaceViewerLazyTests extends LazyTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPerformanceTests.java index e046751c9..180f88398 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPerformanceTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPerformanceTests.java @@ -26,11 +26,13 @@ public class JFaceViewerPerformanceTests extends PerformanceTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ } - protected int getTestModelDepth() { + @Override + protected int getTestModelDepth() { return 5; } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPopupTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPopupTests.java index 8c4b923a6..df2732a0c 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPopupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPopupTests.java @@ -27,7 +27,8 @@ public class JFaceViewerPopupTests extends PopupTests { super(name); } - protected ITreeModelViewer createViewer(Display display, Shell shell, int style) { + @Override + protected ITreeModelViewer createViewer(Display display, Shell shell, int style) { return new TreeModelViewer(fShell, SWT.VIRTUAL | style, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerSelectionTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerSelectionTests.java index 94009bb2c..dd63dcc6a 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerSelectionTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerSelectionTests.java @@ -27,7 +27,8 @@ public class JFaceViewerSelectionTests extends SelectionTests { super(name); } - protected ITreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected ITreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerStateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerStateTests.java index a20055571..c07316b9e 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerStateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerStateTests.java @@ -27,7 +27,8 @@ public class JFaceViewerStateTests extends StateTests { super(name); } - protected ITreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected ITreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.MULTI, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java index b51a4247b..6e7911115 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java @@ -47,7 +47,8 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setSize(300, 80); @@ -63,7 +64,8 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); @@ -76,7 +78,8 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { @@ -514,7 +517,8 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda ModelDelta revealDelta = model.makeElementDelta(pathToBeRevealed, IModelDelta.REVEAL); revealDelta.accept(new IModelDeltaVisitor() { - public boolean visit(IModelDelta delta, int depth) { + @Override + public boolean visit(IModelDelta delta, int depth) { ((ModelDelta)delta).setFlags(delta.getFlags() | IModelDelta.EXPAND); return true; } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerUpdateTests.java index 4ebd01ad7..518eeadd7 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerUpdateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerUpdateTests.java @@ -27,7 +27,8 @@ public class JFaceViewerUpdateTests extends UpdateTests { super(name); } - protected ITreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected ITreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/LazyTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/LazyTests.java index 7dacab8ef..920345ebd 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/LazyTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/LazyTests.java @@ -46,7 +46,8 @@ abstract public class LazyTests extends TestCase implements ITestModelUpdatesLis /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); @@ -63,7 +64,8 @@ abstract public class LazyTests extends TestCase implements ITestModelUpdatesLis /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); @@ -76,7 +78,8 @@ abstract public class LazyTests extends TestCase implements ITestModelUpdatesLis } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PerformanceTests.java index 0caaf4593..6c1b0416c 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PerformanceTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PerformanceTests.java @@ -46,7 +46,8 @@ abstract public class PerformanceTests extends TestCase implements ITestModelUpd /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); @@ -65,7 +66,8 @@ abstract public class PerformanceTests extends TestCase implements ITestModelUpd /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); @@ -78,7 +80,8 @@ abstract public class PerformanceTests extends TestCase implements ITestModelUpd } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { @@ -375,7 +378,8 @@ abstract public class PerformanceTests extends TestCase implements ITestModelUpd fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); fViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, Object element) { + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof TestElement) { String id = ((TestElement)element).getID(); if (id.startsWith("model.")) { //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PopupTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PopupTests.java index d99c149ae..37487c566 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PopupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PopupTests.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation * IBM Corporation - clean-up @@ -35,8 +35,8 @@ import org.eclipse.ui.PlatformUI; /** * Tests to verify that the viewer property updates when created - * with the SWT.POPUP style. - * + * with the SWT.POPUP style. + * * @since 3.6 */ abstract public class PopupTests extends TestCase implements ITestModelUpdatesListenerConstants { @@ -44,7 +44,7 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi Shell fShell; ITreeModelViewer fViewer; TestModelUpdatesListener fListener; - + public PopupTests(String name) { super(name); } @@ -52,14 +52,15 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); fShell.setLayout(new FillLayout()); fViewer = createViewer(fDisplay, fShell, SWT.POP_UP); - + fListener = new TestModelUpdatesListener(fViewer, false, false); fShell.open (); @@ -68,17 +69,18 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi protected IInternalTreeModelViewer getCTargetViewer() { return (IInternalTreeModelViewer)fViewer; } - + abstract protected ITreeModelViewer createViewer(Display display, Shell shell, int style); - + /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); - + // Close the shell and exit. fShell.close(); while (!fShell.isDisposed()) { @@ -89,16 +91,16 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi } /** - * This test verifies that content updates are still being performed. + * This test verifies that content updates are still being performed. */ public void testRefreshStruct() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -108,7 +110,7 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model TestElement element = model.getRootElement().getChildren()[0]; TreePath elementPath = new TreePath(new Object[] { element }); @@ -118,8 +120,8 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi new TestElement(model, "1.3 - new", new TestElement[0]), //$NON-NLS-1$ }; ModelDelta delta = model.setElementChildren(elementPath, newChildren); - - fListener.reset(elementPath, element, -1, true, false); + + fListener.reset(elementPath, element, -1, true, false); model.postDelta(delta); while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { @@ -134,7 +136,7 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi */ public void testExpandAndSelect() throws InterruptedException { TestModel model = TestModel.simpleMultiLevel(); - + // Create the listener fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); @@ -149,8 +151,8 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi // Create the delta fListener.reset(); - // TODO Investigate: there seem to be unnecessary updates being issued - // by the viewer. These include the updates that are commented out: + // TODO Investigate: there seem to be unnecessary updates being issued + // by the viewer. These include the updates that are commented out: // For now disable checking for extra updates. fListener.setFailOnRedundantUpdates(false); TestElement element = model.getRootElement(); @@ -162,10 +164,10 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi delta.addNode(element, 2, IModelDelta.SELECT | IModelDelta.EXPAND, element.fChildren.length); // Validate the expansion state BEFORE posting the delta. - - IInternalTreeModelViewer contentProviderViewer = (IInternalTreeModelViewer)fViewer; + + IInternalTreeModelViewer contentProviderViewer = (IInternalTreeModelViewer)fViewer; assertFalse(contentProviderViewer.getExpandedState(path_root_3)); - + model.postDelta(deltaRoot); while (true) { if (fListener.isFinished(MODEL_CHANGED_COMPLETE)) { @@ -185,28 +187,28 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi // Validate the expansion state AFTER posting the delta. assertFalse(contentProviderViewer.getExpandedState(path_root_3)); - + // Verify selection ISelection selection = fViewer.getSelection(); if (selection instanceof ITreeSelection) { - List selectionPathsList = Arrays.asList( ((ITreeSelection)selection).getPaths() ); + List<TreePath> selectionPathsList = Arrays.asList(((ITreeSelection) selection).getPaths()); assertFalse(selectionPathsList.contains(path_root_3)); } else { fail("Not a tree selection"); //$NON-NLS-1$ } } - - + + public void testPreserveExpandedOnSubTreeContent() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); // Expand all fViewer.setAutoExpandLevel(-1); - - // Create the listener, - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + + // Create the listener, + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -219,14 +221,14 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi // Turn off auto-expansion fViewer.setAutoExpandLevel(0); - + // Set a selection in view TreeSelection originalSelection = new TreeSelection(model.findElement("3.3.1")); //$NON-NLS-1$ fViewer.setSelection(originalSelection); // Update the model model.addElementChild(model.findElement("3"), null, 0, new TestElement(model, "3.0 - new", new TestElement[0])); //$NON-NLS-1$ //$NON-NLS-2$ - + // Create the delta for element "3" with content update. TreePath elementPath = model.findElement("3"); //$NON-NLS-1$ ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE); @@ -236,7 +238,7 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi // Note: Re-expanding nodes causes redundant updates. fListener.reset(false, false); fListener.addUpdates(getCTargetViewer(), elementPath, model.getElement(elementPath), -1, ALL_UPDATES_COMPLETE); - + // Post the sub-tree update model.postDelta(rootDelta); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE)) { @@ -257,14 +259,14 @@ abstract public class PopupTests extends TestCase implements ITestModelUpdatesLi } private boolean areTreeSelectionsEqual(ITreeSelection sel1, ITreeSelection sel2) { - Set sel1Set = new HashSet(); + Set<TreePath> sel1Set = new HashSet<TreePath>(); sel1Set.addAll( Arrays.asList(sel1.getPaths()) ); - - Set sel2Set = new HashSet(); + + Set<TreePath> sel2Set = new HashSet<TreePath>(); sel2Set.addAll( Arrays.asList(sel2.getPaths()) ); - + return sel1Set.equals(sel2Set); } - + } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java index 8f51de89c..625edb48a 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/SelectionTests.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation * IBM Corporation - bug fixing @@ -31,7 +31,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; -/** +/** * Tests to verify that the viewer properly handles selection changes. */ abstract public class SelectionTests extends TestCase implements ITestModelUpdatesListenerConstants { @@ -39,7 +39,7 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat Shell fShell; ITreeModelViewer fViewer; TestModelUpdatesListener fListener; - + public SelectionTests(String name) { super(name); } @@ -47,28 +47,30 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); fShell.setLayout(new FillLayout()); fViewer = createViewer(fDisplay, fShell); - + fListener = new TestModelUpdatesListener(fViewer, false, false); fShell.open (); } abstract protected ITreeModelViewer createViewer(Display display, Shell shell); - + /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); - + // Close the shell and exit. fShell.close(); while (!fShell.isDisposed()) { @@ -79,9 +81,10 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat } private static class SelectionListener implements ISelectionChangedListener { - private final List fEvents = new ArrayList(1); - - public void selectionChanged(SelectionChangedEvent event) { + private final List<SelectionChangedEvent> fEvents = new ArrayList<SelectionChangedEvent>(1); + + @Override + public void selectionChanged(SelectionChangedEvent event) { fEvents.add(event); } } @@ -89,7 +92,7 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat private TestModel makeMultiLevelModel() throws InterruptedException { TestModel model = TestModel.simpleMultiLevel(); fViewer.setAutoExpandLevel(-1); - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); fViewer.setInput(model.getRootElement()); while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { @@ -99,17 +102,17 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat model.validateData(fViewer, TreePath.EMPTY); return model; } - + /** * In this test: * - set selection to an element deep in the model * - verify that selection chagned listener is called - * - verify that the selection is in the viewer is correct + * - verify that the selection is in the viewer is correct */ public void testSimpleSetSelection() throws InterruptedException { // Create the model and populate the view. TestModel model = makeMultiLevelModel(); - + // Create a selection object to the deepest part of the tree. SelectionListener listener = new SelectionListener(); fViewer.addSelectionChangedListener(listener); @@ -120,7 +123,7 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat assertTrue(listener.fEvents.size() == 1); // Check that the new selection is what was requested. - ISelection viewerSelection = fViewer.getSelection(); + ISelection viewerSelection = fViewer.getSelection(); assertEquals(selection, viewerSelection); } @@ -132,27 +135,31 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat public void testSelectionPolicy() throws InterruptedException { // Create the model and populate the view. final TestModel model = makeMultiLevelModel(); - + // Set the selection and verify it. TreeSelection selection_3_3_3 = new TreeSelection(model.findElement("3.3.3")); //$NON-NLS-1$ fViewer.setSelection(selection_3_3_3, true, false); assertEquals(selection_3_3_3, fViewer.getSelection()); model.setSelectionPolicy(new IModelSelectionPolicy() { - - public ISelection replaceInvalidSelection(ISelection invalidSelection, ISelection newSelection) { + + @Override + public ISelection replaceInvalidSelection(ISelection invalidSelection, ISelection newSelection) { return null; } - - public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context) { + + @Override + public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context) { return false; } - - public boolean isSticky(ISelection selection, IPresentationContext context) { + + @Override + public boolean isSticky(ISelection selection, IPresentationContext context) { return true; } - - public boolean contains(ISelection selection, IPresentationContext context) { + + @Override + public boolean contains(ISelection selection, IPresentationContext context) { return true; } }); @@ -165,8 +172,8 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat // Now attempt to *force* selection and verify that new selection was set. fViewer.setSelection(selection_3_3_1, true, true); assertEquals(selection_3_3_1, fViewer.getSelection()); - - // Create the an update delta to attempt to change selection back to + + // Create the an update delta to attempt to change selection back to // 3.3.3 and verify that selection did not get overriden. TreePath path_3_3_3 = model.findElement("3.3.3"); //$NON-NLS-1$ ModelDelta baseDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE); @@ -192,11 +199,11 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat assertEquals(selection_3_3_3, fViewer.getSelection()); } - + /** * In this test: - * - set a seleciton to an element - * - then remove that element + * - set a seleciton to an element + * - then remove that element * - update the view with remove delta * -> The selection should be re-set to empty. */ @@ -205,7 +212,7 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat // Create the model and populate the view. TestModel model = makeMultiLevelModel(); - + // Create a selection object to the deepest part of the tree. TreePath elementPath = model.findElement("3.3.3"); //$NON-NLS-1$ TreeSelection selection = new TreeSelection(elementPath); @@ -225,7 +232,7 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat // Reset the listener and update the viewer. With a remove // delta only wait for the delta to be processed. - fListener.reset(); + fListener.reset(); model.postDelta(delta); while (!fListener.isFinished(ITestModelUpdatesListenerConstants.MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -237,15 +244,15 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat //assertTrue(listener.fEvents.size() == 1); // Check that the new selection is empty - ISelection viewerSelection = fViewer.getSelection(); + ISelection viewerSelection = fViewer.getSelection(); assertTrue(viewerSelection.isEmpty()); } - + /** * In this test: - * - set a selection to an element - * - then remove that element + * - set a selection to an element + * - then remove that element * - then refresh the view. * -> The selection should be re-set to empty. */ @@ -254,7 +261,7 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat // Create the model and populate the view. TestModel model = makeMultiLevelModel(); - + // Create a selection object to the deepest part of the tree. TreePath elementPath = model.findElement("3.3.3"); //$NON-NLS-1$ TreeSelection selection = new TreeSelection(elementPath); @@ -273,8 +280,8 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat fViewer.addSelectionChangedListener(listener); // Reset the listener to ignore redundant updates. When elements are removed - // the viewer may still request updates for those elements. - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + // the viewer may still request updates for those elements. + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Refresh the viewer model.postDelta( new ModelDelta(model.getRootElement(), IModelDelta.CONTENT) ); @@ -289,7 +296,7 @@ abstract public class SelectionTests extends TestCase implements ITestModelUpdat //assertTrue(listener.fEvents.size() == 1); // Check that the new selection is empty - ISelection viewerSelection = fViewer.getSelection(); + ISelection viewerSelection = fViewer.getSelection(); assertTrue(viewerSelection.isEmpty()); } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java index ee5206699..fffc38b7f 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation * IBM Corporation - clean-up @@ -32,9 +32,9 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; /** - * Tests to verify that the viewer can save and restore correctly the expansion + * Tests to verify that the viewer can save and restore correctly the expansion * state of elements. - * + * * @since 3.6 */ abstract public class StateTests extends TestCase implements ITestModelUpdatesListenerConstants { @@ -42,7 +42,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi Shell fShell; ITreeModelViewer fViewer; TestModelUpdatesListener fListener; - + public StateTests(String name) { super(name); } @@ -50,7 +50,8 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); @@ -58,21 +59,22 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi fShell.setLayout(new FillLayout()); fViewer = createViewer(fDisplay, fShell); - + fListener = new TestModelUpdatesListener(fViewer, false, false); fShell.open (); } abstract protected ITreeModelViewer createViewer(Display display, Shell shell); - + /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception, InterruptedException { + @Override + protected void tearDown() throws Exception, InterruptedException { fListener.dispose(); fViewer.getPresentationContext().dispose(); - + // Close the shell and exit. fShell.close(); while (!fShell.isDisposed()) { @@ -82,23 +84,24 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { throw new ExecutionException("Test failed: " + t.getMessage() + "\n fListener = " + fListener.toString(), t); //$NON-NLS-1$ //$NON-NLS-2$ } } - + protected IInternalTreeModelViewer getInternalViewer() { return (IInternalTreeModelViewer)fViewer; } - + public void testUpdateViewer() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); - + TestModel model = TestModel.simpleMultiLevel(); - + // Create the listener fListener.reset(); fListener.addChildreUpdate(TreePath.EMPTY, 0); @@ -114,7 +117,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi } model.validateData(fViewer, TreePath.EMPTY, true); - // Create the update delta + // Create the update delta TestElement element = model.getRootElement(); TreePath path0 = TreePath.EMPTY; ModelDelta delta = new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length); @@ -128,7 +131,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi element = element.getChildren()[1]; TreePath path3 = path2.createChildPath(element); delta = delta.addNode(element, 1, IModelDelta.SELECT); - + fListener.reset(false, false); fListener.addChildreUpdate(path0, 2); @@ -144,7 +147,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi fListener.addChildreUpdate(path2, 1); fListener.addHasChildrenUpdate(path3); fListener.addLabelUpdate(path3); - + fViewer.updateViewer(updateDelta); while (!fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES)) { if (!fDisplay.readAndDispatch ()) { @@ -155,7 +158,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi // Extract the new state from viewer ModelDelta savedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE); fViewer.saveElementState(path0, savedDelta, IModelDelta.EXPAND | IModelDelta.SELECT); - + if (!deltaMatches(updateDelta, savedDelta) ) { fail("Expected:\n" + updateDelta.toString() + "\nGot:\n" + savedDelta); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -166,9 +169,9 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi requested.getFlags() == received.getFlags() && ( requested.getChildCount() == -1 || requested.getChildCount() == received.getChildCount() )&& ( requested.getIndex() == -1 || requested.getIndex() == received.getIndex()) && - ((requested.getReplacementElement() != null && requested.getReplacementElement().equals(received.getReplacementElement())) || - (requested.getReplacementElement() == null && received.getReplacementElement() == null)) && - requested.getChildDeltas().length == received.getChildDeltas().length) + ((requested.getReplacementElement() != null && requested.getReplacementElement().equals(received.getReplacementElement())) || + (requested.getReplacementElement() == null && received.getReplacementElement() == null)) && + requested.getChildDeltas().length == received.getChildDeltas().length) { for (int i = 0; i < requested.getChildDeltas().length; i++) { ModelDelta requestedChildDelta = (ModelDelta)requested.getChildDeltas()[i]; @@ -184,7 +187,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi /** * Creates a model in the pattern of: - * + * * root * 1 * 1.1 @@ -202,36 +205,36 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi */ static TestModel alternatingSubsreesModel(int size) { TestModel model = new TestModel(); - + TestElement[] elements = new TestElement[size]; for (int i = 0; i < size; i++) { String text = Integer.toString(i + 1); - elements[i] = - new TestElement(model, text, new TestElement[] { + elements[i] = + new TestElement(model, text, new TestElement[] { new TestElement(model, text + ".1", new TestElement[] { //$NON-NLS-1$ new TestElement(model, text + ".1.1", new TestElement[0]) //$NON-NLS-1$ }) - }); + }); } model.setRoot(new TestElement(model, "root", elements)); //$NON-NLS-1$ - + return model; } static boolean areTreeSelectionsEqual(ITreeSelection sel1, ITreeSelection sel2) { - Set sel1Set = new HashSet(); + Set<TreePath> sel1Set = new HashSet<TreePath>(); sel1Set.addAll( Arrays.asList(sel1.getPaths()) ); - - Set sel2Set = new HashSet(); + + Set<TreePath> sel2Set = new HashSet<TreePath>(); sel2Set.addAll( Arrays.asList(sel2.getPaths()) ); - + return sel1Set.equals(sel2Set); } - + static void expandAlternateElements(TestModelUpdatesListener listener, TestModel model, boolean waitForAllUpdates) throws InterruptedException { - listener.reset(); + listener.reset(); listener.setFailOnRedundantUpdates(false); - + TestElement rootElement = model.getRootElement(); TestElement[] children = rootElement.getChildren(); ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE); @@ -241,7 +244,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi if (i % 2 == 1) { continue; } - + // Expand the element and the first child of each sub-element TestElement element = children[i]; ModelDelta delta = expandDelta; @@ -249,7 +252,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi while (element.getChildren().length != 0) { TreePath elementPath = model.findElement(element.getLabel()); listener.addUpdates( - elementPath, element, 1, + elementPath, element, 1, CHILD_COUNT_UPDATES | (waitForAllUpdates ? CHILDREN_UPDATES : 0) ); delta = delta.addNode(element, index, IModelDelta.EXPAND, element.getChildren().length); element = element.getChildren()[0]; @@ -264,15 +267,15 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi } } } - + public void testPreserveExpandedOnRemove() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -284,23 +287,23 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi model.validateData(fViewer, TreePath.EMPTY, true); expandAlternateElements(fListener, model, true); - + // Set a selection in view TreeSelection originalSelection = new TreeSelection(model.findElement("5.1")); //$NON-NLS-1$ fViewer.setSelection(originalSelection); // Update the model ModelDelta delta = model.removeElementChild(TreePath.EMPTY, 0); - + // Remove delta should not generate any new updates - fListener.reset(); + fListener.reset(); model.postDelta(delta); while (!fListener.isFinished(MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + // Validate data model.validateData(fViewer, TreePath.EMPTY, true); assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$ @@ -318,9 +321,9 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi TestModel model = alternatingSubsreesModel(6); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -332,18 +335,18 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi model.validateData(fViewer, TreePath.EMPTY, true); expandAlternateElements(fListener, model, true); - + // Set a selection in view TreeSelection originalSelection = new TreeSelection(model.findElement("5.1")); //$NON-NLS-1$ fViewer.setSelection(originalSelection); - + // Update the model ModelDelta delta = model.insertElementChild(TreePath.EMPTY, 0, new TestElement(model, "0 - new", new TestElement[0])); //$NON-NLS-1$ - + // Insert delta should generate updates only for the new element TreePath path = model.findElement("0 - new"); //$NON-NLS-1$ // Note: redundant label updates on insert. - fListener.reset(path, (TestElement)path.getLastSegment(), 0, false, false); + fListener.reset(path, (TestElement)path.getLastSegment(), 0, false, false); fListener.addChildreUpdate(TreePath.EMPTY, 0); model.postDelta(delta); while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | ALL_UPDATES_COMPLETE)) { @@ -351,7 +354,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi Thread.sleep(0); } } - + // Validate data model.validateData(fViewer, TreePath.EMPTY, true); assertTrue(getInternalViewer().getExpandedState(model.findElement("1")) == true); //$NON-NLS-1$ @@ -371,9 +374,9 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi TestModel model = alternatingSubsreesModel(6); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -385,7 +388,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi model.validateData(fViewer, TreePath.EMPTY, true); expandAlternateElements(fListener, model, true); - + // Set a selection in view // Set a selection in view TreeSelection originalSelection = new TreeSelection( @@ -395,16 +398,16 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Update the model model.removeElementChild(TreePath.EMPTY, 0); - + // Note: Re-expanding nodes causes redundant updates. fListener.reset(false, false); fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE); - - // Create the delta which has nodes with CONTENT flag set at multiple levels. + + // Create the delta which has nodes with CONTENT flag set at multiple levels. ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.CONTENT); ModelDelta elementDelta = model.getElementDelta(rootDelta, model.findElement("3.1.1"), true); //$NON-NLS-1$ elementDelta.setFlags(IModelDelta.CONTENT); - + // Post the multi-content update delta model.postDelta(rootDelta); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE)) { @@ -423,8 +426,8 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$ assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); - - // Note: in past it was observed sub-optimal coalescing in this test due + + // Note: in past it was observed sub-optimal coalescing in this test due // to scattered update requests from viewer. assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 5) ); } @@ -436,9 +439,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Expand all fViewer.setAutoExpandLevel(-1); - - // Create the listener, - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + + // Create the listener, + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -451,14 +454,14 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Turn off auto-expansion fViewer.setAutoExpandLevel(0); - + // Set a selection in view TreeSelection originalSelection = new TreeSelection(model.findElement("3.3.1")); //$NON-NLS-1$ fViewer.setSelection(originalSelection); // Update the model model.addElementChild(model.findElement("3"), null, 0, new TestElement(model, "3.0 - new", new TestElement[0])); //$NON-NLS-1$ //$NON-NLS-2$ - + // Create the delta for element "3" with content update. TreePath elementPath = model.findElement("3"); //$NON-NLS-1$ ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE); @@ -468,7 +471,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Note: Re-expanding nodes causes redundant updates. fListener.reset(false, false); fListener.addUpdates(getInternalViewer(), elementPath, model.getElement(elementPath), -1, ALL_UPDATES_COMPLETE); - + // Post the sub-tree update model.postDelta(rootDelta); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE)) { @@ -493,9 +496,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle TestModel model = alternatingSubsreesModel(6); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -507,7 +510,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle model.validateData(fViewer, TreePath.EMPTY, true); expandAlternateElements(fListener, model, true); - + // Set a selection in view // TreeSelection originalSelection = new TreeSelection( // new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findElement("6") }); @@ -515,15 +518,15 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle fViewer.setSelection(originalSelection); assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); - // Run this test ten times as we've seen intermittent failures related + // Run this test ten times as we've seen intermittent failures related // to timing in it. for (int i = 0; i < 10; i++) { // Update the model model.removeElementChild(TreePath.EMPTY, 0); - + // Note: Re-expanding nodes causes redundant updates. fListener.reset(false, false); - fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE); + fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -541,13 +544,13 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$ assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); - + // Update the model again model.addElementChild(TreePath.EMPTY, null, 0, new TestElement(model, "1", new TestElement[0])); //$NON-NLS-1$ - + // Note: Re-expanding nodes causes redundant updates. fListener.reset(false, false); - fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE); + fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -573,7 +576,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle TestModel model = alternatingSubsreesModel(100); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level fListener.reset(); @@ -589,7 +592,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } expandAlternateElements(fListener, model, false); - + // Set a selection in view TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1")); //$NON-NLS-1$ fViewer.setSelection(originalSelection); @@ -597,7 +600,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Update the model model.removeElementChild(TreePath.EMPTY, 0); - + // Note: Re-expanding nodes causes redundant updates. fListener.reset(false, false); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); @@ -616,10 +619,10 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$ assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); - + // Update the model again model.addElementChild(TreePath.EMPTY, null, 0, new TestElement(model, "1", new TestElement[0])); //$NON-NLS-1$ - + // Note: Re-expanding nodes causes redundant updates. fListener.reset(false, false); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); @@ -639,9 +642,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); } - + /** - * This test verifies that if the model selects a new element + * This test verifies that if the model selects a new element * following a content refresh, the state restore logic will * not override the selection requested by the model. */ @@ -651,9 +654,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Expand all fViewer.setAutoExpandLevel(-1); - + // Create the listener. - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -669,7 +672,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Reset the listener (ignore redundant updates) fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); - + // Refresh content. // Note: Wait only for the processing of the delta, not for all updates model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); @@ -690,7 +693,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle Thread.sleep(0); } } - + // Wait for all the updates to complete (note: we're not resetting the listener. model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE)) { @@ -709,9 +712,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Expand all fViewer.setAutoExpandLevel(-1); - + // Create the listener. - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -724,10 +727,10 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Turn off auto-expand fViewer.setAutoExpandLevel(0); - + // Reset the listener (ignore redundant updates) fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); - + // Refresh content. // Note: Wait only for the processing of the delta, not for all updates model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); @@ -739,8 +742,8 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Update the viewer to collapse an element ModelDelta collapseDelta = model.makeElementDelta(model.findElement("3.1"), IModelDelta.COLLAPSE); //$NON-NLS-1$ - - // Remove updates for the collapsed element from listener, because they + + // Remove updates for the collapsed element from listener, because they // will never happen if the element remains collapsed. fListener.resetModelChanged(); fListener.removeLabelUpdate(model.findElement("3.1.1")); //$NON-NLS-1$ @@ -761,7 +764,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle Thread.sleep(0); } } - + // Wait for all the updates to complete (note: we're not resetting the listener. model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE)) { @@ -779,9 +782,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle TestModel model = TestModel.simpleMultiLevel(); // Note: Do not auto-expand! - + // Create the listener. - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -794,7 +797,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Reset the listener (ignore redundant updates) fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false); - + // Refresh content. // Note: Wait only for the processing of the delta, not for all updates model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); @@ -806,7 +809,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Update the viewer to expand an element ModelDelta expandDelta = model.makeElementDelta(model.findElement("3.1"), IModelDelta.EXPAND); //$NON-NLS-1$ - + // Wait for the second model delta to process fListener.resetModelChanged(); model.postDelta(expandDelta); @@ -815,7 +818,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle Thread.sleep(0); } } - + // Wait for all the updates to complete (note: we're not resetting the listener. model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE)) { @@ -828,15 +831,15 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$ } - + public void testSaveAndRestore1() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -852,7 +855,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Set a selection in view fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("5.1"), model.findElement("5.1.1"), model.findElement("6.1.1") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + // Extract the original state from viewer ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE); fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT); @@ -866,9 +869,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle Thread.sleep(0); } } - + // Set the viewer input back to the model. When view updates are complete - // the viewer + // the viewer // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false); // TODO: add state updates somehow? @@ -887,16 +890,16 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle fail("Expected:\n" + originalState.toString() + "\nGot:\n" + restoredState); //$NON-NLS-1$ //$NON-NLS-2$ } } - + public void testSaveAndRestore2() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); // expand all elements fViewer.setAutoExpandLevel(-1); - + // Create the listener, only check the first level - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -910,7 +913,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Set a selection in view fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("3.2"), model.findElement("3.2.1"), model.findElement("2") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ fViewer.setSelection(new TreeSelection(model.findElement("3.2.3"))); //$NON-NLS-1$ - + // Turn off the auto-expand now since we want to text the auto-expand logic fViewer.setAutoExpandLevel(-1); @@ -930,7 +933,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } // Set the viewer input back to the model. When view updates are complete - // the viewer + // the viewer // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false); // TODO: add state updates somehow? @@ -955,9 +958,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle TestModel model = alternatingSubsreesModel(6); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -973,15 +976,15 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Set a selection in view fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("5.1"), model.findElement("5.1.1"), model.findElement("6.1.1") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + // Extract the original state from viewer ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE); fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT); // Do not reset to null, just reset input to the same object. - + // Set the viewer input back to the model. When view updates are complete - // the viewer + // the viewer // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false); fViewer.setInput(model.getRootElement()); @@ -1005,9 +1008,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle TestModel model = alternatingSubsreesModel(6); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level - fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -1023,20 +1026,20 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Set a selection in view fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("5.1"), model.findElement("5.1.1"), model.findElement("6.1.1") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + // Extract the original state from viewer ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE); fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT); - // Create a copy of the input object and set it to model. + // Create a copy of the input object and set it to model. TestElement newRoot = new TestElement(model, model.getRootElement().getID(), model.getRootElement().getChildren()); model.setRoot(newRoot); - + // Set the viewer input back to the model. When view updates are complete - // the viewer + // the viewer // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false); - + fViewer.setInput(model.getRootElement()); while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { @@ -1053,13 +1056,13 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } - + public void testSaveAndRestoreLarge() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(100); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level fListener.reset(); @@ -1072,7 +1075,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } expandAlternateElements(fListener, model, false); - + // Set a selection in view TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1")); //$NON-NLS-1$ fViewer.setSelection(originalSelection); @@ -1094,7 +1097,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } // Set the viewer input back to the model. When view updates are complete - // the viewer + // the viewer // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(); fViewer.setInput(model.getRootElement()); @@ -1118,16 +1121,16 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } /** - * This test saves state of a large tree. Then the tree is modified + * This test saves state of a large tree. Then the tree is modified * to contain much fewer elements. The restore logic should discard the - * rest of the saved state delta once all the elements are visible. + * rest of the saved state delta once all the elements are visible. */ public void testSaveAndRestorePartialStateLarge() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(100); // NOTE: WE ARE NOT EXPANDING ANY CHILDREN - + // Create the listener, only check the first level fListener.reset(); @@ -1140,7 +1143,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } expandAlternateElements(fListener, model, false); - + // Set a selection in view TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1")); //$NON-NLS-1$ fViewer.setSelection(originalSelection); @@ -1161,19 +1164,19 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } - + TestElement[] elements = model.getRootElement().getChildren(); TestElement[] newElements = new TestElement[10]; System.arraycopy(elements, 0, newElements, 0, newElements.length); model.setElementChildren(TreePath.EMPTY, newElements); - + // Set the viewer input back to the model. When view updates are complete - // the viewer + // the viewer // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(); fViewer.setInput(model.getRootElement()); - - // MONITOR FOR THE STATE RESTORE TO COMPLETE + + // MONITOR FOR THE STATE RESTORE TO COMPLETE while (!fListener.isFinished(CONTENT_SEQUENCE_COMPLETE| STATE_RESTORE_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); @@ -1192,16 +1195,16 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); } - + public void testPreserveCollapseAndSelectDeltaAfterSaveAndRestore() throws InterruptedException { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); // Expand all fViewer.setAutoExpandLevel(-1); - + // Create the listener. - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -1216,7 +1219,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Turn off auto-expand fViewer.setAutoExpandLevel(0); - + // Set the viewer input to null. This will trigger the view to save the viewer state. fListener.reset(false, false); fViewer.setInput(null); @@ -1225,9 +1228,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle Thread.sleep(0); } } - + // Set the viewer input back to the model. When view updates are complete - // the viewer + // the viewer // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false); fViewer.setInput(model.getRootElement()); @@ -1237,14 +1240,14 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle fListener.addUpdates(null, path, (TestElement)path.getLastSegment(), 0, STATE_UPDATES); // Wait till we restore state of elements we want to collapse and select - // Bug 372619 - Need to wait until proxy installed delta is processed before + // Bug 372619 - Need to wait until proxy installed delta is processed before // posting the next delta. while (!fListener.isFinished(STATE_RESTORE_STARTED | STATE_UPDATES | CHILDREN_UPDATES | MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + // Post first collapse delta fListener.resetModelChanged(); model.postDelta(model.makeElementDelta(model.findElement("2"), IModelDelta.COLLAPSE)); //$NON-NLS-1$ @@ -1295,9 +1298,9 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Expand all fViewer.setAutoExpandLevel(-1); - + // Create the listener. - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -1307,10 +1310,10 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } model.validateData(fViewer, TreePath.EMPTY, true); - + // a new similar model TestModel copyModel = TestModel.simpleMultiLevel(); - + // Trigger save - restore sequence. fListener.reset(); fListener.expectRestoreAfterSaveComplete(); @@ -1321,7 +1324,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } assertTrue("RESTORE started before SAVE to complete", fListener.isFinished(STATE_SAVE_COMPLETE)); //$NON-NLS-1$ - } + } /** * This test tries to restore a viewer state while input == null. @@ -1332,7 +1335,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -1345,19 +1348,19 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle ModelDelta expandedState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE); fViewer.saveElementState(TreePath.EMPTY, expandedState, IModelDelta.EXPAND); - + // Refresh the viewer so that updates are generated. fListener.reset(); fListener.addChildreCountUpdate(TreePath.EMPTY); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + fViewer.setInput(null); fViewer.updateViewer(expandedState); @@ -1366,6 +1369,6 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle Thread.sleep(0); } } - + } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java index fd46141f7..47e03d33c 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation * IBM Corporation - bug fixing @@ -45,14 +45,14 @@ import org.eclipse.swt.widgets.Display; import org.junit.Assert; /** - * Test model for the use in unit tests. This test model contains a set of - * elements in a tree structure. It contains utility methods for modifying the + * Test model for the use in unit tests. This test model contains a set of + * elements in a tree structure. It contains utility methods for modifying the * model and for verifying that the viewer content matches the model. - * + * * @since 3.6 */ public class TestModel implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory2 , IElementMementoProvider, IModelSelectionPolicyFactory { - + public static class TestElement extends PlatformObject { private final TestModel fModel; private final String fID; @@ -61,7 +61,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider boolean fExpanded; boolean fChecked; boolean fGrayed; - + public TestElement(TestModel model, String text, TestElement[] children) { this (model, text, false, false, children); } @@ -73,42 +73,43 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider fChecked = checked; fGrayed = grayed; } - + public TestModel getModel() { return fModel; } - - public Object getAdapter(Class adapter) { + + @Override + public Object getAdapter(Class adapter) { if (adapter.isInstance(fModel)) { return fModel; } return null; } - + public String getID() { return fID; } - + public void setLabelAppendix(String appendix) { fLabelAppendix = appendix; } - + public String getLabel() { return fID + fLabelAppendix; } - + public TestElement[] getChildren() { return fChildren; } - + public boolean isExpanded() { return fExpanded; } - + public boolean getGrayed() { return fGrayed; } - + public boolean getChecked() { return fChecked; } @@ -117,32 +118,36 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider fChecked = checked; fGrayed = grayed; } - - public boolean equals(Object obj) { + + @Override + public boolean equals(Object obj) { return obj instanceof TestElement && fID.equals(((TestElement)obj).fID); } - - public int hashCode() { + + @Override + public int hashCode() { return fID.hashCode(); } - - public String toString() { + + @Override + public String toString() { return getLabel(); } - + public int indexOf(TestElement child) { return Arrays.asList(fChildren).indexOf(child); } } private class ModelProxy extends AbstractModelProxy { - public void installed(Viewer viewer) { + @Override + public void installed(Viewer viewer) { super.installed(viewer); ModelDelta rootDelta = TestModel.this.getBaseDelta(new ModelDelta(fInput, IModelDelta.NO_CHANGE)); installSubModelProxies(fRootPath, rootDelta); fireModelChanged(rootDelta); } - + private void installSubModelProxies(TreePath path, ModelDelta delta) { TestElement element = getElement(path); if (element.fModel != TestModel.this) { @@ -150,7 +155,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider delta.setFlags(delta.getFlags() | IModelDelta.INSTALL); } else { TestElement[] children = element.getChildren(); - + for (int i = 0; i < children.length; i++) { installSubModelProxies(path.createChildPath(children[i]), delta.addNode(children[i], IModelDelta.NO_CHANGE)); } @@ -165,25 +170,26 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider private IModelSelectionPolicy fModelSelectionPolicy; private boolean fQueueingUpdates = false; private boolean fDelayUpdates = false; - private List fQueuedUpdates = new LinkedList(); - + private List<IViewerUpdate> fQueuedUpdates = new LinkedList<IViewerUpdate>(); + /** - * Constructor private. Use static factory methods instead. + * Constructor private. Use static factory methods instead. */ public TestModel() {} - + public TestElement getRootElement() { return fRoot; } - + public void setSelectionPolicy(IModelSelectionPolicy modelSelectionPolicy) { fModelSelectionPolicy = modelSelectionPolicy; } - - public IModelSelectionPolicy createModelSelectionPolicyAdapter(Object element, IPresentationContext context) { + + @Override + public IModelSelectionPolicy createModelSelectionPolicyAdapter(Object element, IPresentationContext context) { return fModelSelectionPolicy; } - + public ModelDelta getBaseDelta(ModelDelta rootDelta) { ModelDelta delta = rootDelta; for (int i = 0; i < fRootPath.getSegmentCount(); i++) { @@ -200,9 +206,9 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider public int getModelDepth() { return getDepth(getRootElement(), 0); } - + private int getDepth(TestElement element, int atDepth) { - TestElement[] children = element.getChildren(); + TestElement[] children = element.getChildren(); if (children.length == 0) { return atDepth; } @@ -213,7 +219,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider return depth; } - + public void setQeueueingUpdate(boolean queueingUpdates) { fQueueingUpdates = queueingUpdates; if (!fQueueingUpdates) { @@ -225,18 +231,18 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider fDelayUpdates = delayUpdates; } - public List getQueuedUpdates() { + public List<IViewerUpdate> getQueuedUpdates() { return fQueuedUpdates; } - + public void processQueuedUpdates() { - List updates = new ArrayList(fQueuedUpdates); + List<IViewerUpdate> updates = new ArrayList<IViewerUpdate>(fQueuedUpdates); fQueuedUpdates.clear(); for (int i = 0; i < updates.size(); i++) { - processUpdate((IViewerUpdate)updates.get(i)); + processUpdate(updates.get(i)); } } - + public void processUpdate(IViewerUpdate update) { if (update instanceof IHasChildrenUpdate) { doHasChildrenUpdate((IHasChildrenUpdate)update); @@ -256,24 +262,26 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider private void processUpdates(IViewerUpdate[] updates) { for (int i = 0; i < updates.length; i++) { processUpdate(updates[i]); - } + } } - + private void doUpdate(final IViewerUpdate[] updates) { if (fQueueingUpdates) { fQueuedUpdates.addAll(Arrays.asList(updates)); } else if (fDelayUpdates) { Display.getDefault().asyncExec(new Runnable() { - public void run() { + @Override + public void run() { processUpdates(updates); } }); } else { processUpdates(updates); - } + } } - - public void update(IHasChildrenUpdate[] updates) { + + @Override + public void update(IHasChildrenUpdate[] updates) { doUpdate(updates); } @@ -282,9 +290,10 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider update.setHasChilren(element.getChildren().length > 0); update.done(); } - - - public void update(IChildrenCountUpdate[] updates) { + + + @Override + public void update(IChildrenCountUpdate[] updates) { doUpdate(updates); } @@ -293,8 +302,9 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider update.setChildCount(element.getChildren().length); update.done(); } - - public void update(IChildrenUpdate[] updates) { + + @Override + public void update(IChildrenUpdate[] updates) { doUpdate(updates); } @@ -308,25 +318,27 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider } update.done(); } - - public void update(ILabelUpdate[] updates) { + + @Override + public void update(ILabelUpdate[] updates) { doUpdate(updates); } private void doLabelUpdate(ILabelUpdate update) { TestElement element = (TestElement)update.getElement(); update.setLabel(element.getLabel(), 0); - if (update instanceof ICheckUpdate && - Boolean.TRUE.equals(update.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK))) + if (update instanceof ICheckUpdate && + Boolean.TRUE.equals(update.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK))) { ((ICheckUpdate)update).setChecked(element.getChecked(), element.getGrayed()); } update.done(); } - + public final static String ELEMENT_MEMENTO_ID = "id"; //$NON-NLS-1$ - - public void compareElements(final IElementCompareRequest[] updates) { + + @Override + public void compareElements(final IElementCompareRequest[] updates) { doUpdate(updates); } @@ -336,17 +348,18 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider update.setEqual( elementID.equals(mementoID) ); update.done(); } - - public void encodeElements(IElementMementoRequest[] updates) { + + @Override + public void encodeElements(IElementMementoRequest[] updates) { doUpdate(updates); } - + private void doEncodeElements(IElementMementoRequest update) { String elementID = ((TestElement)update.getElement()).getID(); update.getMemento().putString(ELEMENT_MEMENTO_ID, elementID); - update.done(); + update.done(); } - + /** * @param context the context * @param viewerInput the input @@ -354,22 +367,23 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider * @param checked the checked state */ public void elementChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked) { - TestElement element = getElement(path); + TestElement element = getElement(path); Assert.assertFalse(element.getGrayed()); element.setChecked(checked, false); } - - public IModelProxy createTreeModelProxy(Object input, TreePath path, IPresentationContext context) { + + @Override + public IModelProxy createTreeModelProxy(Object input, TreePath path, IPresentationContext context) { fModelProxy = new ModelProxy(); fInput = input; fRootPath = path; return fModelProxy; } - + public IModelProxy getModelProxy() { return fModelProxy; } - + public TestElement getElement(TreePath path) { if (path.getSegmentCount() == 0) { return getRootElement(); @@ -381,7 +395,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider public void setAllExpanded() { doSetExpanded(fRoot); } - + private void doSetExpanded(TestElement element) { element.fExpanded = true; for (int i = 0; i < element.fChildren.length; i++) { @@ -392,7 +406,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider public void setAllAppendix(String appendix) { doSetAllAppendix(fRoot, appendix); } - + private void doSetAllAppendix(TestElement element, String appendix) { element.setLabelAppendix(appendix); for (int i = 0; i < element.fChildren.length; i++) { @@ -403,11 +417,11 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider public void validateData(ITreeModelViewer viewer, TreePath path) { validateData(viewer, path, false); } - + public void validateData(ITreeModelViewer _viewer, TreePath path, boolean expandedElementsOnly) { validateData(_viewer, path, expandedElementsOnly, TestModelUpdatesListener.EMPTY_FILTER_ARRAY); } - + public void validateData(ITreeModelViewer _viewer, TreePath path, boolean expandedElementsOnly, ViewerFilter[] filters) { IInternalTreeModelViewer viewer = (IInternalTreeModelViewer)_viewer; TestElement element = getElement(path); @@ -415,7 +429,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider Assert.assertTrue(element.getChecked() == viewer.getElementChecked(path)); Assert.assertTrue(element.getGrayed() == viewer.getElementGrayed(path)); } - + if (!expandedElementsOnly || path.getSegmentCount() == 0 || viewer.getExpandedState(path) ) { TestElement[] children = element.getChildren(); @@ -428,7 +442,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider validateData(viewer, path.createChildPath(children[i]), expandedElementsOnly, filters); viewerIndex++; } - Assert.assertEquals(viewerIndex, viewer.getChildCount(path)); + Assert.assertEquals(viewerIndex, viewer.getChildCount(path)); } else if (!viewer.getExpandedState(path)) { // If element not expanded, verify the plus sign. Assert.assertTrue(viewer.getHasChildren(path) == element.getChildren().length > 0); @@ -438,20 +452,20 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider public void setRoot(TestElement root) { fRoot = root; } - + public void postDelta(IModelDelta delta) { fModelProxy.fireModelChanged(delta); } - + /** Create or retrieve delta for given path * @param combine if then new deltas for the given path are created. If false existing ones are reused. */ public ModelDelta getElementDelta(ModelDelta baseDelta, TreePath path, boolean combine) { TestElement element = getRootElement(); ModelDelta delta = baseDelta; - + for (int i = 0; i < path.getSegmentCount(); i++) { - TestElement[] children = element.getChildren(); + TestElement[] children = element.getChildren(); delta.setChildCount(children.length); Object segment = path.getSegment(i); int j; @@ -474,9 +488,9 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider } } return delta; - + } - + private TreePath getRelativePath(TreePath path) { Object[] segments = new Object[path.getSegmentCount() - fRootPath.getSegmentCount()]; for (int i = fRootPath.getSegmentCount(), _i = 0; i < path.getSegmentCount(); i++, _i++) { @@ -484,7 +498,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider } return new TreePath(segments); } - + public ModelDelta appendElementLabel(TreePath path, String labelAppendix) { org.junit.Assert.assertTrue(path.startsWith(fRootPath, null)); ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); @@ -520,31 +534,31 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider // Find the parent element and generate the delta node for it. TestElement element = getElement(relativePath); ModelDelta delta = getElementDelta(baseDelta, relativePath, false); - + // Set the new children array element.fChildren = children; - - // Add the delta flag and update the child count in the parent delta. + + // Add the delta flag and update the child count in the parent delta. delta.setFlags(delta.getFlags() | IModelDelta.CONTENT); delta.setChildCount(children.length); - + return rootDelta; } - + public ModelDelta replaceElementChild(TreePath parentPath, int index, TestElement child) { ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); ModelDelta baseDelta = getBaseDelta(rootDelta); TreePath relativePath = getRelativePath(parentPath); - + TestElement element = getElement(relativePath); ModelDelta delta= getElementDelta(baseDelta, relativePath, false); - TestElement oldChild = element.fChildren[index]; + TestElement oldChild = element.fChildren[index]; element.fChildren[index] = child; delta.addNode(oldChild, child, IModelDelta.REPLACED); // TODO: set replacement index!?! - + return rootDelta; - } + } public ModelDelta addElementChild(TreePath parentPath, ModelDelta rootDelta, int index, TestElement newChild) { if (rootDelta == null) { @@ -559,17 +573,17 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider // Add the new element element.fChildren = doInsertElementInArray(element.fChildren, index, newChild); - + // Add the delta flag and update the child count in the parent delta. delta.setChildCount(element.getChildren().length); delta.addNode(newChild, index, IModelDelta.ADDED); - + return rootDelta; - } + } public ModelDelta insertElementChild(TreePath parentPath, int index, TestElement newChild) { return insertElementChild(null, parentPath, index, newChild); - } + } public ModelDelta insertElementChild(ModelDelta rootDelta, TreePath parentPath, int index, TestElement newChild) { if (rootDelta == null) { @@ -581,19 +595,19 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider // Find the parent element and generate the delta node for it. TestElement element = getElement(relativePath); ModelDelta delta= getElementDelta(baseDelta, relativePath, false); - + // Add the new element element.fChildren = doInsertElementInArray(element.fChildren, index, newChild); - + // Add the delta flag and update the child count in the parent delta. delta.setChildCount(element.getChildren().length); delta.addNode(newChild, index, IModelDelta.INSERTED); - + return rootDelta; - } - + } + private TestElement[] doInsertElementInArray(TestElement[] children, int index, TestElement newChild) { - // Create the new children array add the element to it and set it to + // Create the new children array add the element to it and set it to // the parent. TestElement[] newChildren = new TestElement[children.length + 1]; System.arraycopy(children, 0, newChildren, 0, index); @@ -601,7 +615,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider System.arraycopy(children, index, newChildren, index + 1, children.length - index); return newChildren; } - + public ModelDelta removeElementChild(TreePath parentPath, int index) { ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); ModelDelta baseDelta = getBaseDelta(rootDelta); @@ -609,7 +623,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider // Find the parent element and generate the delta node for it. TestElement element = getElement(parentPath); ModelDelta delta= getElementDelta(baseDelta, parentPath, false); - + // Create a new child array with the element removed TestElement[] children = element.getChildren(); TestElement childToRemove = children[index]; @@ -621,9 +635,9 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider // Add the delta flag and update the child count in the parent delta. delta.setChildCount(element.getChildren().length); delta.addNode(childToRemove, index, IModelDelta.REMOVED); - + return rootDelta; - } + } public ModelDelta makeElementDelta(TreePath path, int flags) { ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); @@ -631,10 +645,10 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider // Find the element and generate the delta node for it. ModelDelta delta= getElementDelta(baseDelta, path, false); - + delta.setFlags(flags); return rootDelta; - } + } public TreePath findElement(String label) { return findElement(TreePath.EMPTY, label); @@ -656,14 +670,15 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider } return null; } - - public String toString() { + + @Override + public String toString() { return getElementString(fRoot, ""); //$NON-NLS-1$ } - + public String getElementString(TestElement element, String indent) { StringBuffer builder = new StringBuffer(); - builder.append(indent); + builder.append(indent); builder.append(element.toString()); builder.append('\n'); TestElement[] children = element.getChildren(); @@ -672,7 +687,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider } return builder.toString(); } - + public static TestModel simpleSingleLevel() { TestModel model = new TestModel(); model.setRoot( new TestElement(model, "root", makeSingleLevelModelElements(model, 6, ""))); //$NON-NLS-1$ //$NON-NLS-2$ @@ -686,8 +701,8 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider elements[i - 1] = new TestElement(model, name, new TestElement[0]); } return elements; - } - + } + public static TestElement[] makeMultiLevelElements(TestModel model, int depth, String prefix) { TestElement[] elements = new TestElement[depth]; for (int i = 0; i < depth; i++) { @@ -695,10 +710,12 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider elements[i] = new TestElement(model, name, makeMultiLevelElements(model, i, name + ".")); //$NON-NLS-1$ } return elements; - } + } public static TestElement[] makeMultiLevelElements2(TestModel model, int[] levelCounts, String prefix) { - if (levelCounts.length == 0) return new TestElement[0]; + if (levelCounts.length == 0) { + return new TestElement[0]; + } int count = levelCounts[0]; int[] oldLevelCounts = levelCounts; levelCounts = new int[levelCounts.length - 1]; @@ -709,7 +726,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider elements[i] = new TestElement(model, name, makeMultiLevelElements2(model, levelCounts, name + ".")); //$NON-NLS-1$ } return elements; - } + } public static TestModel simpleMultiLevel() { TestModel model = new TestModel(); @@ -740,7 +757,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider }) ); return model; } - + public static TestModel compositeMultiLevel() { TestModel m2 = new TestModel(); m2.setRoot( new TestElement(m2, "m2.root", new TestElement[] { //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java index fe151710b..88ae8610a 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation * Dorin Ciuca - Top index fix (Bug 324100) @@ -43,42 +43,42 @@ import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.ViewerFilter; import org.junit.Assert; -public class TestModelUpdatesListener +public class TestModelUpdatesListener implements IViewerUpdateListener, ILabelUpdateListener, IModelChangedListener, ITestModelUpdatesListenerConstants, - IStateUpdateListener, IJobChangeListener + IStateUpdateListener, IJobChangeListener { - public static final ViewerFilter[] EMPTY_FILTER_ARRAY = new ViewerFilter[0]; - + public static final ViewerFilter[] EMPTY_FILTER_ARRAY = new ViewerFilter[0]; + private final ITreeModelViewer fViewer; - + private IStatus fJobError; - + private boolean fFailOnRedundantUpdates; private boolean fFailOnRedundantLabelUpdates; - private Set fRedundantUpdates = new HashSet(); - private Set fRedundantLabelUpdates = new HashSet(); - private Set fRedundantHasChildrenUpdateExceptions = new HashSet(); - private Set fRedundantChildCountUpdateExceptions = new HashSet(); - private Set fRedundantChildrenUpdateExceptions = new HashSet(); - private Set fRedundantLabelUpdateExceptions = new HashSet(); - + private Set<IViewerUpdate> fRedundantUpdates = new HashSet<IViewerUpdate>(); + private Set<ILabelUpdate> fRedundantLabelUpdates = new HashSet<ILabelUpdate>(); + private Set<TreePath> fRedundantHasChildrenUpdateExceptions = new HashSet<TreePath>(); + private Set<TreePath> fRedundantChildCountUpdateExceptions = new HashSet<TreePath>(); + private Set<TreePath> fRedundantChildrenUpdateExceptions = new HashSet<TreePath>(); + private Set<TreePath> fRedundantLabelUpdateExceptions = new HashSet<TreePath>(); + private boolean fFailOnMultipleModelUpdateSequences; private boolean fFailOnMultipleLabelUpdateSequences; - - private Set fHasChildrenUpdatesScheduled = new HashSet(); - private Set fHasChildrenUpdatesRunning = new HashSet(); - private Set fHasChildrenUpdatesCompleted = new HashSet(); - private Map fChildrenUpdatesScheduled = new HashMap(); - private Set fChildrenUpdatesRunning = new HashSet(); - private Set fChildrenUpdatesCompleted = new HashSet(); - private Set fChildCountUpdatesScheduled = new HashSet(); - private Set fChildCountUpdatesRunning = new HashSet(); - private Set fChildCountUpdatesCompleted = new HashSet(); - private Set fLabelUpdates = new HashSet(); - private Set fLabelUpdatesRunning = new HashSet(); - private Set fLabelUpdatesCompleted = new HashSet(); - private Set fProxyModels = new HashSet(); - private Set fStateUpdates = new HashSet(); + + private Set<TreePath> fHasChildrenUpdatesScheduled = new HashSet<TreePath>(); + private Set<IViewerUpdate> fHasChildrenUpdatesRunning = new HashSet<IViewerUpdate>(); + private Set<IViewerUpdate> fHasChildrenUpdatesCompleted = new HashSet<IViewerUpdate>(); + private Map<TreePath, Set<Integer>> fChildrenUpdatesScheduled = new HashMap<TreePath, Set<Integer>>(); + private Set<IViewerUpdate> fChildrenUpdatesRunning = new HashSet<IViewerUpdate>(); + private Set<IViewerUpdate> fChildrenUpdatesCompleted = new HashSet<IViewerUpdate>(); + private Set<TreePath> fChildCountUpdatesScheduled = new HashSet<TreePath>(); + private Set<IViewerUpdate> fChildCountUpdatesRunning = new HashSet<IViewerUpdate>(); + private Set<IViewerUpdate> fChildCountUpdatesCompleted = new HashSet<IViewerUpdate>(); + private Set<TreePath> fLabelUpdates = new HashSet<TreePath>(); + private Set<ILabelUpdate> fLabelUpdatesRunning = new HashSet<ILabelUpdate>(); + private Set<ILabelUpdate> fLabelUpdatesCompleted = new HashSet<ILabelUpdate>(); + private Set<TestModel> fProxyModels = new HashSet<TestModel>(); + private Set<TreePath> fStateUpdates = new HashSet<TreePath>(); private int fViewerUpdatesStarted = 0; private int fViewerUpdatesComplete = 0; private int fViewerUpdatesStartedAtReset; @@ -100,8 +100,8 @@ public class TestModelUpdatesListener private boolean fExpectRestoreAfterSaveComplete; private RuntimeException fFailExpectation; - - + + public TestModelUpdatesListener(ITreeModelViewer viewer, boolean failOnRedundantUpdates, boolean failOnMultipleModelUpdateSequences) { this(viewer); setFailOnRedundantUpdates(failOnRedundantUpdates); @@ -124,19 +124,33 @@ public class TestModelUpdatesListener fViewer.removeStateUpdateListener(this); fViewer.removeViewerUpdateListener(this); } - - public void aboutToRun(IJobChangeEvent event) {} - public void awake(IJobChangeEvent event) {} - public void running(IJobChangeEvent event) {} - public void scheduled(IJobChangeEvent event) {} - public void sleeping(IJobChangeEvent event) {} - public void done(IJobChangeEvent event) { - IStatus result = event.getJob().getResult(); + + @Override + public void aboutToRun(IJobChangeEvent event) {} + + @Override + public void awake(IJobChangeEvent event) { + } + + @Override + public void running(IJobChangeEvent event) { + } + + @Override + public void scheduled(IJobChangeEvent event) { + } + + @Override + public void sleeping(IJobChangeEvent event) { + } + @Override + public void done(IJobChangeEvent event) { + IStatus result = event.getJob().getResult(); if (result != null && result.getSeverity() == IStatus.ERROR) { - fJobError = result; + fJobError = result; } } - + public void setFailOnRedundantUpdates(boolean failOnRedundantUpdates) { fFailOnRedundantUpdates = failOnRedundantUpdates; } @@ -152,19 +166,19 @@ public class TestModelUpdatesListener public void setFailOnMultipleLabelUpdateSequences(boolean failOnMultipleLabelUpdateSequences) { fFailOnMultipleLabelUpdateSequences = failOnMultipleLabelUpdateSequences; } - + public void expectRestoreAfterSaveComplete() { fExpectRestoreAfterSaveComplete = true; } /** - * Sets the the maximum amount of time (in milliseconds) that the update listener - * is going to wait. If set to -1, the listener will wait indefinitely. + * Sets the the maximum amount of time (in milliseconds) that the update listener + * is going to wait. If set to -1, the listener will wait indefinitely. */ public void setTimeoutInterval(int milis) { fTimeoutInterval = milis; } - + public void reset(TreePath path, TestElement element, int levels, boolean failOnRedundantUpdates, boolean failOnMultipleUpdateSequences) { reset(path, element, EMPTY_FILTER_ARRAY, levels, failOnRedundantUpdates, failOnMultipleUpdateSequences); } @@ -220,11 +234,11 @@ public class TestModelUpdatesListener fTimeoutTime = System.currentTimeMillis() + fTimeoutInterval; resetModelChanged(); } - + public void resetModelChanged() { fModelChangedComplete = false; } - + public void addHasChildrenUpdate(TreePath path) { fHasChildrenUpdatesScheduled.add(path); } @@ -242,16 +256,16 @@ public class TestModelUpdatesListener } public void addChildreUpdate(TreePath path, int index) { - Set childrenIndexes = (Set)fChildrenUpdatesScheduled.get(path); + Set<Integer> childrenIndexes = fChildrenUpdatesScheduled.get(path); if (childrenIndexes == null) { - childrenIndexes = new TreeSet(); + childrenIndexes = new TreeSet<Integer>(); fChildrenUpdatesScheduled.put(path, childrenIndexes); } childrenIndexes.add(new Integer(index)); } public void removeChildrenUpdate(TreePath path, int index) { - Set childrenIndexes = (Set)fChildrenUpdatesScheduled.get(path); + Set<?> childrenIndexes = fChildrenUpdatesScheduled.get(path); if (childrenIndexes != null) { childrenIndexes.remove(new Integer(index)); if (childrenIndexes.isEmpty()) { @@ -271,7 +285,7 @@ public class TestModelUpdatesListener public void addUpdates(TreePath path, TestElement element, int levels) { addUpdates(null, path, element, EMPTY_FILTER_ARRAY, levels, ALL_UPDATES_COMPLETE ); } - + public void addUpdates(TreePath path, TestElement element, ViewerFilter[] filters, int levels) { addUpdates(null, path, element, filters, levels, ALL_UPDATES_COMPLETE ); } @@ -279,7 +293,7 @@ public class TestModelUpdatesListener public void addStateUpdates(IInternalTreeModelViewer viewer, TreePath path, TestElement element) { addUpdates(viewer, path, element, -1, STATE_UPDATES); } - + public void addStateUpdates(IInternalTreeModelViewer viewer, IModelDelta pendingDelta, int deltaFlags) { TreePath treePath = getViewerTreePath(pendingDelta); if ( !TreePath.EMPTY.equals(treePath) && (pendingDelta.getFlags() & deltaFlags) != 0 ) { @@ -288,9 +302,9 @@ public class TestModelUpdatesListener IModelDelta[] childDeltas = pendingDelta.getChildDeltas(); for (int i = 0; i < childDeltas.length; i++) { addStateUpdates(viewer, childDeltas[i], deltaFlags); - } + } } - + public void addRedundantExceptionHasChildren(TreePath path) { fRedundantHasChildrenUpdateExceptions.add(path); } @@ -306,43 +320,43 @@ public class TestModelUpdatesListener public void addRedundantExceptionLabel(TreePath path) { fRedundantLabelUpdateExceptions.add(path); } - + public boolean checkCoalesced(TreePath path, int offset, int length) { - for (Iterator itr = fChildrenUpdatesCompleted.iterator(); itr.hasNext();) { + for (Iterator<IViewerUpdate> itr = fChildrenUpdatesCompleted.iterator(); itr.hasNext();) { IChildrenUpdate update = (IChildrenUpdate)itr.next(); if (path.equals( update.getElementPath() ) && offset == update.getOffset() && - length == update.getLength()) + length == update.getLength()) { return true; } } return false; } - - - public Set getHasChildrenUpdatesCompleted() { + + + public Set<IViewerUpdate> getHasChildrenUpdatesCompleted() { return fHasChildrenUpdatesCompleted; } - - public Set getChildCountUpdatesCompleted() { + + public Set<IViewerUpdate> getChildCountUpdatesCompleted() { return fChildCountUpdatesCompleted; } - - public Set getChildrenUpdatesCompleted() { + + public Set<IViewerUpdate> getChildrenUpdatesCompleted() { return fChildrenUpdatesCompleted; } - + /** * Returns a tree path for the node, *not* including the root element. - * + * * @param node * model delta * @return corresponding tree path */ private TreePath getViewerTreePath(IModelDelta node) { - ArrayList list = new ArrayList(); + ArrayList<Object> list = new ArrayList<Object>(); IModelDelta parentDelta = node.getParentDelta(); while (parentDelta != null) { list.add(0, node.getElement()); @@ -359,7 +373,7 @@ public class TestModelUpdatesListener public void addUpdates(IInternalTreeModelViewer viewer, TreePath path, TestElement element, int levels, int flags) { addUpdates(viewer, path, element, EMPTY_FILTER_ARRAY, levels, flags); } - + public static boolean isFiltered(Object element, ViewerFilter[] filters) { for (int i = 0; i < filters.length; i++) { if (!filters[i].select(null, null, element)) { @@ -368,12 +382,12 @@ public class TestModelUpdatesListener } return false; } - + public void addUpdates(IInternalTreeModelViewer viewer, TreePath path, TestElement element, ViewerFilter[] filters, int levels, int flags) { if (isFiltered(path.getLastSegment(), filters)) { return; } - + if (!path.equals(TreePath.EMPTY)) { if ((flags & LABEL_UPDATES) != 0) { fLabelUpdates.add(path); @@ -381,7 +395,7 @@ public class TestModelUpdatesListener if ((flags & HAS_CHILDREN_UPDATES) != 0) { fHasChildrenUpdatesScheduled.add(path); } - + if ((flags & STATE_UPDATES) != 0) { fStateUpdates.add(path); } @@ -394,7 +408,7 @@ public class TestModelUpdatesListener fChildCountUpdatesScheduled.add(path); } if ((flags & CHILDREN_UPDATES) != 0) { - Set childrenIndexes = new HashSet(); + Set<Integer> childrenIndexes = new HashSet<Integer>(); for (int i = 0; i < children.length; i++) { if (!isFiltered(children[i], filters)) { childrenIndexes.add(new Integer(i)); @@ -407,7 +421,7 @@ public class TestModelUpdatesListener addUpdates(viewer, path.createChildPath(children[i]), children[i], filters, levels, flags); } } - + } } @@ -421,24 +435,24 @@ public class TestModelUpdatesListener addProxies(children[i]); } } - + public boolean isFinished() { return isFinished(ALL_UPDATES_COMPLETE); } - + public boolean isTimedOut() { return fTimeoutInterval > 0 && fTimeoutTime < System.currentTimeMillis(); } - + public boolean isFinished(int flags) { if (isTimedOut()) { throw new RuntimeException("Timed Out: " + toString(flags)); //$NON-NLS-1$ } - + if (fFailExpectation != null) { throw fFailExpectation; } - + if (fJobError != null) { throw new RuntimeException("Job Error: " + fJobError); //$NON-NLS-1$ } @@ -448,7 +462,7 @@ public class TestModelUpdatesListener } if (fFailOnRedundantLabelUpdates && !fRedundantLabelUpdates.isEmpty()) { Assert.fail("Redundant Label Updates: " + fRedundantLabelUpdates.toString()); //$NON-NLS-1$ - } + } if (fFailOnMultipleLabelUpdateSequences && fLabelUpdatesComplete > (fLabelUpdatesCompleteAtReset + 1)) { Assert.fail("Multiple label update sequences detected"); //$NON-NLS-1$ } @@ -458,57 +472,91 @@ public class TestModelUpdatesListener if ( (flags & LABEL_SEQUENCE_COMPLETE) != 0) { if (fLabelUpdatesComplete == fLabelUpdatesCompleteAtReset || - fLabelUpdatesComplete != fLabelUpdatesStarted) return false; + fLabelUpdatesComplete != fLabelUpdatesStarted) { + return false; + } } if ( (flags & LABEL_SEQUENCE_STARTED) != 0) { - if (fLabelUpdatesStarted == fLabelUpdatesStartedAtReset) return false; + if (fLabelUpdatesStarted == fLabelUpdatesStartedAtReset) { + return false; + } } if ( (flags & LABEL_UPDATES) != 0) { - if (!fLabelUpdates.isEmpty()) return false; + if (!fLabelUpdates.isEmpty()) { + return false; + } } if ( (flags & CONTENT_SEQUENCE_STARTED) != 0) { - if (fViewerUpdatesStarted == fViewerUpdatesStartedAtReset) return false; + if (fViewerUpdatesStarted == fViewerUpdatesStartedAtReset) { + return false; + } } if ( (flags & CONTENT_SEQUENCE_COMPLETE) != 0) { - if (fViewerUpdatesComplete == fViewerUpdatesCompleteAtReset || - fViewerUpdatesStarted != fViewerUpdatesComplete) return false; + if (fViewerUpdatesComplete == fViewerUpdatesCompleteAtReset || + fViewerUpdatesStarted != fViewerUpdatesComplete) { + return false; + } } if ( (flags & HAS_CHILDREN_UPDATES_STARTED) != 0) { - if (fHasChildrenUpdatesRunning.isEmpty() && fHasChildrenUpdatesCompleted.isEmpty()) return false; + if (fHasChildrenUpdatesRunning.isEmpty() && fHasChildrenUpdatesCompleted.isEmpty()) { + return false; + } } if ( (flags & HAS_CHILDREN_UPDATES) != 0) { - if (!fHasChildrenUpdatesScheduled.isEmpty()) return false; + if (!fHasChildrenUpdatesScheduled.isEmpty()) { + return false; + } } if ( (flags & CHILD_COUNT_UPDATES_STARTED) != 0) { - if (fChildCountUpdatesRunning.isEmpty() && fChildCountUpdatesCompleted.isEmpty()) return false; + if (fChildCountUpdatesRunning.isEmpty() && fChildCountUpdatesCompleted.isEmpty()) { + return false; + } } if ( (flags & CHILD_COUNT_UPDATES) != 0) { - if (!fChildCountUpdatesScheduled.isEmpty()) return false; + if (!fChildCountUpdatesScheduled.isEmpty()) { + return false; + } } if ( (flags & CHILDREN_UPDATES_STARTED) != 0) { // Some children updates have already been started or completed. - if (fChildrenUpdatesRunning.isEmpty() && fChildrenUpdatesCompleted.isEmpty()) return false; + if (fChildrenUpdatesRunning.isEmpty() && fChildrenUpdatesCompleted.isEmpty()) { + return false; + } } if ( (flags & CHILDREN_UPDATES_RUNNING) != 0) { - if (!isFinishedChildrenRunning()) return false; + if (!isFinishedChildrenRunning()) { + return false; + } } if ( (flags & CHILDREN_UPDATES) != 0) { - if (!fChildrenUpdatesScheduled.isEmpty()) return false; + if (!fChildrenUpdatesScheduled.isEmpty()) { + return false; + } } if ( (flags & MODEL_CHANGED_COMPLETE) != 0) { - if (!fModelChangedComplete) return false; + if (!fModelChangedComplete) { + return false; + } } if ( (flags & STATE_SAVE_COMPLETE) != 0) { - if (!fStateSaveComplete) return false; + if (!fStateSaveComplete) { + return false; + } } if ( (flags & STATE_SAVE_STARTED) != 0) { - if (!fStateSaveStarted) return false; + if (!fStateSaveStarted) { + return false; + } } if ( (flags & STATE_RESTORE_COMPLETE) != 0) { - if (!fStateRestoreComplete) return false; + if (!fStateRestoreComplete) { + return false; + } } if ( (flags & STATE_RESTORE_STARTED) != 0) { - if (!fStateRestoreStarted) return false; + if (!fStateRestoreStarted) { + return false; + } } if ( (flags & STATE_UPDATES) != 0) { if (!fStateUpdates.isEmpty()) { @@ -516,7 +564,9 @@ public class TestModelUpdatesListener } } if ( (flags & MODEL_PROXIES_INSTALLED) != 0) { - if (fProxyModels.size() != 0) return false; + if (fProxyModels.size() != 0) { + return false; + } } if ( (flags & VIEWER_UPDATES_RUNNING) != 0) { if (fViewerUpdatesCounter != 0) { @@ -528,43 +578,48 @@ public class TestModelUpdatesListener return false; } } - + return true; } /** - * Returns true if all children updates that were scheduled are either currently + * Returns true if all children updates that were scheduled are either currently * running or have already completed. - * + * * @see CHILDREN_UPDATES_RUNNING * @return */ private boolean isFinishedChildrenRunning() { // All children updates that have been scheduled are either running or completed. int scheduledCount = 0; - for (Iterator itr = fChildrenUpdatesScheduled.values().iterator(); itr.hasNext();) { - scheduledCount += ((Set)itr.next()).size(); + for (Iterator<Set<Integer>> itr = fChildrenUpdatesScheduled.values().iterator(); itr.hasNext();) { + scheduledCount += ((Set<?>) itr.next()).size(); } - + int runningCount = 0; - for (Iterator itr = fChildrenUpdatesRunning.iterator(); itr.hasNext();) { + for (Iterator<IViewerUpdate> itr = fChildrenUpdatesRunning.iterator(); itr.hasNext();) { IChildrenUpdate update = ((IChildrenUpdate)itr.next()); - Set set = (Set)fChildrenUpdatesScheduled.get( update.getElementPath() ); + Set<?> set = fChildrenUpdatesScheduled.get(update.getElementPath()); for (int i = update.getOffset(); set != null && i < update.getOffset() + update.getLength(); i++) { - if (set.contains(new Integer(i))) runningCount++; + if (set.contains(new Integer(i))) { + runningCount++; + } } } - for (Iterator itr = fChildrenUpdatesCompleted.iterator(); itr.hasNext();) { + for (Iterator<IViewerUpdate> itr = fChildrenUpdatesCompleted.iterator(); itr.hasNext();) { IChildrenUpdate update = ((IChildrenUpdate)itr.next()); - Set set = (Set)fChildrenUpdatesScheduled.get( update.getElementPath() ); + Set<?> set = fChildrenUpdatesScheduled.get(update.getElementPath()); for (int i = update.getOffset(); set != null && i < update.getOffset() + update.getLength(); i++) { - if (set.contains(new Integer(i))) runningCount++; + if (set.contains(new Integer(i))) { + runningCount++; + } } } return scheduledCount == runningCount; } - - public void updateStarted(IViewerUpdate update) { + + @Override + public void updateStarted(IViewerUpdate update) { synchronized (this) { fViewerUpdatesCounter++; if (update instanceof IHasChildrenUpdate) { @@ -573,11 +628,12 @@ public class TestModelUpdatesListener fChildCountUpdatesRunning.add(update); } else if (update instanceof IChildrenUpdate) { fChildrenUpdatesRunning.add(update); - } + } } } - - public void updateComplete(IViewerUpdate update) { + + @Override + public void updateComplete(IViewerUpdate update) { synchronized (this) { fViewerUpdatesCounter--; } @@ -586,30 +642,30 @@ public class TestModelUpdatesListener TreePath updatePath = update.getElementPath(); if (update instanceof IHasChildrenUpdate) { fHasChildrenUpdatesRunning.remove(update); - fHasChildrenUpdatesCompleted.add(update); + fHasChildrenUpdatesCompleted.add(update); if (!fHasChildrenUpdatesScheduled.remove(updatePath) && - fFailOnRedundantUpdates && - fRedundantHasChildrenUpdateExceptions.contains(updatePath)) + fFailOnRedundantUpdates && + fRedundantHasChildrenUpdateExceptions.contains(updatePath)) { fRedundantUpdates.add(update); } } if (update instanceof IChildrenCountUpdate) { fChildCountUpdatesRunning.remove(update); - fChildCountUpdatesCompleted.add(update); + fChildCountUpdatesCompleted.add(update); if (!fChildCountUpdatesScheduled.remove(updatePath) && fFailOnRedundantUpdates && - !fRedundantChildCountUpdateExceptions.contains(updatePath)) + !fRedundantChildCountUpdateExceptions.contains(updatePath)) { fRedundantUpdates.add(update); } } else if (update instanceof IChildrenUpdate) { fChildrenUpdatesRunning.remove(update); - fChildrenUpdatesCompleted.add(update); - + fChildrenUpdatesCompleted.add(update); + int start = ((IChildrenUpdate)update).getOffset(); int end = start + ((IChildrenUpdate)update).getLength(); - - Set childrenIndexes = (Set)fChildrenUpdatesScheduled.get(updatePath); + + Set<?> childrenIndexes = fChildrenUpdatesScheduled.get(updatePath); if (childrenIndexes != null) { for (int i = start; i < end; i++) { childrenIndexes.remove(new Integer(i)); @@ -620,97 +676,110 @@ public class TestModelUpdatesListener } else if (fFailOnRedundantUpdates && fRedundantChildrenUpdateExceptions.contains(updatePath)) { fRedundantUpdates.add(update); } - } + } } } - - public void viewerUpdatesBegin() { + + @Override + public void viewerUpdatesBegin() { if (fViewerUpdatesStarted > fViewerUpdatesComplete) { fFailExpectation = new RuntimeException("Unmatched updatesStarted/updateCompleted notifications observed."); //$NON-NLS-1$ } fViewerUpdatesStarted++; } - - public void viewerUpdatesComplete() { + + @Override + public void viewerUpdatesComplete() { if (fViewerUpdatesStarted <= fViewerUpdatesComplete) { fFailExpectation = new RuntimeException("Unmatched updatesStarted/updateCompleted notifications observed."); //$NON-NLS-1$ } fViewerUpdatesComplete++; } - public void labelUpdateComplete(ILabelUpdate update) { + @Override + public void labelUpdateComplete(ILabelUpdate update) { fLabelUpdatesRunning.remove(update); fLabelUpdatesCompleted.add(update); fLabelUpdatesCounter--; - if (!fLabelUpdates.remove(update.getElementPath()) && - fFailOnRedundantLabelUpdates && - !fRedundantLabelUpdateExceptions.contains(update.getElementPath())) + if (!fLabelUpdates.remove(update.getElementPath()) && + fFailOnRedundantLabelUpdates && + !fRedundantLabelUpdateExceptions.contains(update.getElementPath())) { fRedundantLabelUpdates.add(update); Assert.fail("Redundant update: " + update); //$NON-NLS-1$ } } - public void labelUpdateStarted(ILabelUpdate update) { + @Override + public void labelUpdateStarted(ILabelUpdate update) { fLabelUpdatesRunning.add(update); fLabelUpdatesCounter++; } - public void labelUpdatesBegin() { + @Override + public void labelUpdatesBegin() { if (fLabelUpdatesStarted > fLabelUpdatesComplete) { fFailExpectation = new RuntimeException("Unmatched labelUpdatesStarted/labelUpdateCompleted notifications observed."); //$NON-NLS-1$ } fLabelUpdatesStarted++; } - public void labelUpdatesComplete() { + @Override + public void labelUpdatesComplete() { if (fLabelUpdatesStarted <= fLabelUpdatesComplete) { fFailExpectation = new RuntimeException("Unmatched labelUpdatesStarted/labelUpdateCompleted notifications observed."); //$NON-NLS-1$ } fLabelUpdatesComplete++; } - - public void modelChanged(IModelDelta delta, IModelProxy proxy) { + + @Override + public void modelChanged(IModelDelta delta, IModelProxy proxy) { fModelChangedComplete = true; - for (Iterator itr = fProxyModels.iterator(); itr.hasNext();) { - TestModel model = (TestModel)itr.next(); + for (Iterator<TestModel> itr = fProxyModels.iterator(); itr.hasNext();) { + TestModel model = itr.next(); if (model.getModelProxy() == proxy) { itr.remove(); break; } } } - - public void stateRestoreUpdatesBegin(Object input) { + + @Override + public void stateRestoreUpdatesBegin(Object input) { if (fExpectRestoreAfterSaveComplete && !fStateSaveComplete) { fFailExpectation = new RuntimeException("RESTORE should begin after SAVE completed!"); //$NON-NLS-1$ } fStateRestoreStarted = true; } - - public void stateRestoreUpdatesComplete(Object input) { + + @Override + public void stateRestoreUpdatesComplete(Object input) { Assert.assertFalse("RESTORE STATE already complete!", fStateRestoreComplete); //$NON-NLS-1$ fStateRestoreComplete = true; } - - public void stateSaveUpdatesBegin(Object input) { + + @Override + public void stateSaveUpdatesBegin(Object input) { fStateSaveStarted = true; } - public void stateSaveUpdatesComplete(Object input) { + @Override + public void stateSaveUpdatesComplete(Object input) { fStateSaveComplete = true; } - - public void stateUpdateComplete(Object input, IViewerUpdate update) { + + @Override + public void stateUpdateComplete(Object input, IViewerUpdate update) { if ( !(update instanceof ElementCompareRequest) || ((ElementCompareRequest)update).isEqual()) { fStateUpdates.remove(update.getElementPath()); - } + } } - - public void stateUpdateStarted(Object input, IViewerUpdate update) { + + @Override + public void stateUpdateStarted(Object input, IViewerUpdate update) { } - + private String toString(int flags) { StringBuffer buf = new StringBuffer("Viewer Update Listener"); //$NON-NLS-1$ @@ -725,7 +794,7 @@ public class TestModelUpdatesListener } } } - + if (fFailOnRedundantUpdates) { buf.append("\n\t"); //$NON-NLS-1$ buf.append("fRedundantUpdates = " + fRedundantUpdates); //$NON-NLS-1$ @@ -832,34 +901,34 @@ public class TestModelUpdatesListener return buf.toString(); } - private String toString(Set set) { + private String toString(Set<TreePath> set) { if (set.isEmpty()) { return "(EMPTY)"; //$NON-NLS-1$ } StringBuffer buf = new StringBuffer(); - for (Iterator itr = set.iterator(); itr.hasNext(); ) { + for (Iterator<TreePath> itr = set.iterator(); itr.hasNext();) { buf.append("\n\t\t"); //$NON-NLS-1$ - buf.append(toString((TreePath)itr.next())); + buf.append(toString(itr.next())); } return buf.toString(); } - - private String toString(Map map) { + + private String toString(Map<TreePath, Set<Integer>> map) { if (map.isEmpty()) { return "(EMPTY)"; //$NON-NLS-1$ } StringBuffer buf = new StringBuffer(); - for (Iterator itr = map.keySet().iterator(); itr.hasNext(); ) { + for (Iterator<TreePath> itr = map.keySet().iterator(); itr.hasNext();) { buf.append("\n\t\t"); //$NON-NLS-1$ - TreePath path = (TreePath)itr.next(); + TreePath path = itr.next(); buf.append(toString(path)); - Set updates = (Set)map.get(path); + Set<?> updates = map.get(path); buf.append(" = "); //$NON-NLS-1$ buf.append(updates.toString()); } return buf.toString(); } - + private String toString(TreePath path) { if (path.getSegmentCount() == 0) { return "/"; //$NON-NLS-1$ @@ -871,12 +940,13 @@ public class TestModelUpdatesListener } return buf.toString(); } - - public String toString() { + + @Override + public String toString() { return toString(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE | STATE_SAVE_COMPLETE | STATE_RESTORE_COMPLETE | ALL_VIEWER_UPDATES_STARTED | LABEL_SEQUENCE_STARTED | STATE_UPDATES); } - - + + } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java index 5d70a64c4..af897a4fd 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Wind River Systems and others. + * Copyright (c) 2009, 2013 Wind River Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Wind River Systems - initial API and implementation + * IBM Corporation - bug fixing *******************************************************************************/ package org.eclipe.debug.tests.viewer.model; @@ -24,28 +25,29 @@ import org.eclipse.swt.widgets.TreeItem; import org.eclipse.swt.widgets.Widget; /** - * + * */ public class TreeModelViewerAutopopulateAgent implements IViewerUpdateListener { private TreeModelViewer fViewer; - - + + public TreeModelViewerAutopopulateAgent(TreeModelViewer viewer) { fViewer = viewer; fViewer.addViewerUpdateListener(this); } - + public void dispose() { fViewer.removeViewerUpdateListener(this); fViewer = null; } - - public void updateComplete(IViewerUpdate update) { + + @Override + public void updateComplete(IViewerUpdate update) { if (update instanceof IChildrenCountUpdate) { TreePath path = update.getElementPath(); - ILazyTreePathContentProvider contentProvider = (ILazyTreePathContentProvider) fViewer.getContentProvider(); - + ILazyTreePathContentProvider contentProvider = (ILazyTreePathContentProvider) fViewer.getContentProvider(); + Widget[] items = fViewer.testFindItems(update.getElement()); for (int i = 0; i < items.length; i++) { if ( path.equals(getTreePath(items[i])) ) { @@ -58,25 +60,28 @@ public class TreeModelViewerAutopopulateAgent implements IViewerUpdateListener { } } - public void updateStarted(IViewerUpdate update) { + @Override + public void updateStarted(IViewerUpdate update) { // TODO Auto-generated method stub } - public void viewerUpdatesBegin() { + @Override + public void viewerUpdatesBegin() { // TODO Auto-generated method stub } - public void viewerUpdatesComplete() { + @Override + public void viewerUpdatesComplete() { // TODO Auto-generated method stub } - + private TreePath getTreePath(Widget w) { if (w instanceof TreeItem) { TreeItem item = (TreeItem)w; - LinkedList segments = new LinkedList(); + LinkedList<Object> segments = new LinkedList<Object>(); while (item != null) { Object segment = item.getData(); Assert.isNotNull(segment); @@ -95,5 +100,5 @@ public class TreeModelViewerAutopopulateAgent implements IViewerUpdateListener { return ((TreeItem)w).getItemCount(); } return 0; - } + } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreePathWrapper.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreePathWrapper.java index bac73a857..06bc29911 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreePathWrapper.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreePathWrapper.java @@ -27,16 +27,19 @@ public class TreePathWrapper { fPath = path; } - public int hashCode() { + @Override + public int hashCode() { return fPath.hashCode(); } - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { return obj instanceof TreePathWrapper && fPath.equals( ((TreePathWrapper)obj).fPath ); } - public String toString() { + @Override + public String toString() { if (fPath.getSegmentCount() == 0) { return "TreePath:EMPTY"; //$NON-NLS-1$ } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/UpdateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/UpdateTests.java index 2af970dc6..bf9682368 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/UpdateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/UpdateTests.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation * IBM Corporation - bug fixing @@ -35,9 +35,9 @@ import org.eclipse.ui.PlatformUI; import org.junit.Assert; /** - * Tests to verify that the viewer property updates following changes in the - * model, following simple content update deltas from the model. - * + * Tests to verify that the viewer property updates following changes in the + * model, following simple content update deltas from the model. + * * @since 3.6 */ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesListenerConstants { @@ -45,7 +45,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL Shell fShell; ITreeModelViewer fViewer; TestModelUpdatesListener fListener; - + public UpdateTests(String name) { super(name); } @@ -53,28 +53,30 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); fShell.setMaximized(true); fShell.setLayout(new FillLayout()); fViewer = createViewer(fDisplay, fShell); - + fListener = new TestModelUpdatesListener(fViewer, false, false); fShell.open (); } abstract protected ITreeModelViewer createViewer(Display display, Shell shell); - + /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); - + // Close the shell and exit. fShell.close(); while (!fShell.isDisposed()) { @@ -84,14 +86,15 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } } - protected void runTest() throws Throwable { + @Override + protected void runTest() throws Throwable { try { super.runTest(); } catch (Throwable t) { throw new ExecutionException("Test failed: " + t.getMessage() + "\n fListener = " + fListener.toString(), t); //$NON-NLS-1$ //$NON-NLS-2$ } } - + /** * This test: * - creates a simple model @@ -103,7 +106,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -113,7 +116,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model TestElement root = model.getRootElement(); TreePath rootPath = new TreePath(new Object[] {}); @@ -123,13 +126,13 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL new TestElement(model, "3", new TestElement[0]), //$NON-NLS-1$ }; model.setElementChildren(rootPath, newElements); - + // Reset the listener to NOT fail on redundant updates. - // When elements are remvoed from the model and the model is - // refreshed the viewer will issue an IChildrenUpdate for the + // When elements are remvoed from the model and the model is + // refreshed the viewer will issue an IChildrenUpdate for the // missing elements as an optimization. fListener.reset(rootPath, root, -1, false, false); - + model.postDelta(new ModelDelta(root, IModelDelta.CONTENT)); while (!fListener.isFinished()) { if (!fDisplay.readAndDispatch ()) { @@ -140,7 +143,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } /** - * This test: + * This test: * - creates a simple model * - sets a list of children to one of the elements * - refreshes the viewer @@ -150,7 +153,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -160,7 +163,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model TestElement element = model.getRootElement().getChildren()[0]; TreePath elementPath = new TreePath(new Object[] { element }); @@ -171,12 +174,12 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL }; model.setElementChildren(elementPath, newChildren); - // Reset the viewer to ignore redundant updates. The '1' element - // will be updated for "hasChildren" before it is expanded, which is + // Reset the viewer to ignore redundant updates. The '1' element + // will be updated for "hasChildren" before it is expanded, which is // expected. TreePath rootPath = TreePath.EMPTY; TestElement rootElement = model.getRootElement(); - fListener.reset(rootPath, rootElement, -1, false, false); + fListener.reset(rootPath, rootElement, -1, false, false); // Refresh the viewer model.postDelta(new ModelDelta(rootElement, IModelDelta.CONTENT)); @@ -188,10 +191,10 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL model.validateData(fViewer, TreePath.EMPTY); } - + private void removeElement(TestModel model, int index, boolean validate) throws InterruptedException { ModelDelta delta = model.removeElementChild(TreePath.EMPTY, index); - + // Remove delta should generate no new updates, but we still need to wait for the event to // be processed. fListener.reset(); @@ -203,25 +206,25 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } if (validate) { - model.validateData(fViewer, TreePath.EMPTY); + model.validateData(fViewer, TreePath.EMPTY); } } - + private void addElement(TestModel model, String label, int position, boolean validate) throws InterruptedException { ModelDelta delta = model.addElementChild(TreePath.EMPTY, null, position, new TestElement(model, label, new TestElement[0])); - + // Remove delta should generate no new updates, but we still need to wait for the event to // be processed. fListener.reset(); model.postDelta(delta); - + if (validate) { while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - model.validateData(fViewer, TreePath.EMPTY); + model.validateData(fViewer, TreePath.EMPTY); } else { while (!fListener.isFinished(MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -233,19 +236,19 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL private void insertElement(TestModel model, String label, int position, boolean validate) throws InterruptedException { ModelDelta delta = model.insertElementChild(TreePath.EMPTY, position, new TestElement(model, label, new TestElement[0])); - + // Remove delta should generate no new updates, but we still need to wait for the event to // be processed. fListener.reset(); model.postDelta(delta); - + if (validate) { while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - model.validateData(fViewer, TreePath.EMPTY); + model.validateData(fViewer, TreePath.EMPTY); } else { while (!fListener.isFinished(MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -262,7 +265,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -272,7 +275,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } } model.validateData(fViewer, TreePath.EMPTY); - + // Update the model removeElement(model, 2, true); addElement(model, "3-new", 3, true); //$NON-NLS-1$ @@ -285,8 +288,8 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } /** - * This test verifies that when the viewer processes a delta that causes viewer - * updates it initiates the model update sequence before it finishes processing + * This test verifies that when the viewer processes a delta that causes viewer + * updates it initiates the model update sequence before it finishes processing * the delta. */ public void testNotifyUpdatesTartedOnModelChanged() throws InterruptedException { @@ -294,7 +297,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -308,30 +311,30 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL // Refresh the viewer so that updates are generated. fListener.reset(); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + Assert.assertTrue( fListener.isFinished(CONTENT_SEQUENCE_STARTED) ); } /** - * This test case attempts to create a race condition between processing - * of the content updates and processing of add/remove model deltas. + * This test case attempts to create a race condition between processing + * of the content updates and processing of add/remove model deltas. * <br> - * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a> + * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a> */ public void testContentPlusAddRemoveUpdateRaceConditionsElement() throws InterruptedException { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -342,12 +345,12 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } model.validateData(fViewer, TreePath.EMPTY); - // Create a listener to listen only to a children count update for the root. + // Create a listener to listen only to a children count update for the root. TestModelUpdatesListener childrenCountUpdateListener = new TestModelUpdatesListener(fViewer, false, false); - + for (int i = 0; i < 10; i++) { String pass = "pass #" + i; //$NON-NLS-1$ - + // Request a content update for view childrenCountUpdateListener.reset(); childrenCountUpdateListener.addChildreCountUpdate(TreePath.EMPTY); @@ -358,7 +361,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL Thread.sleep(0); } } - + removeElement(model, 5, false); removeElement(model, 4, false); removeElement(model, 3, false); @@ -366,46 +369,46 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL removeElement(model, 1, false); removeElement(model, 0, false); - // Wait until the children count update is completed using the count from + // Wait until the children count update is completed using the count from // before elements were removed. while (!childrenCountUpdateListener.isFinished(CHILD_COUNT_UPDATES)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + insertElement(model, "1 - " + pass, 0, false); //$NON-NLS-1$ insertElement(model, "2 - " + pass, 1, false); //$NON-NLS-1$ insertElement(model, "3 - " + pass, 2, false); //$NON-NLS-1$ insertElement(model, "4 - " + pass, 3, false); //$NON-NLS-1$ insertElement(model, "5 - " + pass, 4, false); //$NON-NLS-1$ insertElement(model, "6 - " + pass, 5, false); //$NON-NLS-1$ - + while (!fListener.isFinished(MODEL_CHANGED_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - model.validateData(fViewer, TreePath.EMPTY); + model.validateData(fViewer, TreePath.EMPTY); } - + childrenCountUpdateListener.dispose(); } /** - * This test case attempts to create a race condition between processing - * of the content updates and processing of add/remove model deltas. + * This test case attempts to create a race condition between processing + * of the content updates and processing of add/remove model deltas. * <br> - * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a> + * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a> */ public void testInsertAtInvalidIndex() throws InterruptedException { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -421,7 +424,8 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL ModelDelta delta = model.insertElementChild(TreePath.EMPTY, insertIndex, new TestElement(model, "last - invalid index", new TestElement[0])); //$NON-NLS-1$ // Change insert index to out of range delta.accept(new IModelDeltaVisitor() { - + + @Override public boolean visit(IModelDelta visitorDelta, int depth) { if ((visitorDelta.getFlags() & IModelDelta.INSERTED) != 0) { ((ModelDelta)visitorDelta).setIndex(insertIndex + 1); @@ -430,20 +434,20 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL return true; } }); - + // Remove delta should generate no new updates, but we still need to wait for the event to // be processed. fListener.reset(); model.postDelta(delta); - + while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - model.validateData(fViewer, TreePath.EMPTY); + model.validateData(fViewer, TreePath.EMPTY); } - + /** * This test forces the viewer to reschedule pending content updates * due to a remove event from the model. @@ -454,7 +458,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -471,14 +475,14 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fListener.reset(); fListener.addUpdates(TreePath.EMPTY, model.getRootElement(), 1, CHILD_COUNT_UPDATES); model.postDelta(new ModelDelta(rootElement, IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES | CHILDREN_UPDATES_STARTED)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + // Update the model removeElement(model, 0, true); addElement(model, "1", 0, true); //$NON-NLS-1$ @@ -497,7 +501,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -508,32 +512,32 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } model.validateData(fViewer, TreePath.EMPTY); - + model.setQeueueingUpdate(true); - + for (int i = 0; i < 5; i++) { // Refresh the viewer so that updates are generated. fListener.reset(); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES_STARTED)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + } - + model.setQeueueingUpdate(false); while (!fListener.isFinished(ALL_UPDATES_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + } - + /** * This test forces the viewer to cancel updates then process them at once. * <p> @@ -546,7 +550,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -557,29 +561,29 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } model.validateData(fViewer, TreePath.EMPTY); - + model.setQeueueingUpdate(true); - + for (int i = 0; i < 5; i++) { // Refresh the viewer so that updates are generated. fListener.reset(); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES_STARTED)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + } - - List updates = new ArrayList(model.getQueuedUpdates()); + + ArrayList<IViewerUpdate> updates = new ArrayList<IViewerUpdate>(model.getQueuedUpdates()); model.getQueuedUpdates().clear(); for (int i = updates.size() - 1; i >= 0; i--) { - model.processUpdate((IViewerUpdate)updates.get(i)); + model.processUpdate(updates.get(i)); } - + model.setQeueueingUpdate(false); while (!fListener.isFinished(ALL_UPDATES_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -587,7 +591,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } } } - + /** * This test forces the viewer to cancel updates then process them at once. * <p> @@ -600,7 +604,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -611,14 +615,14 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } model.validateData(fViewer, TreePath.EMPTY); - + model.setQeueueingUpdate(true); - + for (int i = 0; i < 5; i++) { // Refresh the viewer so that updates are generated. fListener.reset(); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILDREN_UPDATES_STARTED)) { completeQueuedUpdatesOfType(model, IChildrenCountUpdate.class); @@ -628,16 +632,16 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } } } - + model.setQeueueingUpdate(false); while (!fListener.isFinished(ALL_UPDATES_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + } - + /** * This test forces the viewer to cancel updates then process them at once. * <p> @@ -650,7 +654,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -661,14 +665,14 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } model.validateData(fViewer, TreePath.EMPTY); - + model.setQeueueingUpdate(true); - + for (int i = 0; i < 5; i++) { // Refresh the viewer so that updates are generated. fListener.reset(); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILDREN_UPDATES_STARTED)) { completeQueuedUpdatesOfType(model, IChildrenCountUpdate.class); @@ -677,15 +681,15 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL Thread.sleep(0); } } - + } - - List updates = new ArrayList(model.getQueuedUpdates()); + + ArrayList<IViewerUpdate> updates = new ArrayList<IViewerUpdate>(model.getQueuedUpdates()); model.getQueuedUpdates().clear(); for (int i = updates.size() - 1; i >= 0; i--) { - model.processUpdate((IViewerUpdate)updates.get(i)); + model.processUpdate(updates.get(i)); } - + model.setQeueueingUpdate(false); while (!fListener.isFinished(ALL_UPDATES_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -693,9 +697,9 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL } } } - + /** - * This test removes an element while there are updates running on its + * This test removes an element while there are updates running on its * sub-tree. With a precise timing this operation caused Bug 373790. * <p> * See Bug 373790 - Debug view stays busy after Resume @@ -707,7 +711,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -724,7 +728,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fListener.addUpdates(path, model.getElement(path), 1, CHILD_COUNT_UPDATES); fListener.addChildreUpdate(path, 0); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed and child updates for "2" to get started. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES | CHILDREN_UPDATES_RUNNING)) { if (!fDisplay.readAndDispatch ()) { @@ -734,7 +738,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL // Remove element "2" removeElement(model, 1, true); - + // Wait for all updates to finish. while (!fListener.isFinished(ALL_UPDATES_COMPLETE)) { if (!fDisplay.readAndDispatch ()) { @@ -755,7 +759,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -767,19 +771,19 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL model.validateData(fViewer, TreePath.EMPTY); model.setQeueueingUpdate(false); - + // Refresh the viewer so that updates are generated. fListener.reset(); fListener.addChildreCountUpdate(TreePath.EMPTY); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + TestModel model2 = new TestModel(); model2.setRoot(new TestElement(model2, "root", new TestElement[0])); //$NON-NLS-1$ fViewer.setInput(model2.getRootElement()); @@ -789,7 +793,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL Thread.sleep(0); } } - + } /** @@ -804,7 +808,7 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL fViewer.setAutoExpandLevel(-1); // Create the listener - fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false); // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); @@ -816,19 +820,19 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL model.validateData(fViewer, TreePath.EMPTY); model.setQeueueingUpdate(false); - + // Refresh the viewer so that updates are generated. fListener.reset(); fListener.addChildreCountUpdate(TreePath.EMPTY); model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT)); - + // Wait for the delta to be processed. while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES)) { if (!fDisplay.readAndDispatch ()) { Thread.sleep(0); } } - + fViewer.setInput(null); while (!fListener.isFinished(CONTENT_COMPLETE | VIEWER_UPDATES_RUNNING)) { @@ -836,24 +840,24 @@ abstract public class UpdateTests extends TestCase implements ITestModelUpdatesL Thread.sleep(0); } } - + } - - private void completeQueuedUpdatesOfType(TestModel model, Class updateClass) { - List updatesToComplete = new LinkedList(); - - for (Iterator itr = model.getQueuedUpdates().iterator(); itr.hasNext();) { - IViewerUpdate update = (IViewerUpdate)itr.next(); + + private void completeQueuedUpdatesOfType(TestModel model, Class<?> updateClass) { + List<IViewerUpdate> updatesToComplete = new LinkedList<IViewerUpdate>(); + + for (Iterator<IViewerUpdate> itr = model.getQueuedUpdates().iterator(); itr.hasNext();) { + IViewerUpdate update = itr.next(); if (updateClass.isInstance(update)) { updatesToComplete.add(update); itr.remove(); } - } + } if (updatesToComplete != null) { - for (Iterator itr = updatesToComplete.iterator(); itr.hasNext();) { - model.processUpdate((IViewerUpdate)itr.next()); + for (Iterator<IViewerUpdate> itr = updatesToComplete.iterator(); itr.hasNext();) { + model.processUpdate(itr.next()); } } } - + } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerContentTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerContentTests.java index 6f06e6346..9cf942bc6 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerContentTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerContentTests.java @@ -26,7 +26,8 @@ public class VirtualViewerContentTests extends ContentTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerDeltaTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerDeltaTests.java index a2ab1a21b..f7dd72850 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerDeltaTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerDeltaTests.java @@ -26,7 +26,8 @@ public class VirtualViewerDeltaTests extends DeltaTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerFilterTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerFilterTests.java index fd584069a..9814cb5d6 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerFilterTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerFilterTests.java @@ -27,7 +27,8 @@ public class VirtualViewerFilterTests extends FilterTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, SWT.VIRTUAL, new PresentationContext("TestViewer"), new VisibleVirtualItemValidator(0, 100)); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerLazyModeTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerLazyModeTests.java index 94c370675..4139b5c4c 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerLazyModeTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerLazyModeTests.java @@ -42,7 +42,8 @@ public class VirtualViewerLazyModeTests extends TestCase { /** * @throws java.lang.Exception */ - protected void setUp() throws Exception { + @Override + protected void setUp() throws Exception { fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/); fShell.setMaximized(true); @@ -67,7 +68,8 @@ public class VirtualViewerLazyModeTests extends TestCase { /** * @throws java.lang.Exception */ - protected void tearDown() throws Exception { + @Override + protected void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPerformanceTests.java index e21fd505b..8c08a904e 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPerformanceTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPerformanceTests.java @@ -27,11 +27,13 @@ public class VirtualViewerPerformanceTests extends PerformanceTests { super(name); } - protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, SWT.VIRTUAL, new PresentationContext("TestViewer"), fVirtualItemValidator); //$NON-NLS-1$ } - protected int getTestModelDepth() { + @Override + protected int getTestModelDepth() { return 7; } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPopupTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPopupTests.java index 4c2dcda52..1d127be36 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPopupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPopupTests.java @@ -26,7 +26,8 @@ public class VirtualViewerPopupTests extends PopupTests { super(name); } - protected ITreeModelViewer createViewer(Display display, Shell shell, int style) { + @Override + protected ITreeModelViewer createViewer(Display display, Shell shell, int style) { return new VirtualTreeModelViewer(fDisplay, style, new PresentationContext("TestViewer")); //$NON-NLS-1$ } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerSelectionTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerSelectionTests.java index a0df1576f..5a7dd44dd 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerSelectionTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerSelectionTests.java @@ -26,7 +26,8 @@ public class VirtualViewerSelectionTests extends SelectionTests { super(name); } - protected ITreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected ITreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerStateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerStateTests.java index b441ca685..46cdd3ad8 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerStateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerStateTests.java @@ -26,7 +26,8 @@ public class VirtualViewerStateTests extends StateTests { super(name); } - protected ITreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected ITreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerUpdateTests.java index d1ce76967..6fc572a21 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerUpdateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerUpdateTests.java @@ -26,7 +26,8 @@ public class VirtualViewerUpdateTests extends UpdateTests { super(name); } - protected ITreeModelViewer createViewer(Display display, Shell shell) { + @Override + protected ITreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ } } diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VisibleVirtualItemValidator.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VisibleVirtualItemValidator.java index aa8c4c51b..bcb6e8659 100644 --- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VisibleVirtualItemValidator.java +++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VisibleVirtualItemValidator.java @@ -40,7 +40,8 @@ public class VisibleVirtualItemValidator implements IVirtualItemValidator { return fEnd - fStart; } - public boolean isItemVisible(VirtualItem item) { + @Override + public boolean isItemVisible(VirtualItem item) { int position = 0; while (item.getParent() != null) { position += item.getIndex().intValue(); @@ -49,7 +50,8 @@ public class VisibleVirtualItemValidator implements IVirtualItemValidator { return position >= fStart && position < fEnd || isSelected(item); } - public void showItem(VirtualItem item) { + @Override + public void showItem(VirtualItem item) { int length = fEnd - fStart; fStart = calcPosition(item); fEnd = fStart + length; diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java index 36de236c9..6324b079b 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java @@ -49,6 +49,7 @@ public class TestsPlugin extends AbstractUIPlugin { * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; @@ -58,6 +59,7 @@ public class TestsPlugin extends AbstractUIPlugin { * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ + @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java index 2454caa1c..1e5155548 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java @@ -65,6 +65,7 @@ public class BreakpointOrderingTests extends TestCase { final IResource resource = ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRunnable wr = new IWorkspaceRunnable() { + @Override public void run( IProgressMonitor monitor ) throws CoreException { // create the marker setMarker(resource.createMarker(markerType)); @@ -88,51 +89,62 @@ public class BreakpointOrderingTests extends TestCase { return fText; } + @Override public void delete() throws CoreException { fMarker.delete(); } + @Override public IMarker getMarker() { return fMarker; } + @Override public String getModelIdentifier() { return "Test"; //$NON-NLS-1$ } + @Override public boolean isEnabled() throws CoreException { fail("not implemented in test"); //$NON-NLS-1$ return false; } + @Override public boolean isPersisted() throws CoreException { fail("not implemented in test"); //$NON-NLS-1$ return false; } + @Override public boolean isRegistered() throws CoreException { fail("not implemented in test"); //$NON-NLS-1$ return false; } + @Override public void setEnabled(boolean enabled) throws CoreException { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public void setMarker(IMarker marker) throws CoreException { assertTrue(fMarker == null && marker != null); fMarker = marker; } + @Override public void setPersisted(boolean registered) throws CoreException { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public void setRegistered(boolean registered) throws CoreException { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public Object getAdapter(Class adapter) { fail("not implemented in test"); //$NON-NLS-1$ return null; @@ -151,15 +163,18 @@ public class BreakpointOrderingTests extends TestCase { fLineNum = lineNum; } + @Override public int getLineNumber() throws CoreException { return fLineNum; } + @Override public int getCharEnd() throws CoreException { fail("not implemented in test"); //$NON-NLS-1$ return 0; } + @Override public int getCharStart() throws CoreException { fail("not implemented in test"); //$NON-NLS-1$ return 0; @@ -171,41 +186,50 @@ public class BreakpointOrderingTests extends TestCase { */ StructuredViewer fTestViewer = new StructuredViewer() { + @Override public IBaseLabelProvider getLabelProvider() { return fDebugModelPres; } + @Override protected Widget doFindInputItem(Object element) { fail("not implemented in test"); //$NON-NLS-1$ return null; } + @Override protected Widget doFindItem(Object element) { fail("not implemented in test"); //$NON-NLS-1$ return null; } + @Override protected void doUpdateItem(Widget item, Object element, boolean fullMap) { fail("not implemented in test"); //$NON-NLS-1$ } + @Override protected List getSelectionFromWidget() { fail("not implemented in test"); //$NON-NLS-1$ return null; } + @Override protected void internalRefresh(Object element) { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public void reveal(Object element) { fail("not implemented in test"); //$NON-NLS-1$ } + @Override protected void setSelectionToWidget(List l, boolean reveal) { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public Control getControl() { fail("not implemented in test"); //$NON-NLS-1$ return null; @@ -214,46 +238,56 @@ public class BreakpointOrderingTests extends TestCase { // Test debug model presentation for label text retrieval. IDebugModelPresentation fDebugModelPres = new IDebugModelPresentation() { + @Override public void computeDetail(IValue value, IValueDetailListener listener) { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public Image getImage(Object element) { fail("not implemented in test"); //$NON-NLS-1$ return null; } + @Override public String getText(Object element) { assertTrue("Unexpected element", element instanceof TestBreakpoint); //$NON-NLS-1$ return ((TestBreakpoint)element).getText(); } + @Override public void setAttribute(String attribute, Object value) { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public void addListener(ILabelProviderListener listener) { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public void dispose() { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public boolean isLabelProperty(Object element, String property) { fail("not implemented in test"); //$NON-NLS-1$ return false; } + @Override public void removeListener(ILabelProviderListener listener) { fail("not implemented in test"); //$NON-NLS-1$ } + @Override public String getEditorId(IEditorInput input, Object element) { fail("not implemented in test"); //$NON-NLS-1$ return null; } + @Override public IEditorInput getEditorInput(Object element) { fail("not implemented in test"); //$NON-NLS-1$ return null; diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/expressions/ExpressionManagerTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/expressions/ExpressionManagerTests.java index 7238c93f7..962c0bd68 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/expressions/ExpressionManagerTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/expressions/ExpressionManagerTests.java @@ -28,12 +28,12 @@ import org.eclipse.debug.internal.core.IExpressionsListener2; * Tests expression manager and listener call backs */ public class ExpressionManagerTests extends TestCase { - + class SinlgeListener implements IExpressionListener { - - List added = new ArrayList(); - List removed = new ArrayList(); - List changed = new ArrayList(); + + List<IExpression> added = new ArrayList<IExpression>(); + List<IExpression> removed = new ArrayList<IExpression>(); + List<IExpression> changed = new ArrayList<IExpression>(); int addedCallbacks = 0; int removedCallbacks = 0; int changedCallbacks = 0; @@ -41,6 +41,7 @@ public class ExpressionManagerTests extends TestCase { /* (non-Javadoc) * @see org.eclipse.debug.core.IExpressionListener#expressionAdded(org.eclipse.debug.core.model.IExpression) */ + @Override public void expressionAdded(IExpression expression) { added.add(expression); addedCallbacks++; @@ -49,6 +50,7 @@ public class ExpressionManagerTests extends TestCase { /* (non-Javadoc) * @see org.eclipse.debug.core.IExpressionListener#expressionRemoved(org.eclipse.debug.core.model.IExpression) */ + @Override public void expressionRemoved(IExpression expression) { removed.add(expression); removedCallbacks++; @@ -57,18 +59,19 @@ public class ExpressionManagerTests extends TestCase { /* (non-Javadoc) * @see org.eclipse.debug.core.IExpressionListener#expressionChanged(org.eclipse.debug.core.model.IExpression) */ + @Override public void expressionChanged(IExpression expression) { changed.add(expression); changedCallbacks++; } - + } - + class MultiListener implements IExpressionsListener { - - List added = new ArrayList(); - List removed = new ArrayList(); - List changed = new ArrayList(); + + List<IExpression> added = new ArrayList<IExpression>(); + List<IExpression> removed = new ArrayList<IExpression>(); + List<IExpression> changed = new ArrayList<IExpression>(); int addedCallbacks = 0; int removedCallbacks = 0; int changedCallbacks = 0; @@ -76,6 +79,7 @@ public class ExpressionManagerTests extends TestCase { /* (non-Javadoc) * @see org.eclipse.debug.core.IExpressionsListener#expressionsAdded(org.eclipse.debug.core.model.IExpression[]) */ + @Override public void expressionsAdded(IExpression[] expressions) { for (int i = 0; i < expressions.length; i++) { added.add(expressions[i]); @@ -86,6 +90,7 @@ public class ExpressionManagerTests extends TestCase { /* (non-Javadoc) * @see org.eclipse.debug.core.IExpressionsListener#expressionsRemoved(org.eclipse.debug.core.model.IExpression[]) */ + @Override public void expressionsRemoved(IExpression[] expressions) { for (int i = 0; i < expressions.length; i++) { removed.add(expressions[i]); @@ -96,26 +101,28 @@ public class ExpressionManagerTests extends TestCase { /* (non-Javadoc) * @see org.eclipse.debug.core.IExpressionsListener#expressionsChanged(org.eclipse.debug.core.model.IExpression[]) */ + @Override public void expressionsChanged(IExpression[] expressions) { for (int i = 0; i < expressions.length; i++) { changed.add(expressions[i]); } changedCallbacks++; } - + } - + class InsertMoveListener extends MultiListener implements IExpressionsListener2 { - List moved = new ArrayList(); - List inserted = new ArrayList(); + List<IExpression> moved = new ArrayList<IExpression>(); + List<IExpression> inserted = new ArrayList<IExpression>(); int insertIndex = -1; int movedCallbacks = 0; int insertedCallbacks = 0; - + /* (non-Javadoc) * @see org.eclipse.debug.internal.core.IExpressionsListener2#expressionsMoved(org.eclipse.debug.core.model.IExpression[], int) */ + @Override public void expressionsMoved(IExpression[] expressions, int index) { for (int i = 0; i < expressions.length; i++) { moved.add(expressions[i]); @@ -127,6 +134,7 @@ public class ExpressionManagerTests extends TestCase { /* (non-Javadoc) * @see org.eclipse.debug.internal.core.IExpressionsListener2#expressionsInserted(org.eclipse.debug.core.model.IExpression[], int) */ + @Override public void expressionsInserted(IExpression[] expressions, int index) { for (int i = 0; i < expressions.length; i++) { inserted.add(expressions[i]); @@ -134,30 +142,31 @@ public class ExpressionManagerTests extends TestCase { insertedCallbacks++; insertIndex = index; } - + } /** * Returns the expression manager. - * + * * @return expression manager */ protected IExpressionManager getManager() { return DebugPlugin.getDefault().getExpressionManager(); } - + /* (non-Javadoc) * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { // remove all expressions from the manager super.tearDown(); getManager().removeExpressions(getManager().getExpressions()); } - + /** * Returns the index of the given expression in the given list or -1 if not present. - * + * * @param expression candidate * @param list list to search * @return index or -1 @@ -170,7 +179,7 @@ public class ExpressionManagerTests extends TestCase { } return -1; } - + /** * Add expressions and ensure proper call backs are received. */ @@ -205,7 +214,7 @@ public class ExpressionManagerTests extends TestCase { manager.removeExpressionListener(multi); } } - + /** * Remove expressions and ensure proper call backs are received. */ @@ -245,7 +254,7 @@ public class ExpressionManagerTests extends TestCase { manager.removeExpressionListener(multi); } } - + /** * Change expressions and ensure proper call backs are received. */ @@ -285,8 +294,8 @@ public class ExpressionManagerTests extends TestCase { manager.removeExpressionListener(single); manager.removeExpressionListener(multi); } - } - + } + /** * Insert expressions and ensure proper call backs are received. */ @@ -311,9 +320,9 @@ public class ExpressionManagerTests extends TestCase { manager.addExpressionListener(single); manager.addExpressionListener(multi); manager.addExpressionListener(insert); - + manager.insertExpressions(new IExpression[] {exp4, exp5}, exp2, true); - + assertEquals(2, single.addedCallbacks); assertEquals(2, single.added.size()); assertEquals(0, single.removedCallbacks); @@ -328,7 +337,7 @@ public class ExpressionManagerTests extends TestCase { assertEquals(2, insert.inserted.size()); assertEquals(0, insert.inserted.indexOf(exp4)); assertEquals(1, insert.inserted.indexOf(exp5)); - + expressions = manager.getExpressions(); assertEquals("Wrong number of expressions", 5, expressions.length); //$NON-NLS-1$ assertEquals(0, indexOf(exp1, expressions)); @@ -336,14 +345,14 @@ public class ExpressionManagerTests extends TestCase { assertEquals(2, indexOf(exp5, expressions)); assertEquals(3, indexOf(exp2, expressions)); assertEquals(4, indexOf(exp3, expressions)); - + } finally { manager.removeExpressionListener(single); manager.removeExpressionListener(multi); manager.removeExpressionListener(insert); } } - + /** * Insert expressions and ensure proper call backs are received. */ @@ -368,9 +377,9 @@ public class ExpressionManagerTests extends TestCase { manager.addExpressionListener(single); manager.addExpressionListener(multi); manager.addExpressionListener(insert); - + manager.insertExpressions(new IExpression[] {exp4, exp5}, exp2, false); - + assertEquals(2, single.addedCallbacks); assertEquals(2, single.added.size()); assertEquals(0, single.removedCallbacks); @@ -385,7 +394,7 @@ public class ExpressionManagerTests extends TestCase { assertEquals(2, insert.inserted.size()); assertEquals(0, insert.inserted.indexOf(exp4)); assertEquals(1, insert.inserted.indexOf(exp5)); - + expressions = manager.getExpressions(); assertEquals("Wrong number of expressions", 5, expressions.length); //$NON-NLS-1$ assertEquals(0, indexOf(exp1, expressions)); @@ -393,14 +402,14 @@ public class ExpressionManagerTests extends TestCase { assertEquals(2, indexOf(exp4, expressions)); assertEquals(3, indexOf(exp5, expressions)); assertEquals(4, indexOf(exp3, expressions)); - + } finally { manager.removeExpressionListener(single); manager.removeExpressionListener(multi); manager.removeExpressionListener(insert); } - } - + } + /** * Move expressions and ensure proper call backs are received. */ @@ -420,9 +429,9 @@ public class ExpressionManagerTests extends TestCase { manager.addExpressionListener(single); manager.addExpressionListener(multi); manager.addExpressionListener(insert); - + manager.moveExpressions(new IExpression[]{exp1,exp2}, exp5, true); - + assertEquals(0, single.addedCallbacks); assertEquals(0, single.removedCallbacks); assertEquals(0, single.changedCallbacks); @@ -435,7 +444,7 @@ public class ExpressionManagerTests extends TestCase { assertEquals(0, insert.moved.indexOf(exp1)); assertEquals(1, insert.moved.indexOf(exp2)); assertEquals(2, insert.insertIndex); - + IExpression[] expressions = manager.getExpressions(); assertEquals("Wrong number of expressions", 5, expressions.length); //$NON-NLS-1$ assertEquals(0, indexOf(exp3, expressions)); @@ -443,14 +452,14 @@ public class ExpressionManagerTests extends TestCase { assertEquals(2, indexOf(exp1, expressions)); assertEquals(3, indexOf(exp2, expressions)); assertEquals(4, indexOf(exp5, expressions)); - + } finally { manager.removeExpressionListener(single); manager.removeExpressionListener(multi); manager.removeExpressionListener(insert); } } - + /** * Move expressions and ensure proper call backs are received. */ @@ -470,9 +479,9 @@ public class ExpressionManagerTests extends TestCase { manager.addExpressionListener(single); manager.addExpressionListener(multi); manager.addExpressionListener(insert); - + manager.moveExpressions(new IExpression[]{exp1,exp2}, exp3, false); - + assertEquals(0, single.addedCallbacks); assertEquals(0, single.removedCallbacks); assertEquals(0, single.changedCallbacks); @@ -485,7 +494,7 @@ public class ExpressionManagerTests extends TestCase { assertEquals(0, insert.moved.indexOf(exp1)); assertEquals(1, insert.moved.indexOf(exp2)); assertEquals(1, insert.insertIndex); - + IExpression[] expressions = manager.getExpressions(); assertEquals("Wrong number of expressions", 5, expressions.length); //$NON-NLS-1$ assertEquals(0, indexOf(exp3, expressions)); @@ -493,14 +502,14 @@ public class ExpressionManagerTests extends TestCase { assertEquals(2, indexOf(exp2, expressions)); assertEquals(3, indexOf(exp4, expressions)); assertEquals(4, indexOf(exp5, expressions)); - + } finally { manager.removeExpressionListener(single); manager.removeExpressionListener(multi); manager.removeExpressionListener(insert); } - } - + } + /** * Test persist and restore of expressions */ @@ -513,7 +522,7 @@ public class ExpressionManagerTests extends TestCase { IWatchExpression exp5 = manager.newWatchExpression("exp5"); //$NON-NLS-1$ manager.addExpressions(new IExpression[]{exp1, exp2, exp3, exp4, exp5}); manager.storeWatchExpressions(); - + // create a new manager that will restore the expressions ExpressionManager manager2 = new ExpressionManager(); IExpression[] expressions = manager2.getExpressions(); @@ -524,16 +533,17 @@ public class ExpressionManagerTests extends TestCase { assertEquals("exp4", expressions[3].getExpressionText()); //$NON-NLS-1$ assertEquals("exp5", expressions[4].getExpressionText()); //$NON-NLS-1$ } - + /** * Tests concurrent access to expressions. - * + * * @throws InterruptedException */ public void testConcurrentAccess() throws InterruptedException { final boolean[] done = new boolean[]{false}; final Exception[] ex = new Exception[]{null}; Runnable add = new Runnable() { + @Override public void run() { try { for (int i = 0; i < 1000; i++) { @@ -546,6 +556,7 @@ public class ExpressionManagerTests extends TestCase { } }; Runnable remove = new Runnable() { + @Override public void run() { try { do { @@ -565,5 +576,5 @@ public class ExpressionManagerTests extends TestCase { assertEquals(0, getManager().getExpressions().length); assertNull(ex[0]); } - + } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandler.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandler.java index 6315b43f1..b8feaa035 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandler.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandler.java @@ -22,6 +22,7 @@ public class StatusHandler implements IStatusHandler { /* (non-Javadoc) * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) */ + @Override public Object handleStatus(IStatus status, Object source) throws CoreException { return null; } |