001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify
008: * it under the terms of the GNU General Public License as published by
009: * the Free Software Foundation; either version 2 of the License, or
010: * (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: *
023: *
024: */
025: /*
026: * $Header: /home/projects/mule/scm/mule/mule/src/test/java/org/mule/test/config/MessagesTestCase.java,v 1.4 2005/06/23 08:01:27 gnt Exp $
027: * $Revision: 1.4 $
028: * $Date: 2005/06/23 08:01:27 $
029: * ------------------------------------------------------------------------------------------------------
030: *
031: * Copyright (c) SymphonySoft Limited. All rights reserved.
032: * http://www.symphonysoft.com
033: *
034: * The software in this package is published under the terms of the BSD
035: * style license a copy of which has been included with this distribution in
036: * the LICENSE.txt file.
037: */
038: package com.bostechcorp.cbesb.common.trn.test;
039:
040: import java.io.IOException;
041:
042: import junit.framework.TestCase;
043:
044: import org.apache.xmlbeans.XmlOptions;
045:
046: import com.bostechcorp.cbesb.common.util.FileUtil;
047: import com.bostechcorp.cbesb.trn.x10.*;
048:
049: public class TrnSerializerTest extends TestCase {
050:
051: public TrnSerializerTest() {
052: super ();
053:
054: }
055:
056: public void testTransferControllDocumentCreate() throws Exception {
057: try {
058:
059: TransformerControlDocument doc = TransformerControlDocument.Factory
060: .newInstance();
061:
062: TransformerControlDef tc = doc.addNewTransformerControl();
063:
064: FormatsDef format = tc.addNewFormats();
065:
066: FormatDef inFd = format.addNewInput();
067:
068: inFd.setFormat("xsd");
069: inFd.setName("target/test-data/config/CWInvoices.xsd");
070:
071: FormatDef outFd = format.addNewOutput();
072:
073: outFd.setFormat("xsd");
074: outFd.setName("target/test-data/config/o4oputl0.xsd");
075: outFd.setRoot("o4oputl0");
076:
077: OperationListDef opLst = tc.addNewOperationList();
078:
079: OperationDef od = opLst.addNewOperation();
080:
081: od.setName("iterate");
082: od.setType("built-in");
083: ParamDef pd = od.addNewParameters();
084:
085: DataAddressDef src = pd.addNewSource();
086:
087: src.setType("absolute");
088: src.setPath("Message/InvoiceHeader/CartonHeader");
089:
090: PropertyListDef pld = pd.addNewPropertyList();
091:
092: SettingDef sd = pld.addNewSetting();
093:
094: sd.setName("context");
095: sd.setValue("carton_header_context");
096:
097: XmlOptions xmlOptions = new XmlOptions();
098:
099: // Requests use of whitespace for easier reading
100: xmlOptions.setSavePrettyPrint();
101:
102: // Requests that nested levels of the xml
103: // document to be indented by multiple of 4
104: // whitespace characters
105: xmlOptions.setSavePrettyPrintIndent(4);
106:
107: System.out.println("XML is: " + doc.xmlText(xmlOptions));
108:
109: } catch (Exception e) {
110: System.err.println("TranslateCompiler exception: " + e);
111: e.printStackTrace();
112: fail("unexpected expection: " + e.getMessage());
113: }
114: }
115:
116: }
|