@Test
public void testExitIfConnectionFails() {        

    core.start(3);
    assertTrue("Should have succeeded", core.exitIfConnectionFails(core.client, 3));
    assertFalse("Success means it shouldn't be closed", core.isClosed());
    
    
    core.close();
    core = new NoSendJMSCore(sourceName, authToken, targetVantiqServer);
    FalseClient fc = new FalseClient(sourceName);
    core.client = core.fClient = fc;
    fc.initiateFullConnection(targetVantiqServer, authToken);
    fc.completeWebSocketConnection(true);
    fc.completeAuthentication(false);
    assertFalse("Should fail due to authentication failing", core.exitIfConnectionFails(core.client, 3));
    assertFalse("Failure does not mean it should be closed", core.isClosed());
    
    core.close();
    core = new NoSendJMSCore(sourceName, authToken, targetVantiqServer);
    fc = new FalseClient(sourceName);
    core.client = core.fClient = fc;
    fc.initiateFullConnection(targetVantiqServer, authToken);
    fc.completeWebSocketConnection(false);
    assertFalse("Should fail due to WebSocket failing", core.exitIfConnectionFails(core.client, 3));
    assertFalse("Failure does not mean it should be closed", core.isClosed());
    
    core.close();
    core = new NoSendJMSCore(sourceName, authToken, targetVantiqServer);
    fc = new FalseClient(sourceName);
    core.client = core.fClient = fc;
    fc.initiateFullConnection(targetVantiqServer, authToken);
    fc.completeWebSocketConnection(true);
    fc.completeAuthentication(true);
    assertFalse("Should fail due to timeout on source connection", core.exitIfConnectionFails(core.client, 3));
    assertFalse("Failure does not mean it should be closed", core.isClosed());
}