@Test public void testInsecureSourceWithDisconnectedChannel() { final InetSocketAddress remoteAddress = new InetSocketAddress("192.168.1.22", 2727); final NetworkChannel channel = Mockito.mock(NetworkChannel.class); final NetworkGuard guard = new DirectNetworkGuard(); Mockito.when(channel.isConnected()).thenReturn(false); final boolean secure = guard.isSecure(channel, remoteAddress); Assert.assertFalse(secure); }
@Override public boolean isSecure(NetworkChannel channel, InetSocketAddress source) { if(channel.isConnected()) { return channel.getRemoteAddress().equals(source); } return false; }
DirectNetworkGuard implements NetworkGuard { @Override public boolean isSecure(NetworkChannel channel, InetSocketAddress source) { if(channel.isConnected()) { return channel.getRemoteAddress().equals(source); } return false; } }
DirectNetworkGuard implements NetworkGuard { @Override public boolean isSecure(NetworkChannel channel, InetSocketAddress source) { if(channel.isConnected()) { return channel.getRemoteAddress().equals(source); } return false; }  }
DirectNetworkGuard implements NetworkGuard { @Override public boolean isSecure(NetworkChannel channel, InetSocketAddress source) { if(channel.isConnected()) { return channel.getRemoteAddress().equals(source); } return false; }  @Override boolean isSecure(NetworkChannel channel, InetSocketAddress source); }
DirectNetworkGuard implements NetworkGuard { @Override public boolean isSecure(NetworkChannel channel, InetSocketAddress source) { if(channel.isConnected()) { return channel.getRemoteAddress().equals(source); } return false; }  @Override boolean isSecure(NetworkChannel channel, InetSocketAddress source);  }