]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.castor/src/test/java/org/argeo/slc/castor/SlcAgentDescriptorCastorTest.java
Introduce H
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.castor / src / test / java / org / argeo / slc / castor / SlcAgentDescriptorCastorTest.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.castor;
18
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.argeo.slc.execution.ExecutionModuleDescriptor;
23 import org.argeo.slc.runtime.SlcAgentDescriptor;
24
25 public class SlcAgentDescriptorCastorTest extends AbstractCastorTestCase {
26 public void testMarshUnmarshMini() throws Exception {
27 SlcAgentDescriptor agentDescriptor = createMiniAgentDescriptor();
28 SlcAgentDescriptor agentDescriptorUnm = marshUnmarsh(agentDescriptor,
29 false);
30 assertSlcAgentDescriptor(agentDescriptor, agentDescriptorUnm);
31 }
32
33 public void testMarshUnmarshWithModuleDescriptor() throws Exception {
34 SlcAgentDescriptor agentDescriptor = createMiniAgentDescriptor();
35
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);
42
43 SlcAgentDescriptor agentDescriptorUnm = marshUnmarsh(agentDescriptor,
44 false);
45 assertSlcAgentDescriptor(agentDescriptor, agentDescriptorUnm);
46 }
47
48 protected static SlcAgentDescriptor createMiniAgentDescriptor() {
49 SlcAgentDescriptor agentDescriptor = new SlcAgentDescriptor();
50 agentDescriptor.setHost("localhost");
51 agentDescriptor.setUuid("555");
52 return agentDescriptor;
53 }
54
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());
62 }
63 }