]> git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/integration-tests/org.argeo.slc.it.webapp/src/test/java-old/org/argeo/slc/ws/SlcExecutionWsIntegrationTest.java
2f5d05b23bfd122752d51961253fc7c5d70112e2
[gpl/argeo-slc.git] / legacy / integration-tests / org.argeo.slc.it.webapp / src / test / java-old / org / argeo / slc / ws / SlcExecutionWsIntegrationTest.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
17 package org.argeo.slc.ws;
18
19 import java.util.List;
20 import java.util.Vector;
21
22 import org.springframework.ws.client.core.WebServiceTemplate;
23 import org.springframework.ws.soap.client.SoapFaultClientException;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28 import org.argeo.slc.msg.process.SlcExecutionRequest;
29 import org.argeo.slc.msg.process.SlcExecutionStatusRequest;
30 import org.argeo.slc.msg.process.SlcExecutionStepsRequest;
31 import org.argeo.slc.process.SlcExecution;
32 import org.argeo.slc.process.SlcExecutionStep;
33 import org.argeo.slc.unit.AbstractSpringTestCase;
34 import org.argeo.slc.unit.process.SlcExecutionTestUtils;
35 import org.argeo.slc.ws.client.WebServiceUtils;
36
37 public class SlcExecutionWsIntegrationTest extends AbstractSpringTestCase {
38 private Log log = LogFactory.getLog(getClass());
39
40 private WebServiceTemplate template;
41
42 public void setUp() {
43 template = getBean(WebServiceTemplate.class);
44 }
45
46 public void testSlcExecutionRequests() {
47 SlcExecution slcExec = createAndSendSlcExecution();
48
49 slcExec.setUser("otherUser");
50 log.info("Send update SlcExecutionRequest for SlcExecution #"
51 + slcExec.getUuid());
52 template.marshalSendAndReceive(new SlcExecutionRequest(slcExec));
53 }
54
55 public void testSlcExecutionStatusRequest() {
56 SlcExecution slcExec = createAndSendSlcExecution();
57
58 slcExec.setStatus(SlcExecution.STATUS_FINISHED);
59 log.info("Send SlcExecutionStatusRequest for SlcExecution #"
60 + slcExec.getUuid());
61 template.marshalSendAndReceive(new SlcExecutionStatusRequest(slcExec
62 .getUuid(), slcExec.getStatus()));
63 }
64
65 public void testSendSlcExecutionStepRequest() {
66 SlcExecution slcExec = createAndSendSlcExecution();
67
68 SlcExecutionStep step1 = new SlcExecutionStep(
69 "Logline\nAnother log line.");
70 SlcExecutionStep step2 = new SlcExecutionStep(
71 "Logline2\nAnother log line2.");
72 List<SlcExecutionStep> steps = new Vector<SlcExecutionStep>();
73 steps.add(step1);
74 steps.add(step2);
75
76 log.info("Send SlcExecutionStepsRequest for SlcExecution #"
77 + slcExec.getUuid());
78 try {
79 template.marshalSendAndReceive(new SlcExecutionStepsRequest(slcExec
80 .getUuid(), steps));
81 } catch (SoapFaultClientException e) {
82 WebServiceUtils.manageSoapException(e);
83 throw e;
84 }
85 }
86
87 protected SlcExecution createAndSendSlcExecution() {
88 SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();
89
90 log.info("Send create SlcExecutionRequest for SlcExecution #"
91 + slcExec.getUuid());
92 template.marshalSendAndReceive(new SlcExecutionRequest(slcExec));
93 return slcExec;
94 }
95 }