public void flushToServer() {
        if (buffer.isEmpty()) {
            return;
        }

        List sent = new ArrayList();
        try {
            synchronized (buffer) {
                while (!buffer.isEmpty()) {
                    sent.add(buffer.remove());
                }
            }
            StringBuilder result = new StringBuilder();
            for (Object string : sent) {
                result.append(string);
                result.append("\n");
            }
            consoleAppender.append(result.toString());
        } catch (IOException e) {
            LOGGER.warn("Could not send console output to server", e);
            synchronized (buffer) {
                sent.addAll(buffer);
                buffer.clear();
                buffer.addAll(sent);
            }
        }
    }
@Test
    public void shouldNotFlushToServerWhenBufferIsEmpty() throws Exception {
        transmitter.flushToServer();

        verify(consoleAppender, never()).append(any(String.class));
    }