@Test public void testEstimateSendBufferSndBufOptionThrowsException() throws Exception { ByteArrayOutputStream expected = new ByteArrayOutputStream(); SnifferSocketImpl.defaultSendBufferSize = null; when(delegate, "getOutputStream").thenReturn(expected); when(delegate, "getOption", SO_SNDBUF).thenThrow(new SocketException()); OutputStream actual = sniffySocket.getOutputStream(); verifyPrivate(delegate).invoke("getOutputStream"); verifyNoMoreInteractions(ignoreStubs(delegate)); assertEquals(SnifferOutputStream.class, actual.getClass()); actual.write(3); assertEquals(3, (int) expected.toByteArray()[0]); assertEquals((Integer) 0, SnifferSocketImpl.defaultSendBufferSize); }
@Override protected OutputStream getOutputStream() throws IOException { estimateSendBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferOutputStream(this, (OutputStream) method("getOutputStream").invoke(delegate)); } catch (Exception e) { throw ExceptionUtil.processException(e); } finally { logSocket(System.currentTimeMillis() - start); copyFromDelegate(); } }
SnifferSocketImpl extends SocketImpl implements SniffySocket { @Override protected OutputStream getOutputStream() throws IOException { estimateSendBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferOutputStream(this, (OutputStream) method("getOutputStream").invoke(delegate)); } catch (Exception e) { throw ExceptionUtil.processException(e); } finally { logSocket(System.currentTimeMillis() - start); copyFromDelegate(); } } }
SnifferSocketImpl extends SocketImpl implements SniffySocket { @Override protected OutputStream getOutputStream() throws IOException { estimateSendBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferOutputStream(this, (OutputStream) method("getOutputStream").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 OutputStream getOutputStream() throws IOException { estimateSendBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferOutputStream(this, (OutputStream) method("getOutputStream").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 OutputStream getOutputStream() throws IOException { estimateSendBuffer(); checkConnectionAllowed(); copyToDelegate(); long start = System.currentTimeMillis(); try { return new SnifferOutputStream(this, (OutputStream) method("getOutputStream").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();  }