1 package br.org.articulus.server.dao;
2
3 import java.util.Date;
4 import java.util.List;
5
6 import junit.framework.TestCase;
7
8 import org.springframework.context.support.ClassPathXmlApplicationContext;
9
10 import br.org.articulus.domain.Log;
11
12
13
14
15
16
17
18 public class LogDaoTest extends TestCase {
19
20 private static final int ID = 1;
21 private ClassPathXmlApplicationContext ctx;
22
23 protected void setUp() throws Exception {
24 ctx = new ClassPathXmlApplicationContext(new String[] {
25 "applicationContext-hibernate.xml"});
26 }
27
28
29
30
31
32
33
34 public void testSave() {
35 Log l = new Log();
36 l.setIdUser(ID);
37 l.setDate(new Date());
38 l.setTime(new Date());
39 l.setAction("User logged");
40
41 LogDao ld = (LogDao)ctx.getBean("logDao");
42 ld.save(l);
43
44 assertNotNull(l);
45 }
46
47
48
49
50
51
52
53 @SuppressWarnings("unchecked")
54 public void testGet() {
55 LogDao ld = (LogDao)ctx.getBean("logDao");
56 List<Log> l = ld.getAll();
57
58 assertNotNull(ld.get(l.get(0).getId()));
59 }
60
61
62
63
64
65
66
67 public void testGetAll() {
68 LogDao ld = (LogDao)ctx.getBean("logDao");
69
70 assertNotNull(ld.getAll());
71 }
72 }