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: TestDatatypeDefinition.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.IDatatypeDefinition;
33: import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
34: import com.bostechcorp.cbesb.common.mdl.MDLParser;
35: import com.bostechcorp.cbesb.common.mdl.impl.DatatypeDefinitionImpl;
36: import com.bostechcorp.cbesb.common.mdl.impl.MDLDocumentImpl;
37:
38: /**
39: * test datatypeDefinition
40: *
41: */
42: public class TestDatatypeDefinition extends TestCase {
43: File mdlFile = new File("target/test-data/in/datatypes.mdl");
44:
45: IMDLDocument mdlDoc = new MDLDocumentImpl();
46:
47: protected void setUp() throws Exception {
48: super .setUp();
49: mdlDoc = MDLParser.load(mdlFile);
50: }
51:
52: protected void tearDown() throws Exception {
53: super .tearDown();
54: }
55:
56: public void testGetDatatype() {
57: IDatatypeDefinition datatypeDef = new DatatypeDefinitionImpl();
58: datatypeDef = mdlDoc.getAllDatatypeDefinitions()[0];
59: assertEquals("AN", datatypeDef.getName());
60:
61: datatypeDef = mdlDoc.getDatatypeDefinition(mdlDoc
62: .getTargetNamespace(), "AN");
63: assertEquals("string", datatypeDef.getBaseType());
64: assertEquals("String", datatypeDef.getDescription());
65:
66: }
67:
68: public void testaddDatatype() {
69: IDatatypeDefinition datatypeDef = new DatatypeDefinitionImpl();
70: datatypeDef.setBaseType("number");
71: datatypeDef.setName("add");
72: datatypeDef.setDescription("new");
73: datatypeDef.setNamespaceURI("com.add");
74:
75: int count = mdlDoc.getAllDatatypeDefinitions().length;
76: mdlDoc.addDatatypeDefinition(datatypeDef);
77:
78: assertEquals(count + 1,
79: mdlDoc.getAllDatatypeDefinitions().length);
80: assertEquals("number", datatypeDef.getBaseType());
81: assertEquals("add", datatypeDef.getName());
82: assertEquals("new", datatypeDef.getDescription());
83: assertEquals("com.add", datatypeDef.getNamespaceURI());
84:
85: }
86: }
|