@Override
    public void write(final Message message) throws Exception {
        // Use #trySend instead of #send on the transport, so we don't block and can handle the shutdown of the output.
        while (isRunning() && !transport.trySend(toGELFMessage(message))) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("Couldn't send message to GELF transport. Waiting 100 ms before trying again.");
            }
            TimeUnit.MICROSECONDS.sleep(100);
        }
    }
@Test
    public void testWrite() throws Exception {
        final GelfTransport transport = mock(GelfTransport.class);
        final Message message = mock(Message.class);
        final GelfMessage gelfMessage = new GelfMessage("Test");
        final GelfOutput gelfOutput = Mockito.spy(new GelfOutput(transport));
        doReturn(gelfMessage).when(gelfOutput).toGELFMessage(message);
        when(transport.trySend(gelfMessage)).thenReturn(true);

        gelfOutput.write(message);

        verify(transport).trySend(eq(gelfMessage));
    }