Program: 69831
Project: 69831
Buggy source:
@Test public void testImport_QTI12_processAttachments_matimg() throws IOException, URISyntaxException {
  URL itemUrl=QTIImportProcessorTest.class.getResource("String_Node_Str");
  Assert.assertNotNull(itemUrl);
  File itemFile=new File(itemUrl.toURI());
  QTIImportProcessor proc=new QTIImportProcessor(owner,itemFile.getName(),itemFile,questionItemDao,qItemTypeDao,qEduContextDao,qpoolFileStorage);
  List<QuestionItem> items=proc.process();
  Assert.assertNotNull(items);
  Assert.assertEquals(3,items.size());
  dbInstance.commitAndCloseSession();
  for (  QuestionItem item : items) {
    QuestionItemFull itemFull=(QuestionItemFull)item;
    String dir=itemFull.getDirectory();
    String file=itemFull.getRootFilename();
    VFSContainer itemContainer=qpoolFileStorage.getContainer(dir);
    Assert.assertNotNull(itemContainer);
    VFSItem itemLeaf=itemContainer.resolve(file);
    Assert.assertNotNull(itemLeaf);
    Assert.assertTrue(itemLeaf instanceof VFSLeaf);
    InputStream is=((VFSLeaf)itemLeaf).getInputStream();
    XMLParser xmlParser=new XMLParser(new IMSEntityResolver());
    Document doc=xmlParser.parse(is,false);
    Node itemNode=doc.selectSingleNode("String_Node_Str");
    Assert.assertNotNull(itemNode);
    if ("String_Node_Str".equals(itemFull.getTitle())) {
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
    }
 else     if ("String_Node_Str".equals(itemFull.getTitle())) {
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
    }
 else     if ("String_Node_Str".equals(itemFull.getTitle())) {
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
    }
 else {
      Assert.fail();
    }
  }
}

Fixed version (ground truth):
@Test public void testImport_QTI12_processAttachments_matimg() throws IOException, URISyntaxException {
  URL itemUrl=QTIImportProcessorTest.class.getResource("String_Node_Str");
  Assert.assertNotNull(itemUrl);
  File itemFile=new File(itemUrl.toURI());
  QTIImportProcessor proc=new QTIImportProcessor(owner,Locale.ENGLISH,itemFile.getName(),itemFile,questionItemDao,qItemTypeDao,qEduContextDao,qpoolFileStorage);
  List<QuestionItem> items=proc.process();
  Assert.assertNotNull(items);
  Assert.assertEquals(3,items.size());
  dbInstance.commitAndCloseSession();
  for (  QuestionItem item : items) {
    QuestionItemFull itemFull=(QuestionItemFull)item;
    String dir=itemFull.getDirectory();
    String file=itemFull.getRootFilename();
    VFSContainer itemContainer=qpoolFileStorage.getContainer(dir);
    Assert.assertNotNull(itemContainer);
    VFSItem itemLeaf=itemContainer.resolve(file);
    Assert.assertNotNull(itemLeaf);
    Assert.assertTrue(itemLeaf instanceof VFSLeaf);
    InputStream is=((VFSLeaf)itemLeaf).getInputStream();
    XMLParser xmlParser=new XMLParser(new IMSEntityResolver());
    Document doc=xmlParser.parse(is,false);
    Node itemNode=doc.selectSingleNode("String_Node_Str");
    Assert.assertNotNull(itemNode);
    if ("String_Node_Str".equals(itemFull.getTitle())) {
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
    }
 else     if ("String_Node_Str".equals(itemFull.getTitle())) {
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
    }
 else     if ("String_Node_Str".equals(itemFull.getTitle())) {
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
      Assert.assertTrue(exists(itemFull,"String_Node_Str"));
      Assert.assertFalse(exists(itemFull,"String_Node_Str"));
    }
 else {
      Assert.fail();
    }
  }
}