cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1453542 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/wsdl11/ tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/ tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/
Date Wed, 06 Mar 2013 20:43:00 GMT
Author: dkulp
Date: Wed Mar  6 20:42:59 2013
New Revision: 1453542

URL: http://svn.apache.org/r1453542
Log:
[CXF-4877] Fix problems where extensors may be adding namespace declarations into the root
wsdl instead of the current wsdl when dealing with services that generated imports.

Added:
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/Hello.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/HelloImpl.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHi.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHiResponse.java
Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?rev=1453542&r1=1453541&r2=1453542&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java Wed Mar
 6 20:42:59 2013
@@ -99,7 +99,6 @@ import org.apache.ws.commons.schema.XmlS
 public class ServiceWSDLBuilder {
 
     private final Map<String, String> ns2prefix;
-    private Definition definition;
     private final List<ServiceInfo> services;
     private boolean useSchemaImports;
     private String baseFileName;
@@ -168,6 +167,7 @@ public class ServiceWSDLBuilder {
      * @throws WSDLException
      */
     public Definition build(Map<String, SchemaInfo> imports) throws WSDLException {
+        Definition definition = null;
         try {
             definition = services.get(0).getProperty(WSDLServiceBuilder.WSDL_DEFINITION,
Definition.class);
         } catch (ClassCastException e) {
@@ -177,11 +177,12 @@ public class ServiceWSDLBuilder {
             ServiceInfo si = services.get(0);
             definition = newDefinition(si.getName(), si.getTargetNamespace());
             addNamespace(WSDLConstants.CONVENTIONAL_TNS_PREFIX, si.getTargetNamespace(),
definition);
-            addExtensibilityElements(definition, getWSDL11Extensors(si.getDescription()));
+            addExtensibilityElements(definition, definition, getWSDL11Extensors(si.getDescription()));
 
             Collection<PortType> portTypes = new HashSet<PortType>();
             for (ServiceInfo service : services) {
                 Definition portTypeDef = definition;
+                Definition orig = definition;
                 if (!isSameTNS(service)) {
                     portTypeDef = newDefinition(service.getInterface().getName(),
                                                 service.getInterface().getName().getNamespaceURI());
@@ -192,6 +193,7 @@ public class ServiceWSDLBuilder {
                     wsdlImport.setLocationURI(service.getInterface().getName().getLocalPart()
+ ".wsdl");
                     definition.addImport(wsdlImport);
                     addNamespace(getPrefix(tns), tns, definition);
+                    definition = portTypeDef;
                 }
                 portTypes.add(buildPortType(service.getInterface(), portTypeDef));
                 
@@ -203,11 +205,12 @@ public class ServiceWSDLBuilder {
                                 imports, portTypeDef);
                     }
                 }
+                definition = orig;
             }
             
             for (ServiceInfo service : services) {
-                buildBinding(service.getBindings(), portTypes);
-                buildService(service);
+                buildBinding(definition, service.getBindings(), portTypes);
+                buildService(service, definition);
             }
         }
         return definition;
@@ -254,30 +257,32 @@ public class ServiceWSDLBuilder {
         el.setTextContent(text);
         wsdlel.setDocumentationElement(el);
     }
-    protected void addExtensibilityElements(ElementExtensible elementExtensible, 
-        List<ExtensibilityElement> extensibilityElements) {
+    protected void addExtensibilityElements(Definition def,
+                                            ElementExtensible elementExtensible, 
+                                            List<ExtensibilityElement> extensibilityElements)
{
         if (extensibilityElements != null) {
             for (ExtensibilityElement element : extensibilityElements) {
                 if (element instanceof UnknownExtensibilityElement) {
                     UnknownExtensibilityElement uee = (UnknownExtensibilityElement)element;
                     String pfx = uee.getElement().getPrefix();
-                    addNamespace(pfx, element.getElementType().getNamespaceURI());
+                    addNamespace(pfx, element.getElementType().getNamespaceURI(), def);
                 } else {
                     QName qn = element.getElementType();
-                    addNamespace(qn.getNamespaceURI());
+                    addNamespace(qn.getNamespaceURI(), def);
                 }
                 elementExtensible.addExtensibilityElement(element);
             }
         }
     }
     
-    private void addExtensibilityAttributes(AttributeExtensible attributeExtensible, 
+    private void addExtensibilityAttributes(Definition def,
+                                            AttributeExtensible attributeExtensible, 
                                             Map<QName, Object> attributes) {
         if (attributes == null) {
             return;
         }
         for (QName qname : attributes.keySet()) {
-            addNamespace(qname.getNamespaceURI());
+            addNamespace(qname.getNamespaceURI(), def);
             attributeExtensible.setExtensionAttribute(qname, attributes.get(qname));
         }
     }
@@ -469,7 +474,9 @@ public class ServiceWSDLBuilder {
         schema.addImport(imp);
     }
     
-    protected void buildBinding(Collection<BindingInfo> bindingInfos, Collection<PortType>
portTypes) {
+    protected void buildBinding(Definition definition,
+                                Collection<BindingInfo> bindingInfos,
+                                Collection<PortType> portTypes) {
         Binding binding = null;
         for (BindingInfo bindingInfo : bindingInfos) {
             binding = definition.createBinding();
@@ -483,10 +490,10 @@ public class ServiceWSDLBuilder {
             }
             binding.setQName(bindingInfo.getName());
             if (!bindingInfo.getName().getNamespaceURI().equals(definition.getTargetNamespace()))
{
-                addNamespace(bindingInfo.getName().getNamespaceURI());
+                addNamespace(bindingInfo.getName().getNamespaceURI(), definition);
             }
             buildBindingOperation(definition, binding, bindingInfo.getOperations());
-            addExtensibilityElements(binding, getWSDL11Extensors(bindingInfo));
+            addExtensibilityElements(definition, binding, getWSDL11Extensors(bindingInfo));
             definition.addBinding(binding);
         }
     }
@@ -508,8 +515,8 @@ public class ServiceWSDLBuilder {
             buildBindingInput(def, bindingOperation, bindingOperationInfo.getInput());
             buildBindingOutput(def, bindingOperation, bindingOperationInfo.getOutput());
             buildBindingFault(def, bindingOperation, bindingOperationInfo.getFaults());
-            addExtensibilityAttributes(bindingOperation, bindingOperationInfo.getExtensionAttributes());
-            addExtensibilityElements(bindingOperation, getWSDL11Extensors(bindingOperationInfo));
+            addExtensibilityAttributes(def, bindingOperation, bindingOperationInfo.getExtensionAttributes());
+            addExtensibilityElements(def, bindingOperation, getWSDL11Extensors(bindingOperationInfo));
             binding.addBindingOperation(bindingOperation);
         }
     }
@@ -523,8 +530,8 @@ public class ServiceWSDLBuilder {
             addDocumentation(bindingFault, bindingFaultInfo.getDocumentation());
             bindingFault.setName(bindingFaultInfo.getFaultInfo().getFaultName().getLocalPart());
             bindingOperation.addBindingFault(bindingFault);
-            addExtensibilityAttributes(bindingFault, bindingFaultInfo.getExtensionAttributes());
-            addExtensibilityElements(bindingFault, getWSDL11Extensors(bindingFaultInfo));
+            addExtensibilityAttributes(def, bindingFault, bindingFaultInfo.getExtensionAttributes());
+            addExtensibilityElements(def, bindingFault, getWSDL11Extensors(bindingFaultInfo));
         }
         
     }
@@ -537,8 +544,8 @@ public class ServiceWSDLBuilder {
             addDocumentation(bindingInput, bindingMessageInfo.getDocumentation());
             bindingInput.setName(bindingMessageInfo.getMessageInfo().getName().getLocalPart());
             bindingOperation.setBindingInput(bindingInput);
-            addExtensibilityAttributes(bindingInput, bindingMessageInfo.getExtensionAttributes());
-            addExtensibilityElements(bindingInput, getWSDL11Extensors(bindingMessageInfo));
+            addExtensibilityAttributes(def, bindingInput, bindingMessageInfo.getExtensionAttributes());
+            addExtensibilityElements(def, bindingInput, getWSDL11Extensors(bindingMessageInfo));
         }
     }
     
@@ -550,12 +557,12 @@ public class ServiceWSDLBuilder {
             addDocumentation(bindingOutput, bindingMessageInfo.getDocumentation());
             bindingOutput.setName(bindingMessageInfo.getMessageInfo().getName().getLocalPart());
             bindingOperation.setBindingOutput(bindingOutput);
-            addExtensibilityAttributes(bindingOutput, bindingMessageInfo.getExtensionAttributes());
-            addExtensibilityElements(bindingOutput, getWSDL11Extensors(bindingMessageInfo));
+            addExtensibilityAttributes(def, bindingOutput, bindingMessageInfo.getExtensionAttributes());
+            addExtensibilityElements(def, bindingOutput, getWSDL11Extensors(bindingMessageInfo));
         }
     }
 
-    protected void buildService(ServiceInfo serviceInfo) {
+    protected void buildService(ServiceInfo serviceInfo, Definition definition) {
         
         Map<QName, MessageInfo> messages = serviceInfo.getMessages();
         for (Map.Entry<QName, MessageInfo> mie : messages.entrySet()) {
@@ -594,17 +601,17 @@ public class ServiceWSDLBuilder {
         Service serv = definition.createService();
         addDocumentation(serv, serviceInfo.getDocumentation());
         serv.setQName(serviceInfo.getName());
-        addNamespace(serviceInfo.getName().getNamespaceURI());
-        addExtensibilityElements(serv, getWSDL11Extensors(serviceInfo));
+        addNamespace(serviceInfo.getName().getNamespaceURI(), definition);
+        addExtensibilityElements(definition, serv, getWSDL11Extensors(serviceInfo));
         definition.addService(serv);
 
         for (EndpointInfo ei : serviceInfo.getEndpoints()) {
-            addNamespace(ei.getTransportId());
+            addNamespace(ei.getTransportId(), definition);
             Port port = definition.createPort();
             addDocumentation(port, ei.getDocumentation());
             port.setName(ei.getName().getLocalPart());
             port.setBinding(definition.getBinding(ei.getBinding().getName()));
-            addExtensibilityElements(port, getWSDL11Extensors(ei));
+            addExtensibilityElements(definition, port, getWSDL11Extensors(ei));
             serv.addPort(port);
         }
     }
@@ -622,8 +629,8 @@ public class ServiceWSDLBuilder {
             portType.setQName(intf.getName());
             addDocumentation(portType, intf.getDocumentation());
             addNamespace(intf.getName().getNamespaceURI(), def);
-            addExtensibilityElements(portType, getWSDL11Extensors(intf));
-            addExtensibilityAttributes(portType, intf.getExtensionAttributes());
+            addExtensibilityElements(def, portType, getWSDL11Extensors(intf));
+            addExtensibilityAttributes(def, portType, intf.getExtensionAttributes());
             portType.setUndefined(false);
             buildPortTypeOperation(portType, intf.getOperations(), def);
         }
@@ -636,14 +643,6 @@ public class ServiceWSDLBuilder {
         addNamespace(getPrefix(namespaceURI), namespaceURI, def);
     }
 
-    protected void addNamespace(String namespaceURI) {
-        addNamespace(getPrefix(namespaceURI), namespaceURI);
-    }
-
-    protected void addNamespace(String prefix, String namespaceURI) {
-        addNamespace(prefix, namespaceURI, definition);
-    }
-
     protected void addNamespace(String prefix, String namespaceURI, Definition def) {
         ns2prefix.put(namespaceURI, prefix);
         def.addNamespace(prefix, namespaceURI);
@@ -685,14 +684,14 @@ public class ServiceWSDLBuilder {
                 if (operationInfo.isOneWay()) {
                     operation.setStyle(OperationType.ONE_WAY);
                 }
-                addExtensibilityElements(operation, getWSDL11Extensors(operationInfo));
+                addExtensibilityElements(def, operation, getWSDL11Extensors(operationInfo));
                 Input input = def.createInput();
                 addDocumentation(input, operationInfo.getInput().getDocumentation());
                 input.setName(operationInfo.getInputName());
                 Message message = def.createMessage();
                 buildMessage(message, operationInfo.getInput(), def);
-                this.addExtensibilityAttributes(input, getInputExtensionAttributes(operationInfo));
-                this.addExtensibilityElements(input, getWSDL11Extensors(operationInfo.getInput()));
+                this.addExtensibilityAttributes(def, input, getInputExtensionAttributes(operationInfo));
+                this.addExtensibilityElements(def, input, getWSDL11Extensors(operationInfo.getInput()));
                 input.setMessage(message);
                 operation.setInput(input);
                 operation.setParameterOrdering(operationInfo.getParameterOrdering());
@@ -703,8 +702,8 @@ public class ServiceWSDLBuilder {
                     output.setName(operationInfo.getOutputName());
                     message = def.createMessage();
                     buildMessage(message, operationInfo.getOutput(), def);
-                    this.addExtensibilityAttributes(output, getOutputExtensionAttributes(operationInfo));
-                    this.addExtensibilityElements(output, getWSDL11Extensors(operationInfo.getOutput()));
+                    this.addExtensibilityAttributes(def, output, getOutputExtensionAttributes(operationInfo));
+                    this.addExtensibilityElements(def, output, getWSDL11Extensors(operationInfo.getOutput()));
                     output.setMessage(message);
                     operation.setOutput(output);
                 }
@@ -717,8 +716,8 @@ public class ServiceWSDLBuilder {
                     fault.setName(faultInfo.getFaultName().getLocalPart());
                     message = def.createMessage();
                     buildMessage(message, faultInfo, def);
-                    this.addExtensibilityAttributes(fault, faultInfo.getExtensionAttributes());
-                    this.addExtensibilityElements(fault, getWSDL11Extensors(faultInfo));
+                    this.addExtensibilityAttributes(def, fault, faultInfo.getExtensionAttributes());
+                    this.addExtensibilityElements(def, fault, getWSDL11Extensors(faultInfo));
                     fault.setMessage(message);
                     operation.addFault(fault);
                 }

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/Hello.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/Hello.java?rev=1453542&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/Hello.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/Hello.java
Wed Mar  6 20:42:59 2013
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.fortest.cxf4877;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.Action;
+
+@WebService(targetNamespace = "http://foo.com/HelloWorld", name = "HelloWorld")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface Hello {
+
+    @WebResult(partName = "out", name = "out")
+    @WebMethod
+    @Action
+    String echoFoo(@WebParam(partName = "in", name = "in") String s);
+
+    @WebResult
+    @WebMethod
+    @Action
+    SayHiResponse sayHi(SayHi s);
+} 

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/HelloImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/HelloImpl.java?rev=1453542&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/HelloImpl.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/HelloImpl.java
Wed Mar  6 20:42:59 2013
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.fortest.cxf4877;
+
+import javax.jws.WebService;
+
+@WebService(serviceName = "HelloService",
+            portName = "HelloPort",
+            endpointInterface = "org.apache.cxf.tools.fortest.cxf4877.Hello",
+            targetNamespace = "http://foo.com/MyImpl")
+public class HelloImpl {
+    public String echoFoo(String s) {
+        return s;
+    }
+
+    public SayHiResponse sayHi(SayHi s) {
+        return new SayHiResponse();
+    }
+}

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHi.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHi.java?rev=1453542&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHi.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHi.java
Wed Mar  6 20:42:59 2013
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.fortest.cxf4877;
+
+public class SayHi {
+
+    /**
+     * Describe msg here.
+     */
+    private String msg;
+
+    /**
+     * Get the <code>Msg</code> value.
+     *
+     * @return a <code>String</code> value
+     */
+    public final String getMsg() {
+        return msg;
+    }
+
+    /**
+     * Set the <code>Msg</code> value.
+     *
+     * @param newMsg The new Msg value.
+     */
+    public final void setMsg(final String newMsg) {
+        this.msg = newMsg;
+    }
+}

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHiResponse.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHiResponse.java?rev=1453542&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHiResponse.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/cxf4877/SayHiResponse.java
Wed Mar  6 20:42:59 2013
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.fortest.cxf4877;
+
+public class SayHiResponse {
+
+    /**
+     * Describe msg here.
+     */
+    private String msg;
+
+    /**
+     * Get the <code>Msg</code> value.
+     *
+     * @return a <code>String</code> value
+     */
+    public final String getMsg() {
+        return msg;
+    }
+
+    /**
+     * Set the <code>Msg</code> value.
+     *
+     * @param newMsg The new Msg value.
+     */
+    public final void setMsg(final String newMsg) {
+        this.msg = newMsg;
+    }
+}

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=1453542&r1=1453541&r2=1453542&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Wed Mar  6 20:42:59 2013
@@ -20,6 +20,7 @@
 package org.apache.cxf.tools.java2wsdl.processor;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.net.URI;
 import java.util.List;
 
@@ -36,6 +37,7 @@ import org.apache.cxf.common.util.String
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.WSDLHelper;
 import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
@@ -587,7 +589,7 @@ public class JavaToProcessorTest extends
         assertTrue(getStringFromFile(requestWrapperClass).indexOf(expectedString) != -1);
     }
 
-    // Generated schema should use unquolified form in the jaxws case
+    // Generated schema should use unqualified form in the jaxws case
     @Test
     public void testAction() throws Exception {
         env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/action.wsdl");
@@ -772,6 +774,20 @@ public class JavaToProcessorTest extends
         assertTrue(unboundIndex > -1);
     }
     
+    @Test
+    public void testCXF4877() throws Exception {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/testwsdl.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.cxf4877.HelloImpl");
+        env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+
+        processor.setEnvironment(env);
+        processor.process();
+        
+        File wsdlFile = new File(output, "HelloWorld.wsdl");
+        assertTrue(wsdlFile.exists());
+        //if the test works, this won't throw an exception.  CXF-4877 generated bad XML at
this point
+        StaxUtils.read(new FileInputStream(wsdlFile));
+    }
     
     
 }



Mime
View raw message