cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1511946 - in /cxf/trunk/api/src: main/java/org/apache/cxf/staxutils/StaxUtils.java test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
Date Thu, 08 Aug 2013 18:53:11 GMT
Author: ay
Date: Thu Aug  8 18:53:11 2013
New Revision: 1511946

URL: http://svn.apache.org/r1511946
Log:
[CXF-5191] StaxUtils readQName not accepting leading and trailing whitespcaes

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1511946&r1=1511945&r2=1511946&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Thu Aug  8 18:53:11
2013
@@ -1518,6 +1518,7 @@ public final class StaxUtils {
         if (value == null) {
             return null;
         }
+        value = value.trim();
         
         int index = value.indexOf(":");
 

Modified: cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java?rev=1511946&r1=1511945&r2=1511946&view=diff
==============================================================================
--- cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java (original)
+++ cxf/trunk/api/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java Thu Aug  8 18:53:11
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
+        }
+    }
 }



Mime
View raw message