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: * @(#)TestJBIComponentInfo.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 TestJBIComponentInfo extends TestCase {
043:
044: /**
045: * Creates a new instance of TestMgmtMessage
046: * @param aTestName name
047: */
048: public TestJBIComponentInfo(String aTestName) {
049: super (aTestName);
050: }
051:
052: /**
053: * test sucess msg
054: * @throws Exception on error
055: */
056: public void testJBIComponentInfoLoadSave() throws Exception {
057: List list = getTestData();
058:
059: String xmlText = JBIComponentInfo.writeAsXmlText(list);
060: System.out.println("Serialized JBI Component Info ");
061: System.out.println(xmlText);
062:
063: List testList = JBIComponentInfo.readFromXmlText(xmlText);
064: System.out.println("DeSerialized JBI Component Info ");
065: for (Iterator itr = testList.iterator(); itr.hasNext();) {
066: System.out.println(itr.next());
067: }
068:
069: System.out.println("From File : JBI Component Info ");
070:
071: InputStream res = this .getClass().getResourceAsStream(
072: "test_component_info_list.xml");
073: InputStreamReader xmlReader = new InputStreamReader(res);
074: testList = JBIComponentInfo.readFromXmlText(xmlReader);
075:
076: for (Iterator itr = testList.iterator(); itr.hasNext();) {
077: System.out.println(itr.next());
078: }
079:
080: }
081:
082: /** test data
083: * @return test list objects
084: */
085: public static List getTestData() {
086: ArrayList list = new ArrayList();
087:
088: JBIComponentInfo info1 = new JBIComponentInfo("service-engine",
089: "started", "comp1", "comp1engine");
090:
091: JBIComponentInfo info2 = new JBIComponentInfo(
092: "binding-component", "stopped", "comp2", "comp2binding");
093:
094: JBIComponentInfo info3 = new JBIComponentInfo("shared-library",
095: "installed", "comp3", "comp3namespace");
096:
097: list.add(info1);
098: list.add(info2);
099: list.add(info3);
100:
101: return list;
102: }
103:
104: /**
105: * main
106: * @param args the command line arguments
107: */
108: public static void main(String[] args) {
109: // TODO code application logic here
110: try {
111: new TestJBIComponentInfo("test")
112: .testJBIComponentInfoLoadSave();
113: } catch (Exception ex) {
114: ex.printStackTrace();
115: }
116: }
117: }
|