History log of /libcore/luni/src/test/java/libcore/java/util/LinkedHashMapTest.java
Revision Date Author Comments
508f0abe4f8686d29466b2c364cb4f60bf0484b5 16-Jan-2017 Tobias Thierer <tobiast@google.com> Basic tests for wrapper Collection factories in java.util.Collections

Basic test coverage for the wrapper Collections constructed by
the following static factory methods in java.util.Collections:

checkedNavigableMap()
checkedNavigableSet()
checkedQueue()
emptyNavigableMap()
emptyNavigableSet()
emptySortedMap()
emptySortedSet()
synchronizedNavigableMap()
synchronizedNavigableSet()
unmodifiableNavigableMap()
unmodifiableNavigableSet()

These 11 methods under test are the only ones currently annotated
@hide in Collections.java; this CL provides sufficient test coverage
for those to be un-hidden in a follow-up CL.

Most (perhaps all) aspects covered by these tests are also covered
by guava-testlib-21.0 tests, but those are not yet available in
AOSP and would take 80min to run, whereas these new tests only take
a few seconds to run.

SpliteratorTester previously contained some overly strict assertions
that Spliterator.trySplit() != null. This CL relaxes this assumption
for non-empty spliterables but adds a separate assertSupportsTrySplit()
check in the places that previously exercised this strict test logic;
Where the old tests appeared to be testing the wrong collection (e.g.
in HashSetTest), this CL asserts the support for trySplit on what
appears to be the correct Collection, but does not otherwise fix the
existing test code.

Bug: 29935305
Test: CtsLibcoreTestCases
Change-Id: Ibeac242bb60df7b06a1c8c80dc744707f734d91c
b7614d4830d62ea3980797669e69ade24ac0d98c 16-Aug-2016 Tobias Thierer <tobiast@google.com> Update TreeMap to OpenJDK8u60.

All existing local changes were kept:

* toplevel documentation link via openjdk-redirect.html

* naming of nested class TreeMapEntry
- added a test
- added an Android-changed comment block

* value of NavigableSubMap.serialVersionUID

* range checks for tailMap() / headMap()
- changed "BEGIN android" comment format to the more common
(640 vs. 69 occurences) format "Android-changed BEGIN".
- these are covered by the tests added in AOSP commit
26b39cc71ae9c0890b1c56f7062debd4b555811c

Existing tests in HashtableTest and LinkedHashMapTest differed
slightly from the new tests in TreeMapTest, so they were tweaked
to make them consistent.

Test: cts-tradefed run cts -p android.core.tests.libcore.package.libcore
Test: Guava 19.0 guava-testlib's testForTreeMapNatural() and
testsForTreeMapWithComparator() (96850 test methods run).

Bug: 29935305

Change-Id: Ia5064afa38c64b8ca0d08a91d1766958da58d6e6
9efb6d12ce4d2ffedb73d6e9887ea2c89f8ec129 08-Jun-2016 Narayan Kamath <narayan@google.com> Update HashMap, HashSet, LinkedHashMap to JDK8u60.

Added tests for:
- entrySet()/keySet()/values() spliterators (LinkedHashMap
has completely new implementations)
- LinkedHashMap.eldest (Android specific API, previously
existed but was untested)
- naming of nested class LinkedHashMap.LinkedHashMapEntry
- tweaked test for Map.getOrDefault() method so it's useful
for LinkedHashMap

This CL doesn't touch HashSetTest since it already covered
spliterator() and serialization.

Test: Ran all libcore tests.

Bug: 29935305
Change-Id: I9d991a08c403b83b15e9c88ce97cbd5cd77a8bcf
44e194b71d606cd7d1e8ebdfe80a45a587968b88 11-Aug-2016 Tobias Thierer <tobiast@google.com> Add test to verify new LinkedHashMap.removeEldestEntry() behavior.

The previous commit deliberately changed behavior by reverting
http://r.android.com/212434

This CL is adding a test for the new behavior. It is very similar
to the test for the old behavior that was removed by the previous
change.

Test: Ran all libcore tests at a later CL that will get merged
at the same time as this one.

Change-Id: Ia74aada58733110aa06278e6ad047b4b228dbc08
62e3fcccb91fa405516e6288239590ebac210dea 11-Aug-2016 Tobias Thierer <tobiast@google.com> Revert "Change LinkedHashMap#removeEldestEntry behaviour."

This reverts commit 9c4d5752a75ab0f1fa37aac2984629bf30cafa94.

Bug: 27964914
Change-Id: I984b093607128ba2de5f4a85c911f8106cd36a1a
0976dc2e109a3ca2bd977d18eee74e4b7c9ada30 04-Apr-2016 Shubham Ajmera <shubhamajmera@google.com> Add Map::replaceAll method

and corresponding unit test.

Bug: 27426743

(cherry-picked from commit 135ea6cd4f7ebe2f225351a1928d8a62bce5cb00)

Change-Id: Ia86b769fbf5ce55379325ae575d4b3818cb6ccc1
135ea6cd4f7ebe2f225351a1928d8a62bce5cb00 04-Apr-2016 Shubham Ajmera <shubhamajmera@google.com> Add Map::replaceAll method

and corresponding unit test.

Bug: 27426743
Change-Id: Ia86b769fbf5ce55379325ae575d4b3818cb6ccc1
9c4d5752a75ab0f1fa37aac2984629bf30cafa94 01-Apr-2016 Joachim Sauer <jsauer@google.com> Change LinkedHashMap#removeEldestEntry behaviour.

