01: package org.emforge.test;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05: import org.emforge.CommentService;
06: import org.emforge.EmForgeException;
07: import org.emforge.xfer.CommentTO;
08:
09: import static org.junit.Assert.assertNotNull;
10: import static org.junit.Assert.assertEquals;
11: import org.junit.Test;
12:
13: import org.springframework.beans.factory.annotation.Autowired;
14:
15: public class CommentServiceTest extends BaseWsUnitTest {
16: private final Log log = LogFactory.getLog(getClass());
17:
18: @Autowired
19: private CommentService commentService;
20:
21: @Test
22: public void testWorkWithCommentsForPage() throws EmForgeException {
23: // get comments for main page
24: CommentTO[] comments = commentService.getComments("Main");
25: Integer commentsSize = 0;
26: if (comments != null) {
27: commentsSize = comments.length;
28: }
29:
30: // add new comment
31: commentService.addComment("Main",
32: "This is comment from unit-test");
33:
34: // now check - is comment size increased
35: comments = commentService.getComments("Main");
36: assertNotNull(comments);
37: assertEquals(commentsSize + 1, comments.length);
38:
39: for (CommentTO comment : comments) {
40: log.info(comment.getAuthor() + " " + comment.getTime()
41: + ":" + comment.getHtmlMessage());
42: }
43: }
44: }
|