Program: 172095
Project: 172095
Buggy source:
/** 
 * This test method uses the eventually consistent find*() method and so may fail if Lucene is disabled.
 */
@Test public void findBlogPostsByPublishedDate() throws Exception {
  final List<String> tags=Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"});
  final Calendar cal=Calendar.getInstance();
  cal.set(1971,6,15);
  final Date _1971=cal.getTime();
  cal.set(1975,0,1);
  final Date _1975=cal.getTime();
  cal.set(1980,0,1);
  final Date _1980=cal.getTime();
  cal.set(1981,0,1);
  final Date _1981=cal.getTime();
  cal.set(1985,6,15);
  final Date _1985=cal.getTime();
  cal.set(1991,6,15);
  final Date _1991=cal.getTime();
  final Map<Integer,NodeRef> blogPosts=TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Map<Integer,NodeRef>>(){
    @Override public Map<Integer,NodeRef> execute() throws Throwable {
      Map<Integer,NodeRef> result=new HashMap<Integer,NodeRef>();
      final BlogPostInfo blogPost1971=BLOG_SERVICE.createBlogPost(BLOG_CONTAINER_NODE,"String_Node_Str","String_Node_Str",true);
      final BlogPostInfo blogPost1981=BLOG_SERVICE.createBlogPost(BLOG_CONTAINER_NODE,"String_Node_Str","String_Node_Str",true);
      final BlogPostInfo blogPost1991=BLOG_SERVICE.createBlogPost(BLOG_CONTAINER_NODE,"String_Node_Str","String_Node_Str",true);
      TAGGING_SERVICE.addTags(blogPost1971.getNodeRef(),tags);
      TAGGING_SERVICE.addTags(blogPost1981.getNodeRef(),tags);
      TAGGING_SERVICE.addTags(blogPost1991.getNodeRef(),tags);
      testNodesToTidy.add(blogPost1971.getNodeRef());
      testNodesToTidy.add(blogPost1981.getNodeRef());
      testNodesToTidy.add(blogPost1991.getNodeRef());
      NODE_SERVICE.setProperty(blogPost1971.getNodeRef(),ContentModel.PROP_PUBLISHED,_1971);
      NODE_SERVICE.setProperty(blogPost1981.getNodeRef(),ContentModel.PROP_PUBLISHED,_1981);
      NODE_SERVICE.setProperty(blogPost1991.getNodeRef(),ContentModel.PROP_PUBLISHED,_1991);
      result.put(1971,blogPost1971.getNodeRef());
      result.put(1981,blogPost1981.getNodeRef());
      result.put(1991,blogPost1991.getNodeRef());
      return result;
    }
  }
);
  TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>(){
    @SuppressWarnings("String_Node_Str") @Override public Void execute() throws Throwable {
      assertEquals("String_Node_Str",71,((Date)NODE_SERVICE.getProperty(blogPosts.get(1971),ContentModel.PROP_PUBLISHED)).getYear());
      PagingRequest pagingReq=new PagingRequest(0,10,null);
      final RangedDateProperty publishedBefore1980=new RangedDateProperty(null,_1980,ContentModel.PROP_PUBLISHED);
      final RangedDateProperty publishedAfter1980=new RangedDateProperty(_1980,null,ContentModel.PROP_PUBLISHED);
      final RangedDateProperty publishedBetween1975And1985=new RangedDateProperty(_1975,_1985,ContentModel.PROP_PUBLISHED);
      PagingResults<BlogPostInfo> pagedResults=BLOG_SERVICE.findBlogPosts(BLOG_CONTAINER_NODE,null,null,pagingReq);
      assertEquals("String_Node_Str",3,pagedResults.getPage().size());
      Set<NodeRef> recoveredBlogNodes=new HashSet<NodeRef>();
      for (      BlogPostInfo bpi : pagedResults.getPage()) {
        recoveredBlogNodes.add(bpi.getNodeRef());
      }
      assertTrue("String_Node_Str",recoveredBlogNodes.contains(blogPosts.get(1971)));
      assertTrue("String_Node_Str",recoveredBlogNodes.contains(blogPosts.get(1981)));
      assertTrue("String_Node_Str",recoveredBlogNodes.contains(blogPosts.get(1991)));
      pagedResults=BLOG_SERVICE.findBlogPosts(BLOG_CONTAINER_NODE,publishedBefore1980,null,pagingReq);
      assertEquals("String_Node_Str",1,pagedResults.getPage().size());
      NodeRef blogNode=pagedResults.getPage().get(0).getNodeRef();
      assertEquals("String_Node_Str",blogNode,blogPosts.get(1971));
      List<String> recoveredTags=TAGGING_SERVICE.getTags(blogNode);
      assertEquals("String_Node_Str",tags,recoveredTags);
      pagedResults=BLOG_SERVICE.findBlogPosts(BLOG_CONTAINER_NODE,publishedAfter1980,"String_Node_Str",pagingReq);
      assertEquals("String_Node_Str",2,pagedResults.getPage().size());
      blogNode=pagedResults.getPage().get(0).getNodeRef();
      assertEquals("String_Node_Str",blogNode,blogPosts.get(1991));
      pagedResults=BLOG_SERVICE.findBlogPosts(BLOG_CONTAINER_NODE,publishedBetween1975And1985,"String_Node_Str",pagingReq);
      assertEquals("String_Node_Str",1,pagedResults.getPage().size());
      blogNode=pagedResults.getPage().get(0).getNodeRef();
      assertEquals("String_Node_Str",blogNode,blogPosts.get(1981));
      return null;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * This test method uses the eventually consistent find*() method and so may fail if Lucene is disabled.
 */
@Test public void findBlogPostsByPublishedDate() throws Exception {
  final List<String> tags=Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"});
  final Calendar cal=Calendar.getInstance();
  cal.set(1971,6,15);
  final Date _1971=cal.getTime();
  cal.set(1975,0,1);
  final Date _1975=cal.getTime();
  cal.set(1980,0,1);
  final Date _1980=cal.getTime();
  cal.set(1981,0,1);
  final Date _1981=cal.getTime();
  cal.set(1985,6,15);
  final Date _1985=cal.getTime();
  cal.set(1991,6,15);
  final Date _1991=cal.getTime();
  final Map<Integer,NodeRef> blogPosts=TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Map<Integer,NodeRef>>(){
    @Override public Map<Integer,NodeRef> execute() throws Throwable {
      Map<Integer,NodeRef> result=new HashMap<Integer,NodeRef>();
      final BlogPostInfo blogPost1971=BLOG_SERVICE.createBlogPost(BLOG_CONTAINER_NODE,"String_Node_Str","String_Node_Str",true);
      final BlogPostInfo blogPost1981=BLOG_SERVICE.createBlogPost(BLOG_CONTAINER_NODE,"String_Node_Str","String_Node_Str",true);
      final BlogPostInfo blogPost1991=BLOG_SERVICE.createBlogPost(BLOG_CONTAINER_NODE,"String_Node_Str","String_Node_Str",true);
      TAGGING_SERVICE.addTags(blogPost1971.getNodeRef(),tags);
      TAGGING_SERVICE.addTags(blogPost1981.getNodeRef(),tags);
      TAGGING_SERVICE.addTags(blogPost1991.getNodeRef(),tags);
      testNodesToTidy.add(blogPost1971.getNodeRef());
      testNodesToTidy.add(blogPost1981.getNodeRef());
      testNodesToTidy.add(blogPost1991.getNodeRef());
      NODE_SERVICE.setProperty(blogPost1971.getNodeRef(),ContentModel.PROP_PUBLISHED,_1971);
      NODE_SERVICE.setProperty(blogPost1981.getNodeRef(),ContentModel.PROP_PUBLISHED,_1981);
      NODE_SERVICE.setProperty(blogPost1991.getNodeRef(),ContentModel.PROP_PUBLISHED,_1991);
      result.put(1971,blogPost1971.getNodeRef());
      result.put(1981,blogPost1981.getNodeRef());
      result.put(1991,blogPost1991.getNodeRef());
      return result;
    }
  }
);
  TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>(){
    @SuppressWarnings("String_Node_Str") @Override public Void execute() throws Throwable {
      assertEquals("String_Node_Str",71,((Date)NODE_SERVICE.getProperty(blogPosts.get(1971),ContentModel.PROP_PUBLISHED)).getYear());
      PagingRequest pagingReq=new PagingRequest(0,10,null);
      final RangedDateProperty publishedBefore1980=new RangedDateProperty(null,_1980,ContentModel.PROP_PUBLISHED);
      final RangedDateProperty publishedAfter1980=new RangedDateProperty(_1980,null,ContentModel.PROP_PUBLISHED);
      final RangedDateProperty publishedBetween1975And1985=new RangedDateProperty(_1975,_1985,ContentModel.PROP_PUBLISHED);
      PagingResults<BlogPostInfo> pagedResults=BLOG_SERVICE.findBlogPosts(BLOG_CONTAINER_NODE,null,null,pagingReq);
      assertEquals("String_Node_Str",3,pagedResults.getPage().size());
      Set<NodeRef> recoveredBlogNodes=new HashSet<NodeRef>();
      for (      BlogPostInfo bpi : pagedResults.getPage()) {
        recoveredBlogNodes.add(bpi.getNodeRef());
      }
      assertTrue("String_Node_Str",recoveredBlogNodes.contains(blogPosts.get(1971)));
      assertTrue("String_Node_Str",recoveredBlogNodes.contains(blogPosts.get(1981)));
      assertTrue("String_Node_Str",recoveredBlogNodes.contains(blogPosts.get(1991)));
      pagedResults=BLOG_SERVICE.findBlogPosts(BLOG_CONTAINER_NODE,publishedBefore1980,null,pagingReq);
      assertEquals("String_Node_Str",1,pagedResults.getPage().size());
      NodeRef blogNode=pagedResults.getPage().get(0).getNodeRef();
      assertEquals("String_Node_Str",blogNode,blogPosts.get(1971));
      List<String> recoveredTags=TAGGING_SERVICE.getTags(blogNode);
      assertEquals("String_Node_Str",tags,recoveredTags);
      pagedResults=BLOG_SERVICE.findBlogPosts(BLOG_CONTAINER_NODE,publishedAfter1980,"String_Node_Str",pagingReq);
      assertEquals("String_Node_Str",2,pagedResults.getPage().size());
      blogNode=pagedResults.getPage().get(0).getNodeRef();
      assertEquals("String_Node_Str",blogNode,blogPosts.get(1981));
      pagedResults=BLOG_SERVICE.findBlogPosts(BLOG_CONTAINER_NODE,publishedBetween1975And1985,"String_Node_Str",pagingReq);
      assertEquals("String_Node_Str",1,pagedResults.getPage().size());
      blogNode=pagedResults.getPage().get(0).getNodeRef();
      assertEquals("String_Node_Str",blogNode,blogPosts.get(1981));
      return null;
    }
  }
);
}