01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License as published by
09: * the Free Software Foundation; either version 2 of the License, or
10: * (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
20: * USA
21: *
22: *
23: * $ID$
24: */
25: package com.bostechcorp.cbesb.common.mdl;
26:
27: import java.io.File;
28:
29: import junit.framework.TestCase;
30:
31: import com.bostechcorp.cbesb.common.mdl.IContentElement;
32: import com.bostechcorp.cbesb.common.mdl.IContentNode;
33: import com.bostechcorp.cbesb.common.mdl.IElementDefinition;
34: import com.bostechcorp.cbesb.common.mdl.IFixedChildAttributes;
35: import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
36: import com.bostechcorp.cbesb.common.mdl.MDLParser;
37: import com.bostechcorp.cbesb.common.mdl.impl.MDLDocumentImpl;
38:
39: public class TestFixedFormatDefinition extends TestCase {
40:
41: File mdlFile5 = new File("target/test-data/in/fixed1.mdl");
42:
43: IMDLDocument mdlDoc5 = new MDLDocumentImpl();
44:
45: protected void setUp() throws Exception {
46: super .setUp();
47:
48: mdlDoc5 = MDLParser.load(mdlFile5);
49: }
50:
51: protected void tearDown() throws Exception {
52: super .tearDown();
53: }
54:
55: /**
56: * test fixedFormatDefinition
57: * The only allowed value for the content are
58: * type = "sequence" and idMethod = "position" all child elements are
59: * required and non-repeating, so the minOccurs and maxOccurs may also be
60: * omitted from each child.
61: * minOccurs=1 and maxOccurs=1
62: * length required
63: */
64: public void testFixedFormatDefinition() {
65: IContentNode cNode[] = mdlDoc5.getAllMessageDefinitions()[0]
66: .getChildren();
67: for (int i = 0; i < cNode.length; i++) {
68: assertEquals(1, cNode[i].getMinOccurs());
69: assertEquals(1, cNode[i].getMaxOccurs());
70: if (cNode[i] instanceof IContentElement) {
71: IContentElement cElement = (IContentElement) cNode[i];
72: IFixedChildAttributes fCAttributes = (IFixedChildAttributes) cElement
73: .getFormatChildAttributes();
74: assertNotNull(fCAttributes.getLength());
75: }
76: }
77: IContentElement cElement = (IContentElement) cNode[0];
78: IFixedChildAttributes fixAttributes = (IFixedChildAttributes) cElement
79: .getFormatChildAttributes();
80: assertEquals(10, fixAttributes.getLength());
81: assertEquals('0', fixAttributes.getFillChar());
82: assertEquals(1, fixAttributes.getJustification());
83: }
84: }
|