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