Skip to content

Commit 323f225

Browse files
committed
Syncs unit tests affected by this PR with the Android libcore latest.
1 parent 3131aec commit 323f225

15 files changed

Lines changed: 346 additions & 250 deletions

File tree

jre_emul/android/platform/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/AbstractCollectionTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one or more
3-
* contributor license agreements. See the NOTICE file distributed with
4-
* this work for additional information regarding copyright ownership.
5-
* The ASF licenses this file to You under the Apache License, Version 2.0
6-
* (the "License"); you may not use this file except in compliance with
7-
* the License. You may obtain a copy of the License at
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
88
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
9+
* http://www.apache.org/licenses/LICENSE-2.0
1010
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
1616
*/
1717

1818
package org.apache.harmony.tests.java.util;
@@ -285,7 +285,7 @@ public int size() {
285285
}
286286
};
287287
try {
288-
ac.toArray(null);
288+
ac.toArray((Object[]) null);
289289
fail("No expected NullPointerException");
290290
} catch (NullPointerException e) {
291291
// expected

jre_emul/android/platform/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ArrayDequeTest.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one or more
3-
* contributor license agreements. See the NOTICE file distributed with
4-
* this work for additional information regarding copyright ownership.
5-
* The ASF licenses this file to You under the Apache License, Version 2.0
6-
* (the "License"); you may not use this file except in compliance with
7-
* the License. You may obtain a copy of the License at
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
88
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
9+
* http://www.apache.org/licenses/LICENSE-2.0
1010
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
1616
*/
1717

1818
package org.apache.harmony.tests.java.util;
@@ -31,6 +31,9 @@
3131

3232
import libcore.java.util.ForEachRemainingTester;
3333
import libcore.java.util.SpliteratorTester;
34+
import libcore.test.annotation.NonCts;
35+
import libcore.test.reasons.NonCtsReasons;
36+
3437
import org.apache.harmony.testframework.serialization.SerializationTest;
3538
import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
3639

@@ -592,6 +595,7 @@ public void test_isEmpty() throws Exception {
592595
/**
593596
* {@link java.util.ArrayDeque#iterator()}
594597
*/
598+
@NonCts(bug = 287231726, reason = NonCtsReasons.NON_BREAKING_BEHAVIOR_FIX)
595599
public void test_iterator() throws Exception {
596600
assertFalse(testQue.iterator().hasNext());
597601
assertTrue(testQue.add(testObjOne));
@@ -608,12 +612,7 @@ public void test_iterator() throws Exception {
608612
// expected
609613
}
610614
assertTrue(testQue.add(testObjThree));
611-
try {
612-
result.next();
613-
fail("should throw ConcurrentModificationException");
614-
} catch (ConcurrentModificationException e) {
615-
// expected
616-
}
615+
617616
result = testQue.iterator();
618617
assertEquals(testObjOne, result.next());
619618
assertEquals(testObjTwo, result.next());
@@ -868,7 +867,7 @@ public void test_toArray() throws Exception {
868867
assertEquals(5, testQue.size());
869868
assertEquals(testObjOne, testQue.peek());
870869
try {
871-
testQue.toArray(null);
870+
testQue.toArray((Object[]) null);
872871
fail("should throw NullPointerException");
873872
} catch (NullPointerException e) {
874873
// expected
@@ -903,6 +902,7 @@ public void test_forEachRemaining_iterator() throws Exception {
903902
new String[]{"foo", "bar", "baz "});
904903
}
905904

905+
@NonCts(bug = 287231726, reason = NonCtsReasons.NON_BREAKING_BEHAVIOR_FIX)
906906
public void test_forEachRemaining_CME() throws Exception {
907907
ArrayDeque<String> adq = new ArrayDeque<>();
908908
adq.add("foo");
@@ -947,11 +947,11 @@ public void test_spliterator_CME() throws Exception {
947947
* java.util.ArrayDeque#Serialization()
948948
*/
949949
public void test_serialization() throws Exception {
950-
assertTrue(testQue.add(new Integer(1)));
951-
assertTrue(testQue.add(new Integer(2)));
952-
assertTrue(testQue.add(new Integer(3)));
953-
assertTrue(testQue.add(new Integer(4)));
954-
assertTrue(testQue.add(new Integer(5)));
950+
assertTrue(testQue.add(Integer.valueOf(1)));
951+
assertTrue(testQue.add(Integer.valueOf(2)));
952+
assertTrue(testQue.add(Integer.valueOf(3)));
953+
assertTrue(testQue.add(Integer.valueOf(4)));
954+
assertTrue(testQue.add(Integer.valueOf(5)));
955955
SerializationTest.verifySelf(testQue, new SerializableAssert() {
956956
public void assertDeserialized(Serializable initial,
957957
Serializable deserialized) {
@@ -967,11 +967,11 @@ public void assertDeserialized(Serializable initial,
967967
*/
968968
@SuppressWarnings({ "unchecked", "boxing" })
969969
public void testSerializationCompatibility() throws Exception {
970-
assertTrue(testQue.add(new Integer(1)));
971-
assertTrue(testQue.add(new Integer(2)));
972-
assertTrue(testQue.add(new Integer(3)));
973-
assertTrue(testQue.add(new Integer(4)));
974-
assertTrue(testQue.add(new Integer(5)));
970+
assertTrue(testQue.add(Integer.valueOf(1)));
971+
assertTrue(testQue.add(Integer.valueOf(2)));
972+
assertTrue(testQue.add(Integer.valueOf(3)));
973+
assertTrue(testQue.add(Integer.valueOf(4)));
974+
assertTrue(testQue.add(Integer.valueOf(5)));
975975
SerializationTest.verifyGolden(this, testQue, new SerializableAssert() {
976976
public void assertDeserialized(Serializable initial,
977977
Serializable deserialized) {

jre_emul/android/platform/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/LinkedHashSetTest.java

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* (the "License"); you may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -119,12 +119,12 @@ public void test_ConstructorLjava_util_Collection() {
119119
public void test_addLjava_lang_Object() {
120120
// Test for method boolean java.util.LinkedHashSet.add(java.lang.Object)
121121
int size = hs.size();
122-
hs.add(new Integer(8));
122+
hs.add(Integer.valueOf(8));
123123
assertTrue("Added element already contained by set", hs.size() == size);
124-
hs.add(new Integer(-9));
124+
hs.add(Integer.valueOf(-9));
125125
assertTrue("Failed to increment set size after add",
126126
hs.size() == size + 1);
127-
assertTrue("Failed to add element to set", hs.contains(new Integer(-9)));
127+
assertTrue("Failed to add element to set", hs.contains(Integer.valueOf(-9)));
128128
}
129129

130130
/**
@@ -207,8 +207,8 @@ public void test_removeLjava_lang_Object() {
207207
// Test for method boolean
208208
// java.util.LinkedHashSet.remove(java.lang.Object)
209209
int size = hs.size();
210-
hs.remove(new Integer(98));
211-
assertTrue("Failed to remove element", !hs.contains(new Integer(98)));
210+
hs.remove(Integer.valueOf(98));
211+
assertTrue("Failed to remove element", !hs.contains(Integer.valueOf(98)));
212212
assertTrue("Failed to decrement set size", hs.size() == size - 1);
213213

214214
LinkedHashSet s = new LinkedHashSet();
@@ -236,27 +236,27 @@ public boolean retainAll(Collection c) {
236236
public void test_retainAllLjava_util_Collection() {
237237
LinkedHashSet<Integer> lhs = new LinkedHashSet<Integer>();
238238
Vector v = new Vector<Float>();
239-
v.add(new Float(3.14));
240-
lhs.add(new Integer(1));
239+
v.add(Float.valueOf(3.14f));
240+
lhs.add(Integer.valueOf(1));
241241
assertEquals(1, lhs.size());
242242
lhs.retainAll(v);
243243
assertEquals(0, lhs.size());
244244
v = new Vector<Integer>();
245-
v.add(new Integer(1));
246-
v.add(new Integer(2));
247-
v.add(new Integer(3));
248-
v.add(new Integer(4));
249-
v.add(new Integer(5));
250-
v.add(new Integer(6));
251-
lhs.add(new Integer(1));
252-
lhs.add(new Integer(6));
253-
lhs.add(new Integer(7));
254-
lhs.add(new Integer(8));
255-
lhs.add(new Integer(9));
256-
lhs.add(new Integer(10));
257-
lhs.add(new Integer(11));
258-
lhs.add(new Integer(12));
259-
lhs.add(new Integer(13));
245+
v.add(Integer.valueOf(1));
246+
v.add(Integer.valueOf(2));
247+
v.add(Integer.valueOf(3));
248+
v.add(Integer.valueOf(4));
249+
v.add(Integer.valueOf(5));
250+
v.add(Integer.valueOf(6));
251+
lhs.add(Integer.valueOf(1));
252+
lhs.add(Integer.valueOf(6));
253+
lhs.add(Integer.valueOf(7));
254+
lhs.add(Integer.valueOf(8));
255+
lhs.add(Integer.valueOf(9));
256+
lhs.add(Integer.valueOf(10));
257+
lhs.add(Integer.valueOf(11));
258+
lhs.add(Integer.valueOf(12));
259+
lhs.add(Integer.valueOf(13));
260260
assertEquals(9, lhs.size());
261261
lhs.retainAll(v);
262262
assertEquals(2, lhs.size());
@@ -280,15 +280,15 @@ public void test_retainAllLjava_util_Collection() {
280280

281281
public void test_toArray() {
282282
LinkedHashSet<Integer> lhs = new LinkedHashSet<Integer>();
283-
lhs.add(new Integer(1));
284-
lhs.add(new Integer(6));
285-
lhs.add(new Integer(7));
286-
lhs.add(new Integer(8));
287-
lhs.add(new Integer(9));
288-
lhs.add(new Integer(10));
289-
lhs.add(new Integer(11));
290-
lhs.add(new Integer(12));
291-
lhs.add(new Integer(13));
283+
lhs.add(Integer.valueOf(1));
284+
lhs.add(Integer.valueOf(6));
285+
lhs.add(Integer.valueOf(7));
286+
lhs.add(Integer.valueOf(8));
287+
lhs.add(Integer.valueOf(9));
288+
lhs.add(Integer.valueOf(10));
289+
lhs.add(Integer.valueOf(11));
290+
lhs.add(Integer.valueOf(12));
291+
lhs.add(Integer.valueOf(13));
292292

293293
Object[] o = lhs.toArray();
294294
for (int i = 0; i < o.length; i++) {
@@ -299,15 +299,15 @@ public void test_toArray() {
299299

300300
public void test_toArray$Ljava_lang_Object() {
301301
LinkedHashSet<Integer> lhs = new LinkedHashSet<Integer>();
302-
lhs.add(new Integer(1));
303-
lhs.add(new Integer(6));
304-
lhs.add(new Integer(7));
305-
lhs.add(new Integer(8));
306-
lhs.add(new Integer(9));
307-
lhs.add(new Integer(10));
308-
lhs.add(new Integer(11));
309-
lhs.add(new Integer(12));
310-
lhs.add(new Integer(13));
302+
lhs.add(Integer.valueOf(1));
303+
lhs.add(Integer.valueOf(6));
304+
lhs.add(Integer.valueOf(7));
305+
lhs.add(Integer.valueOf(8));
306+
lhs.add(Integer.valueOf(9));
307+
lhs.add(Integer.valueOf(10));
308+
lhs.add(Integer.valueOf(11));
309+
lhs.add(Integer.valueOf(12));
310+
lhs.add(Integer.valueOf(13));
311311

312312
Object[] o1 = new Object[lhs.size()];
313313
Object[] o2 = new Double[lhs.size()];
@@ -317,7 +317,7 @@ public void test_toArray() {
317317
}
318318

319319
try {
320-
lhs.toArray(null);
320+
lhs.toArray((Object[]) null);
321321
fail("NullPointerException expected");
322322
} catch (NullPointerException e) {
323323
//expected
@@ -358,7 +358,7 @@ public void test_spliterator() throws Exception {
358358
protected void setUp() {
359359
objArray = new Object[1000];
360360
for (int i = 0; i < objArray.length; i++)
361-
objArray[i] = new Integer(i);
361+
objArray[i] = Integer.valueOf(i);
362362

363363
hs = new LinkedHashSet();
364364
for (int i = 0; i < objArray.length; i++)

jre_emul/android/platform/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/LinkedListTest.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one or more
3-
* contributor license agreements. See the NOTICE file distributed with
4-
* this work for additional information regarding copyright ownership.
5-
* The ASF licenses this file to You under the Apache License, Version 2.0
6-
* (the "License"); you may not use this file except in compliance with
7-
* the License. You may obtain a copy of the License at
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
88
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
9+
* http://www.apache.org/licenses/LICENSE-2.0
1010
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
1616
*/
1717

1818
package org.apache.harmony.tests.java.util;
@@ -65,7 +65,7 @@ public void test_Constructor() {
6565

6666
LinkedList subList = new LinkedList();
6767
for (int i = -50; i < 150; i++)
68-
subList.add(new Integer(i));
68+
subList.add(Integer.valueOf(i));
6969
new Support_ListTest("", subList.subList(50, 150)).runTest();
7070
}
7171

@@ -411,7 +411,7 @@ public void test_indexOfLjava_lang_Object() {
411411
public void test_lastIndexOfLjava_lang_Object() {
412412
// Test for method int
413413
// java.util.LinkedList.lastIndexOf(java.lang.Object)
414-
ll.add(new Integer(99));
414+
ll.add(Integer.valueOf(99));
415415
assertEquals("Returned incorrect index",
416416
100, ll.lastIndexOf(objArray[99]));
417417
assertEquals("Returned index for invalid Object", -1, ll
@@ -646,7 +646,7 @@ public void test_toArray() {
646646
assertTrue("Lists are not equal", li.next() == ri.next());
647647

648648
try {
649-
ll.toArray(null);
649+
ll.toArray((Object[]) null);
650650
fail("NullPointerException expected");
651651
} catch (NullPointerException e) {
652652
//expected
@@ -996,11 +996,11 @@ public void test_removeIf() {
996996
* java.util.LinkedList#Serialization()
997997
*/
998998
public void test_serialization() throws Exception {
999-
assertTrue(ll.add(new Integer(1)));
1000-
assertTrue(ll.add(new Integer(2)));
1001-
assertTrue(ll.add(new Integer(3)));
1002-
assertTrue(ll.add(new Integer(4)));
1003-
assertTrue(ll.add(new Integer(5)));
999+
assertTrue(ll.add(Integer.valueOf(1)));
1000+
assertTrue(ll.add(Integer.valueOf(2)));
1001+
assertTrue(ll.add(Integer.valueOf(3)));
1002+
assertTrue(ll.add(Integer.valueOf(4)));
1003+
assertTrue(ll.add(Integer.valueOf(5)));
10041004
SerializationTest.verifySelf(ll, new SerializableAssert() {
10051005
public void assertDeserialized(Serializable initial,
10061006
Serializable deserialized) {
@@ -1020,7 +1020,7 @@ protected void setUp() throws Exception {
10201020

10211021
objArray = new Object[100];
10221022
for (int i = 0; i < objArray.length; i++) {
1023-
objArray[i] = new Integer(i);
1023+
objArray[i] = Integer.valueOf(i);
10241024
}
10251025

10261026
ll = new LinkedList();

0 commit comments

Comments
 (0)