cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1399365 - in /cxf/branches/2.5.x-fixes: ./ common/common/src/main/java/org/apache/cxf/staxutils/transform/ common/common/src/test/java/org/apache/cxf/staxutils/resources/ common/common/src/test/java/org/apache/cxf/staxutils/transform/
Date Wed, 17 Oct 2012 18:02:50 GMT
Author: ay
Date: Wed Oct 17 18:02:50 2012
New Revision: 1399365

URL: http://svn.apache.org/viewvc?rev=1399365&view=rev
Log:
Merged revisions 1399344 via  svn merge from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1399344 | ay | 2012-10-17 18:57:12 +0200 (Wed, 17 Oct 2012) | 9 lines
  
  Merged revisions 1398860 via  svn merge from
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1398860 | ay | 2012-10-16 17:55:50 +0200 (Tue, 16 Oct 2012) | 1 line
    
    [CXF-4566] StaxTransformFeature outTransformElements does not work when coverting namespaces
  ........
  
........

Added:
    cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReq5.xml
  (with props)
    cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReqIn5.xml
  (with props)
Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
    cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java

Propchange: cxf/branches/2.5.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java?rev=1399365&r1=1399364&r2=1399365&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
Wed Oct 17 18:02:50 2012
@@ -80,7 +80,9 @@ class DelegatingNamespaceContext impleme
             }
         }
         String ns = nc.getNamespaceURI(prefix);
-        addPrefix(prefix, ns);
+        if (ns != null) {
+            addPrefix(prefix, ns);
+        }
         return ns;
     }
 
@@ -98,7 +100,9 @@ class DelegatingNamespaceContext impleme
             return prefixes.get(0).get(actualNs);
         }
         String prefix = nc.getPrefix(actualNs);
-        addPrefix(prefix, actualNs);
+        if (prefix != null) {
+            addPrefix(prefix, actualNs);
+        }
         return prefix;
     }
 

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java?rev=1399365&r1=1399364&r2=1399365&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
Wed Oct 17 18:02:50 2012
@@ -306,6 +306,8 @@ public class InTransformReader extends D
         String actualNs = nsMap.get(ns);
         if (actualNs != null) {
             return actualNs;
+        } else if (ns.equals(reader.getNamespaceURI())) {
+            return getNamespaceURI();
         } else {
             return ns;
         }
@@ -320,6 +322,8 @@ public class InTransformReader extends D
             } else {
                 return "";
             }
+        } else if (ns.equals(reader.getNamespaceURI())) {
+            return getPrefix();
         } else {
             return namespaceContext.getPrefix(ns);
         }

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java?rev=1399365&r1=1399364&r2=1399365&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
Wed Oct 17 18:02:50 2012
@@ -34,6 +34,7 @@ import javax.xml.stream.XMLStreamConstan
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
 
@@ -48,6 +49,7 @@ public class OutTransformWriter extends 
     private Set<QName> dropElements;
     private Stack<List<ParsingEvent>> pushedAheadEvents = new Stack<List<ParsingEvent>>();
     private Stack<QName> elementsStack = new Stack<QName>();
+    private String replaceNamespace;
     private String replaceText;
     private int currentDepth;
     private int dropDepth;
@@ -86,11 +88,16 @@ public class OutTransformWriter extends 
 
     @Override
     public void writeNamespace(String prefix, String uri) throws XMLStreamException {
+        if (StringUtils.isEmpty(prefix) || "xmlns".equals(prefix)) {
+            writeDefaultNamespace(uri);
+            return;
+        }
         if (matchesDropped(true)) {
             return;
         }
         String value = nsMap.get(uri);
-        if (value != null && value.length() == 0) {
+        if ((value != null && value.length() == 0)
+            || uri.equals(replaceNamespace)) {
             return;
         }
         
@@ -103,11 +110,13 @@ public class OutTransformWriter extends 
         
         if (defaultNamespace != null && defaultNamespace.equals(uri)) {
             super.writeDefaultNamespace(uri);
+            namespaceContext.addPrefix("", uri);
         } else {
             if (prefix.length() == 0) {
                 prefix = namespaceContext.findUniquePrefix(uri);
             }
             super.writeNamespace(prefix, uri);
+            namespaceContext.addPrefix(prefix, uri);
         }
         writtenUris.get(0).add(uri);
     }
@@ -120,7 +129,8 @@ public class OutTransformWriter extends 
         }
         String value = nsMap.get(uri);
         if ((value != null && value.length() == 0) 
-            || (isDefaultNamespaceRedefined() && !isDefaultNamespaceRedefined(uri)))
{
+            || (isDefaultNamespaceRedefined() && !isDefaultNamespaceRedefined(uri))
+            || uri.equals(replaceNamespace)) {
             return;
         }
         
@@ -130,7 +140,7 @@ public class OutTransformWriter extends 
             return;
         }
         super.writeDefaultNamespace(uri);
-
+        namespaceContext.addPrefix("", uri);
         writtenUris.get(0).add(uri);
     }
 
@@ -247,6 +257,8 @@ public class OutTransformWriter extends 
         }
         pushedAheadEvents.push(pe);
         elementsStack.push(expected);
