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: */package org.apache.cxf.wsdl11;
019:
020: import java.util.Map;
021:
022: import javax.wsdl.Binding;
023: import javax.wsdl.Definition;
024: import javax.wsdl.Operation;
025: import javax.wsdl.Part;
026: import javax.wsdl.Port;
027: import javax.wsdl.PortType;
028: import javax.wsdl.Service;
029: import javax.xml.namespace.QName;
030:
031: import org.junit.Assert;
032: import org.junit.Test;
033:
034: public class WSDLManagerImplTest extends Assert {
035:
036: @Test
037: public void testBuildSimpleWSDL() throws Exception {
038: String qname = "http://apache.org/hello_world_soap_http";
039: String wsdlUrl = getClass().getResource("hello_world.wsdl")
040: .toString();
041:
042: WSDLManagerImpl builder = new WSDLManagerImpl();
043: Definition def = builder.getDefinition(wsdlUrl);
044: assertNotNull(def);
045:
046: Map services = def.getServices();
047: assertNotNull(services);
048: assertEquals(1, services.size());
049: Service service = (Service) services.get(new QName(qname,
050: "SOAPService"));
051: assertNotNull(service);
052:
053: Map ports = service.getPorts();
054: assertNotNull(ports);
055: assertEquals(1, ports.size());
056: Port port = service.getPort("SoapPort");
057: assertNotNull(port);
058: }
059:
060: @Test
061: public void testBuildImportedWSDL() throws Exception {
062: String wsdlUrl = getClass().getResource(
063: "hello_world_services.wsdl").toString();
064:
065: WSDLManagerImpl builder = new WSDLManagerImpl();
066: Definition def = builder.getDefinition(wsdlUrl);
067:
068: assertNotNull(def);
069: Map services = def.getServices();
070: assertNotNull(services);
071: assertEquals(1, services.size());
072:
073: String serviceQName = "http://apache.org/hello_world/services";
074: Service service = (Service) services.get(new QName(
075: serviceQName, "SOAPService"));
076: assertNotNull(service);
077:
078: Map ports = service.getPorts();
079: assertNotNull(ports);
080: assertEquals(1, ports.size());
081: Port port = service.getPort("SoapPort");
082: assertNotNull(port);
083:
084: Binding binding = port.getBinding();
085: assertNotNull(binding);
086: QName bindingQName = new QName(
087: "http://apache.org/hello_world/bindings", "SOAPBinding");
088: assertEquals(bindingQName, binding.getQName());
089: PortType portType = binding.getPortType();
090: assertNotNull(portType);
091: QName portTypeQName = new QName(
092: "http://apache.org/hello_world", "Greeter");
093: assertEquals(portTypeQName, portType.getQName());
094: Operation op1 = portType.getOperation("sayHi", "sayHiRequest",
095: "sayHiResponse");
096: assertNotNull(op1);
097: QName messageQName = new QName(
098: "http://apache.org/hello_world/messages",
099: "sayHiRequest");
100: assertEquals(messageQName, op1.getInput().getMessage()
101: .getQName());
102:
103: Part part = op1.getInput().getMessage().getPart("in");
104: assertNotNull(part);
105: assertEquals(new QName("http://apache.org/hello_world/types",
106: "sayHi"), part.getElementName());
107: }
108: }
|