author | duke |
Wed, 05 Jul 2017 22:06:37 +0200 | |
changeset 40471 | ad45133ff99e |
parent 34682 | fbee345d8615 |
child 43068 | df01087b2c43 |
permissions | -rw-r--r-- |
34527
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
1 |
/* |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
4 |
* |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
8 |
* |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
13 |
* accompanied this code). |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
14 |
* |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
18 |
* |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
21 |
* questions. |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
22 |
*/ |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
23 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
24 |
import java.io.ByteArrayInputStream; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
25 |
import java.io.ByteArrayOutputStream; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
26 |
import java.io.IOException; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
27 |
import java.io.ObjectInputStream; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
28 |
import java.io.ObjectOutputStream; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
29 |
import java.util.AbstractMap; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
30 |
import java.util.ArrayList; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
31 |
import java.util.Arrays; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
32 |
import java.util.Collections; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
33 |
import java.util.Iterator; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
34 |
import java.util.HashMap; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
35 |
import java.util.List; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
36 |
import java.util.Map; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
37 |
import java.util.stream.Collectors; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
38 |
import java.util.stream.IntStream; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
39 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
40 |
import org.testng.annotations.DataProvider; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
41 |
import org.testng.annotations.Test; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
42 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
43 |
import static org.testng.Assert.assertEquals; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
44 |
import static org.testng.Assert.assertFalse; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
45 |
import static org.testng.Assert.assertTrue; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
46 |
import static org.testng.Assert.fail; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
47 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
48 |
/* |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
49 |
* @test |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
50 |
* @bug 8048330 |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
51 |
* @summary Test convenience static factory methods on Map. |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
52 |
* @run testng MapFactories |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
53 |
*/ |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
54 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
55 |
public class MapFactories { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
56 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
57 |
static final int MAX_ENTRIES = 20; // should be larger than the largest fixed-arg overload |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
58 |
static String valueFor(int i) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
59 |
// the String literal below should be of length MAX_ENTRIES |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
60 |
return "abcdefghijklmnopqrst".substring(i, i+1); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
61 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
62 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
63 |
// for "expected" values |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
64 |
Map<Integer,String> genMap(int n) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
65 |
Map<Integer,String> result = new HashMap<>(); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
66 |
for (int i = 0; i < n; i++) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
67 |
result.put(i, valueFor(i)); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
68 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
69 |
return result; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
70 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
71 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
72 |
// for varargs Map.Entry methods |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
73 |
@SuppressWarnings("unchecked") |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
74 |
Map.Entry<Integer,String>[] genEntries(int n) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
75 |
return IntStream.range(0, n) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
76 |
.mapToObj(i -> Map.entry(i, valueFor(i))) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
77 |
.toArray(Map.Entry[]::new); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
78 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
79 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
80 |
// returns array of [actual, expected] |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
81 |
static Object[] a(Map<Integer,String> act, Map<Integer,String> exp) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
82 |
return new Object[] { act, exp }; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
83 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
84 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
85 |
@DataProvider(name="empty") |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
86 |
public Iterator<Object[]> empty() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
87 |
return Collections.singletonList( |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
88 |
a(Map.of(), genMap(0)) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
89 |
).iterator(); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
90 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
91 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
92 |
@DataProvider(name="nonempty") |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
93 |
@SuppressWarnings("unchecked") |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
94 |
public Iterator<Object[]> nonempty() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
95 |
return Arrays.asList( |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
96 |
a(Map.of(0, "a"), genMap(1)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
97 |
a(Map.of(0, "a", 1, "b"), genMap(2)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
98 |
a(Map.of(0, "a", 1, "b", 2, "c"), genMap(3)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
99 |
a(Map.of(0, "a", 1, "b", 2, "c", 3, "d"), genMap(4)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
100 |
a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e"), genMap(5)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
101 |
a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f"), genMap(6)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
102 |
a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g"), genMap(7)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
103 |
a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h"), genMap(8)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
104 |
a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i"), genMap(9)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
105 |
a(Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f", 6, "g", 7, "h", 8, "i", 9, "j"), genMap(10)), |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
106 |
a(Map.ofEntries(genEntries(MAX_ENTRIES)), genMap(MAX_ENTRIES)) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
107 |
).iterator(); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
108 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
109 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
110 |
@DataProvider(name="all") |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
111 |
public Iterator<Object[]> all() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
112 |
List<Object[]> all = new ArrayList<>(); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
113 |
empty().forEachRemaining(all::add); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
114 |
nonempty().forEachRemaining(all::add); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
115 |
return all.iterator(); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
116 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
117 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
118 |
@Test(dataProvider="all", expectedExceptions=UnsupportedOperationException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
119 |
public void cannotPutNew(Map<Integer,String> act, Map<Integer,String> exp) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
120 |
act.put(-1, "xyzzy"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
121 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
122 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
123 |
@Test(dataProvider="nonempty", expectedExceptions=UnsupportedOperationException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
124 |
public void cannotPutOld(Map<Integer,String> act, Map<Integer,String> exp) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
125 |
act.put(0, "a"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
126 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
127 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
128 |
@Test(dataProvider="nonempty", expectedExceptions=UnsupportedOperationException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
129 |
public void cannotRemove(Map<Integer,String> act, Map<Integer,String> exp) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
130 |
act.remove(act.keySet().iterator().next()); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
131 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
132 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
133 |
@Test(dataProvider="all") |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
134 |
public void contentsMatch(Map<Integer,String> act, Map<Integer,String> exp) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
135 |
assertEquals(act, exp); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
136 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
137 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
138 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
139 |
public void dupKeysDisallowed2() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
140 |
Map<Integer, String> map = Map.of(0, "a", 0, "b"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
141 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
142 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
143 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
144 |
public void dupKeysDisallowed3() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
145 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 0, "c"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
146 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
147 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
148 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
149 |
public void dupKeysDisallowed4() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
150 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 0, "d"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
151 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
152 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
153 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
154 |
public void dupKeysDisallowed5() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
155 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 0, "e"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
156 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
157 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
158 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
159 |
public void dupKeysDisallowed6() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
160 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
161 |
0, "f"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
162 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
163 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
164 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
165 |
public void dupKeysDisallowed7() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
166 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
167 |
5, "f", 0, "g"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
168 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
169 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
170 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
171 |
public void dupKeysDisallowed8() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
172 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
173 |
5, "f", 6, "g", 0, "h"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
174 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
175 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
176 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
177 |
public void dupKeysDisallowed9() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
178 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
179 |
5, "f", 6, "g", 7, "h", 0, "i"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
180 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
181 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
182 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
183 |
public void dupKeysDisallowed10() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
184 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
185 |
5, "f", 6, "g", 7, "h", 8, "i", 0, "j"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
186 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
187 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
188 |
@Test(expectedExceptions=IllegalArgumentException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
189 |
public void dupKeysDisallowedN() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
190 |
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
191 |
entries[MAX_ENTRIES-1] = Map.entry(0, "xxx"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
192 |
Map<Integer, String> map = Map.ofEntries(entries); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
193 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
194 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
195 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
196 |
public void nullKeyDisallowed1() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
197 |
Map<Integer, String> map = Map.of(null, "a"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
198 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
199 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
200 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
201 |
public void nullValueDisallowed1() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
202 |
Map<Integer, String> map = Map.of(0, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
203 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
204 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
205 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
206 |
public void nullKeyDisallowed2() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
207 |
Map<Integer, String> map = Map.of(0, "a", null, "b"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
208 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
209 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
210 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
211 |
public void nullValueDisallowed2() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
212 |
Map<Integer, String> map = Map.of(0, "a", 1, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
213 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
214 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
215 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
216 |
public void nullKeyDisallowed3() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
217 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", null, "c"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
218 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
219 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
220 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
221 |
public void nullValueDisallowed3() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
222 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
223 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
224 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
225 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
226 |
public void nullKeyDisallowed4() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
227 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", null, "d"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
228 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
229 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
230 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
231 |
public void nullValueDisallowed4() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
232 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
233 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
234 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
235 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
236 |
public void nullKeyDisallowed5() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
237 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", null, "e"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
238 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
239 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
240 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
241 |
public void nullValueDisallowed5() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
242 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
243 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
244 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
245 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
246 |
public void nullKeyDisallowed6() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
247 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
248 |
null, "f"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
249 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
250 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
251 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
252 |
public void nullValueDisallowed6() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
253 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
254 |
5, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
255 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
256 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
257 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
258 |
public void nullKeyDisallowed7() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
259 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
260 |
5, "f", null, "g"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
261 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
262 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
263 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
264 |
public void nullValueDisallowed7() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
265 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
266 |
5, "f", 6, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
267 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
268 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
269 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
270 |
public void nullKeyDisallowed8() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
271 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
272 |
5, "f", 6, "g", null, "h"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
273 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
274 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
275 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
276 |
public void nullValueDisallowed8() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
277 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
278 |
5, "f", 6, "g", 7, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
279 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
280 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
281 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
282 |
public void nullKeyDisallowed9() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
283 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
284 |
5, "f", 6, "g", 7, "h", null, "i"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
285 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
286 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
287 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
288 |
public void nullValueDisallowed9() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
289 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
290 |
5, "f", 6, "g", 7, "h", 8, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
291 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
292 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
293 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
294 |
public void nullKeyDisallowed10() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
295 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
296 |
5, "f", 6, "g", 7, "h", 8, "i", null, "j"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
297 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
298 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
299 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
300 |
public void nullValueDisallowed10() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
301 |
Map<Integer, String> map = Map.of(0, "a", 1, "b", 2, "c", 3, "d", 4, "e", |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
302 |
5, "f", 6, "g", 7, "h", 8, "i", 9, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
303 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
304 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
305 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
306 |
public void nullKeyDisallowedN() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
307 |
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
308 |
entries[0] = new AbstractMap.SimpleImmutableEntry(null, "a"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
309 |
Map<Integer, String> map = Map.ofEntries(entries); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
310 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
311 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
312 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
313 |
public void nullValueDisallowedN() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
314 |
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
315 |
entries[0] = new AbstractMap.SimpleImmutableEntry(0, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
316 |
Map<Integer, String> map = Map.ofEntries(entries); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
317 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
318 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
319 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
320 |
public void nullEntryDisallowedN() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
321 |
Map.Entry<Integer,String>[] entries = genEntries(MAX_ENTRIES); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
322 |
entries[5] = null; |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
323 |
Map<Integer, String> map = Map.ofEntries(entries); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
324 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
325 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
326 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
327 |
public void nullArrayDisallowed() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
328 |
Map.ofEntries(null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
329 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
330 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
331 |
@Test(dataProvider="all") |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
332 |
public void serialEquality(Map<Integer, String> act, Map<Integer, String> exp) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
333 |
// assume that act.equals(exp) tested elsewhere |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
334 |
Map<Integer, String> copy = serialClone(act); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
335 |
assertEquals(act, copy); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
336 |
assertEquals(copy, exp); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
337 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
338 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
339 |
@SuppressWarnings("unchecked") |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
340 |
static <T> T serialClone(T obj) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
341 |
try { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
342 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
343 |
ObjectOutputStream oos = new ObjectOutputStream(baos); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
344 |
oos.writeObject(obj); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
345 |
oos.close(); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
346 |
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
347 |
ObjectInputStream ois = new ObjectInputStream(bais); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
348 |
return (T) ois.readObject(); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
349 |
} catch (IOException | ClassNotFoundException e) { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
350 |
throw new AssertionError(e); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
351 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
352 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
353 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
354 |
// Map.entry() tests |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
355 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
356 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
357 |
public void entryWithNullKeyDisallowed() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
358 |
Map.Entry<Integer,String> e = Map.entry(null, "x"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
359 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
360 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
361 |
@Test(expectedExceptions=NullPointerException.class) |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
362 |
public void entryWithNullValueDisallowed() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
363 |
Map.Entry<Integer,String> e = Map.entry(0, null); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
364 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
365 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
366 |
@Test |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
367 |
public void entryBasicTests() { |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
368 |
Map.Entry<String,String> kvh1 = Map.entry("xyzzy", "plugh"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
369 |
Map.Entry<String,String> kvh2 = Map.entry("foobar", "blurfl"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
370 |
Map.Entry<String,String> sie = new AbstractMap.SimpleImmutableEntry("xyzzy", "plugh"); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
371 |
|
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
372 |
assertTrue(kvh1.equals(sie)); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
373 |
assertTrue(sie.equals(kvh1)); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
374 |
assertFalse(kvh2.equals(sie)); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
375 |
assertFalse(sie.equals(kvh2)); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
376 |
assertEquals(sie.hashCode(), kvh1.hashCode()); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
377 |
assertEquals(sie.toString(), kvh1.toString()); |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
378 |
} |
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
379 |
|
34682
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
380 |
// compile-time test of wildcards |
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
381 |
@Test |
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
382 |
public void entryWildcardTests() { |
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
383 |
Map.Entry<Integer,Double> e1 = Map.entry(1, 2.0); |
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
384 |
Map.Entry<Float,Long> e2 = Map.entry(3.0f, 4L); |
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
385 |
Map<Number,Number> map = Map.ofEntries(e1, e2); |
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
386 |
assertEquals(map.size(), 2); |
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
387 |
} |
fbee345d8615
8144952: add wildcards to the Map.ofEntries() method
smarks
parents:
34527
diff
changeset
|
388 |
|
34527
e3caf3a43d09
8139232: JEP-269 initial API and skeleton implementations
smarks
parents:
diff
changeset
|
389 |
} |