Bug 509276 - Move o.e.tests to Java 8
Bump BREE to Java 1.8 and use lambdas, try-with-resources, add missing
annotations and etc..
Change-Id: Ic748e487f303fd2e5b61b8f5a85a80333257e2b6
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.test/.classpath b/bundles/org.eclipse.test/.classpath
index 64c5e31..eca7bdb 100644
--- a/bundles/org.eclipse.test/.classpath
+++ b/bundles/org.eclipse.test/.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.5"/>
+ <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/bundles/org.eclipse.test/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.test/.settings/org.eclipse.jdt.core.prefs
index 0cac038..e54adb3 100644
--- a/bundles/org.eclipse.test/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.test/.settings/org.eclipse.jdt.core.prefs
@@ -6,9 +6,9 @@
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=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+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
@@ -97,4 +97,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.5
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/bundles/org.eclipse.test/META-INF/MANIFEST.MF b/bundles/org.eclipse.test/META-INF/MANIFEST.MF
index efe3f97..7fa7d66 100644
--- a/bundles/org.eclipse.test/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.test/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.test; singleton:=true
-Bundle-Version: 3.3.200.qualifier
+Bundle-Version: 3.4.0.qualifier
Eclipse-BundleShape: dir
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -13,5 +13,5 @@
org.eclipse.ui.ide.application,
org.eclipse.equinox.app
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.test
diff --git a/bundles/org.eclipse.test/pom.xml b/bundles/org.eclipse.test/pom.xml
index f511369..1877234 100644
--- a/bundles/org.eclipse.test/pom.xml
+++ b/bundles/org.eclipse.test/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.test</groupId>
<artifactId>org.eclipse.test</artifactId>
- <version>3.3.200-SNAPSHOT</version>
+ <version>3.4.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
<defaultSigning-excludeInnerJars>true</defaultSigning-excludeInnerJars>
diff --git a/bundles/org.eclipse.test/src/org/eclipse/test/CoreTestApplication.java b/bundles/org.eclipse.test/src/org/eclipse/test/CoreTestApplication.java
index 60a6c64..c3d28ea 100644
--- a/bundles/org.eclipse.test/src/org/eclipse/test/CoreTestApplication.java
+++ b/bundles/org.eclipse.test/src/org/eclipse/test/CoreTestApplication.java
@@ -28,6 +28,7 @@
* This is the platform application entry point.
* @see IPlatformRunnable
*/
+ @Override
public Object run(Object arguments) throws Exception {
String[] args= Platform.getCommandLineArgs();//getCommand//processCommandLine((String[]) arguments);
return new Integer(runTests(args));
diff --git a/bundles/org.eclipse.test/src/org/eclipse/test/EclipseTestRunner.java b/bundles/org.eclipse.test/src/org/eclipse/test/EclipseTestRunner.java
index 68f1fc4..3221723 100644
--- a/bundles/org.eclipse.test/src/org/eclipse/test/EclipseTestRunner.java
+++ b/bundles/org.eclipse.test/src/org/eclipse/test/EclipseTestRunner.java
@@ -108,8 +108,7 @@
@Override
public void run() {
- try {
- BufferedReader reader= new BufferedReader(new InputStreamReader(fProcessOutput));
+ try (BufferedReader reader= new BufferedReader(new InputStreamReader(fProcessOutput))) {
String line= null;
while ((line= reader.readLine()) != null) {
fStream.println(line);
@@ -168,11 +167,11 @@
/**
* Formatters from the command line.
*/
- private static Vector<JUnitResultFormatter> fgFromCmdLine = new Vector<JUnitResultFormatter>();
+ private static Vector<JUnitResultFormatter> fgFromCmdLine = new Vector<>();
/**
* Holds the registered formatters.
*/
- private Vector<JUnitResultFormatter> formatters = new Vector<JUnitResultFormatter>();
+ private Vector<JUnitResultFormatter> formatters = new Vector<>();
/**
* Do we stop on errors.
*/
@@ -272,9 +271,9 @@
} else if (args[i].startsWith("formatter=")) {
formatterString = args[i].substring(10);
} else if (args[i].startsWith("propsfile=")) {
- FileInputStream in = new FileInputStream(args[i].substring(10));
- props.load(in);
- in.close();
+ try (FileInputStream in = new FileInputStream(args[i].substring(10))) {
+ props.load(in);
+ }
} else if (args[i].equals("-testlistener")) {
System.err.println("The -testlistener option is no longer supported\nuse the formatter= option instead");
return ERRORS;
@@ -509,6 +508,7 @@
assumeUiThreadIsResponsive = false;
display.asyncExec(new Runnable() {
+ @Override
public void run() {
assumeUiThreadIsResponsive= true;
@@ -788,18 +788,21 @@
/*
* @see TestListener.addFailure
*/
+ @Override
public void startTest(Test t) {
}
/*
* @see TestListener.addFailure
*/
+ @Override
public void endTest(Test test) {
}
/*
* @see TestListener.addFailure
*/
+ @Override
public void addFailure(Test test, AssertionFailedError t) {
if (fHaltOnFailure) {
fTestResult.stop();
@@ -809,6 +812,7 @@
/*
* @see TestListener.addError
*/
+ @Override
public void addError(Test test, Throwable t) {
if (fHaltOnError) {
fTestResult.stop();
diff --git a/bundles/org.eclipse.test/src/org/eclipse/test/RegressionTest.java b/bundles/org.eclipse.test/src/org/eclipse/test/RegressionTest.java
index 487db1c..2e82bbf 100644
--- a/bundles/org.eclipse.test/src/org/eclipse/test/RegressionTest.java
+++ b/bundles/org.eclipse.test/src/org/eclipse/test/RegressionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation 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
@@ -154,13 +154,13 @@
*/
static String readFile(String s) throws IOException {
byte[] buf = new byte[8192];
- FileInputStream r = new FileInputStream(s);
ByteArrayOutputStream aStream = new ByteArrayOutputStream();
- int n;
- while ((n = r.read(buf)) != -1) {
- aStream.write(buf, 0, n);
+ try (FileInputStream r = new FileInputStream(s)) {
+ int n;
+ while ((n = r.read(buf)) != -1) {
+ aStream.write(buf, 0, n);
+ }
}
- r.close();
return aStream.toString();
}
diff --git a/bundles/org.eclipse.test/src/org/eclipse/test/UITestApplication.java b/bundles/org.eclipse.test/src/org/eclipse/test/UITestApplication.java
index 4e5aaf2..b83a195 100644
--- a/bundles/org.eclipse.test/src/org/eclipse/test/UITestApplication.java
+++ b/bundles/org.eclipse.test/src/org/eclipse/test/UITestApplication.java
@@ -47,6 +47,7 @@
private IApplicationContext appContext;
+ @Override
public Object run(final Object args) throws Exception {
// Get the application to test
Object application = getApplication((String[])args);
@@ -159,46 +160,48 @@
// for the first time only.
final boolean[] started = { false };
workbench.addWindowListener(new IWindowListener() {
+ @Override
public void windowOpened(IWorkbenchWindow w) {
if (started[0])
return;
- w.getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- started[0] = true;
- try {
- fTestRunnerResult = EclipseTestRunner.run((String[]) args);
- } catch (IOException e) {
- e.printStackTrace();
- }
- workbench.close();
+ w.getShell().getDisplay().asyncExec(() -> {
+ started[0] = true;
+ try {
+ fTestRunnerResult = EclipseTestRunner.run((String[]) args);
+ } catch (IOException e) {
+ e.printStackTrace();
}
+ workbench.close();
});
}
+ @Override
public void windowActivated(IWorkbenchWindow window) {
}
+ @Override
public void windowDeactivated(IWorkbenchWindow window) {
}
+ @Override
public void windowClosed(IWorkbenchWindow window) {
}
});
return ((IPlatformRunnable) workbench).run(args);
}
+ @Override
public void runTests() {
fTestableObject.testingStarting();
- fTestableObject.runTest(new Runnable() {
- public void run() {
- try {
- fTestRunnerResult = EclipseTestRunner.run(Platform.getCommandLineArgs());
- } catch (IOException e) {
- e.printStackTrace();
- }
+ fTestableObject.runTest(() -> {
+ try {
+ fTestRunnerResult = EclipseTestRunner.run(Platform.getCommandLineArgs());
+ } catch (IOException e) {
+ e.printStackTrace();
}
});
fTestableObject.testingFinished();
}
+ @Override
public Object start(IApplicationContext context) throws Exception {
this.appContext = context;
String[] args = (String[]) appContext.getArguments().get("application.args");
@@ -208,6 +211,7 @@
}
+ @Override
public void stop() {
// TODO Auto-generated method stub