harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r769824 - in /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io: BufferedInputStreamTest.java ByteArrayInputStreamTest.java ByteArrayOutputStreamTest.java
Date Wed, 29 Apr 2009 16:43:39 GMT
Author: odeakin
Date: Wed Apr 29 16:43:38 2009
New Revision: 769824

URL: http://svn.apache.org/viewvc?rev=769824&view=rev
Log:
Make sure bytes are UTF-8 encoded when making assertion checks

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedInputStreamTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayInputStreamTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayOutputStreamTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedInputStreamTest.java?rev=769824&r1=769823&r2=769824&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedInputStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedInputStreamTest.java
Wed Apr 29 16:43:38 2009
@@ -24,6 +24,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import junit.framework.TestCase;
 import tests.support.Support_PlatformFile;
@@ -265,7 +266,8 @@
      * @tests java.io.BufferedInputStream#read()
      */
     public void test_read() throws IOException {
-        int c = is.read();
+        InputStreamReader isr = new InputStreamReader(is);
+        int c = isr.read();
         assertTrue("read returned incorrect char", c == fileString.charAt(0));
 
         byte[] bytes = new byte[256];

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayInputStreamTest.java?rev=769824&r1=769823&r2=769824&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayInputStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayInputStreamTest.java
Wed Apr 29 16:43:38 2009
@@ -20,6 +20,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 
 public class ByteArrayInputStreamTest extends junit.framework.TestCase {
 
@@ -113,7 +114,8 @@
      * @tests ByteArrayInputStream#read()
      */
     public void test_read() throws IOException {
-        int c = is.read();
+        InputStreamReader isr = new InputStreamReader(is);
+        int c = isr.read();
         is.reset();
         assertTrue("read returned incorrect char", c == fileString.charAt(0));
     }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayOutputStreamTest.java?rev=769824&r1=769823&r2=769824&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayOutputStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ByteArrayOutputStreamTest.java
Wed Apr 29 16:43:38 2009
@@ -21,6 +21,7 @@
 import java.io.FileDescriptor;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 
 import junit.framework.TestCase;
 
@@ -126,12 +127,12 @@
     public void test_toStringLjava_lang_String() throws IOException {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
-        bos.write(fileString.getBytes(), 0, fileString.length());
+        bos.write(fileString.getBytes("UTF-8"), 0, fileString.length());
         assertTrue("Returned incorrect 8859-1 String", bos.toString("8859_1")
                 .equals(fileString));
 
         bos = new ByteArrayOutputStream();
-        bos.write(fileString.getBytes(), 0, fileString.length());
+        bos.write(fileString.getBytes("UTF-8"), 0, fileString.length());
         assertTrue("Returned incorrect 8859-2 String", bos.toString("8859_2")
                 .equals(fileString));
     }
@@ -160,12 +161,12 @@
     /**
      * @tests java.io.ByteArrayOutputStream#write(int)
      */
-    public void test_writeI() {
+    public void test_writeI() throws UnsupportedEncodingException {
         bos = new ByteArrayOutputStream();
         bos.write('t');
         byte[] result = bos.toByteArray();
         assertEquals("Wrote incorrect bytes", "t", new String(result, 0,
-                result.length));
+                result.length, "UTF-8"));
     }
 
     /**



Mime
View raw message