forked from sommer1991/javaWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostTest.java
More file actions
41 lines (35 loc) · 1.02 KB
/
Copy pathPostTest.java
File metadata and controls
41 lines (35 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package webproject;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.weibo.dashboard.entity.Post;
import com.weibo.dashboard.service.PostService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:conf/spring-mybatis.xml"})
public class PostTest {
@Resource
PostService postservice;
@Test
public void testFindList(){
List<Post> list = postservice.findList();
for (Post post : list) {
System.out.println(post.getAuthorName());
if(post.getCommentList()!=null){
System.out.println(post.getCommentList().get(0).getcContent());
}
}
}
@Test
public void testAdd(){
Post post = new Post();
post.setAuthorName("wei");
post.setDate(new Date());
post.setContent("Sunny day");
int res = postservice.insert(post);
System.out.println(res);
}
}