InfluxDbTcpSender extends InfluxDbBaseSender { @Override protected int writeData(byte[] line) throws Exception { retryConnect(false); for (int i = 1; i <= NUM_OF_RETRIES; i++) { try { OutputStream outputStream = tcpSocket.getOutputStream(); outputStream.write(line); outputStream.flush(); return 0; } catch (IOException e) { retryConnect(true); } } return 0; } InfluxDbTcpSender(
        final String hostname,
        final int port,
        final int socketTimeout,
        final String database,
        final String measurementPrefix);   }
@Test(expected = UnknownHostException.class) public void shouldThrowUnknownHostException() throws Exception { InfluxDbTcpSender influxDbTcpSender = new InfluxDbTcpSender( "testtestasdfg", 10080, 1000, "test", "" ); influxDbTcpSender.writeData(new byte[0]); }
@Test(expected = ConnectException.class) public void shouldThrowConnectionException() throws Exception { InfluxDbTcpSender influxDbTcpSender = new InfluxDbTcpSender( "0.0.0.0", 10080, 1000, "test", "" ); influxDbTcpSender.writeData(new byte[0]); }
@Test public void shouldNotThrowException() throws Exception { ServerSocket server = new ServerSocket(10080); InfluxDbTcpSender influxDbTcpSender = new InfluxDbTcpSender( "0.0.0.0", 10080, 1000, "test", "" ); assertThat(influxDbTcpSender.writeData(new byte[0]) == 0); server.close(); }