* Test method for {@link tifauv.jplop.core.board.Post#Post(long, java.lang.String, java.lang.String, java.lang.String)}.
*/
public void testPostLongStringStringString() {
// First simple test
Date now = new Date();
Post post = new Post(0, null, "message", null);
DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
assertEquals(0, post.getId());
assertEquals("", post.getInfo());
assertEquals("message", post.getMessage());
assertEquals(Post.ANONYMOUS_LOGIN, post.getLogin());
String postStr = " <post id=\"0\" time=\"" + formatter.format(now) + "\">\n"
+ " <info><![CDATA[]]></info>\n"
+ " <message><![CDATA[message]]></message>\n"
+ " <login><![CDATA[" + Post.ANONYMOUS_LOGIN + "]]></login>\n"
+ " </post>\n";
assertEquals(postStr, post.toString());
// Check with a non-null login
post = new Post(1, "info", "message", "login");
assertEquals(1, post.getId());
assertEquals("info", post.getInfo());
assertEquals("message", post.getMessage());
assertEquals("login", post.getLogin());
// Check with a well-formatted message
post = new Post(2, "info", "<i>italic</i>", "login");
assertEquals(2, post.getId());
assertEquals("info", post.getInfo());
assertEquals("<i>italic</i>", post.getMessage());
assertEquals("login", post.getLogin());
// Check with a bad-formatted message
post = new Post(1, "info", "<i>italic", "login");
assertEquals(1, post.getId());
assertEquals("info", post.getInfo());
assertEquals("<i>italic</i>", post.getMessage());
assertEquals("login", post.getLogin());
// Check with a bad-formatted message
post = new Post(1, "info", "italic</i>", "login");
assertEquals(1, post.getId());
assertEquals("info", post.getInfo());
assertEquals("italic</i>", post.getMessage());
assertEquals("login", post.getLogin());
// Check with a bad-formatted message
post = new Post(3, "info", "<i>italic<b>bold", "login");
assertEquals(3, post.getId());
assertEquals("info", post.getInfo());
assertEquals("<i>italic<b>bold</b></i>", post.getMessage());
assertEquals("login", post.getLogin());
// Check with a bad-formatted message
post = new Post(4, "info", "<i>italic</b>bold", "login");
assertEquals(4, post.getId());
assertEquals("info", post.getInfo());
assertEquals("<i>italic</b>bold</i>", post.getMessage());
assertEquals("login", post.getLogin());
// Check with a bad-formatted message
post = new Post(5, "info", "<i>italic<u>underline</b>bold</u>", "login");
assertEquals(5, post.getId());
assertEquals("info", post.getInfo());
assertEquals("<i>italic<u>underline</b>bold</u></i>", post.getMessage());
assertEquals("login", post.getLogin());
// Check with a bad-formatted message
post = new Post(6, "info", "<b>bold<i>italic<u>underline</b>normal", "login");
assertEquals(6, post.getId());
assertEquals("info", post.getInfo());
assertEquals("<b>bold<i>italic<u>underline</u></i></b>normal", post.getMessage());
assertEquals("login", post.getLogin());
// Check with an http url in the message
post = new Post(7, "info", "plop http://www.example.com toto", "login");
assertEquals(7, post.getId());
assertEquals("info", post.getInfo());
assertEquals("plop <a href=\"http://www.example.com\">[http]</a> toto", post.getMessage());
assertEquals("login", post.getLogin());
// Check with an https url in the message
post = new Post(8, "info", "plop https://www.example.com toto", "login");
assertEquals(8, post.getId());
assertEquals("info", post.getInfo());
assertEquals("plop <a href=\"https://www.example.com\">[https]</a> toto", post.getMessage());
assertEquals("login", post.getLogin());
// Check with an ftp url in the message
post = new Post(9, "info", "plop ftp://www.example.com toto", "login");
assertEquals(9, post.getId());
assertEquals("info", post.getInfo());
assertEquals("plop <a href=\"ftp://www.example.com\">[ftp]</a> toto", post.getMessage());
assertEquals("login", post.getLogin());
// Check with an http url in the message
post = new Post(10, "info", "plop http://www.example.com00:11:22 toto", "login");
assertEquals(10, post.getId());
assertEquals("info", post.getInfo());
assertEquals("plop <a href=\"http://www.example.com00:11:22\">[http]</a> toto", post.getMessage());
assertEquals("login", post.getLogin());
// Check with an http url in the message
post = new Post(11, "info", "<i>http://www.example.com</i>", "login");
assertEquals(11, post.getId());
assertEquals("info", post.getInfo());
assertEquals("<i><a href=\"http://www.example.com\">[http]</a></i>", post.getMessage());
assertEquals("login", post.getLogin());
// Check with an http url in the message
post = new Post(12, "info", "http://www.example.com[:totoz]", "login");
assertEquals(12, post.getId());
assertEquals("info", post.getInfo());
assertEquals("<a href=\"http://www.example.com[:totoz]\">[http]</a>", post.getMessage());
assertEquals("login", post.getLogin());
}