001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)TestServiceAssemblyInfo.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.ui.common;
030:
031: import java.io.InputStream;
032: import java.io.InputStreamReader;
033: import java.util.ArrayList;
034: import java.util.Iterator;
035: import java.util.List;
036: import junit.framework.TestCase;
037:
038: /**
039: * test class
040: * @author Sun Microsystems, Inc.
041: */
042: public class TestServiceAssemblyInfo extends TestCase {
043:
044: /**
045: * Creates a new instance of TestMgmtMessage
046: * @param aTestName name
047: */
048: public TestServiceAssemblyInfo(String aTestName) {
049: super (aTestName);
050: }
051:
052: /**
053: * fix it
054: * @throws Exception fix it
055: */
056: public void testLoad() throws Exception {
057:
058: InputStream res = this .getClass().getResourceAsStream(
059: "test_service_assembly_info.xml");
060: InputStreamReader xmlReader = new InputStreamReader(res);
061:
062: List testList = ServiceAssemblyInfo
063: .readFromXmlTextWithProlog(xmlReader);
064: for (Iterator itr = testList.iterator(); itr.hasNext();) {
065: ServiceAssemblyInfo info = (ServiceAssemblyInfo) itr.next();
066: System.out.println(info);
067: List suList = info.getServiceUnitInfoList();
068: for (Iterator suItr = suList.iterator(); suItr.hasNext();) {
069: System.out.println(suItr.next());
070: }
071: }
072:
073: String xmlText = ServiceAssemblyInfo
074: .writeAsXmlTextWithProlog(testList);
075: System.out.println("Serialized Service Assembly Inof List XML");
076: System.out.println(xmlText);
077: testList = ServiceAssemblyInfo
078: .readFromXmlTextWithProlog(xmlText);
079: System.out
080: .println("Deserialized Service Assembly Inof List XML");
081: for (Iterator itr = testList.iterator(); itr.hasNext();) {
082: ServiceAssemblyInfo info = (ServiceAssemblyInfo) itr.next();
083: System.out.println(info);
084: List suList = info.getServiceUnitInfoList();
085: for (Iterator suItr = suList.iterator(); suItr.hasNext();) {
086: System.out.println(suItr.next());
087: }
088: }
089:
090: }
091:
092: /**
093: * fix it
094: * @throws Exception fix it
095: */
096: public void testLoadFromDD() throws Exception {
097: InputStream res = this .getClass().getResourceAsStream(
098: "test_jbi.xml");
099: InputStreamReader reader = new InputStreamReader(res);
100: ServiceAssemblyInfo saInfo = ServiceAssemblyInfo
101: .createFromServiceAssemblyDD(reader);
102: System.out.println(saInfo);
103: List suList = saInfo.getServiceUnitInfoList();
104: for (Iterator suItr = suList.iterator(); suItr.hasNext();) {
105: System.out.println(suItr.next());
106: }
107: }
108:
109: /**
110: * main
111: * @param args the command line arguments
112: */
113: public static void main(String[] args) {
114: // TODO code application logic here
115: try {
116: TestServiceAssemblyInfo test = new TestServiceAssemblyInfo(
117: "test");
118: test.testLoad();
119: test.testLoadFromDD();
120: } catch (Exception ex) {
121: ex.printStackTrace();
122: }
123: }
124: }
|