+        replaceNamespace = expected.getNamespaceURI().equals(theName.getNamespaceURI()) 
+            ? null : theName.getNamespaceURI();
 
         if (appendProp != null && !replaceContent && appendProp.isChild())
{
             // ap-post-*
@@ -355,7 +367,6 @@ public class OutTransformWriter extends 
                 }
             } else {
                 prefix = qname.getPrefix();
-                namespaceContext.addPrefix(prefix, qname.getNamespaceURI());    
             }
             
         }
@@ -364,7 +375,8 @@ public class OutTransformWriter extends 
         }
         
         super.writeStartElement(prefix, qname.getLocalPart(), qname.getNamespaceURI());
-        if (writeNs) {
+        if (writeNs 
+            || !qname.getNamespaceURI().equals(namespaceContext.getNamespaceURI(prefix)))
{
             this.writeNamespace(prefix, qname.getNamespaceURI());
         }
     }

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java?rev=1399365&r1=1399364&r2=1399365&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
Wed Oct 17 18:02:50 2012
@@ -97,7 +97,8 @@ public final class TransformUtils {
                 QName lname = XMLUtils.convertStringToQName(entry.getKey());
                 QName rname = XMLUtils.convertStringToQName(entry.getValue());
                 elementsMap.put(lname, rname);
-                if (nsMap != null && !isEmptyQName(rname)) {
+                if (nsMap != null && !isEmptyQName(rname)
+                    && ("*".equals(lname.getLocalPart()) && "*".equals(rname.getLocalPart())))
{
                     nsMap.put(lname.getNamespaceURI(), rname.getNamespaceURI());
                 }
             }

Added: cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReq5.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReq5.xml?rev=1399365&view=auto
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReq5.xml
(added)
+++ cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReq5.xml
Wed Oct 17 18:02:50 2012
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  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.
+-->
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Header/>
+  <soap:Body>
+    <ns2:subscribeResponse xmlns="http://cxf.apache.org/vgop/serviceorder/v1_0/common"
xmlns:ns2="http://cxf.apache.org/vgop/serviceorder/v1_0">
+     <ns2:SubscribeResp>
+      <result xmlns="">0</result>
+     </ns2:SubscribeResp>
+   </ns2:subscribeResponse>
+  </soap:Body>
+</soap:Envelope>

Propchange: cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReq5.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReqIn5.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReqIn5.xml?rev=1399365&view=auto
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReqIn5.xml
(added)
+++ cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReqIn5.xml
Wed Oct 17 18:02:50 2012
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  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.
+-->
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Header/>
+  <soap:Body>
+    <ns2:subscribeResponse xmlns="http://cxf.apache.org/vgop/serviceorder/v1_0/common"
xmlns:ns2="http://cxf.apache.org/vgop/serviceorder/v1_0">
+     <ns2:SubscribeResp>
+      <ns2:result>0</ns2:result>
+     </ns2:SubscribeResp>
+   </ns2:subscribeResponse>
+  </soap:Body>
+</soap:Envelope>

Propchange: cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/resources/complexReqIn5.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java?rev=1399365&r1=1399364&r2=1399365&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
Wed Oct 17 18:02:50 2012
@@ -115,9 +115,9 @@ public class OutTransformWriterTest exte
         String xmlPI = "<?xml version='1.0' encoding='UTF-8'?>";
         String start = "<testBean xmlns=\"http://testbeans.com/v2\"";
         String expected1 = xmlPI + start
-            + " xmlns:ps2=\"http://testbeans.com/v3\"><ps2:bean/></testBean>";
+            + " xmlns:ps1=\"http://testbeans.com/v3\"><ps1:bean/></testBean>";
         String expected2 = xmlPI + start
-            + "><ps2:bean xmlns:ps2=\"http://testbeans.com/v3\"/></testBean>";
+            + "><ps1:bean xmlns:ps1=\"http://testbeans.com/v3\"/></testBean>";
         String out = os.toString();
         assertTrue("Output \"" + out + "\" does not match expected values",
                 expected1.equals(out) || expected2.equals(out));
@@ -286,6 +286,20 @@ public class OutTransformWriterTest exte
     }
 
     @Test
+    public void testRemoveOneNamespace() throws Exception {
+        Map<String, String> inMap = new HashMap<String, String>();
+        inMap.put("{http://cxf.apache.org/vgop/serviceorder/v1_0}result", "result"); 
+        XMLStreamReader reader = 
+            TransformTestUtils.createOutTransformedStreamReader("../resources/complexReqIn5.xml",

+                                                                inMap, null, null, null,
false, null);
+        
+        XMLStreamReader reader2 = 
+            StaxUtils.createXMLStreamReader(
+                InTransformReader.class.getResourceAsStream("../resources/complexReq5.xml"));
+        TransformTestUtils.verifyReaders(reader2, reader, true, true);
+    }
+    
+    @Test
     public void testReadWithReplaceAppend() throws Exception {
         Map<String, String> transformElements = new HashMap<String, String>();
         transformElements.put("requestValue",



Mime
View raw message