Modernize o.e.dlkt.ruby.formatter.tests.

* Bump BREE to Java 1.8.
* Enable more warnings and fix them.
* Enable save actions.
* Fix deprecated usages.

Change-Id: I29ebf7ac5cf3dc95cfe67b9886c6acc282da1e82
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tests/org.eclipse.dltk.ruby.debug.tests/.classpath b/tests/org.eclipse.dltk.ruby.debug.tests/.classpath
index ad32c83..eca7bdb 100644
--- a/tests/org.eclipse.dltk.ruby.debug.tests/.classpath
+++ b/tests/org.eclipse.dltk.ruby.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/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="output" path="bin"/>
diff --git a/tests/org.eclipse.dltk.ruby.debug.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.dltk.ruby.debug.tests/.settings/org.eclipse.jdt.core.prefs
index dfdb304..f82645a 100644
--- a/tests/org.eclipse.dltk.ruby.debug.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tests/org.eclipse.dltk.ruby.debug.tests/.settings/org.eclipse.jdt.core.prefs
@@ -10,9 +10,9 @@
 org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.compliance=1.8
 org.eclipse.jdt.core.compiler.debug.lineNumber=generate
 org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -27,7 +27,7 @@
 org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
 org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
 org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
 org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
 org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
@@ -38,7 +38,7 @@
 org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
 org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
 org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
 org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
 org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
@@ -86,10 +86,10 @@
 org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
 org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
 org.eclipse.jdt.core.compiler.problem.unusedImport=warning
 org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
@@ -103,4 +103,4 @@
 org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/tests/org.eclipse.dltk.ruby.debug.tests/.settings/org.eclipse.jdt.ui.prefs b/tests/org.eclipse.dltk.ruby.debug.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..fbac55c
--- /dev/null
+++ b/tests/org.eclipse.dltk.ruby.debug.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,59 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=true
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/tests/org.eclipse.dltk.ruby.debug.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.dltk.ruby.debug.tests/META-INF/MANIFEST.MF
index f68987c..9d2458e 100644
--- a/tests/org.eclipse.dltk.ruby.debug.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.dltk.ruby.debug.tests/META-INF/MANIFEST.MF
@@ -16,4 +16,4 @@
  org.eclipse.dltk.launching
 Bundle-ActivationPolicy: lazy
 Export-Package: org.eclipse.dltk.ruby.debug.tests
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/console/RubyFilenameLinenumberTests.java b/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/console/RubyFilenameLinenumberTests.java
index 9e5cb91..22dd5f3 100644
--- a/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/console/RubyFilenameLinenumberTests.java
+++ b/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/console/RubyFilenameLinenumberTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2016 xored software, Inc.
+ * Copyright (c) 2008, 2017 xored software, Inc. and others.
  *
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -31,27 +31,27 @@
 	}
 
 	@Test
