]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/SlcExecutionDaoJcrTest.java
Improve unit tests
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.jcr / src / test / java / org / argeo / slc / jcr / dao / SlcExecutionDaoJcrTest.java
1 package org.argeo.slc.jcr.dao;
2
3 import java.net.InetAddress;
4
5 import javax.jcr.Session;
6
7 import org.argeo.jcr.JcrUtils;
8 import org.argeo.slc.dao.process.SlcExecutionDao;
9 import org.argeo.slc.process.SlcExecution;
10 import org.argeo.slc.process.SlcExecutionStep;
11 import org.argeo.slc.unit.AbstractSpringTestCase;
12 import org.argeo.slc.unit.process.SlcExecutionTestUtils;
13
14 public class SlcExecutionDaoJcrTest extends AbstractSpringTestCase {
15 private SlcExecutionDao slcExecutionDao;
16 private Session session;
17 private String host;
18
19 @Override
20 protected void setUp() throws Exception {
21 super.setUp();
22 slcExecutionDao = getBean(SlcExecutionDao.class);
23 session = getBean(Session.class);
24 host = InetAddress.getLocalHost().getCanonicalHostName();
25 }
26
27 public void testCreate() throws Exception {
28 SlcExecution slcExecution0 = SlcExecutionTestUtils
29 .createSimpleSlcExecution();
30 slcExecution0.setHost(host);
31 slcExecutionDao.create(slcExecution0);
32
33 SlcExecution slcExecution = SlcExecutionTestUtils
34 .createSlcExecutionWithRealizedFlows();
35 slcExecution.setHost(host);
36 String uuid = slcExecution.getUuid();
37 slcExecutionDao.create(slcExecution);
38
39 JcrUtils.debug(session.getRootNode());
40
41 SlcExecution slcExecutionPersist = slcExecutionDao
42 .getSlcExecution(uuid);
43 SlcExecutionTestUtils.assertSlcExecution(slcExecution,
44 slcExecutionPersist);
45 }
46
47 public void testUpdate() throws Exception {
48 SlcExecution slcExecution0 = SlcExecutionTestUtils
49 .createSimpleSlcExecution();
50 slcExecution0.setHost(host);
51 slcExecutionDao.create(slcExecution0);
52 String uuid = slcExecution0.getUuid();
53
54 SlcExecution slcExecution = SlcExecutionTestUtils
55 .createSlcExecutionWithRealizedFlows();
56 slcExecution.setUuid(uuid);
57 slcExecution.setHost(host);
58 slcExecution.getSteps().add(new SlcExecutionStep("My log"));
59 slcExecutionDao.update(slcExecution);
60
61 JcrUtils.debug(session.getRootNode());
62
63 SlcExecution slcExecutionPersist = slcExecutionDao
64 .getSlcExecution(uuid);
65 SlcExecutionTestUtils.assertSlcExecution(slcExecution,
66 slcExecutionPersist);
67 }
68
69 // // FIXME
70 // protected void tearDown() {
71 // try {
72 // super.tearDown();
73 // } catch (Exception e) {
74 // log.debug("pbs Remain while closing jcr test env.");
75 // log.debug("Exc Name : " + e.getClass().getName());
76 // }
77 // }
78 }