@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(); }
@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 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 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); }
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(); }
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();  }