@Test(expected = SocketException.class)
public void basicConnectionExceptionTest (@Mocked final Socket socket, @Mocked final InetAddress inetAddress) throws Exception {

    new Expectations() {{
        InetAddress.getByName(anyString);
        result = loopbackAddress;
        socket.connect((SocketAddress) any, anyInt);
        times = 1;
        result = new SocketException("Forcefully thrown exception");
    }};
    controlConnection = new QoSControlConnection(clientHolder, testParameter);
    try {
        controlConnection.connect();
    } catch (SocketException ex) {
        assertEquals("Forcefully thrown exception", ex.getMessage());
        assertFalse("ControlConnection wrongly says it's running", controlConnection.isRunning.get());
        assertTrue("ControlConnection wrongly says it could connect", controlConnection.couldNotConnect.get());
        throw ex;
    }
}