Skip to content

Commit 944ac49

Browse files
committed
BAEL-3603 Update method names and variable name for PR
1 parent 0a79578 commit 944ac49

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void setup() {
2525
}
2626

2727
@Test
28-
public void givenJavaIOSocket_whenReadingAndWritingWithStreams_thenReadSuccessfully() throws IOException {
28+
public void givenJavaIOSocket_whenReadingAndWritingWithStreams_thenSuccess() throws IOException {
2929
// given an IO socket and somewhere to store our result
3030
Socket socket = new Socket("localhost", wireMockRule.port());
3131
StringBuilder ourStore = new StringBuilder();

core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void setup() {
3131
}
3232

3333
@Test
34-
public void givenJavaNIOSocketChannel_whenReadingAndWriting_thenUseBuffers() throws IOException {
34+
public void givenJavaNIOSocketChannel_whenReadingAndWritingWithBuffers_thenSuccess() throws IOException {
3535
// given a NIO SocketChannel and a charset
3636
InetSocketAddress address = new InetSocketAddress("localhost", wireMockRule.port());
3737
SocketChannel socketChannel = SocketChannel.open(address);
@@ -58,25 +58,25 @@ public void givenJavaNIOSocketChannel_whenReadingAndWriting_thenUseBuffers() thr
5858
}
5959

6060
@Test
61-
public void givenJavaNIO_whenReadingAndWriting_thenSmallBuffers() throws IOException {
61+
public void givenJavaNIOSocketChannel_whenReadingAndWritingWithSmallBuffers_thenSuccess() throws IOException {
6262
// given a NIO SocketChannel and a charset
6363
InetSocketAddress address = new InetSocketAddress("localhost", wireMockRule.port());
64-
SocketChannel socket = SocketChannel.open(address);
64+
SocketChannel socketChannel = SocketChannel.open(address);
6565
Charset charset = StandardCharsets.UTF_8;
6666

6767
// when we write and read using buffers that are too small for our message
68-
socket.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n")));
68+
socketChannel.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n")));
6969

7070
ByteBuffer buffer = ByteBuffer.allocate(8); // or allocateDirect if we need direct memory access
7171
CharBuffer charBuffer = CharBuffer.allocate(8);
7272
CharsetDecoder decoder = charset.newDecoder();
7373
StringBuilder ourStore = new StringBuilder();
74-
while (socket.read(buffer) != -1 || buffer.position() > 0) {
74+
while (socketChannel.read(buffer) != -1 || buffer.position() > 0) {
7575
buffer.flip();
7676
storeBufferContents(buffer, charBuffer, decoder, ourStore);
7777
buffer.compact();
7878
}
79-
socket.close();
79+
socketChannel.close();
8080

8181
// then we read and saved our data
8282
assertTrue(ourStore

0 commit comments

Comments
 (0)