Merge "Update junit with Android runner specific changes."
diff --git a/Android.mk b/Android.mk
index ef7e3af..4a842dd 100644
--- a/Android.mk
+++ b/Android.mk
@@ -15,10 +15,16 @@
 #
 
 LOCAL_PATH := $(call my-dir)
+
+# include definition of core-junit-files
+include $(LOCAL_PATH)/Common.mk
+
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
+# note: ideally this should be junit-host, but leave as is for now to avoid
+# changing all its dependencies
 LOCAL_MODULE := junit
 
 LOCAL_MODULE_TAGS := optional
@@ -26,3 +32,38 @@
 LOCAL_STATIC_JAVA_LIBRARIES := hamcrest-host
 
 include $(BUILD_HOST_JAVA_LIBRARY)
+
+# ----------------------------------
+# build a core-junit target jar that is built into Android system image
+
+include $(CLEAR_VARS)
+
+# TODO: remove extensions once core-tests is no longer dependent on it
+LOCAL_SRC_FILES := $(call all-java-files-under, src/junit/extensions)
+LOCAL_SRC_FILES += $(core-junit-files)
+
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES := core
+LOCAL_JAVACFLAGS := $(local_javac_flags)
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := core-junit
+include $(BUILD_JAVA_LIBRARY)
+
+# ----------------------------------
+# build a core-junit-hostdex jar that contains exactly the same classes
+# as core-junit.
+
+include $(CLEAR_VARS)
+
+# TODO: remove extensions once apache-harmony/luni/ is no longer dependent
+# on it
+LOCAL_SRC_FILES := $(call all-java-files-under, src/junit/extensions)
+LOCAL_SRC_FILES += $(core-junit-files)
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES := core-hostdex
+LOCAL_JAVACFLAGS := $(local_javac_flags)
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := core-junit-hostdex
+LOCAL_BUILD_HOST_DEX := true
+include $(BUILD_HOST_JAVA_LIBRARY)
+
diff --git a/Common.mk b/Common.mk
new file mode 100644
index 0000000..2275c9b
--- /dev/null
+++ b/Common.mk
@@ -0,0 +1,31 @@
+# -*- mode: makefile -*-
+# List of junit files include in documentation.
+# Shared with frameworks/base.
+# based off libcore/Docs.mk
+
+
+# List of source to build into the core-junit library
+#
+# The list also includes all junit files in public API.
+#
+core-junit-files := \
+src/junit/framework/Assert.java \
+src/junit/framework/AssertionFailedError.java \
+src/junit/framework/ComparisonCompactor.java \
+src/junit/framework/ComparisonFailure.java \
+src/junit/framework/Protectable.java \
+src/junit/framework/Test.java \
+src/junit/framework/TestCase.java \
+src/junit/framework/TestFailure.java \
+src/junit/framework/TestListener.java \
+src/junit/framework/TestResult.java \
+src/junit/framework/TestSuite.java
+
+# TODO: add define for public API files in android.test.runner
+
+# List of junit javadoc source files for Android public API
+#
+# $(1): directory for search (to support use from frameworks/base)
+define junit_to_document
+ $(core-junit-files)
+endef
diff --git a/src/junit/extensions/package.html b/src/junit/extensions/package.html
new file mode 100644
index 0000000..6b4be72
--- /dev/null
+++ b/src/junit/extensions/package.html
@@ -0,0 +1,6 @@
+<HTML>
+<BODY>
+Utility classes supporting the junit test framework.
+{@hide} - Not needed for 1.0 SDK 
+</BODY>
+</HTML>
diff --git a/src/junit/framework/ComparisonCompactor.java b/src/junit/framework/ComparisonCompactor.java
index bbc3ba1..24ad42f 100644
--- a/src/junit/framework/ComparisonCompactor.java
+++ b/src/junit/framework/ComparisonCompactor.java
@@ -1,5 +1,9 @@
 package junit.framework;
 
+// android-changed add @hide
+/**
+ * @hide not needed for public API
+ */
 public class ComparisonCompactor {
 
 	private static final String ELLIPSIS= "...";
diff --git a/src/junit/framework/TestResult.java b/src/junit/framework/TestResult.java
index 5768e9a..3052e94 100644
--- a/src/junit/framework/TestResult.java
+++ b/src/junit/framework/TestResult.java
@@ -4,6 +4,7 @@
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.Vector;
 
 /**
  * A <code>TestResult</code> collects the results of executing
@@ -15,16 +16,20 @@
  * @see Test
  */
 public class TestResult extends Object {
-	protected List<TestFailure> fFailures;
-	protected List<TestFailure> fErrors;
-	protected List<TestListener> fListeners;
+	// BEGIN android-changed changed types from List<> to Vector<> for API compatibility
+	protected Vector<TestFailure> fFailures;
+	protected Vector<TestFailure> fErrors;
+	protected Vector<TestListener> fListeners;
+	// END android-changed
 	protected int fRunTests;
 	private boolean fStop;
 	
 	public TestResult() {
-		fFailures= new ArrayList<TestFailure>();
-		fErrors= new ArrayList<TestFailure>();
-		fListeners= new ArrayList<TestListener>();
+		// BEGIN android-changed to Vector
+		fFailures= new Vector<TestFailure>();
+		fErrors= new Vector<TestFailure>();
+		fListeners= new Vector<TestListener>();
+		// END android-changed
 		fRunTests= 0;
 		fStop= false;
 	}
@@ -166,4 +171,4 @@
 	public synchronized boolean wasSuccessful() {
 		return failureCount() == 0 && errorCount() == 0;
 	}
-}
\ No newline at end of file
+}
diff --git a/src/junit/framework/package.html b/src/junit/framework/package.html
new file mode 100644
index 0000000..770d470
--- /dev/null
+++ b/src/junit/framework/package.html
@@ -0,0 +1,5 @@
+<HTML>
+<BODY>
+The junit test framework.
+</BODY>
+</HTML>