4 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
< |
import junit.framework.*; |
8 |
< |
import java.util.*; |
9 |
< |
import static java.util.Spliterator.*; |
10 |
< |
import java.util.function.*; |
11 |
< |
import java.util.concurrent.atomic.LongAdder; |
7 |
> |
import static java.util.Spliterator.CONCURRENT; |
8 |
> |
import static java.util.Spliterator.DISTINCT; |
9 |
> |
import static java.util.Spliterator.NONNULL; |
10 |
> |
|
11 |
> |
import java.util.AbstractMap; |
12 |
> |
import java.util.Arrays; |
13 |
> |
import java.util.Collection; |
14 |
> |
import java.util.Collections; |
15 |
> |
import java.util.Iterator; |
16 |
> |
import java.util.Map; |
17 |
> |
import java.util.NoSuchElementException; |
18 |
> |
import java.util.Set; |
19 |
> |
import java.util.Spliterator; |
20 |
> |
import java.util.Vector; |
21 |
|
import java.util.concurrent.ConcurrentHashMap; |
22 |
< |
import java.util.concurrent.ConcurrentHashMap.KeySetView; |
22 |
> |
import java.util.concurrent.atomic.LongAdder; |
23 |
> |
import java.util.function.BiFunction; |
24 |
> |
|
25 |
> |
import junit.framework.Test; |
26 |
> |
import junit.framework.TestSuite; |
27 |
|
|
28 |
|
public class ConcurrentHashMap8Test extends JSR166TestCase { |
29 |
|
public static void main(String[] args) { |
180 |
|
return a; |
181 |
|
} |
182 |
|
|
183 |
< |
/* |
183 |
> |
/** |
184 |
|
* replaceAll replaces all matching values. |
185 |
|
*/ |
186 |
|
public void testReplaceAll() { |
187 |
|
ConcurrentHashMap<Integer, String> map = map5(); |
188 |
< |
map.replaceAll((x, y) -> {return x > 3 ? "Z" : y;}); |
188 |
> |
map.replaceAll((x, y) -> { return x > 3 ? "Z" : y; }); |
189 |
|
assertEquals("A", map.get(one)); |
190 |
|
assertEquals("B", map.get(two)); |
191 |
|
assertEquals("C", map.get(three)); |
210 |
|
Set set1 = map.keySet(); |
211 |
|
Set set2 = map.keySet(true); |
212 |
|
set2.add(six); |
213 |
< |
assertTrue(((KeySetView)set2).getMap() == map); |
214 |
< |
assertTrue(((KeySetView)set1).getMap() == map); |
213 |
> |
assertTrue(((ConcurrentHashMap.KeySetView)set2).getMap() == map); |
214 |
> |
assertTrue(((ConcurrentHashMap.KeySetView)set1).getMap() == map); |
215 |
|
assertEquals(set2.size(), map.size()); |
216 |
|
assertEquals(set1.size(), map.size()); |
217 |
|
assertTrue((Boolean)map.get(six)); |
303 |
|
map.keySet(null); |
304 |
|
shouldThrow(); |
305 |
|
} catch (NullPointerException e) {} |
306 |
< |
KeySetView set = map.keySet(one); |
306 |
> |
ConcurrentHashMap.KeySetView set = map.keySet(one); |
307 |
|
set.add(one); |
308 |
|
set.add(six); |
309 |
|
set.add(seven); |
318 |
|
assertEquals(requiredCharacteristics, |
319 |
|
requiredCharacteristics & sp.characteristics()); |
320 |
|
} |
321 |
< |
|
321 |
> |
|
322 |
|
/** |
323 |
|
* KeySetView.spliterator returns spliterator over the elements in this set |
324 |
|
*/ |
552 |
|
|
553 |
|
assertNotSame(x, y); |
554 |
|
assertEquals(x.size(), y.size()); |
542 |
– |
assertEquals(x.toString(), y.toString()); |
543 |
– |
assertTrue(Arrays.equals(x.toArray(), y.toArray())); |
555 |
|
assertEquals(x, y); |
556 |
|
assertEquals(y, x); |
557 |
|
} |
1003 |
|
public void testSearchValuesSequentially() { |
1004 |
|
ConcurrentHashMap<Long, Long> m = longMap(); |
1005 |
|
Long r; |
1006 |
< |
r = m.searchValues(Long.MAX_VALUE, (Long x) -> x.longValue() == (long)(SIZE/2)? x : null); |
1006 |
> |
r = m.searchValues(Long.MAX_VALUE, |
1007 |
> |
(Long x) -> (x.longValue() == (long)(SIZE/2)) ? x : null); |
1008 |
|
assertEquals((long)r, (long)(SIZE/2)); |
1009 |
< |
r = m.searchValues(Long.MAX_VALUE, (Long x) -> x.longValue() < 0L ? x : null); |
1009 |
> |
r = m.searchValues(Long.MAX_VALUE, |
1010 |
> |
(Long x) -> (x.longValue() < 0L) ? x : null); |
1011 |
|
assertNull(r); |
1012 |
|
} |
1013 |
|
|