@Test public void testEstimateReceiveBufferRcvBufOptionThrowsException() throws Exception { InputStream expected = new ByteArrayInputStream(new byte[]{1, 2, 3}); SnifferSocketImpl.defaultReceiveBufferSize = null; when(delegate, "getInputStream").thenReturn(expected); when(delegate, "getOption", SO_RCVBUF).thenThrow(new SocketException()); InputStream actual = sniffySocket.getInputStream(); verifyPrivate(delegate).invoke("getInputStream"); verifyNoMoreInteractions(ignoreStubs(delegate)); assertEquals(SnifferInputStream.class, actual.getClass()); assertEquals(1, actual.read()); assertEquals((Integer) 0, SnifferSocketImpl.defaultReceiveBufferSize); }
@Override protected InputStream getInputStream() throws IOException { estimateReceiveBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferInputStream(this, (InputStream) method("getInputStream").invoke(delegate)); } catch (Exception e) { throw ExceptionUtil.processException(e); } finally { logSocket(System.currentTimeMillis() - start); copyFromDelegate(); } }
SnifferSocketImpl extends SocketImpl implements SniffySocket { @Override protected InputStream getInputStream() throws IOException { estimateReceiveBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferInputStream(this, (InputStream) method("getInputStream").invoke(delegate)); } catch (Exception e) { throw ExceptionUtil.processException(e); } finally { logSocket(System.currentTimeMillis() - start); copyFromDelegate(); } } }
SnifferSocketImpl extends SocketImpl implements SniffySocket { @Override protected InputStream getInputStream() throws IOException { estimateReceiveBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferInputStream(this, (InputStream) method("getInputStream").invoke(delegate)); } catch (Exception e) { throw ExceptionUtil.processException(e); } finally { logSocket(System.currentTimeMillis() - start); copyFromDelegate(); } } protected  SnifferSocketImpl(SocketImpl delegate); }
SnifferSocketImpl extends SocketImpl implements SniffySocket { @Override protected InputStream getInputStream() throws IOException { estimateReceiveBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferInputStream(this, (InputStream) method("getInputStream").invoke(delegate)); } catch (Exception e) { throw ExceptionUtil.processException(e); } finally { logSocket(System.currentTimeMillis() - start); copyFromDelegate(); } } protected  SnifferSocketImpl(SocketImpl delegate); @Override void setConnectionStatus(Integer connectionStatus); @Override String toString(); @Override void setOption(int optID, Object value); @Override Object getOption(int optID); @Override InetSocketAddress getInetSocketAddress(); }
SnifferSocketImpl extends SocketImpl implements SniffySocket { @Override protected InputStream getInputStream() throws IOException { estimateReceiveBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferInputStream(this, (InputStream) method("getInputStream").invoke(delegate)); } catch (Exception e) { throw ExceptionUtil.processException(e); } finally { logSocket(System.currentTimeMillis() - start); copyFromDelegate(); } } protected  SnifferSocketImpl(SocketImpl delegate); @Override void setConnectionStatus(Integer connectionStatus); @Override String toString(); @Override void setOption(int optID, Object value); @Override Object getOption(int optID); @Override InetSocketAddress getInetSocketAddress();  }