NPipeSocket extends Socket { @Override public synchronized void close() throws IOException { impl.close(); closed = true; } NPipeSocket(); private  NPipeSocket(NPipeSocketImpl impl); @Override void bind(SocketAddress bindpoint); @Override boolean isConnected(); @Override boolean isBound(); @Override SocketAddress getLocalSocketAddress(); @Override void connect(SocketAddress endpoint, int timeout); @Override synchronized void close(); @Override boolean isClosed();  }
@Test public void close() throws IOException { NPipeSocket socket = new NPipeSocket(); NPipeSocketImpl impl = socket.getImpl(); socket.connect(createTestSocket()); assertThat(socket.isClosed()).isFalse(); assertThat(impl.isClosed()).isFalse(); socket.close(); assertThat(socket.isClosed()).isTrue(); assertThat(impl.isClosed()).isTrue(); }