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
.util
.ArrayList
;
20 import java
.util
.List
;
22 import org
.argeo
.slc
.execution
.ExecutionModuleDescriptor
;
23 import org
.argeo
.slc
.runtime
.SlcAgentDescriptor
;
25 public class SlcAgentDescriptorCastorTest
extends AbstractCastorTestCase
{
26 public void testMarshUnmarshMini() throws Exception
{
27 SlcAgentDescriptor agentDescriptor
= createMiniAgentDescriptor();
28 SlcAgentDescriptor agentDescriptorUnm
= marshUnmarsh(agentDescriptor
,
30 assertSlcAgentDescriptor(agentDescriptor
, agentDescriptorUnm
);
33 public void testMarshUnmarshWithModuleDescriptor() throws Exception
{
34 SlcAgentDescriptor agentDescriptor
= createMiniAgentDescriptor();
36 List
<ExecutionModuleDescriptor
> lst
= new ArrayList
<ExecutionModuleDescriptor
>();
37 ExecutionModuleDescriptor moduleDescriptor
= new ExecutionModuleDescriptor();
38 moduleDescriptor
.setName("test.moodule");
39 moduleDescriptor
.setVersion("1.0.0");
40 lst
.add(moduleDescriptor
);
41 agentDescriptor
.setModuleDescriptors(lst
);
43 SlcAgentDescriptor agentDescriptorUnm
= marshUnmarsh(agentDescriptor
,
45 assertSlcAgentDescriptor(agentDescriptor
, agentDescriptorUnm
);
48 protected static SlcAgentDescriptor
createMiniAgentDescriptor() {
49 SlcAgentDescriptor agentDescriptor
= new SlcAgentDescriptor();
50 agentDescriptor
.setHost("localhost");
51 agentDescriptor
.setUuid("555");
52 return agentDescriptor
;
55 protected static void assertSlcAgentDescriptor(SlcAgentDescriptor expected
,
56 SlcAgentDescriptor reached
) {
57 assertNotNull(reached
);
58 assertEquals(expected
.getHost(), reached
.getHost());
59 assertEquals(expected
.getUuid(), expected
.getUuid());
60 assertEquals(expected
.getModuleDescriptors().size(), reached
61 .getModuleDescriptors().size());