ChannelUtil { public static String getDesc(Channel channel){ if(channel == null){ return null; } return String.format("L(%s)->R(%s)", getSimpleIpport(channel.localAddress()), getSimpleIpport(channel.remoteAddress())); }  static String getRemoteIpLocalPort(Channel channel); static String getRemoteAddr(Channel channel); static String getSimpleIpport(SocketAddress remoteAddr); static String getDesc(Channel channel); static void closeChannelAutoRead(Channel channel); static void openChannelAutoRead(Channel channel); static void triggerChannelAutoRead(Channel channel); static void closeOnFlush(Channel ch);  }
@Test public void test(){ Channel channel = mock(Channel.class); Assert.assertEquals("L(null)->R(null)", ChannelUtil.getDesc(channel)); when(channel.localAddress()).thenReturn(new InetSocketAddress("localhost", 1234)); Assert.assertEquals("L(127.0.0.1:1234)->R(null)", ChannelUtil.getDesc(channel)); }