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: * @(#)TestWSDLHelper.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.messaging.util;
030:
031: import com.sun.jbi.messaging.WsdlDocument;
032:
033: import java.util.HashMap;
034: import javax.xml.namespace.QName;
035:
036: import org.w3c.dom.Document;
037:
038: /**
039: * Tests for the TestWSDLHelper class
040: *
041: * @author Sun Microsystems, Inc.
042: */
043: public class TestWSDLHelper extends junit.framework.TestCase {
044: /**
045: * The constructor for this testcase, forwards the test name to
046: * the jUnit TestCase base class.
047: * @param aTestName String with the name of this test.
048: */
049: public TestWSDLHelper(String aTestName) {
050: super (aTestName);
051: }
052:
053: /**
054: * Setup for the test. This creates the ComponentRegistry instance
055: * and other objects needed for the tests.
056: * @throws Exception when set up fails for any reason.
057: */
058: public void setUp() throws Exception {
059: super .setUp();
060: }
061:
062: /**
063: * Cleanup for the test.
064: * @throws Exception when tearDown fails for any reason.
065: */
066: public void tearDown() throws Exception {
067: super .tearDown();
068:
069: }
070:
071: // ============================= test methods ================================
072:
073: /**
074: * Test single operation case for service
075: */
076: public void testGetOperationForServiceSingle() throws Exception {
077: Document desc;
078: HashMap map;
079:
080: desc = WsdlDocument.readDefaultDocument();
081: map = WSDLHelper.getOperationsForService(desc,
082: WsdlDocument.STOCK_SERVICE_Q);
083:
084: // only one operation for this service
085: assertTrue(map.size() == 1);
086: // make sure the operation name is correct
087: assertTrue(map.containsKey(WsdlDocument.STOCK_OPERATION_Q
088: .toString()));
089: }
090:
091: /**
092: * Test multiple operation case for service
093: */
094: public void testGetOperationsForServiceMultiple() throws Exception {
095: Document desc;
096: HashMap map;
097:
098: desc = WsdlDocument.readDefaultDocument();
099: map = WSDLHelper.getOperationsForService(desc,
100: WsdlDocument.HELLO_SERVICE_Q);
101:
102: // three operation for this service
103: assertTrue(map.size() == 3);
104: // make sure the operation name is correct
105: assertTrue(map.containsKey(WsdlDocument.HELLO_C_OPERATION_1_Q
106: .toString()));
107: assertTrue(map.containsKey(WsdlDocument.HELLO_W_OPERATION_Q
108: .toString()));
109: }
110:
111: /**
112: * Test single operation case for service
113: */
114: public void testGetInterfacesForServiceSingle() throws Exception {
115: Document desc;
116: QName[] interfaces;
117:
118: desc = WsdlDocument.readDefaultDocument();
119: interfaces = WSDLHelper.getInterfacesForService(desc,
120: WsdlDocument.STOCK_SERVICE_Q);
121:
122: assertTrue(interfaces.length == 1);
123: assertTrue(interfaces[0].equals(WsdlDocument.STOCK_INTERFACE_Q));
124: }
125:
126: /**
127: * Test multiple operation case for service
128: */
129: public void testGetInterfacesForServiceMultiple() throws Exception {
130: Document desc;
131: QName[] interfaces;
132:
133: desc = WsdlDocument.readDefaultDocument();
134: interfaces = WSDLHelper.getInterfacesForService(desc,
135: WsdlDocument.HELLO_SERVICE_Q);
136:
137: assertTrue(interfaces.length == 2);
138: }
139: }
|