/**
* Tests that searches work across comments.
*/
public void testSearchOnComments() {
try {
SearchResults results = index.search("swing");
assertEquals(0, results.getNumberOfHits());
BlogEntry blogEntry = new BlogEntry(blog);
blogEntry.addCategory(blog.getCategory("/category1"));
blogEntry.setPublished(true);
index.index(blogEntry);
// should be no hits returned yet
results = index.search("swing");
assertEquals(0, results.getNumberOfHits());
// now add some comments
Comment comment = blogEntry.createComment("Comment title", "Comment body", "Some author", "me@somedomain.com", "http://www.google.com", "http://graph.facebook.com/user/picture", "127.0.0.1");
blogEntry.addComment(comment);
index.index(blogEntry);
results = index.search("swing");
assertEquals(0, results.getNumberOfHits());
comment = blogEntry.createComment("Comment title", "Comment body with Swing in it", "Some author", "me@somedomain.com", "http://www.google.com", "http://graph.facebook.com/user/picture", "127.0.0.1");
blogEntry.addComment(comment);
index.index(blogEntry);
results = index.search("swing");
assertEquals(1, results.getNumberOfHits());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}