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: * @(#)TestConfigReader.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.file.util;
030:
031: import com.sun.jbi.binding.file.EndpointBean;
032:
033: import junit.framework.Test;
034: import junit.framework.TestCase;
035: import junit.framework.TestSuite;
036:
037: import org.w3c.dom.Document;
038:
039: /**
040: * DOCUMENT ME!
041: *
042: * @author Sun Microsystems, Inc.
043: */
044: public class TestConfigReader extends TestCase {
045: /**
046: * DOCUMENT ME!
047: */
048: private ConfigFileValidator mValidator;
049:
050: /**
051: * DOCUMENT ME!
052: */
053: private ConfigReader mConfigReader;
054:
055: /**
056: * Creates a new TestConfigReader object.
057: *
058: * @param testName DOCUMENT ME!
059: */
060: public TestConfigReader(java.lang.String testName) {
061: super (testName);
062: }
063:
064: /**
065: * DOCUMENT ME!
066: *
067: * @return DOCUMENT ME!
068: */
069: public static Test suite() {
070: TestSuite suite = new TestSuite(TestConfigReader.class);
071:
072: return suite;
073: }
074:
075: /**
076: * Sets up tests.
077: */
078: public void setUp() {
079: mConfigReader = new ConfigReader();
080: System.out.println("testInit");
081:
082: String srcroot = System.getProperty("junit.srcroot");
083:
084: try {
085: mValidator = new ConfigFileValidator(srcroot
086: + "/binding/file/schema/endpoints.xsd", srcroot
087: + "/binding/file/config/endpoints.xml");
088: mValidator.validate();
089: mConfigReader.init(mValidator.getDocument());
090: } catch (Exception jbiException) {
091: jbiException.printStackTrace();
092: fail("Cannot Init Config Reader");
093: }
094: }
095:
096: /**
097: * Test of getBean method, of class
098: * com.sun.jbi.binding.file.util.ConfigReader.
099: */
100: public void testGetBean() {
101: System.out.println("testGetBean");
102:
103: String ep = "PullEndpoint";
104: EndpointBean eb = mConfigReader
105: .getBean("OnlineStockServicestockEndpoint");
106: assertNotNull("Endpoint Bean is Null ", eb);
107: assertEquals("Invalid Bean object ", eb
108: .getValue("endpoint-name"), "stockEndpoint");
109: }
110:
111: /**
112: * Test of getEndpoint method, of class
113: * com.sun.jbi.binding.file.util.ConfigReader.
114: */
115: public void testGetEndpoint() {
116: System.out.println("testGetEndpoint");
117: assertNotNull("Endpointlist is null", mConfigReader
118: .getEndpoint());
119: }
120:
121: /**
122: * Test of getEndpointCount method, of class
123: * com.sun.jbi.binding.file.util.ConfigReader.
124: */
125: public void testGetEndpointCount() {
126: System.out.println("testGetEndpointCount");
127: assertEquals("Failed getting endpoint count ", mConfigReader
128: .getEndpointCount(), 1);
129: }
130:
131: /**
132: * Test of init method, of class
133: * com.sun.jbi.binding.file.util.ConfigReader.
134: */
135: public void testInit() {
136: System.out.println("testInit");
137: }
138:
139: // Add test methods here, they have to start with 'test' name.
140: // for example:
141: // public void testHello() {}
142: }
|