equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
59 private static final List<String> lines(String text) { |
59 private static final List<String> lines(String text) { |
60 return new BufferedReader(new StringReader(text)).lines().collect(Collectors.toList()); |
60 return new BufferedReader(new StringReader(text)).lines().collect(Collectors.toList()); |
61 } |
61 } |
62 |
62 |
63 @Test |
63 @Test |
64 void testUncomplete() throws Exception { |
64 public void testUncomplete() throws Exception { |
65 // Uses U+10400 which is encoded as the surrogate pair U+D801 U+DC00 |
65 // Uses U+10400 which is encoded as the surrogate pair U+D801 U+DC00 |
66 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r les\n\n" + |
66 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r les\n\n" + |
67 " fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres\ud801\udc00"; |
67 " fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres\ud801\udc00"; |
68 Charset charset = UTF_8; |
68 Charset charset = UTF_8; |
69 |
69 |
119 throw new RuntimeException("Unexpected exception", errorRef.get()); |
119 throw new RuntimeException("Unexpected exception", errorRef.get()); |
120 } |
120 } |
121 } |
121 } |
122 |
122 |
123 @Test |
123 @Test |
124 void testStream1() throws Exception { |
124 public void testStream1() throws Exception { |
125 // Uses U+10400 which is encoded as the surrogate pair U+D801 U+DC00 |
125 // Uses U+10400 which is encoded as the surrogate pair U+D801 U+DC00 |
126 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r\r les\n\n" + |
126 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r\r les\n\n" + |
127 " fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres"; |
127 " fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres"; |
128 Charset charset = UTF_8; |
128 Charset charset = UTF_8; |
129 |
129 |
168 } |
168 } |
169 } |
169 } |
170 |
170 |
171 |
171 |
172 @Test |
172 @Test |
173 void testStream2() throws Exception { |
173 public void testStream2() throws Exception { |
174 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r\r" + |
174 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r\r" + |
175 " les fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres\r\r"; |
175 " les fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres\r\r"; |
176 Charset charset = UTF_8; |
176 Charset charset = UTF_8; |
177 |
177 |
178 BodySubscriber<Stream<String>> bodySubscriber = BodySubscribers.ofLines(charset); |
178 BodySubscriber<Stream<String>> bodySubscriber = BodySubscribers.ofLines(charset); |
214 throw new RuntimeException("Unexpected exception", errorRef.get()); |
214 throw new RuntimeException("Unexpected exception", errorRef.get()); |
215 } |
215 } |
216 } |
216 } |
217 |
217 |
218 @Test |
218 @Test |
219 void testStream3_UTF16() throws Exception { |
219 public void testStream3_UTF16() throws Exception { |
220 // Uses U+10400 which is encoded as the surrogate pair U+D801 U+DC00 |
220 // Uses U+10400 which is encoded as the surrogate pair U+D801 U+DC00 |
221 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r\r" + |
221 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r\r" + |
222 " les\n\n fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres"; |
222 " les\n\n fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres"; |
223 Charset charset = UTF_16; |
223 Charset charset = UTF_16; |
224 |
224 |
261 } |
261 } |
262 } |
262 } |
263 |
263 |
264 |
264 |
265 @Test |
265 @Test |
266 void testStream4_UTF16() throws Exception { |
266 public void testStream4_UTF16() throws Exception { |
267 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r\r" + |
267 String text = "Bient\u00f4t\r\n nous plongerons\r\n dans\r\r" + |
268 " les fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres\r\r"; |
268 " les fr\u00f4\ud801\udc00des\r\n t\u00e9n\u00e8bres\r\r"; |
269 Charset charset = UTF_16; |
269 Charset charset = UTF_16; |
270 |
270 |
271 BodySubscriber<Stream<String>> bodySubscriber = BodySubscribers.ofLines(charset); |
271 BodySubscriber<Stream<String>> bodySubscriber = BodySubscribers.ofLines(charset); |