The move to OpenJDK changed the behaviour of the removeEldestEntry
method in a way that is incompatible with earlier Android versions.
While that behaviour was never documented, we try to be compatible for
now. Future Android releases will probably revert to behaviour that's
closer to the RI.

This is attempt #2. The behaviour of of the previous implementation was
even stranger then expected. removeEldestEntry() was called between
incrementing the size field and actually adding the entry. So any code
that inspected the map during the removeEldestEntry() call would see
a size that's 1 bigger than the actual elements (and the newly added
element would not be in the map yet).

The code to reproduce this in the OpenJDK based implementation is less
than elegant and should be removed for future releases.

Bug: 27929722
(cherry picked from commit 7a0fb3b1203df27e0bb3e5b1ee3346851f9af38d)

Change-Id: If4351b9979ba744d5c6556c73c1e23077b369b1b
7a0fb3b1203df27e0bb3e5b1ee3346851f9af38d 01-Apr-2016 Joachim Sauer <jsauer@google.com> Change LinkedHashMap#removeEldestEntry behaviour.

The move to OpenJDK changed the behaviour of the removeEldestEntry
method in a way that is incompatible with earlier Android versions.
While that behaviour was never documented, we try to be compatible for
now. Future Android releases will probably revert to behaviour that's
closer to the RI.

This is attempt #2. The behaviour of of the previous implementation was
even stranger then expected. removeEldestEntry() was called between
incrementing the size field and actually adding the entry. So any code
that inspected the map during the removeEldestEntry() call would see
a size that's 1 bigger than the actual elements (and the newly added
element would not be in the map yet).

The code to reproduce this in the OpenJDK based implementation is less
than elegant and should be removed for future releases.

Bug: 27929722
Change-Id: If6bf7fe7f7b2caa655e25b11f18b552c3b4844e4
aad2abaafbc03c7750d7e65f187dcefb4bbcc090 01-Apr-2016 Narayan Kamath <narayan@google.com> Revert "Change LinkedHashMap#removeEldestEntry behaviour."

This reverts commit fca5aaa0a2c31d322b708012df2158d8399cefe3.

Breaks org.apache.harmony.tests.java.util.LinkedHashMapTest#test_remove_eldest.

bug: 27929722

(cherry picked from commit 90932be12a5e012347549ad293d15015eb2410a9)

Change-Id: Id5b910e90fb08f4902215ad86e6dae16dc82dbb6
90932be12a5e012347549ad293d15015eb2410a9 01-Apr-2016 Narayan Kamath <narayan@google.com> Revert "Change LinkedHashMap#removeEldestEntry behaviour."

This reverts commit fca5aaa0a2c31d322b708012df2158d8399cefe3.

Breaks org.apache.harmony.tests.java.util.LinkedHashMapTest#test_remove_eldest.

Change-Id: I8b71e40f2d6c7e936a6d604d0326c2312cbb9459
bug: 27929722
452d7ae56a3d07eab0a422f68f0a391633931df8 01-Apr-2016 Joachim Sauer <jsauer@google.com> Change LinkedHashMap#removeEldestEntry behaviour.

The move to OpenJDK changed the behaviour of the removeEldestEntry
method in a way that is incompatible with earlier Android versions.
While that behaviour was never documented, we try to be compatible for
now. Future Android releases will probably revert to behaviour that's
closer to the RI.

Bug: 27929722
(cherry picked from commit fca5aaa0a2c31d322b708012df2158d8399cefe3)

Change-Id: I3151428cb9444212b40749d4f425f25e521a29c6
fca5aaa0a2c31d322b708012df2158d8399cefe3 01-Apr-2016 Joachim Sauer <jsauer@google.com> Change LinkedHashMap#removeEldestEntry behaviour.

The move to OpenJDK changed the behaviour of the removeEldestEntry
method in a way that is incompatible with earlier Android versions.
While that behaviour was never documented, we try to be compatible for
now. Future Android releases will probably revert to behaviour that's
closer to the RI.

Bug: 27929722
Change-Id: I8569ade68fe0abbd712b3e3551fc95a26e09ffd9
0e83756c4295f4df3853047205d94fe845573522 08-Mar-2016 Shubham Ajmera <shubhamajmera@google.com> Port OpenJDK8 changes in java.util.Map

& add tests.

The CL add tests for map default methods added in Java 8 - getOrDefault,
putIfAbsent, remove(K, V), replace(K, V, V), replace(K, V), forEach,
replaceAll, compute, computeIfAbsent, computeIfPresent, putIfAbsent,
merge.

Methods have been made synchronzed in Hashtable. They are using the
default map methods instead of taking the upstream changes.

Replace(K, V, V) in LinkedHashMap has been overridden as it doesn't
record access when the replace method doesn't make any replacement.

Bug: 27426743
(cherry-picked from commit 88f1a4f0b1efb746419672919654c285ce44fbc5)
Change-Id: Ifb2130698dd0ed42acc5c0f429496eebb444e21c
44aed07672d7775f168a49dbb5b8a13682c02600 08-Mar-2016 Shubham Ajmera <shubhamajmera@google.com> Port OpenJDK8 changes in java.util.Map

& add tests.

The CL add tests for map default methods added in Java 8 - getOrDefault,
putIfAbsent, remove(K, V), replace(K, V, V), replace(K, V), forEach,
replaceAll, compute, computeIfAbsent, computeIfPresent, putIfAbsent,
merge.

Methods have been made synchronzed in Hashtable. They are using the
default map methods instead of taking the upstream changes.

Replace(K, V, V) in LinkedHashMap has been overridden as it doesn't
record access when the replace method doesn't make any replacement.

Bug: 27426743

Change-Id: Ifb2130698dd0ed42acc5c0f429496eebb444e21c