Update JSR166 tck tests.
The following tests have been omitted because they are
unsupported :
- Atomic8Test.java
- CompletableFutureTest.java
- ConcurrentHashMap8Test.java
- DoubleAccumulatorTest.java
- DoubleAdderTest.java
- ForkJoinPool8Test.java
- ForkJoinTask8Test.java
- LongAccumulatorTest.java
- LongAdderTest.java
- SplittableRandomTest.java
- StampedLockTest.java
- ThreadLocalRandom8Test.java
- ThreadPoolExecutor9Test.java
A package declaration has been added to all files (package jsr166;)
and the base-class JSR166Test has been changed not to rely on features
that aren't available on android / junit in the android environment.
We also avoid using junit4 style TestSuite declarations. While the CTS
test runner handles them properly usually, it trips over itself when it
encounters a failure and tries to run each test in an invidual process
and fails each test for no good reason (needs investigation on the CTS
side of things)
bug: 20628776
(cherry picked from commit 5da8b2b3cac51f0f592a5e1941bd84eade9648cd)
Change-Id: If35be0881ad8da4c604ce6683149b15c1a85f289
diff --git a/jsr166-tests/src/test/java/jsr166/TreeMapTest.java b/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
index 87baa1a..afc73de 100644
--- a/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
+++ b/jsr166-tests/src/test/java/jsr166/TreeMapTest.java
@@ -6,10 +6,31 @@
package jsr166;
-import junit.framework.*;
-import java.util.*;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.NavigableSet;
+import java.util.NoSuchElementException;
+import java.util.Random;
+import java.util.Set;
+import java.util.TreeMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
public class TreeMapTest extends JSR166TestCase {
+ // android-note: Removed because the CTS runner does a bad job of
+ // retrying tests that have suite() declarations.
+ //
+ // public static void main(String[] args) {
+ // main(suite(), args);
+ // }
+ // public static Test suite() {
+ // return new TestSuite(...);
+ // }
/**
* Returns a new map from Integers 1-5 to Strings "A"-"E".
@@ -559,8 +580,8 @@
* get(null) of nonempty map throws NPE
*/
public void testGet_NullPointerException() {
+ TreeMap c = map5();
try {
- TreeMap c = map5();
c.get(null);
shouldThrow();
} catch (NullPointerException success) {}
@@ -570,8 +591,8 @@
* containsKey(null) of nonempty map throws NPE
*/
public void testContainsKey_NullPointerException() {
+ TreeMap c = map5();
try {
- TreeMap c = map5();
c.containsKey(null);
shouldThrow();
} catch (NullPointerException success) {}
@@ -581,9 +602,9 @@
* remove(null) throws NPE for nonempty map
*/
public void testRemove1_NullPointerException() {
+ TreeMap c = new TreeMap();
+ c.put("sadsdf", "asdads");
try {
- TreeMap c = new TreeMap();
- c.put("sadsdf", "asdads");
c.remove(null);
shouldThrow();
} catch (NullPointerException success) {}
@@ -819,7 +840,7 @@
// Add entries till we're back to original size
while (map.size() < size) {
int key = min + rnd.nextInt(rangeSize);
- assertTrue(key >= min && key<= max);
+ assertTrue(key >= min && key <= max);
put(map, key);
}
}
@@ -844,7 +865,7 @@
// Add entries till we're back to original size
while (map.size() < size) {
int key = min - 5 + rnd.nextInt(rangeSize + 10);
- if (key >= min && key<= max) {
+ if (key >= min && key <= max) {
put(map, key);
} else {
try {