Update junit with Android runner specific changes.
Copied from source from frameworks/base/test-runner/src/junit.
Bug 5826326
Change-Id: Ia8df5765fb0271bb9753c3e20f91d204fd8a3419
diff --git a/src/junit/runner/BaseTestRunner.java b/src/junit/runner/BaseTestRunner.java
index 6a4b090..e7e0431 100644
--- a/src/junit/runner/BaseTestRunner.java
+++ b/src/junit/runner/BaseTestRunner.java
@@ -62,7 +62,8 @@
}
}
- public static void setPreference(String key, String value) {
+ // android-changed remove 'static' qualifier for API compatibility
+ public void setPreference(String key, String value) {
getPreferences().put(key, value);
}
@@ -200,6 +201,17 @@
*/
protected abstract void runFailed(String message);
+ // BEGIN android-changed - add back getLoader() for API compatibility
+ /**
+ * Returns the loader to be used.
+ *
+ * @deprecated not present in JUnit4.10
+ */
+ public TestSuiteLoader getLoader() {
+ return new StandardTestSuiteLoader();
+ }
+ // END android-changed
+
/**
* Returns the loaded Class for a suite name.
*/
@@ -265,6 +277,13 @@
return BaseTestRunner.getFilteredTrace(trace);
}
+ // BEGIN android-changed - add back this method for API compatibility
+ /** @deprecated not present in JUnit4.10 */
+ public static boolean inVAJava() {
+ return false;
+ }
+ // END android-changed
+
/**
* Filters stack frames from internal JUnit classes
*/
@@ -275,7 +294,10 @@
StringWriter sw= new StringWriter();
PrintWriter pw= new PrintWriter(sw);
StringReader sr= new StringReader(stack);
- BufferedReader br= new BufferedReader(sr);
+ // BEGIN android-changed
+ // Use a sensible default buffer size
+ BufferedReader br= new BufferedReader(sr, 1000);
+ // END android-changed
String line;
try {
diff --git a/src/junit/runner/StandardTestSuiteLoader.java b/src/junit/runner/StandardTestSuiteLoader.java
new file mode 100644
index 0000000..808963a
--- /dev/null
+++ b/src/junit/runner/StandardTestSuiteLoader.java
@@ -0,0 +1,23 @@
+package junit.runner;
+
+// android-changed - class not present in upstream JUnit 4.10
+// added here to retain BaseTestRunner.getLoader API
+
+/**
+ * The standard test suite loader. It can only load the same class once.
+ * {@hide}
+ */
+public class StandardTestSuiteLoader implements TestSuiteLoader {
+ /**
+ * Uses the system class loader to load the test class
+ */
+ public Class load(String suiteClassName) throws ClassNotFoundException {
+ return Class.forName(suiteClassName);
+ }
+ /**
+ * Uses the system class loader to load the test class
+ */
+ public Class reload(Class aClass) throws ClassNotFoundException {
+ return aClass;
+ }
+}
diff --git a/src/junit/runner/TestRunListener.java b/src/junit/runner/TestRunListener.java
index b11ef07..0e95819 100644
--- a/src/junit/runner/TestRunListener.java
+++ b/src/junit/runner/TestRunListener.java
@@ -4,6 +4,7 @@
* execution of a test run. Unlike TestListener,
* this interface using only primitive objects,
* making it suitable for remote test execution.
+ * {@hide} - Not needed for 1.0 SDK
*/
public interface TestRunListener {
/* test status constants*/
diff --git a/src/junit/runner/TestSuiteLoader.java b/src/junit/runner/TestSuiteLoader.java
new file mode 100644
index 0000000..75a96fe
--- /dev/null
+++ b/src/junit/runner/TestSuiteLoader.java
@@ -0,0 +1,12 @@
+package junit.runner;
+
+/**
+ * An interface to define how a test suite should be loaded.
+ *
+ * // android-changed
+ * @deprecated unused and not present in current upstream JUnit
+ */
+public interface TestSuiteLoader {
+ abstract public Class load(String suiteClassName) throws ClassNotFoundException;
+ abstract public Class reload(Class aClass) throws ClassNotFoundException;
+}
diff --git a/src/junit/runner/Version.java b/src/junit/runner/Version.java
index eb4794b..dd88c03 100644
--- a/src/junit/runner/Version.java
+++ b/src/junit/runner/Version.java
@@ -11,7 +11,9 @@
public static String id() {
return "4.10";
}
-
+
+ // android-changed
+ /** @hide - not needed for public API */
public static void main(String[] args) {
System.out.println(id());
}
diff --git a/src/junit/textui/ResultPrinter.java b/src/junit/textui/ResultPrinter.java
index f2f01f5..b491452 100644
--- a/src/junit/textui/ResultPrinter.java
+++ b/src/junit/textui/ResultPrinter.java
@@ -2,7 +2,9 @@
package junit.textui;
import java.io.PrintStream;
-import java.text.NumberFormat;
+// android-changed
+// The following line was removed for compatibility with Android libraries.
+// import java.text.NumberFormat;
import java.util.Enumeration;
import junit.framework.AssertionFailedError;
@@ -99,7 +101,10 @@
* Duplicated from BaseTestRunner. Fix it.
*/
protected String elapsedTimeAsString(long runTime) {
- return NumberFormat.getInstance().format((double)runTime/1000);
+ // android-changed
+ // The following line was altered for compatibility with
+ // Android libraries.
+ return Double.toString((double)runTime/1000);
}
public PrintStream getWriter() {