cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1399338 - in /cxf/branches/2.6.x-fixes: ./ api/src/main/java/org/apache/cxf/staxutils/transform/ api/src/test/java/org/apache/cxf/staxutils/resources/ api/src/test/java/org/apache/cxf/staxutils/transform/
Date Wed, 17 Oct 2012 16:52:05 GMT
Author: ay
Date: Wed Oct 17 16:52:04 2012
New Revision: 1399338

URL: http://svn.apache.org/viewvc?rev=1399338&view=rev
Log:
Merged revisions 1398414 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1398414 | ay | 2012-10-15 19:39:40 +0200 (Mon, 15 Oct 2012) | 1 line
  
  [CXF-4566] StaxTransformFeature outTransformElements does not work when conversing namespaces
........

Added:
    cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/resources/complexReq5.xml
      - copied unchanged from r1398414, cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/resources/complexReq5.xml
    cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/resources/complexReqIn5.xml
      - copied unchanged from r1398414, cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/resources/complexReqIn5.xml
Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
    cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java

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

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

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java?rev=1399338&r1=1399337&r2=1399338&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
Wed Oct 17 16:52:04 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.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java?rev=1399338&r1=1399337&r2=1399338&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
Wed Oct 17 16:52:04 2012
@@ -108,11 +108,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);
     }
@@ -135,7 +137,7 @@ public class OutTransformWriter extends 
             return;
         }
         super.writeDefaultNamespace(uri);
-
+        namespaceContext.addPrefix("", uri);
         writtenUris.get(0).add(uri);
     }
 
@@ -363,13 +365,13 @@ public class OutTransformWriter extends 
                 namespaceContext.addPrefix(prefix, qname.getNamespaceURI());    
             }
             
-        }
+        } 
         if (isDefaultNamespaceRedefined(qname.getNamespaceURI())) {
             prefix = "";
         }
-        
         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.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java?rev=1399338&r1=1399337&r2=1399338&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
Wed Oct 17 16:52:04 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());
                 }
             }

Modified: cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java?rev=1399338&r1=1399337&r2=1399338&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/staxutils/transform/OutTransformWriterTest.java
Wed Oct 17 16:52:04 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://www.chinamobile.com/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