You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ay...@apache.org on 2013/08/09 14:43:29 UTC

svn commit: r1512286 - in /cxf/branches/2.7.x-fixes: ./ api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java

Author: ay
Date: Fri Aug  9 12:43:29 2013
New Revision: 1512286

URL: http://svn.apache.org/r1512286
Log:
Merged revisions 1511946 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1511946 | ay | 2013-08-08 20:53:11 +0200 (Thu, 08 Aug 2013) | 1 line
  
  [CXF-5191] StaxUtils readQName not accepting leading and trailing whitespcaes
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java

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

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

Modified: cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1512286&r1=1512285&r2=1512286&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Fri Aug  9 12:43:29 2013
@@ -1518,6 +1518,7 @@ public final class StaxUtils {
         if (value == null) {
             return null;
         }
+        value = value.trim();
         
         int index = value.indexOf(":");
 

Modified: cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java?rev=1512286&r1=1512285&r2=1512286&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java (original)
+++ cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java Fri Aug  9 12:43:29 2013
@@ -334,4 +334,34 @@ public class StaxUtilsTest extends Asser
         
         assertEquals(in.toString(), out.toString());
     }
+    
+    @Test
+    public void testQName() throws Exception {
+        StringBuilder in = new StringBuilder();
+        in.append("<f:foo xmlns:f=\"http://example.com/\">");
+        in.append("<bar>f:Bar</bar>");
+        in.append("<bar> f:Bar </bar>");
+        in.append("<bar>x:Bar</bar>");
+        in.append("</f:foo>");
+
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(
+             new ByteArrayInputStream(in.toString().getBytes()));
+        
+        QName qname = new QName("http://example.com/", "Bar");
+        assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
+        assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
+        // first bar
+        assertEquals(qname, StaxUtils.readQName(reader));
+        assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
+        // second bar
+        assertEquals(qname, StaxUtils.readQName(reader));
+        assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
+        // third bar
+        try {
+            StaxUtils.readQName(reader);
+            fail("invalid qname in mapping");
+        } catch (Exception e) {
+            // ignore
+        }
+    }
 }