You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by me...@apache.org on 2012/07/24 16:34:36 UTC

svn commit: r1365084 - in /xmlgraphics/commons/branches/Temp_URI_Resolution: ./ src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java status.xml test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java

Author: mehdi
Date: Tue Jul 24 14:34:36 2012
New Revision: 1365084

URL: http://svn.apache.org/viewvc?rev=1365084&view=rev
Log:
Merged trunk@1365077.

Modified:
    xmlgraphics/commons/branches/Temp_URI_Resolution/   (props changed)
    xmlgraphics/commons/branches/Temp_URI_Resolution/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java
    xmlgraphics/commons/branches/Temp_URI_Resolution/status.xml
    xmlgraphics/commons/branches/Temp_URI_Resolution/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java

Propchange: xmlgraphics/commons/branches/Temp_URI_Resolution/
------------------------------------------------------------------------------
  Merged /xmlgraphics/commons/trunk:r1365043-1365077

Modified: xmlgraphics/commons/branches/Temp_URI_Resolution/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_URI_Resolution/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java?rev=1365084&r1=1365083&r2=1365084&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_URI_Resolution/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java (original)
+++ xmlgraphics/commons/branches/Temp_URI_Resolution/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java Tue Jul 24 14:34:36 2012
@@ -72,7 +72,7 @@ public class DataURIResolver implements 
             ByteArrayInputStream encodedStream = new ByteArrayInputStream(bytes);
             Base64DecodeStream decodedStream = new Base64DecodeStream(
                     encodedStream);
-            return new StreamSource(decodedStream);
+            return new StreamSource(decodedStream, href);
         } else {
             String encoding = "UTF-8";
             final int charsetpos = header.indexOf(";charset=");
@@ -83,7 +83,7 @@ public class DataURIResolver implements 
                 final String unescapedString = URLDecoder
                         .decode(data, encoding);
                 return new StreamSource(new java.io.StringReader(
-                        unescapedString));
+                        unescapedString), href);
             } catch (IllegalArgumentException e) {
                 LOG.warn(e.getMessage());
             } catch (UnsupportedEncodingException e) {

Modified: xmlgraphics/commons/branches/Temp_URI_Resolution/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_URI_Resolution/status.xml?rev=1365084&r1=1365083&r2=1365084&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_URI_Resolution/status.xml (original)
+++ xmlgraphics/commons/branches/Temp_URI_Resolution/status.xml Tue Jul 24 14:34:36 2012
@@ -41,6 +41,9 @@
   </contexts>
   <changes>
     <release version="Trunk" date="n/a">
+      <action context="Code" dev="MH" type="fix" fixes-bug="53570" due-to="Robert Meyer">
+        Set the systemID of the StreamSource within the DataURIResolver
+      </action>
       <action context="Code" dev="GA" type="fix" fixes-bug="53408" due-to="Luis Bernardo, Matthias Reischenbacher">
         Add two PNG image loaders, one using internal XGC PNG code, the other using an externally supplied IDAT chunk (for raw decoding).
       </action>

Modified: xmlgraphics/commons/branches/Temp_URI_Resolution/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_URI_Resolution/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java?rev=1365084&r1=1365083&r2=1365084&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_URI_Resolution/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java (original)
+++ xmlgraphics/commons/branches/Temp_URI_Resolution/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java Tue Jul 24 14:34:36 2012
@@ -25,14 +25,19 @@ import javax.xml.transform.Source;
 import javax.xml.transform.URIResolver;
 import javax.xml.transform.stream.StreamSource;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 import org.apache.commons.io.IOUtils;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 /**
  * Test case for the RFC 2397 data URL/URI resolver.
  */
-public class DataURIResolverTestCase extends TestCase {
+public class DataURIResolverTestCase {
 
     private static final byte[] TESTDATA = new byte[] { 0, 1, 2, 3, 4, 5 };
 
@@ -42,6 +47,7 @@ public class DataURIResolverTestCase ext
      * @throws Exception
      *             if an error occurs
      */
+    @Test
     public void testRFC2397Generator() throws Exception {
         String url = DataURLUtil.createDataURL(new ByteArrayInputStream(
                 TESTDATA), null);
@@ -61,6 +67,7 @@ public class DataURIResolverTestCase ext
      * @throws Exception
      *             if an error occurs
      */
+    @Test
     public void testNonMatchingContract() throws Exception {
         URIResolver resolver = new DataURIResolver();
         Source src;
@@ -89,6 +96,7 @@ public class DataURIResolverTestCase ext
      * @throws Exception
      *             if an error occurs
      */
+    @Test
     public void testDataURLHandling() throws Exception {
         URIResolver resolver = new DataURIResolver();
         actualURLHAndlingTest(resolver);
@@ -138,4 +146,17 @@ public class DataURIResolverTestCase ext
         assertEquals("\u038e\u03c9\u038e", text);
     }
 
+    /**
+     * Test that the system Id is not null for the resulting stream objects
+     * @throws Exception If an error occurs.
+     */
+    @Test
+    public void testSystemIdForNull() throws Exception {
+        URIResolver resolver = new DataURIResolver();
+        Source source = resolver.resolve("data:;base64,AAECAwQF", null);
+        assertNotNull(source.getSystemId());
+
+        source = resolver.resolve("data:text/plain;charset=iso-8859-7,%be%f9%be", null);
+        assertNotNull(source.getSystemId());
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org