Offer restricted access to DataBuffer's ByteBuffer
This commit introduces DataBuffer::readableByteBuffers and DataBuffer::writableByteBuffers, allowing restricted access to the ByteBuffer used internally by DataBuffer implementations. Closes gh-29943
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,9 +68,9 @@ class ServerHttpResponseTests {
|
||||
assertThat(response.cookiesWritten).isTrue();
|
||||
|
||||
assertThat(response.body).hasSize(3);
|
||||
assertThat(new String(response.body.get(0).toByteBuffer().array(), StandardCharsets.UTF_8)).isEqualTo("a");
|
||||
assertThat(new String(response.body.get(1).toByteBuffer().array(), StandardCharsets.UTF_8)).isEqualTo("b");
|
||||
assertThat(new String(response.body.get(2).toByteBuffer().array(), StandardCharsets.UTF_8)).isEqualTo("c");
|
||||
assertThat(response.body.get(0).toString(StandardCharsets.UTF_8)).isEqualTo("a");
|
||||
assertThat(response.body.get(1).toString(StandardCharsets.UTF_8)).isEqualTo("b");
|
||||
assertThat(response.body.get(2).toString(StandardCharsets.UTF_8)).isEqualTo("c");
|
||||
}
|
||||
|
||||
@Test // SPR-14952
|
||||
@@ -84,7 +84,7 @@ class ServerHttpResponseTests {
|
||||
assertThat(response.cookiesWritten).isTrue();
|
||||
|
||||
assertThat(response.body).hasSize(1);
|
||||
assertThat(new String(response.body.get(0).toByteBuffer().array(), StandardCharsets.UTF_8)).isEqualTo("foo");
|
||||
assertThat(response.body.get(0).toString(StandardCharsets.UTF_8)).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,9 +139,9 @@ class ServerHttpResponseTests {
|
||||
assertThat(response.getCookies().getFirst("ID")).isSameAs(cookie);
|
||||
|
||||
assertThat(response.body).hasSize(3);
|
||||
assertThat(new String(response.body.get(0).toByteBuffer().array(), StandardCharsets.UTF_8)).isEqualTo("a");
|
||||
assertThat(new String(response.body.get(1).toByteBuffer().array(), StandardCharsets.UTF_8)).isEqualTo("b");
|
||||
assertThat(new String(response.body.get(2).toByteBuffer().array(), StandardCharsets.UTF_8)).isEqualTo("c");
|
||||
assertThat(response.body.get(0).toString(StandardCharsets.UTF_8)).isEqualTo("a");
|
||||
assertThat(response.body.get(1).toString(StandardCharsets.UTF_8)).isEqualTo("b");
|
||||
assertThat(response.body.get(2).toString(StandardCharsets.UTF_8)).isEqualTo("c");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user