-	public void testSimple() throws Exception {
+	public void testSimple() {
 		assertTrue(pattern.matcher("script.rb:2").matches());
 	}
 
 	@Test
-	public void testRoot() throws Exception {
+	public void testRoot() {
 		assertTrue(pattern.matcher("/script.rb:2").matches());
 	}
 
 	@Test
-	public void testFullWindows() throws Exception {
+	public void testFullWindows() {
 		assertTrue(pattern.matcher("C:/runtime/A/script.rb:2").matches());
 	}
 
 	@Test
-	public void testFullUnix() throws Exception {
+	public void testFullUnix() {
 		assertTrue(pattern.matcher("/home/user/runtime/A/script.rb:2").matches());
 	}
 
 	@Test
-	public void testFrom() throws Exception {
+	public void testFrom() {
 		Matcher m = pattern.matcher("from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:61:in `require_gem'");
 		assertTrue(m.find());
 		assertEquals(2, m.groupCount());
diff --git a/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/launching/RubyLaunchingTests.java b/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/launching/RubyLaunchingTests.java
index 3c68d88..dfab024 100644
--- a/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/launching/RubyLaunchingTests.java
+++ b/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/launching/RubyLaunchingTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2016 xored software, Inc. and others.
+ * Copyright (c) 2016, 2017 xored software, Inc. 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
@@ -13,9 +13,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.Test;
-
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.dltk.core.tests.launching.ScriptLaunchingTests;
@@ -28,6 +28,8 @@
 import org.eclipse.dltk.ruby.debug.RubyDebugPlugin;
 import org.eclipse.dltk.ruby.launching.RubyLaunchConfigurationDelegate;
 
+import junit.framework.Test;
+
 public class RubyLaunchingTests extends ScriptLaunchingTests {
 
 	public RubyLaunchingTests(String name) {
@@ -59,62 +61,59 @@
 
 	@Override
 	protected ILaunchConfiguration createLaunchConfiguration(String arguments) {
-		return createTestLaunchConfiguration(getNatureId(), getProjectName(),
-				"src/test.rb", arguments);
+		return createTestLaunchConfiguration(getNatureId(), getProjectName(), "src/test.rb", arguments);
 	}
 
 	@Override
 	protected void startLaunch(ILaunch launch, final IInterpreterInstall install) throws CoreException {
 		final AbstractScriptLaunchConfigurationDelegate delegate = new RubyLaunchConfigurationDelegate() {
 			@Override
-			public IInterpreterInstall getInterpreterInstall(
-					ILaunchConfiguration configuration) throws CoreException {
+			public IInterpreterInstall getInterpreterInstall(ILaunchConfiguration configuration) {
 				return install;
 			}
 		};
-		delegate.launch(launch.getLaunchConfiguration(),
-				launch.getLaunchMode(), launch, null);
+		delegate.launch(launch.getLaunchConfiguration(), launch.getLaunchMode(), launch, null);
 	}
 
 	public void testDebugRuby() throws Exception {
-		RubyDebugPlugin.getDefault().getPluginPreferences().setValue(
-				RubyDebugConstants.DEBUGGING_ENGINE_ID_KEY,
-				"org.eclipse.dltk.ruby.basicdebugger");
+		IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(RubyDebugPlugin.PLUGIN_ID);
+		prefs.put(RubyDebugConstants.DEBUGGING_ENGINE_ID_KEY, "org.eclipse.dltk.ruby.basicdebugger");
+		prefs.flush();
 
 		DebugEventStats stats = this.internalTestDebug("ruby");
 		int suspendCount = stats.getSuspendCount();
 		assertEquals(1, suspendCount);
 
-//		assertEquals(2, stats.getResumeCount());
+		// assertEquals(2, stats.getResumeCount());
 
 		// Checking extended events count
 		assertEquals(1, stats.getBeforeVmStarted());
 		assertEquals(1, stats.getBeforeCodeLoaded());
-//		assertEquals(2, stats.getBeforeResumeCount());
+		// assertEquals(2, stats.getBeforeResumeCount());
 		assertEquals(1, stats.getBeforeSuspendCount());
 	}
+
 	public void testFastDebugRuby() throws Exception {
-		RubyDebugPlugin.getDefault().getPluginPreferences().setValue(
-				RubyDebugConstants.DEBUGGING_ENGINE_ID_KEY,
-				"org.eclipse.dltk.ruby.fastdebugger");
+		IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(RubyDebugPlugin.PLUGIN_ID);
+		prefs.put(RubyDebugConstants.DEBUGGING_ENGINE_ID_KEY, "org.eclipse.dltk.ruby.fastdebugger");
+		prefs.flush();
 		DebugEventStats stats = this.internalTestDebug("ruby");
 		int suspendCount = stats.getSuspendCount();
 		assertEquals(1, suspendCount);
 
-//		assertEquals(2, stats.getResumeCount());
+		// assertEquals(2, stats.getResumeCount());
 
 		// Checking extended events count
 		assertEquals(1, stats.getBeforeVmStarted());
 		assertEquals(1, stats.getBeforeCodeLoaded());
-//		assertEquals(2, stats.getBeforeResumeCount());
+		// assertEquals(2, stats.getBeforeResumeCount());
 		assertEquals(1, stats.getBeforeSuspendCount());
 	}
 
-
 	public void testDebugJRuby() throws Exception {
-		RubyDebugPlugin.getDefault().getPluginPreferences().setValue(
-				RubyDebugConstants.DEBUGGING_ENGINE_ID_KEY,
-				"org.eclipse.dltk.ruby.basicdebugger");
+		IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(RubyDebugPlugin.PLUGIN_ID);
+		prefs.put(RubyDebugConstants.DEBUGGING_ENGINE_ID_KEY, "org.eclipse.dltk.ruby.basicdebugger");
+		prefs.flush();
 
 		DebugEventStats stats = this.internalTestDebug("jruby");
 		int suspendCount = stats.getSuspendCount();
@@ -143,20 +142,17 @@
 
 	@Override
 	protected IInterpreterInstall[] getPredefinedInterpreterInstalls() {
-		IInterpreterInstallType[] installTypes = ScriptRuntime
-				.getInterpreterInstallTypes(RubyNature.NATURE_ID);
+		IInterpreterInstallType[] installTypes = ScriptRuntime.getInterpreterInstallTypes(RubyNature.NATURE_ID);
 		int id = 0;
-		List <IInterpreterInstall>installs = new ArrayList<IInterpreterInstall>();
+		List<IInterpreterInstall> installs = new ArrayList<>();
 		for (int i = 0; i < installTypes.length; i++) {
 			String installId = getNatureId() + "_";
-			createAddInstall(installs, "/usr/bin/ruby", installId
-					+ Integer.toString(++id), installTypes[i]);
-			createAddInstall(installs, "/home/dltk/apps/jruby/bin/jruby",
-					installId + Integer.toString(++id), installTypes[i]);
+			createAddInstall(installs, "/usr/bin/ruby", installId + Integer.toString(++id), installTypes[i]);
+			createAddInstall(installs, "/home/dltk/apps/jruby/bin/jruby", installId + Integer.toString(++id),
+					installTypes[i]);
 		}
 		if (installs.size() > 0) {
-			return installs
-					.toArray(new IInterpreterInstall[installs.size()]);
+			return installs.toArray(new IInterpreterInstall[installs.size()]);
 		}
 		return searchInstalls(RubyNature.NATURE_ID);
 	}