Program: 3991
Project: 3991
Buggy source:
/** 
 * Tests the getFiles().iterator() method.
 */
public void testGetFiles() throws Exception {
  Map<URN,Long> toSerialize=new HashMap<URN,Long>();
  Long old=new Long(1);
  Long middle=new Long(2);
  Long young=new Long(3);
  toSerialize.put(hash1,middle);
  toSerialize.put(hash2,young);
  toSerialize.put(hash3,old);
  toSerialize.put(hash4,middle);
  ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(new File(_settingsDir,CREATION_CACHE_FILE)));
  oos.writeObject(toSerialize);
  oos.close();
  CreationTimeCache ctCache=new CreationTimeCache(fileManager);
  assertEquals(ctCache.getCreationTime(hash1),middle);
  assertEquals(ctCache.getCreationTime(hash2),young);
  assertEquals(ctCache.getCreationTime(hash3),old);
  assertEquals(ctCache.getCreationTime(hash4),middle);
{
    Iterator iter=ctCache.getFiles().iterator();
    assertEquals(hash2,iter.next());
    URN urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    assertEquals(hash3,iter.next());
    assertFalse(iter.hasNext());
  }
{
    Iterator iter=ctCache.getFiles(4).iterator();
    assertEquals(hash2,iter.next());
    URN urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    assertEquals(hash3,iter.next());
    assertFalse(iter.hasNext());
  }
{
    Iterator iter=ctCache.getFiles(3).iterator();
    assertEquals(hash2,iter.next());
    URN urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    assertFalse(iter.hasNext());
  }
{
    Iterator iter=ctCache.getFiles(2).iterator();
    assertEquals(hash2,iter.next());
    URN urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    assertFalse(iter.hasNext());
  }
{
    Iterator iter=ctCache.getFiles(1).iterator();
    assertEquals(hash2,iter.next());
    assertFalse(iter.hasNext());
  }
{
    try {
      ctCache.getFiles(0).iterator();
      fail("String_Node_Str");
    }
 catch (    IllegalArgumentException expected) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Tests the getFiles().iterator() method.
 */
public void testGetFiles() throws Exception {
  Map<URN,Long> toSerialize=new HashMap<URN,Long>();
  Long old=new Long(1);
  Long middle=new Long(2);
  Long young=new Long(3);
  toSerialize.put(hash1,middle);
  toSerialize.put(hash2,young);
  toSerialize.put(hash3,old);
  toSerialize.put(hash4,middle);
  ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(new File(_settingsDir,CREATION_CACHE_FILE)));
  oos.writeObject(toSerialize);
  oos.close();
  CreationTimeCache ctCache=new CreationTimeCache(fileManager);
  assertEquals(ctCache.getCreationTime(hash1),middle);
  assertEquals(ctCache.getCreationTime(hash2),young);
  assertEquals(ctCache.getCreationTime(hash3),old);
  assertEquals(ctCache.getCreationTime(hash4),middle);
{
    Iterator iter=ctCache.getFiles().iterator();
    assertEquals(hash2,iter.next());
    URN urn=(URN)iter.next();
    assertTrue("String_Node_Str" + urn,urn.equals(hash1) || urn.equals(hash4));
    urn=(URN)iter.next();
    assertTrue("String_Node_Str" + urn,urn.equals(hash1) || urn.equals(hash4));
    assertEquals(hash3,iter.next());
    assertFalse(iter.hasNext());
  }
{
    Iterator iter=ctCache.getFiles(4).iterator();
    assertEquals(hash2,iter.next());
    URN urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    assertEquals(hash3,iter.next());
    assertFalse(iter.hasNext());
  }
{
    Iterator iter=ctCache.getFiles(3).iterator();
    assertEquals(hash2,iter.next());
    URN urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    assertFalse(iter.hasNext());
  }
{
    Iterator iter=ctCache.getFiles(2).iterator();
    assertEquals(hash2,iter.next());
    URN urn=(URN)iter.next();
    assertTrue(urn.equals(hash1) || urn.equals(hash4));
    assertFalse(iter.hasNext());
  }
{
    Iterator iter=ctCache.getFiles(1).iterator();
    assertEquals(hash2,iter.next());
    assertFalse(iter.hasNext());
  }
{
    try {
      ctCache.getFiles(0).iterator();
      fail("String_Node_Str");
    }
 catch (    IllegalArgumentException expected) {
    }
  }
}