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 com.bostechcorp.cbesb.common.mdl.IMDLDocument;
30: import com.bostechcorp.cbesb.common.mdl.IMessageDefinition;
31: import com.bostechcorp.cbesb.common.mdl.MDLParser;
32: import com.bostechcorp.cbesb.common.mdl.impl.MDLDocumentImpl;
33: import com.bostechcorp.cbesb.common.mdl.impl.MessageDefinitionImpl;
34:
35: import junit.framework.TestCase;
36:
37: public class TestProcessMessageDefinition extends TestCase {
38:
39: File mdlFile5 = new File("target/test-data/in/fixed1.mdl");
40:
41: IMDLDocument mdlDoc5 = new MDLDocumentImpl();
42:
43: private static final boolean Flase = false;
44:
45: protected void setUp() throws Exception {
46: super .setUp();
47: mdlDoc5 = MDLParser.load(mdlFile5);
48: }
49:
50: protected void tearDown() throws Exception {
51: super .tearDown();
52: }
53:
54: /**
55: * test get/add/remove messageDefinition.
56: * Message definitions must be defined globally. The
57: * definition of a message must contain a name and either a format or
58: * datatype.
59: */
60: public void testMessageDefinition() {
61: IMessageDefinition messageDefinition[] = mdlDoc5
62: .getAllMessageDefinitions();
63: String messageName = messageDefinition[0].getName();
64: assertNotNull(messageName);
65: boolean isGlobal = Flase;
66: isGlobal = messageDefinition[0].isGlobal();
67: assertTrue(isGlobal);
68:
69: //create a messageDefinition
70: IMessageDefinition addMessageDef = new MessageDefinitionImpl();
71: addMessageDef.setName("add");
72: addMessageDef.setNamespaceURI("com.add");
73:
74: //add messageDefinition
75: mdlDoc5.addMessageDefinition(addMessageDef);
76: assertNotNull(mdlDoc5.getMessageDefinition("com.add", "add"));
77:
78: //remove messageDefinition
79: mdlDoc5.removeMessageDefinition("com.add", "add");
80: assertNull(mdlDoc5.getMessageDefinition("com.add", "add"));
81: mdlDoc5.removeMessageDefinition(
82: "http://www.bostechcorp.com/fixed1", "OrderRecord");
83: assertEquals(0, mdlDoc5.getAllMessageDefinitions().length);
84:
85: }
86: }
|