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 import br.org.articulus.domain.SubSession;
11
12
13
14
15
16
17
18 public class SubSessionDaoTest extends TestCase {
19
20 private ClassPathXmlApplicationContext ctx;
21 private SubSessionDao ssd;
22
23
24 protected void setUp() throws Exception {
25 ctx = new ClassPathXmlApplicationContext(new String[] {
26 "applicationContext-hibernate.xml"});
27
28 ssd = (SubSessionDao)ctx.getBean("subSessionDao");
29 }
30
31
32
33
34
35
36
37 public void testSave() {
38 Session s = new Session();
39 s.setName("Test");
40 s.setPage("testPage.jsp");
41 s.setComment("Test Comment");
42
43 SessionDao sd = (SessionDao)ctx.getBean("sessionDao");
44 sd.save(s);
45
46 SubSession ss = new SubSession();
47 ss.setName("Test");
48 ss.setPage("testPage.jsp");
49 ss.setComment("test comment");
50 ss.setIdSession(s);
51
52 ssd.save(ss);
53
54 assertNotNull(s);
55 }
56
57
58
59
60
61
62
63 @SuppressWarnings("unchecked")
64 public void testGet() {
65 List<SubSession> l = ssd.getAll();
66
67 SubSession ss = ssd.get(l.get(0).getId());
68
69 assertNotNull(ss);
70 }
71
72
73
74
75
76
77
78 @SuppressWarnings("unchecked")
79 public void testUpdate() {
80 List<SubSession> l = ssd.getAll();
81
82 SubSession ss = (SubSession)ssd.get(l.get(0).getId());
83 ss.setName("Subsessao Atualizado!");
84
85 ssd.update(ss);
86
87 assertNotNull(ss);
88 }
89
90
91
92
93
94
95
96 @SuppressWarnings("unchecked")
97 public void testGetAll() {
98 List<SubSession> all = ssd.getAll();
99 assertNotNull(all.get(0));
100 }
101
102
103
104
105
106
107
108 @SuppressWarnings("unchecked")
109 public void testDelete() {
110 List<SubSession> l = ssd.getAll();
111
112 SubSession ss = ssd.get(l.get(0).getId());
113
114
115
116 assertNotNull(ss);
117 }
118 }