1 package br.org.articulus.server.dao;
2
3 import java.util.List;
4
5 import junit.framework.TestCase;
6
7 import org.springframework.context.support.ClassPathXmlApplicationContext;
8
9 import br.org.articulus.domain.Session;
10
11
12
13
14
15
16
17 public class SessionDaoTest extends TestCase {
18
19 private ClassPathXmlApplicationContext ctx;
20 private SessionDao ssd;
21
22
23 protected void setUp() throws Exception {
24 ctx = new ClassPathXmlApplicationContext(new String[] {
25 "applicationContext-hibernate.xml"});
26
27 ssd = (SessionDao)ctx.getBean("sessionDao");
28 }
29
30
31
32
33
34
35
36 public void testSave() {
37 Session s = new Session();
38 s.setName("Cadastro");
39 s.setPage("cadastro.jsp");
40 s.setComment("Pagina de cadastro");
41
42 ssd.save(s);
43
44 assertNotNull(s);
45 }
46
47
48
49
50
51
52
53 @SuppressWarnings("unchecked")
54 public void testGet() {
55 List<Session> l = ssd.getAll();
56
57 Session s = ssd.get(l.get(0).getId());
58
59 assertNotNull(s);
60 }
61
62
63
64
65
66
67
68 @SuppressWarnings("unchecked")
69 public void testUpdate() {
70 List<Session> l = ssd.getAll();
71
72 Session s = (Session)ssd.get(l.get(0).getId());
73 s.setName("Cadastro Atualizado!");
74
75 ssd.update(s);
76
77 assertNotNull(s);
78 }
79
80
81
82
83
84
85
86 @SuppressWarnings("unchecked")
87 public void testGetAll() {
88 List<Session> all = ssd.getAll();
89 assertNotNull(all.get(0));
90 }
91
92
93
94
95
96
97
98 @SuppressWarnings("unchecked")
99 public void testDelete() {
100 List<Session> l = ssd.getAll();
101
102 Session s = ssd.get(l.get(0).getId());
103
104
105
106 assertNotNull(s);
107 }
108 }