/**
* Tests that a permalink can be generated for a blog entry when there are
* duplicate titles for the same day.
*/
public void testBlogEntryPermalinkForEntriesWithSameTitle() throws Exception {
BlogService service = new BlogService();
BlogEntry blogEntry1 = new BlogEntry(blog);
blogEntry1.setTitle("A Title");
service.putBlogEntry(blogEntry1);
String prefix = "/";
String suffix = "";
assertEquals(prefix + "a-title" + suffix, permalinkProvider.getPermalink(blogEntry1));
// now add another with the same name
BlogEntry blogEntry2 = new BlogEntry(blog);
blogEntry2.setTitle("A Title");
service.putBlogEntry(blogEntry2);
assertEquals(prefix + "a-title" + suffix, permalinkProvider.getPermalink(blogEntry1));
assertEquals(prefix + "a-title_" + blogEntry2.getId() + suffix, permalinkProvider.getPermalink(blogEntry2));
// now add another with the same name a year ahead
BlogEntry blogEntry3 = new BlogEntry(blog);
blogEntry3.setTitle("A Title");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.YEAR, 1);
blogEntry3.setDate(cal.getTime());
service.putBlogEntry(blogEntry3);
assertEquals(prefix + "a-title" + suffix, permalinkProvider.getPermalink(blogEntry1));
assertEquals(prefix + "a-title_" + blogEntry2.getId() + suffix, permalinkProvider.getPermalink(blogEntry2));
assertEquals(prefix + "a-title_" + blogEntry3.getId() + suffix, permalinkProvider.getPermalink(blogEntry3));
}