/** Tests that the avatar is properly escaped and set. */ public void testAvatar() { assertEquals("http://graph.facebook.com/user/picture", comment.getAvatar()); // blank or null avatar name defaults to null comment.setAvatar(""); assertEquals(null, comment.getAvatar()); comment.setAvatar(null); assertEquals(null, comment.getAvatar()); // for security, special HTML characters are removed comment.setAvatar("<script>http://graph.facebook.com/user/picture"); assertEquals("http://graph.facebook.com/user/picture", comment.getAvatar()); // anything avatar are also checked for known prefixes and "http://" // is prepended if missing comment.setAvatar("http://graph.facebook.com/user/picture"); assertEquals("http://graph.facebook.com/user/picture", comment.getAvatar()); comment.setAvatar("https://graph.facebook.com/user/picture"); assertEquals("https://graph.facebook.com/user/picture", comment.getAvatar()); comment.setAvatar("ftp://graph.facebook.com/user/picture"); assertEquals("ftp://graph.facebook.com/user/picture", comment.getAvatar()); comment.setAvatar("mailto://graph.facebook.com/user/picture"); assertEquals("mailto://graph.facebook.com/user/picture", comment.getAvatar()); comment.setAvatar("graph.facebook.com/user/picture"); assertEquals("http://graph.facebook.com/user/picture", comment.getAvatar()); }
/** Tests that a comment can be cloned. */ public void testClone() { Comment clonedComment = (Comment) comment.clone(); assertEquals(comment.getTitle(), clonedComment.getTitle()); assertEquals(comment.getBody(), clonedComment.getBody()); assertEquals(comment.getWebsite(), clonedComment.getWebsite()); assertEquals(comment.getAvatar(), clonedComment.getAvatar()); assertEquals(comment.getAuthor(), clonedComment.getAuthor()); assertEquals(comment.getIpAddress(), clonedComment.getIpAddress()); assertEquals(comment.getDate(), clonedComment.getDate()); assertEquals(comment.getId(), clonedComment.getId()); assertEquals(comment.getState(), clonedComment.getState()); assertEquals(comment.getParent(), clonedComment.getParent()); assertEquals(comment.getBlogEntry(), clonedComment.getBlogEntry()); }
/** Test that a Comment instance can be created correctly. */ public void testConstructionOfSimpleInstance() { assertNotNull(comment); assertEquals("Title", comment.getTitle()); assertEquals("Body", comment.getBody()); assertEquals("Author", comment.getAuthor()); assertEquals("*****@*****.**", comment.getEmail()); assertEquals("http://www.google.com", comment.getWebsite()); assertEquals("http://graph.facebook.com/user/picture", comment.getAvatar()); assertEquals("127.0.0.1", comment.getIpAddress()); assertNotNull(comment.getDate()); assertEquals(comment.getDate().getTime(), comment.getId()); assertNotNull(comment.getBlogEntry()); assertEquals(State.APPROVED, comment.getState()); assertEquals("c/" + comment.getBlogEntry().getId() + "/" + comment.getId(), comment.getGuid()); }