001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.jaxws.databinding;
020:
021: import javax.xml.namespace.QName;
022:
023: import junit.framework.TestCase;
024:
025: /**
026: * A suite of tests for reading the binding from a WSDL file and
027: * making sure we are configuring the Protocol correctly for
028: * messages based on that binding ID.
029: */
030: public class BindingToProtocolTests extends TestCase {
031:
032: private static final String SOAP11_TEST_NS = "http://jaxws.axis2.apache.org/bindingtest/soap11";
033: private static final String SOAP12_TEST_NS = "http://jaxws.axis2.apache.org/bindingtest/soap12";
034: private static final QName SOAP11_SVC_QNAME = new QName(
035: SOAP11_TEST_NS, "SOAP11EchoService");
036: private static final QName SOAP12_SVC_QNAME = new QName(
037: SOAP12_TEST_NS, "SOAP12EchoService");
038:
039: public BindingToProtocolTests(String name) {
040: super (name);
041: }
042:
043: /**
044: * Test to see if we can read the SOAP 1.1 binding transport URL
045: * in a WSDL, as specified by JAX-WS section 10.4.1.
046: */
047: public void testReadJAXWSSOAP11Binding() throws Exception {
048: /*
049: // Get the WSDL with the JAX-WS binding url
050: URL wsdlUrl = new URL("file:./test-resources/wsdl/SOAP11Binding-JAXWS.wsdl");
051:
052: // TODO: There should be an easier way to do this without
053: // requring the creating of a Service object. Should the
054: // ServiceDescription be constructed from just a WSDL file?
055: Service svc = Service.create(wsdlUrl, SOAP11_SVC_QNAME);
056: ServiceDelegate delegate = DescriptionTestUtils.getServiceDelegate(svc);
057: ServiceDescription sd = delegate.getServiceDescription();
058:
059: EndpointDescription[] eds = sd.getEndpointDescriptions();
060: for (int i = 0; i < eds.length; i++) {
061: System.out.println("port [" + eds[i].getTargetNamespace() + ":" + eds[i].getName() + "]");
062: }
063:
064: EndpointDescription ed = sd.getEndpointDescription(new QName(SOAP11_TEST_NS, "EchoPort"));
065: assertNotNull("The EndpointDescription was not created.", ed);
066:
067: String bindingID = ed.getClientBindingID();
068: assertNotNull("The binding ID was null.", bindingID);
069:
070: Protocol p = Protocol.getProtocolForBinding(bindingID);
071: assertTrue("Protocol configured incorrectly", p.equals(Protocol.soap11));
072: */
073: }
074:
075: /**
076: * Test to see if we can read the SOAP 1.1 binding transport URL
077: * in a WSDL, as specified by WS-I Basic Profile 1.1.
078: */
079: public void testReadWSISOAP11Binding() throws Exception {
080: /*
081: // Get the WSDL with the JAX-WS binding url
082: URL wsdlUrl = new URL("file:./test-resources/wsdl/SOAP11Binding-WSI.wsdl");
083:
084: // TODO: There should be an easier way to do this without
085: // requring the creating of a Service object. Should the
086: // ServiceDescription be constructed from just a WSDL file?
087: Service svc = Service.create(wsdlUrl, SOAP11_SVC_QNAME);
088: ServiceDelegate delegate = DescriptionTestUtils.getServiceDelegate(svc);
089: ServiceDescription sd = delegate.getServiceDescription();
090:
091: EndpointDescription[] eds = sd.getEndpointDescriptions();
092: for (int i = 0; i < eds.length; i++) {
093: System.out.println("port [" + eds[i].getTargetNamespace() + ":" + eds[i].getName() + "]");
094: }
095:
096: EndpointDescription ed = sd.getEndpointDescription(new QName(SOAP11_TEST_NS, "EchoPort"));
097: assertNotNull("The EndpointDescription was not created.", ed);
098:
099: String bindingID = ed.getClientBindingID();
100: assertNotNull("The binding ID was null.", bindingID);
101:
102: Protocol p = Protocol.getProtocolForBinding(bindingID);
103: assertTrue("Protocol configured incorrectly", p.equals(Protocol.soap11));
104: */
105: }
106:
107: /**
108: * Test to see if we can read the SOAP 1.2 binding transport URL
109: * in a WSDL, as specified by JAX-WS.
110: */
111: public void testReadJAXWSSOAP12Binding() throws Exception {
112: /*
113: // Get the WSDL with the JAX-WS binding url
114: URL wsdlUrl = new URL("file:./test-resources/wsdl/SOAP12Binding-JAXWS.wsdl");
115:
116: // TODO: There should be an easier way to do this without
117: // requring the creating of a Service object. Should the
118: // ServiceDescription be constructed from just a WSDL file?
119: Service svc = Service.create(wsdlUrl, SOAP12_SVC_QNAME);
120: ServiceDelegate delegate = DescriptionTestUtils.getServiceDelegate(svc);
121: ServiceDescription sd = delegate.getServiceDescription();
122:
123: EndpointDescription[] eds = sd.getEndpointDescriptions();
124: for (int i = 0; i < eds.length; i++) {
125: System.out.println("port [" + eds[i].getTargetNamespace() + ":" + eds[i].getName() + "]");
126: }
127:
128: EndpointDescription ed = sd.getEndpointDescription(new QName(SOAP12_TEST_NS, "EchoPort"));
129: assertNotNull("The EndpointDescription was not created.", ed);
130:
131: String bindingID = ed.getClientBindingID();
132: assertNotNull("The binding ID was null.", bindingID);
133:
134: Protocol p = Protocol.getProtocolForBinding(bindingID);
135: assertTrue("Protocol configured incorrectly", p.equals(Protocol.soap12));
136: */
137: }
138:
139: /**
140: * Test to see if we are defaulting the soap binding to SOAP 1.1
141: * correctly in the absence of a WSDL document.
142: */
143: public void testDefaultBindingNoWSDL() {
144:
145: }
146: }
|