ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1210066 - /ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java
Date Sun, 04 Dec 2011 07:55:45 GMT
Author: bodewig
Date: Sun Dec  4 07:55:45 2011
New Revision: 1210066

URL: http://svn.apache.org/viewvc?rev=1210066&view=rev
Log:
trying to narrow down transcoding error of exec test on Ubuntu.  Looks like ReaderInputStream
was working just fine

Modified:
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java?rev=1210066&r1=1210065&r2=1210066&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java Sun
Dec  4 07:55:45 2011
@@ -74,6 +74,43 @@ public class ReaderInputStreamTest exten
         System.out.println("Preample len is " + bytes.length);
     }
     
+    public void testIso88591ToUtf8() throws Exception {
+        InputStreamReader fin = null;
+        ReaderInputStream r = null;
+        FileInputStream utf8 = null;
+        try {
+            fin = new InputStreamReader(new FileInputStream("src/tests/antunit/taskdefs/exec/input/iso8859-1"),
+                                        "ISO8859_1");
+            r = new ReaderInputStream(fin, "UTF8");
+
+            ByteArrayOutputStream actualOS = new ByteArrayOutputStream();
+            int b = r.read();
+            while (b > -1) {
+                actualOS.write((byte) b);
+                b = r.read();
+            }
+
+            utf8 = new FileInputStream("src/tests/antunit/taskdefs/exec/expected/utf-8");
+            ByteArrayOutputStream expectedOS = new ByteArrayOutputStream();
+            b = utf8.read();
+            while (b > -1) {
+                expectedOS.write((byte) b);
+                b = utf8.read();
+            }
+
+            byte[] expected = expectedOS.toByteArray();
+            byte[] actual = actualOS.toByteArray();
+            assertEquals("length", expected.length, actual.length);
+            for (int i = 0; i < actual.length; i++) {
+                assertEquals("byte " + i, expected[i], actual[i]);
+            }
+        } finally {
+            FileUtils.close(fin);
+            FileUtils.close(r);
+            FileUtils.close(utf8);
+        }
+    }
+
     private void compareBytes(String s, String encoding) throws Exception {
         byte[] expected = s.getBytes(encoding);
         



Mime
View raw message