public void testRetries() {
    JUnitMessageQueue queue = createQueue(TWO_CLIENTS, ONE_BLOCK, ONE_TEST_PER_BLOCK);
    TestInfo testInfo = queue.getTestBlocks().get(0)[0];
    Map<TestInfo, JUnitResult> results = new HashMap<TestInfo, JUnitResult>();
    JUnitResult junitResult = new JUnitResult();
    junitResult.setException(new AssertionError());
    results.put(testInfo, junitResult);
    queue.reportResults(createClientInfo(0, "ff3"), results);
    assertTrue(queue.needsRerunning(testInfo));
    Map<ClientStatus, JUnitResult> queueResults = queue.getResults(testInfo);
    assertEquals(1, queueResults.size());
    for (JUnitResult result : queueResults.values()) {
      assertNotNull(result.getException());
    }

    queue.removeResults(testInfo);

    queue.reportResults(createClientInfo(0, "ff3"), createTestResults(ONE_TEST_PER_BLOCK));
    queue.reportResults(createClientInfo(1, "ie6"), createTestResults(ONE_TEST_PER_BLOCK));
    assertFalse(queue.needsRerunning(testInfo));
    // check that the updated result appears now.
    queueResults = queue.getResults(testInfo);
    assertEquals(2, queueResults.size());
    for (JUnitResult result : queueResults.values()) {
      assertNull(result.getException());
    }
  }
  public void testNeedRerunningExceptions() {
    JUnitMessageQueue queue = createQueue(TWO_CLIENTS, ONE_BLOCK, ONE_TEST_PER_BLOCK);
    // an exception
    TestInfo testInfo = queue.getTestBlocks().get(0)[0];
    Map<TestInfo, JUnitResult> results = new HashMap<TestInfo, JUnitResult>();
    JUnitResult junitResult = new JUnitResult();
    junitResult.setException(new UnableToCompleteException());
    results.put(testInfo, junitResult);
    queue.reportResults(createClientInfo(0, "ie6"), results);
    results = new HashMap<TestInfo, JUnitResult>();
    junitResult = new JUnitResult();
    junitResult.setException(new JUnitFatalLaunchException());
    results.put(testInfo, junitResult);
    queue.reportResults(createClientInfo(1, "ff3"), createTestResults(ONE_TEST_PER_BLOCK));
    assertTrue(queue.needsRerunning(testInfo));

    // an exception but exception in launch module
    queue.removeResults(testInfo);
    results = new HashMap<TestInfo, JUnitResult>();
    junitResult = new JUnitResult();
    junitResult.setException(new JUnitFatalLaunchException());
    results.put(testInfo, junitResult);
    queue.reportResults(createClientInfo(0, "ie6"), results);
    queue.reportResults(createClientInfo(1, "ff3"), createTestResults(ONE_TEST_PER_BLOCK));
    assertFalse(queue.needsRerunning(testInfo));
  }
  public void testRemove() {
    JUnitMessageQueue queue = createQueue(TWO_CLIENTS, ONE_BLOCK, ONE_TEST_PER_BLOCK);
    TestInfo testInfo = queue.getTestBlocks().get(0)[0];
    assertFalse(queue.hasResults(testInfo));

    queue.reportResults(createClientInfo(0, "ie6"), createTestResults(ONE_TEST_PER_BLOCK));
    assertFalse(queue.hasResults(testInfo));
    queue.reportResults(createClientInfo(1, "ff3"), createTestResults(ONE_TEST_PER_BLOCK));
    assertTrue(queue.hasResults(testInfo));

    queue.removeResults(testInfo);
    assertFalse(queue.hasResults(testInfo));
  }