@Test
void shouldRespondToInterruptsWhenConnectingToUnresponsiveServer() throws Exception
{

    try ( ServerSocket serverSocket = new ServerSocket( 0 ) )
    {
        // setup other thread to interrupt current thread when it blocks
        TestUtil.interruptWhenInWaitingState( Thread.currentThread() );
        final Driver driver = GraphDatabase.driver( "bolt://localhost:" + serverSocket.getLocalPort() );
        try
        {
            assertThrows( ServiceUnavailableException.class, driver::verifyConnectivity );
        }
        finally
        {
            // clear interrupted flag
            Thread.interrupted();
        }
    }
}