Add JUnit 4 TestRule for running tests with a specific target SDK
Refactors code to replace lots of custom code for testing behavior for
specific target SDK versions, whether it is try...finally... blocks or
methods using lambdas with a JUnit 4 TestRule.
As the tests were JUnit 3 that also required switching them from
extending TestCase to extending TestCaseWithRules which adds support
for JUnit 4 TestRules to TestCase.
This is preparation work for some follow up work on ObjectStreamClass.
Test: atest \
core-tests:org.apache.harmony.tests.java.io.ObjectStreamClassTest \
core-tests:libcore.java.lang.OldRuntimeTest \
core-tests:libcore.java.lang.PackageTest \
core-tests:libcore.java.lang.reflect.annotations.AnnotationsTest \
core-tests:libcore.java.util.CollectionsTest \
core-tests:org.apache.harmony.regex.tests.java.util.regex.PatternTest \
core-tests:libcore.junit.util.SwitchTargetSdkVersionRuleTest
Bug: 109930347
Change-Id: I4ea11288eb344eaeb2e6cc9f3225748e518e1827
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index e763224..066a0ac 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -467,6 +467,7 @@
"harmony-tests/src/test/java/**/*.java",
"json/src/test/java/**/*.java",
"luni/src/test/java/**/*.java",
+ "test-rules/src/test/java/**/*.java",
"xml/src/test/java/**/*.java",
],
exclude_srcs: [