### Question:
UnixDomainSocket implements IOFacade { @Override public String read() throws IOException { CharBuffer response = CharBuffer.allocate(bufferSize); String result = ""; do { response.clear(); reader.read(response); result += new String(response.array(), response.arrayOffset(), response.position()); } while (response.position() == response.limit() && response.get(response.limit() - 1) != '\n'); return result; } UnixDomainSocket(String ipcSocketPath);  UnixDomainSocket(String ipcSocketPath, int bufferSize);   UnixDomainSocket(InputStreamReader reader, PrintWriter writer, int bufferSize); @Override void write(String payload); @Override String read();  }### Answer:
@Test public void testIpcService() throws IOException { unixDomainSocket = new UnixDomainSocket(reader, writer, RESPONSE.length()); doAnswer(invocation -> { Object[] args = invocation.getArguments(); ((CharBuffer) args[0]).append(RESPONSE); return RESPONSE.length(); }).when(reader).read(any(CharBuffer.class)); runTest(); }
@Test public void testReadExceedsBuffer() throws IOException { int bufferSize = RESPONSE.length() / 3; unixDomainSocket = new UnixDomainSocket(reader, writer, RESPONSE.length() / 3); doAnswer(invocation -> { Object[] args = invocation.getArguments(); ((CharBuffer) args[0]).append(RESPONSE.substring(0, bufferSize)); return RESPONSE.length(); }) .doAnswer(invocation -> { Object[] args = invocation.getArguments(); ((CharBuffer) args[0]).append( RESPONSE.substring(bufferSize, bufferSize * 2)); return RESPONSE.length(); }).doAnswer(invocation -> { Object[] args = invocation.getArguments(); ((CharBuffer) args[0]).append( RESPONSE.substring(bufferSize * 2, bufferSize * 3)); return RESPONSE.length(); }) .doAnswer(invocation -> { Object[] args = invocation.getArguments(); ((CharBuffer) args[0]).append( RESPONSE.substring(bufferSize * 3, RESPONSE.length())); return RESPONSE.length(); }) .when(reader).read(any(CharBuffer.class)); runTest(); }