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: *
24: * $Id: TestForamtChildAttributes.java 3531 2006-12-08 09:28:11Z sji $
25: */
26: package com.bostechcorp.cbesb.common.mdl;
27:
28: import java.io.File;
29:
30: import junit.framework.TestCase;
31:
32: import com.bostechcorp.cbesb.common.mdl.IContentElement;
33: import com.bostechcorp.cbesb.common.mdl.IContentNode;
34: import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
35: import com.bostechcorp.cbesb.common.mdl.IMessageDefinition;
36: import com.bostechcorp.cbesb.common.mdl.IVariableChildAttributes;
37: import com.bostechcorp.cbesb.common.mdl.MDLParser;
38: import com.bostechcorp.cbesb.common.mdl.impl.MDLDocumentImpl;
39:
40: public class TestForamtChildAttributes extends TestCase {
41:
42: File mdlFile = new File("target/test-data/in/group1.mdl");
43:
44: IMDLDocument mdlDoc = new MDLDocumentImpl();
45:
46: protected void setUp() throws Exception {
47: super .setUp();
48:
49: mdlDoc = MDLParser.load(mdlFile);
50:
51: }
52:
53: protected void tearDown() throws Exception {
54: super .tearDown();
55: }
56:
57: /**
58: * minLength :optional Specifies the minimum length of the data. default value is -1
59: * maxLength :optional Specifies the maximum length of the data. default value is -1
60: * tag optional If the content idMethod is set to "tag",
61: * then each child element must specify the
62: * value of its tag using this attribute.
63: */
64: public void testVarialbeChildAttributes() {
65: //test variableChildAttributes
66: IMessageDefinition msgDef = mdlDoc.getAllMessageDefinitions()[0];
67: IContentNode cNode[] = msgDef.getChildren();
68:
69: IContentElement contentElement = (IContentElement) cNode[0];
70: assertEquals(-1, ((IVariableChildAttributes) contentElement
71: .getFormatChildAttributes()).getMaxLength());
72: assertEquals(-1, ((IVariableChildAttributes) contentElement
73: .getFormatChildAttributes()).getMinLength());
74: assertEquals("DG1", ((IVariableChildAttributes) contentElement
75: .getFormatChildAttributes()).getTag());
76:
77: IContentElement contentElement2 = (IContentElement) cNode[1];
78: assertEquals(50, ((IVariableChildAttributes) contentElement2
79: .getFormatChildAttributes()).getMaxLength());
80: assertEquals(1, ((IVariableChildAttributes) contentElement2
81: .getFormatChildAttributes()).getMinLength());
82: assertEquals("MNF", ((IVariableChildAttributes) contentElement2
83: .getFormatChildAttributes()).getTag());
84: }
85: }
86: //fixedVariableChildAttributes has been tested in the Class:TestFixedFormatDefinition
|