Program: 172330
Project: 172330
Buggy source:
public void testReadAgainstDelta() throws Exception {
  testTX.commit();
  UserTransaction tx=transactionService.getUserTransaction();
  tx.begin();
  luceneFTS.pause();
  buildBaseIndex();
  runBaseTests();
  tx.commit();
  tx=transactionService.getUserTransaction();
  tx.begin();
  runBaseTests();
  serviceRegistry.getNodeService().deleteNode(n1);
  SearchParameters sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  ResultSet results=serviceRegistry.getSearchService().query(sp);
  assertEquals(5,results.length());
  results.close();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(true);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  tx.rollback();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  tx=transactionService.getUserTransaction();
  tx.begin();
  runBaseTests();
  assertEquals(5,serviceRegistry.getNodeService().getChildAssocs(rootNodeRef).size());
  serviceRegistry.getNodeService().createNode(rootNodeRef,ContentModel.ASSOC_CHILDREN,QName.createQName("String_Node_Str"),testSuperType).getChildRef();
  assertEquals(6,serviceRegistry.getNodeService().getChildAssocs(rootNodeRef).size());
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(16,results.length());
  results.close();
  tx.rollback();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  tx=transactionService.getUserTransaction();
  tx.begin();
  runBaseTests();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(2,results.length());
  results.close();
  nodeService.setProperty(n1,QName.createQName("String_Node_Str"),"String_Node_Str");
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(1,results.length());
  results.close();
  tx.rollback();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  sp.addSort("String_Node_Str",true);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(2,results.length());
  results.close();
  tx=transactionService.getUserTransaction();
  tx.begin();
  runBaseTests();
  serviceRegistry.getNodeService().deleteNode(n1);
  serviceRegistry.getNodeService().createNode(rootNodeRef,ContentModel.ASSOC_CHILDREN,QName.createQName("String_Node_Str"),testSuperType).getChildRef();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(6,results.length());
  results.close();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(true);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  tx.rollback();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
}

Fixed version (ground truth):
public void testReadAgainstDelta() throws Exception {
  testTX.commit();
  UserTransaction tx=transactionService.getUserTransaction();
  tx.begin();
  luceneFTS.pause();
  buildBaseIndex();
  runBaseTests();
  tx.commit();
  tx=transactionService.getUserTransaction();
  tx.begin();
  runBaseTests();
  serviceRegistry.getNodeService().deleteNode(n1);
  SearchParameters sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  ResultSet results=serviceRegistry.getSearchService().query(sp);
  assertEquals(5,results.length());
  results.close();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(true);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  tx.rollback();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  tx=transactionService.getUserTransaction();
  tx.begin();
  runBaseTests();
  assertEquals(5,serviceRegistry.getNodeService().getChildAssocs(rootNodeRef).size());
  serviceRegistry.getNodeService().createNode(rootNodeRef,ContentModel.ASSOC_CHILDREN,QName.createQName("String_Node_Str"),testSuperType).getChildRef();
  assertEquals(6,serviceRegistry.getNodeService().getChildAssocs(rootNodeRef).size());
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(16,results.length());
  results.close();
  tx.rollback();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  tx=transactionService.getUserTransaction();
  tx.begin();
  runBaseTests();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(2,results.length());
  results.close();
  nodeService.setProperty(n1,QName.createQName("String_Node_Str"),"String_Node_Str");
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(1,results.length());
  results.close();
  tx.rollback();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  sp.addSort("String_Node_Str",true);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(2,results.length());
  results.close();
  tx=transactionService.getUserTransaction();
  tx.begin();
  runBaseTests();
  serviceRegistry.getNodeService().deleteNode(n1);
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(5,results.length());
  results.close();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(true);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  NodeRef created=serviceRegistry.getNodeService().createNode(rootNodeRef,ContentModel.ASSOC_CHILDREN,QName.createQName("String_Node_Str"),testSuperType).getChildRef();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(6,results.length());
  results.close();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(true);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  serviceRegistry.getNodeService().deleteNode(created);
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(5,results.length());
  results.close();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.excludeDataInTheCurrentTransaction(true);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
  tx.rollback();
  sp=new SearchParameters();
  sp.addStore(rootNodeRef.getStoreRef());
  sp.setLanguage(SearchService.LANGUAGE_LUCENE);
  sp.setQuery("String_Node_Str");
  sp.addSort("String_Node_Str",true);
  sp.excludeDataInTheCurrentTransaction(false);
  results=serviceRegistry.getSearchService().query(sp);
  assertEquals(15,results.length());
  results.close();
}