NPipeSocketImpl extends SocketImpl { @Override protected void connect(String host, int port) throws IOException { throw new UnsupportedSocketOperationException("Connection is only possible with NPipeSocketAddress."); }  @Override void setOption(int optID, Object value); @Override Object getOption(int optID); boolean isClosed();  }
@Test public void connect() throws IOException { NPipeSocketImpl impl = new NPipeSocketImpl(); assertThatExceptionOfType(SocketException.class) .isThrownBy(() -> impl.connect(new InetSocketAddress(InetAddress.getLocalHost(), 80), 0)); assertThatExceptionOfType(NoSuchFileException.class) .isThrownBy(() -> impl.connect(new NPipeSocketAddress(Paths.get("/non_existing_file")), 0)); assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> impl.connect((SocketAddress) null, 0)); impl.connect(createTestSocket(), 0); }