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.IProperty;
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.PropertyImpl;
34:
35: import junit.framework.TestCase;
36:
37: /**
38: * test get/add/remove property
39: * name required
40: * value required
41: */
42: public class TestProcessProperty extends TestCase {
43: File mdlFile = new File("target/test-data/in/delimiterRef.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:
53: protected void tearDown() throws Exception {
54: super .tearDown();
55: }
56:
57: public void testGetAllProperty() {
58: IProperty property[] = mdlDoc.getAllProperties();
59: assertEquals(5, property.length);
60: assertEquals("XLength", property[1].getName());
61: assertEquals("3", property[1].getValue());
62: }
63:
64: public void testGetProperty() {
65: IProperty property = mdlDoc.getProperty("XescapeChar");
66: assertEquals("\\", property.getValue());
67: }
68:
69: public void testAddProperty() {
70: // IProperty addProperty=new PropertyImpl();
71: // addProperty.setName("add");
72: // addProperty.setValue("addOne");
73: mdlDoc.addProperty("add", "addOne");
74: assertEquals(6, mdlDoc.getAllProperties().length);
75: assertEquals("addOne", mdlDoc.getProperty("add").getValue());
76: }
77:
78: public void testRemoveProperty() {
79: mdlDoc.removeProperty("XescapeChar");
80: mdlDoc.removeProperty("XquoteChar");
81: assertEquals(3, mdlDoc.getAllProperties().length);
82: assertNull(mdlDoc.getProperty("XescapeChar"));
83: assertNull(mdlDoc.getProperty("XquoteChar"));
84:
85: }
86:
87: }
|