diff options
author | Lucas Lin <lucaslin@google.com> | 2020-04-20 03:02:42 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-20 03:02:42 +0000 |
commit | cae30c6ec849d437746b21cac7f178c47cb3223b (patch) | |
tree | 24cf8ccea9f5566ad7d54942f66dbdcd941df16d | |
parent | 527f860de4b28c9818f3ef3052ed8723ede8892c (diff) | |
parent | 037df74b348f1d02cc305489f1f8e73099c85384 (diff) |
Merge "Refine NetworkMonitorTest#testReadAsString_StreamShorterThanLimit()" into rvc-dev am: e2509d6f9d am: 037df74b34
Change-Id: I91c009f1a595b746557676079469d56ac2ae0cff
-rw-r--r-- | tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java index b755d61..26630f8 100644 --- a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +++ b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java @@ -1861,15 +1861,13 @@ public class NetworkMonitorTest { @Test public void testReadAsString_StreamShorterThanLimit() throws Exception { final WrappedNetworkMonitor wnm = makeNotMeteredNetworkMonitor(); - final String content = "The HTTP response code is 200 but it is not a captive portal."; - ByteArrayInputStream inputStream = new ByteArrayInputStream( - content.getBytes(StandardCharsets.UTF_8)); - assertEquals(content, wnm.readAsString(inputStream, content.length(), - StandardCharsets.UTF_8)); - // Reset the inputStream and test the case that the stream ends earlier than the limit. - inputStream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); - assertEquals(content, wnm.readAsString(inputStream, content.length() + 10, - StandardCharsets.UTF_8)); + final byte[] content = "The HTTP response code is 200 but it is not a captive portal." + .getBytes(StandardCharsets.UTF_8); + assertEquals(new String(content), wnm.readAsString(new ByteArrayInputStream(content), + content.length, StandardCharsets.UTF_8)); + // Test the case that the stream ends earlier than the limit. + assertEquals(new String(content), wnm.readAsString(new ByteArrayInputStream(content), + content.length + 10, StandardCharsets.UTF_8)); } @Test |