2 * Copyright (C) 2007-2012 Mathieu Baudier
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.slc
.castor
;
18 import java
.text
.SimpleDateFormat
;
19 import java
.util
.UUID
;
21 import org
.argeo
.slc
.msg
.process
.SlcExecutionRequest
;
22 import org
.argeo
.slc
.msg
.process
.SlcExecutionStepsRequest
;
23 import org
.argeo
.slc
.process
.SlcExecution
;
24 import org
.argeo
.slc
.process
.SlcExecutionStep
;
25 import org
.argeo
.slc
.unit
.process
.SlcExecutionTestUtils
;
26 import org
.springframework
.xml
.transform
.StringResult
;
28 public class SlcExecutionCastorTest
extends AbstractCastorTestCase
{
29 public void testMarshalling() throws Exception
{
30 SlcExecution slcExec
= SlcExecutionTestUtils
.createSimpleSlcExecution();
32 SlcExecutionRequest msgSave
= new SlcExecutionRequest();
33 msgSave
.setSlcExecution(slcExec
);
35 StringResult msgSaveXml
= marshalAndValidate(msgSave
);
37 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd HH:mm");
38 SlcExecutionStep step0
= new SlcExecutionStep();
39 step0
.setUuid(UUID
.randomUUID().toString());
40 step0
.setTimestamp(sdf
.parse("2008-04-17 18:21"));
42 step0
.addLog("A log message\nand another line");
44 SlcExecutionStep step1
= new SlcExecutionStep();
45 step1
.setUuid(UUID
.randomUUID().toString());
46 step1
.setTimestamp(sdf
.parse("2008-04-17 18:25"));
48 step1
.addLog("A nother log message");
50 SlcExecutionStepsRequest msgNotif
= new SlcExecutionStepsRequest();
51 msgNotif
.addStep(step0
);
52 msgNotif
.addStep(step1
);
53 msgNotif
.setSlcExecutionUuid(slcExec
.getUuid());
55 StringResult msgNotifXml
= marshalAndValidate(msgNotif
);
57 SlcExecutionRequest msgSaveUnm
= unmarshal(msgSaveXml
);
58 assertNotNull(msgSaveUnm
);
59 SlcExecutionTestUtils
.assertSlcExecution(slcExec
, msgSaveUnm
62 SlcExecutionStepsRequest msgNotifUnm
= unmarshal(msgNotifXml
);
63 assertNotNull(msgNotifUnm
);
64 assertEquals(slcExec
.getUuid(), msgNotifUnm
.getSlcExecutionUuid());
65 assertEquals(2, msgNotifUnm
.getSteps().size());
66 SlcExecutionTestUtils
.assertSlcExecutionStep(step0
, msgNotifUnm
68 SlcExecutionTestUtils
.assertSlcExecutionStep(step1
, msgNotifUnm
71 SlcExecution slcExecUnm
= msgSaveUnm
.getSlcExecution();
72 slcExecUnm
.getSteps().addAll(msgNotifUnm
.getSteps());
74 SlcExecutionRequest msgUpdate
= new SlcExecutionRequest();
75 msgUpdate
.setSlcExecution(slcExecUnm
);
76 StringResult msgUpdateXml
= marshalAndValidate(msgUpdate
);
78 SlcExecutionRequest msgUpdateUnm
= unmarshal(msgUpdateXml
);
79 assertNotNull(msgUpdateUnm
);
82 public void testMarshUnmarsh() throws Exception
{
83 SlcExecution slcExec
= SlcExecutionTestUtils
84 .createSlcExecutionWithRealizedFlows();
85 marshUnmarsh(slcExec
, false);