50681
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @summary Tests for HttpHeaders.of factory method
|
|
27 |
* @run testng HttpHeadersOf
|
|
28 |
*/
|
|
29 |
|
|
30 |
import java.net.http.HttpHeaders;
|
|
31 |
import java.util.ArrayList;
|
|
32 |
import java.util.LinkedList;
|
|
33 |
import java.util.List;
|
|
34 |
import java.util.Map;
|
|
35 |
import java.util.function.BiPredicate;
|
|
36 |
import org.testng.annotations.DataProvider;
|
|
37 |
import org.testng.annotations.Test;
|
|
38 |
import static org.testng.Assert.assertFalse;
|
|
39 |
import static org.testng.Assert.assertEquals;
|
|
40 |
import static org.testng.Assert.assertThrows;
|
|
41 |
import static org.testng.Assert.assertTrue;
|
|
42 |
import static org.testng.Assert.fail;
|
|
43 |
|
|
44 |
public class HttpHeadersOf {
|
|
45 |
|
|
46 |
static final Class<NullPointerException> NPE = NullPointerException.class;
|
|
47 |
static final Class<NumberFormatException> NFE = NumberFormatException.class;
|
|
48 |
static final Class<UnsupportedOperationException> UOE = UnsupportedOperationException.class;
|
|
49 |
|
|
50 |
static final BiPredicate<String,String> ACCEPT_ALL =
|
|
51 |
new BiPredicate<>() {
|
|
52 |
@Override public boolean test(String name, String value) { return true; }
|
|
53 |
@Override public String toString() { return "ACCEPT_ALL"; }
|
|
54 |
};
|
|
55 |
|
|
56 |
static final BiPredicate<String,String> REJECT_ALL =
|
|
57 |
new BiPredicate<>() {
|
|
58 |
@Override public boolean test(String name, String value) { return false; }
|
|
59 |
@Override public String toString() { return "REJECT_ALL"; }
|
|
60 |
};
|
|
61 |
|
|
62 |
@DataProvider(name = "predicates")
|
|
63 |
public Object[][] predicates() {
|
|
64 |
return new Object[][] { { ACCEPT_ALL }, { REJECT_ALL } };
|
|
65 |
}
|
|
66 |
|
|
67 |
@Test(dataProvider = "predicates")
|
|
68 |
public void testNull(BiPredicate<String,String> filter) {
|
|
69 |
assertThrows(NPE, () -> HttpHeaders.of(null, null));
|
|
70 |
assertThrows(NPE, () -> HttpHeaders.of(null, filter));
|
|
71 |
assertThrows(NPE, () -> HttpHeaders.of(Map.of(), null));
|
|
72 |
assertThrows(NPE, () -> HttpHeaders.of(Map.of("name", List.of("value")), null));
|
|
73 |
|
|
74 |
// nulls in the Map
|
|
75 |
assertThrows(NPE, () -> HttpHeaders.of(Map.of(null, List.of("value)")), filter));
|
|
76 |
assertThrows(NPE, () -> HttpHeaders.of(Map.of("name", null), filter));
|
|
77 |
assertThrows(NPE, () -> HttpHeaders.of(Map.of("name", List.of(null)), filter));
|
|
78 |
assertThrows(NPE, () -> HttpHeaders.of(Map.of("name", List.of("aValue", null)), filter));
|
|
79 |
assertThrows(NPE, () -> HttpHeaders.of(Map.of("name", List.of(null, "aValue")), filter));
|
|
80 |
}
|
|
81 |
|
|
82 |
|
|
83 |
@DataProvider(name = "filterMaps")
|
|
84 |
public Object[][] filterMaps() {
|
|
85 |
List<Map<String, List<String>>> maps = List.of(
|
|
86 |
Map.of("A", List.of("B"), "X", List.of("Y", "Z")),
|
|
87 |
Map.of("A", List.of("B", "C"), "X", List.of("Y", "Z")),
|
|
88 |
Map.of("A", List.of("B", "C", "D"), "X", List.of("Y", "Z"))
|
|
89 |
);
|
|
90 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
91 |
}
|
|
92 |
|
|
93 |
@Test(dataProvider = "filterMaps")
|
|
94 |
public void testFilter(Map<String,List<String>> map) {
|
|
95 |
HttpHeaders headers = HttpHeaders.of(map, REJECT_ALL);
|
|
96 |
assertEquals(headers.map().size(), 0);
|
|
97 |
assertFalse(headers.firstValue("A").isPresent());
|
|
98 |
assertEquals(headers.allValues("A").size(), 0);
|
|
99 |
|
|
100 |
headers = HttpHeaders.of(map, (name, value) -> {
|
|
101 |
if (name.equals("A")) return true; else return false; });
|
|
102 |
assertEquals(headers.map().size(), 1);
|
|
103 |
assertTrue(headers.firstValue("A").isPresent());
|
|
104 |
assertEquals(headers.allValues("A"), map.get("A"));
|
|
105 |
assertEquals(headers.allValues("A").size(), map.get("A").size());
|
|
106 |
assertFalse(headers.firstValue("X").isPresent());
|
|
107 |
|
|
108 |
headers = HttpHeaders.of(map, (name, value) -> {
|
|
109 |
if (name.equals("X")) return true; else return false; });
|
|
110 |
assertEquals(headers.map().size(), 1);
|
|
111 |
assertTrue(headers.firstValue("X").isPresent());
|
|
112 |
assertEquals(headers.allValues("X"), map.get("X"));
|
|
113 |
assertEquals(headers.allValues("X").size(), map.get("X").size());
|
|
114 |
assertFalse(headers.firstValue("A").isPresent());
|
|
115 |
}
|
|
116 |
|
|
117 |
|
|
118 |
@DataProvider(name = "mapValues")
|
|
119 |
public Object[][] mapValues() {
|
|
120 |
List<Map<String, List<String>>> maps = List.of(
|
|
121 |
Map.of("A", List.of("B")),
|
|
122 |
Map.of("A", List.of("B", "C")),
|
|
123 |
Map.of("A", List.of("B", "C", "D")),
|
|
124 |
|
|
125 |
Map.of("A", List.of("B"), "X", List.of("Y", "Z")),
|
|
126 |
Map.of("A", List.of("B", "C"), "X", List.of("Y", "Z")),
|
|
127 |
Map.of("A", List.of("B", "C", "D"), "X", List.of("Y", "Z")),
|
|
128 |
|
|
129 |
Map.of("A", List.of("B"), "X", List.of("Y", "Z")),
|
|
130 |
Map.of("A", List.of("B", "C"), "X", List.of("Y", "Z")),
|
|
131 |
Map.of("A", List.of("B", "C", "D"), "X", List.of("Y", "Z")),
|
|
132 |
|
|
133 |
Map.of("X", List.of("Y", "Z"), "A", List.of("B")),
|
|
134 |
Map.of("X", List.of("Y", "Z"), "A", List.of("B", "C")),
|
|
135 |
Map.of("X", List.of("Y", "Z"), "A", List.of("B", "C", "D"))
|
|
136 |
);
|
|
137 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
138 |
}
|
|
139 |
|
|
140 |
@Test(dataProvider = "mapValues")
|
|
141 |
public void testMapValues(Map<String,List<String>> map) {
|
|
142 |
HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL);
|
|
143 |
|
|
144 |
assertEquals(headers.map().size(), map.size());
|
|
145 |
assertTrue(headers.firstValue("A").isPresent());
|
|
146 |
assertTrue(headers.firstValue("a").isPresent());
|
|
147 |
assertEquals(headers.firstValue("A").get(), "B");
|
|
148 |
assertEquals(headers.firstValue("a").get(), "B");
|
|
149 |
assertEquals(headers.allValues("A"), map.get("A"));
|
|
150 |
assertEquals(headers.allValues("a"), map.get("A"));
|
|
151 |
assertEquals(headers.allValues("F").size(), 0);
|
|
152 |
assertTrue(headers.map().get("A").contains("B"));
|
|
153 |
assertFalse(headers.map().get("A").contains("F"));
|
|
154 |
assertThrows(NFE, () -> headers.firstValueAsLong("A"));
|
|
155 |
|
|
156 |
// a non-exhaustive list of mutators
|
|
157 |
assertThrows(UOE, () -> headers.map().put("Z", List.of("Z")));
|
|
158 |
assertThrows(UOE, () -> headers.map().remove("A"));
|
|
159 |
assertThrows(UOE, () -> headers.map().remove("A", "B"));
|
|
160 |
assertThrows(UOE, () -> headers.map().clear());
|
|
161 |
assertThrows(UOE, () -> headers.allValues("A").remove("B"));
|
|
162 |
assertThrows(UOE, () -> headers.allValues("A").remove(1));
|
|
163 |
assertThrows(UOE, () -> headers.allValues("A").clear());
|
|
164 |
assertThrows(UOE, () -> headers.allValues("A").add("Z"));
|
|
165 |
assertThrows(UOE, () -> headers.allValues("A").addAll(List.of("Z")));
|
|
166 |
assertThrows(UOE, () -> headers.allValues("A").add(1, "Z"));
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
@DataProvider(name = "caseInsensitivity")
|
|
171 |
public Object[][] caseInsensitivity() {
|
|
172 |
List<Map<String, List<String>>> maps = List.of(
|
|
173 |
Map.of("Accept-Encoding", List.of("gzip, deflate")),
|
|
174 |
Map.of("accept-encoding", List.of("gzip, deflate")),
|
|
175 |
Map.of("AccePT-ENCoding", List.of("gzip, deflate")),
|
|
176 |
Map.of("ACCept-EncodING", List.of("gzip, deflate")),
|
|
177 |
Map.of("ACCEPT-ENCODING", List.of("gzip, deflate"))
|
|
178 |
);
|
|
179 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
180 |
}
|
|
181 |
|
|
182 |
@Test(dataProvider = "caseInsensitivity")
|
|
183 |
public void testCaseInsensitivity(Map<String,List<String>> map) {
|
|
184 |
HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL);
|
|
185 |
|
|
186 |
for (String name : List.of("Accept-Encoding", "accept-encoding",
|
|
187 |
"aCCept-EnCODing", "accepT-encodinG")) {
|
|
188 |
assertTrue(headers.firstValue(name).isPresent());
|
|
189 |
assertTrue(headers.allValues(name).contains("gzip, deflate"));
|
|
190 |
assertEquals(headers.firstValue(name).get(), "gzip, deflate");
|
|
191 |
assertEquals(headers.allValues(name).size(), 1);
|
|
192 |
assertEquals(headers.map().size(), 1);
|
|
193 |
assertEquals(headers.map().get(name).size(), 1);
|
|
194 |
assertEquals(headers.map().get(name).get(0), "gzip, deflate");
|
|
195 |
}
|
|
196 |
}
|
|
197 |
|
|
198 |
@Test
|
|
199 |
public void testEqualsAndHashCode() {
|
|
200 |
List<Map<String, List<String>>> maps = List.of(
|
|
201 |
Map.of("Accept-Encoding", List.of("gzip, deflate")),
|
|
202 |
Map.of("accept-encoding", List.of("gzip, deflate")),
|
|
203 |
Map.of("AccePT-ENCoding", List.of("gzip, deflate")),
|
|
204 |
Map.of("ACCept-EncodING", List.of("gzip, deflate")),
|
|
205 |
Map.of("ACCEPT-ENCODING", List.of("gzip, deflate"))
|
|
206 |
);
|
|
207 |
int mapDiffer = 0;
|
|
208 |
int mapHashDiffer = 0;
|
|
209 |
for (Map<String, List<String>> m1 : maps) {
|
|
210 |
HttpHeaders h1 = HttpHeaders.of(m1, ACCEPT_ALL);
|
|
211 |
for (Map<String, List<String>> m2 : maps) {
|
|
212 |
HttpHeaders h2 = HttpHeaders.of(m2, ACCEPT_ALL);
|
|
213 |
if (!m1.equals(m2)) mapDiffer++;
|
|
214 |
if (m1.hashCode() != m2.hashCode()) mapHashDiffer++;
|
|
215 |
assertEquals(h1, h2, "HttpHeaders differ");
|
|
216 |
assertEquals(h1.hashCode(), h2.hashCode(),
|
|
217 |
"hashCode differ for " + List.of(m1,m2));
|
|
218 |
}
|
|
219 |
}
|
|
220 |
assertTrue(mapDiffer > 0, "all maps were equal!");
|
|
221 |
assertTrue(mapHashDiffer > 0, "all maps had same hashCode!");
|
|
222 |
}
|
|
223 |
|
|
224 |
@DataProvider(name = "valueAsLong")
|
|
225 |
public Object[][] valueAsLong() {
|
|
226 |
return new Object[][] {
|
|
227 |
new Object[] { Map.of("Content-Length", List.of("10")), 10l },
|
|
228 |
new Object[] { Map.of("Content-Length", List.of("101")), 101l },
|
|
229 |
new Object[] { Map.of("Content-Length", List.of("56789")), 56789l },
|
|
230 |
new Object[] { Map.of("Content-Length", List.of(Long.toString(Long.MAX_VALUE))), Long.MAX_VALUE },
|
|
231 |
new Object[] { Map.of("Content-Length", List.of(Long.toString(Long.MIN_VALUE))), Long.MIN_VALUE }
|
|
232 |
};
|
|
233 |
}
|
|
234 |
|
|
235 |
@Test(dataProvider = "valueAsLong")
|
|
236 |
public void testValueAsLong(Map<String,List<String>> map, long expected) {
|
|
237 |
HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL);
|
|
238 |
assertEquals(headers.firstValueAsLong("Content-Length").getAsLong(), expected);
|
|
239 |
}
|
|
240 |
|
|
241 |
|
|
242 |
@DataProvider(name = "duplicateNames")
|
|
243 |
public Object[][] duplicateNames() {
|
|
244 |
List<Map<String, List<String>>> maps = List.of(
|
|
245 |
Map.of("X-name", List.of(),
|
|
246 |
"x-name", List.of()),
|
|
247 |
Map.of("X-name", List.of(""),
|
|
248 |
"x-name", List.of("")),
|
|
249 |
Map.of("X-name", List.of("C"),
|
|
250 |
"x-name", List.of("D")),
|
|
251 |
Map.of("X-name", List.of("E"),
|
|
252 |
"Y-name", List.of("F"),
|
|
253 |
"X-Name", List.of("G")),
|
|
254 |
Map.of("X-chegar", List.of("H"),
|
|
255 |
"y-dfuchs", List.of("I"),
|
|
256 |
"Y-dfuchs", List.of("J")),
|
|
257 |
Map.of("X-name ", List.of("K"),
|
|
258 |
"X-Name", List.of("L")),
|
|
259 |
Map.of("X-name", List.of("M"),
|
|
260 |
"\rX-Name", List.of("N"))
|
|
261 |
);
|
|
262 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
263 |
}
|
|
264 |
|
|
265 |
@Test(dataProvider = "duplicateNames")
|
|
266 |
public void testDuplicates(Map<String,List<String>> map) {
|
|
267 |
HttpHeaders headers;
|
|
268 |
try {
|
|
269 |
headers = HttpHeaders.of(map, ACCEPT_ALL);
|
|
270 |
fail("UNEXPECTED: " + headers);
|
|
271 |
} catch (IllegalArgumentException iae) {
|
|
272 |
System.out.println("caught EXPECTED IAE:" + iae);
|
|
273 |
assertTrue(iae.getMessage().contains("duplicate"));
|
|
274 |
}
|
|
275 |
}
|
|
276 |
|
|
277 |
|
|
278 |
@DataProvider(name = "noSplittingJoining")
|
|
279 |
public Object[][] noSplittingJoining() {
|
|
280 |
List<Map<String, List<String>>> maps = List.of(
|
|
281 |
Map.of("A", List.of("B")),
|
|
282 |
Map.of("A", List.of("B", "C")),
|
|
283 |
Map.of("A", List.of("B", "C", "D")),
|
|
284 |
Map.of("A", List.of("B", "C", "D", "E")),
|
|
285 |
Map.of("A", List.of("B", "C", "D", "E", "F")),
|
|
286 |
Map.of("A", List.of("B, C")),
|
|
287 |
Map.of("A", List.of("B, C, D")),
|
|
288 |
Map.of("A", List.of("B, C, D, E")),
|
|
289 |
Map.of("A", List.of("B, C, D, E, F")),
|
|
290 |
Map.of("A", List.of("B, C", "D", "E", "F")),
|
|
291 |
Map.of("A", List.of("B", "C, D", "E", "F")),
|
|
292 |
Map.of("A", List.of("B", "C, D", "E, F")),
|
|
293 |
Map.of("A", List.of("B", "C, D, E", "F")),
|
|
294 |
Map.of("A", List.of("B", "C, D, E, F"))
|
|
295 |
);
|
|
296 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
297 |
}
|
|
298 |
|
|
299 |
@Test(dataProvider = "noSplittingJoining")
|
|
300 |
public void testNoSplittingJoining(Map<String,List<String>> map) {
|
|
301 |
HttpHeaders headers = HttpHeaders.of(map, ACCEPT_ALL);
|
|
302 |
Map<String,List<String>> headersMap = headers.map();
|
|
303 |
|
|
304 |
assertEquals(headers.map().size(), map.size());
|
|
305 |
for (Map.Entry<String,List<String>> entry : map.entrySet()) {
|
|
306 |
String headerName = entry.getKey();
|
|
307 |
List<String> headerValues = entry.getValue();
|
|
308 |
assertEquals(headerValues, headersMap.get(headerName));
|
|
309 |
assertEquals(headerValues, headers.allValues(headerName));
|
|
310 |
assertEquals(headerValues.get(0), headers.firstValue(headerName).get());
|
|
311 |
}
|
|
312 |
}
|
|
313 |
|
|
314 |
|
|
315 |
@DataProvider(name = "trimming")
|
|
316 |
public Object[][] trimming() {
|
|
317 |
List<Map<String, List<String>>> maps = List.of(
|
|
318 |
Map.of("A", List.of("B")),
|
|
319 |
Map.of(" A", List.of("B")),
|
|
320 |
Map.of("A ", List.of("B")),
|
|
321 |
Map.of("A", List.of(" B")),
|
|
322 |
Map.of("A", List.of("B ")),
|
|
323 |
Map.of("\tA", List.of("B")),
|
|
324 |
Map.of("A\t", List.of("B")),
|
|
325 |
Map.of("A", List.of("\tB")),
|
|
326 |
Map.of("A", List.of("B\t")),
|
|
327 |
Map.of("A\r", List.of("B")),
|
|
328 |
Map.of("A\n", List.of("B")),
|
|
329 |
Map.of("A\r\n", List.of("B"))
|
|
330 |
);
|
|
331 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
332 |
}
|
|
333 |
|
|
334 |
@Test(dataProvider = "trimming")
|
|
335 |
public void testTrimming(Map<String,List<String>> map) {
|
|
336 |
HttpHeaders headers = HttpHeaders.of(map, (name, value) -> {
|
|
337 |
assertEquals(name, "A");
|
|
338 |
assertEquals(value, "B");
|
|
339 |
return true;
|
|
340 |
});
|
|
341 |
|
|
342 |
assertEquals(headers.map().size(), 1);
|
|
343 |
assertEquals(headers.firstValue("A").get(), "B");
|
|
344 |
assertEquals(headers.allValues("A"), List.of("B"));
|
|
345 |
assertTrue(headers.map().get("A").equals(List.of("B")));
|
|
346 |
}
|
|
347 |
|
|
348 |
|
|
349 |
@DataProvider(name = "emptyKey")
|
|
350 |
public Object[][] emptyKey() {
|
|
351 |
List<Map<String, List<String>>> maps = List.of(
|
|
352 |
Map.of("", List.of("B")),
|
|
353 |
Map.of(" ", List.of("B")),
|
|
354 |
Map.of(" ", List.of("B")),
|
|
355 |
Map.of("\t", List.of("B")),
|
|
356 |
Map.of("\t\t", List.of("B"))
|
|
357 |
);
|
|
358 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
359 |
}
|
|
360 |
|
|
361 |
@Test(dataProvider = "emptyKey")
|
|
362 |
public void testEmptyKey(Map<String,List<String>> map) {
|
|
363 |
HttpHeaders headers;
|
|
364 |
try {
|
|
365 |
headers = HttpHeaders.of(map, ACCEPT_ALL);
|
|
366 |
fail("UNEXPECTED: " + headers);
|
|
367 |
} catch (IllegalArgumentException iae) {
|
|
368 |
System.out.println("caught EXPECTED IAE:" + iae);
|
|
369 |
assertTrue(iae.getMessage().contains("empty"));
|
|
370 |
}
|
|
371 |
}
|
|
372 |
|
|
373 |
|
|
374 |
@DataProvider(name = "emptyValue")
|
|
375 |
public Object[][] emptyValue() {
|
|
376 |
List<Map<String, List<String>>> maps = List.of(
|
|
377 |
Map.of("A", List.of("")),
|
|
378 |
Map.of("A", List.of("", "")),
|
|
379 |
Map.of("A", List.of("", "", " ")),
|
|
380 |
Map.of("A", List.of("\t")),
|
|
381 |
Map.of("A", List.of("\t\t"))
|
|
382 |
);
|
|
383 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
384 |
}
|
|
385 |
|
|
386 |
@Test(dataProvider = "emptyValue")
|
|
387 |
public void testEmptyValue(Map<String,List<String>> map) {
|
|
388 |
HttpHeaders headers = HttpHeaders.of(map, (name, value) -> {
|
|
389 |
assertEquals(value, "");
|
|
390 |
return true;
|
|
391 |
});
|
|
392 |
assertEquals(headers.map().size(), map.size());
|
|
393 |
assertEquals(headers.map().get("A").get(0), "");
|
|
394 |
headers.allValues("A").forEach(v -> assertEquals(v, ""));
|
|
395 |
assertEquals(headers.firstValue("A").get(), "");
|
|
396 |
}
|
|
397 |
|
|
398 |
|
|
399 |
@DataProvider(name = "noValues")
|
|
400 |
public Object[][] noValues() {
|
|
401 |
List<Map<String, List<String>>> maps = List.of(
|
|
402 |
Map.of("A", List.of()),
|
|
403 |
Map.of("A", List.of(), "B", List.of()),
|
|
404 |
Map.of("A", List.of(), "B", List.of(), "C", List.of()),
|
|
405 |
Map.of("A", new ArrayList()),
|
|
406 |
Map.of("A", new LinkedList())
|
|
407 |
);
|
|
408 |
return maps.stream().map(p -> new Object[] { p }).toArray(Object[][]::new);
|
|
409 |
}
|
|
410 |
|
|
411 |
@Test(dataProvider = "noValues")
|
|
412 |
public void testNoValues(Map<String,List<String>> map) {
|
|
413 |
HttpHeaders headers = HttpHeaders.of(map, (name, value) -> {
|
|
414 |
fail("UNEXPECTED call to filter");
|
|
415 |
return true;
|
|
416 |
});
|
|
417 |
assertEquals(headers.map().size(), 0);
|
|
418 |
assertEquals(headers.map().get("A"), null);
|
|
419 |
assertEquals(headers.allValues("A").size(), 0);
|
|
420 |
assertFalse(headers.firstValue("A").isPresent());
|
|
421 |
}
|
|
422 |
}
|