Fix test on Windows

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/commons/trunk@1876186 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/xmlgraphics/util/io/Base64TestCase.java b/src/test/java/org/apache/xmlgraphics/util/io/Base64TestCase.java
index 0955e51..19a4860 100644
--- a/src/test/java/org/apache/xmlgraphics/util/io/Base64TestCase.java
+++ b/src/test/java/org/apache/xmlgraphics/util/io/Base64TestCase.java
@@ -19,6 +19,8 @@
 
 package org.apache.xmlgraphics.util.io;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -31,6 +33,8 @@
 
 import static org.junit.Assert.fail;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * This test validates that the Base64 encoder/decoders work properly.
  *
@@ -39,7 +43,7 @@
 public class Base64TestCase {
 
     private void innerBase64Test(String action, URL in, URL ref) throws Exception {
-        InputStream inIS = in.openStream();
+        InputStream inIS = dos2Unix(in);
 
         if (action.equals("ROUND")) {
             ref = in;
@@ -47,7 +51,7 @@
             fail("Bad action string");
         }
 
-        InputStream refIS = ref.openStream();
+        InputStream refIS = dos2Unix(ref);
 
         if (action.equals("ENCODE") || action.equals("ROUND")) {
             // We need to encode the incomming data
@@ -74,6 +78,21 @@
         }
     }
 
+    private InputStream dos2Unix(URL url) throws IOException {
+        InputStream is = url.openStream();
+        byte[] data = IOUtils.toByteArray(is);
+        if (data.length > 1 && data[data.length - 1] == '\n') {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            for (byte b : data) {
+                if (b != '\r') {
+                    bos.write(b);
+                }
+            }
+            return new ByteArrayInputStream(bos.toByteArray());
+        }
+        return new ByteArrayInputStream(data);
+    }
+
     private void innerBase64Test(String action, String in, String ref) throws Exception {
         final String baseURL = "file:src/test/resources/org/apache/xmlgraphics/util/io/";
         innerBase64Test(action, new URL(baseURL + in), new URL(baseURL + ref));