Skip to content

Commit 689d50b

Browse files
Update NettyUtilsTest.java
1 parent 72ab912 commit 689d50b

File tree

1 file changed

+30
-0
lines changed
  • http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/utils

1 file changed

+30
-0
lines changed

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/utils/NettyUtilsTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,34 @@ public void runAndLogError_runnableThrows_loggerInvoked() {
222222

223223
verify(delegateLogger).error(msg, error);
224224
}
225+
226+
@Test
227+
public void closedChannelMessage_with_nullChannelAttribute() throws Exception {
228+
229+
Channel channel = Mockito.mock(Channel.class);
230+
when(channel.parent()).thenReturn(null);
231+
232+
assertThat(NettyUtils.closedChannelMessage(channel))
233+
.isEqualTo(NettyUtils.CLOSED_CHANNEL_ERROR_MESSAGE);
234+
}
235+
236+
@Test
237+
public void closedChannelMessage_with_nullChannel() throws Exception {
238+
Channel channel = null;
239+
assertThat(NettyUtils.closedChannelMessage(channel))
240+
.isEqualTo(NettyUtils.CLOSED_CHANNEL_ERROR_MESSAGE);
241+
}
242+
243+
244+
@Test
245+
public void closedChannelMessage_with_nullParentChannel() throws Exception {
246+
247+
Channel channel = Mockito.mock(Channel.class);
248+
Attribute attribute = Mockito.mock(Attribute.class);
249+
when(channel.parent()).thenReturn(null);
250+
when(channel.attr(Mockito.any())).thenReturn(attribute);
251+
252+
assertThat(NettyUtils.closedChannelMessage(channel))
253+
.isEqualTo(NettyUtils.CLOSED_CHANNEL_ERROR_MESSAGE);
254+
}
225255
}

0 commit comments

Comments
 (0)