]> 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
Adapt to changes in Argeo Commons
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.jcr / src / test / java / org / argeo / slc / jcr / dao / SlcExecutionDaoJcrTest.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.jcr.dao;
17
18 import java.net.InetAddress;
19
20 import javax.jcr.Session;
21
22 import org.argeo.jcr.JcrUtils;
23 import org.argeo.slc.dao.process.SlcExecutionDao;
24 import org.argeo.slc.process.SlcExecution;
25 import org.argeo.slc.process.SlcExecutionStep;
26 import org.argeo.slc.unit.AbstractSpringTestCase;
27 import org.argeo.slc.unit.process.SlcExecutionTestUtils;
28
29 public class SlcExecutionDaoJcrTest extends AbstractSpringTestCase {
30 private SlcExecutionDao slcExecutionDao;
31 private Session session;
32 private String host;
33
34 @Override
35 protected void setUp() throws Exception {
36 super.setUp();
37 slcExecutionDao = getBean(SlcExecutionDao.class);
38 session = getBean(Session.class);
39 host = "localhost";
40 }
41
42 public void testCreate() throws Exception {
43 SlcExecution slcExecution0 = SlcExecutionTestUtils
44 .createSimpleSlcExecution();
45 slcExecution0.setHost(host);
46 slcExecutionDao.create(slcExecution0);
47
48 SlcExecution slcExecution = SlcExecutionTestUtils
49 .createSlcExecutionWithRealizedFlows();
50 slcExecution.setHost(host);
51 String uuid = slcExecution.getUuid();
52 slcExecutionDao.create(slcExecution);
53
54 JcrUtils.debug(session.getRootNode());
55
56 SlcExecution slcExecutionPersist = slcExecutionDao
57 .getSlcExecution(uuid);
58 SlcExecutionTestUtils.assertSlcExecution(slcExecution,
59 slcExecutionPersist);
60 }
61
62 public void testUpdate() throws Exception {
63 SlcExecution slcExecution0 = SlcExecutionTestUtils
64 .createSimpleSlcExecution();
65 slcExecution0.setHost(host);
66 slcExecutionDao.create(slcExecution0);
67 String uuid = slcExecution0.getUuid();
68
69 SlcExecution slcExecution = SlcExecutionTestUtils
70 .createSlcExecutionWithRealizedFlows();
71 slcExecution.setUuid(uuid);
72 slcExecution.setHost(host);
73 slcExecution.getSteps().add(new SlcExecutionStep("My log"));
74 slcExecutionDao.update(slcExecution);
75
76 JcrUtils.debug(session.getRootNode());
77
78 SlcExecution slcExecutionPersist = slcExecutionDao
79 .getSlcExecution(uuid);
80 SlcExecutionTestUtils.assertSlcExecution(slcExecution,
81 slcExecutionPersist);
82 }
83
84 // // FIXME
85 // protected void tearDown() {
86 // try {
87 // super.tearDown();
88 // } catch (Exception e) {
89 // log.debug("pbs Remain while closing jcr test env.");
90 // log.debug("Exc Name : " + e.getClass().getName());
91 // }
92 // }
93 }