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.IElementDefinition;
32: import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
33: import com.bostechcorp.cbesb.common.mdl.MDLParser;
34: import com.bostechcorp.cbesb.common.mdl.impl.MDLDocumentImpl;
35:
36: /**
37: * now we can get any element by using :
38: * getElementDefinition(namespaceURI, localName)
39: * even though elements are in different mdl files
40: *
41: */
42: public class TestNewGetElementDefinition extends TestCase {
43: File mdlFile = new File("target/test-data/in/variable2a.mdl");
44: File mdlFile2 = new File("target/test-data/in/variable4a.mdl");
45:
46: IMDLDocument mdlDoc = new MDLDocumentImpl();
47: IMDLDocument mdlDoc2 = new MDLDocumentImpl();
48:
49: protected void setUp() throws Exception {
50: super .setUp();
51: mdlDoc = MDLParser.load(mdlFile);
52: mdlDoc2 = MDLParser.load(mdlFile2);
53: }
54:
55: protected void tearDown() throws Exception {
56: super .tearDown();
57: }
58:
59: public void testGetNull() {
60: IElementDefinition elementDef = mdlDoc.getElementDefinition(
61: "com.get", "element");
62: assertNull(elementDef);
63: }
64:
65: public void testGetIncludeElement() {
66: IElementDefinition elementDef = mdlDoc.getElementDefinition(
67: "http://www.bostechcorp.com/variable2", "Manufacturer");
68: assertEquals("Manufacturer", elementDef.getName());
69: assertEquals("string", elementDef.getDatatype());
70: }
71:
72: public void testGetImportElement() {
73: assertEquals("http://www.bostechcorp.com/variable4", mdlDoc2
74: .getTargetNamespace());
75: IElementDefinition elementDef = mdlDoc2.getElementDefinition(
76: "http://www.bostechcorp.com/variable2", "UnitPrice");
77: assertNotNull(elementDef);
78: assertEquals("UnitPrice", elementDef.getName());
79: assertEquals("http://www.bostechcorp.com/variable2", elementDef
80: .getNamespaceURI());
81: assertEquals("string", elementDef.getDatatype());
82: }
83: }
|