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