2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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.
17 package org
.argeo
.slc
.castor
;
19 import java
.text
.SimpleDateFormat
;
20 import java
.util
.UUID
;
22 import org
.argeo
.slc
.msg
.process
.SlcExecutionRequest
;
23 import org
.argeo
.slc
.msg
.process
.SlcExecutionStepsRequest
;
24 import org
.argeo
.slc
.process
.SlcExecution
;
25 import org
.argeo
.slc
.process
.SlcExecutionStep
;
26 import org
.argeo
.slc
.unit
.process
.SlcExecutionTestUtils
;
27 import org
.springframework
.xml
.transform
.StringResult
;
29 public class SlcExecutionCastorTest
extends AbstractCastorTestCase
{
30 public void testMarshalling() throws Exception
{
31 SlcExecution slcExec
= SlcExecutionTestUtils
.createSimpleSlcExecution();
33 SlcExecutionRequest msgSave
= new SlcExecutionRequest();
34 msgSave
.setSlcExecution(slcExec
);
36 StringResult msgSaveXml
= marshalAndValidate(msgSave
);
38 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd HH:mm");
39 SlcExecutionStep step0
= new SlcExecutionStep();
40 step0
.setUuid(UUID
.randomUUID().toString());
41 step0
.setTimestamp(sdf
.parse("2008-04-17 18:21"));
43 step0
.addLog("A log message\nand another line");
45 SlcExecutionStep step1
= new SlcExecutionStep();
46 step1
.setUuid(UUID
.randomUUID().toString());
47 step1
.setTimestamp(sdf
.parse("2008-04-17 18:25"));
49 step1
.addLog("A nother log message");
51 SlcExecutionStepsRequest msgNotif
= new SlcExecutionStepsRequest();
52 msgNotif
.addStep(step0
);
53 msgNotif
.addStep(step1
);
54 msgNotif
.setSlcExecutionUuid(slcExec
.getUuid());
56 StringResult msgNotifXml
= marshalAndValidate(msgNotif
);
58 SlcExecutionRequest msgSaveUnm
= unmarshal(msgSaveXml
);
59 assertNotNull(msgSaveUnm
);
60 SlcExecutionTestUtils
.assertSlcExecution(slcExec
, msgSaveUnm
63 SlcExecutionStepsRequest msgNotifUnm
= unmarshal(msgNotifXml
);
64 assertNotNull(msgNotifUnm
);
65 assertEquals(slcExec
.getUuid(), msgNotifUnm
.getSlcExecutionUuid());
66 assertEquals(2, msgNotifUnm
.getSteps().size());
67 SlcExecutionTestUtils
.assertSlcExecutionStep(step0
, msgNotifUnm
69 SlcExecutionTestUtils
.assertSlcExecutionStep(step1
, msgNotifUnm
72 SlcExecution slcExecUnm
= msgSaveUnm
.getSlcExecution();
73 slcExecUnm
.getSteps().addAll(msgNotifUnm
.getSteps());
75 SlcExecutionRequest msgUpdate
= new SlcExecutionRequest();
76 msgUpdate
.setSlcExecution(slcExecUnm
);
77 StringResult msgUpdateXml
= marshalAndValidate(msgUpdate
);
79 SlcExecutionRequest msgUpdateUnm
= unmarshal(msgUpdateXml
);
80 assertNotNull(msgUpdateUnm
);
83 public void testMarshUnmarsh() throws Exception
{
84 SlcExecution slcExec
= SlcExecutionTestUtils
85 .createSlcExecutionWithRealizedFlows();
86 marshUnmarsh(slcExec
, false);