commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1021986 - /commons/proper/io/trunk/src/test/java/org/apache/commons/io/CopyUtilsTest.java
Date Wed, 13 Oct 2010 03:37:23 GMT
Author: ggregory
Date: Wed Oct 13 03:37:23 2010
New Revision: 1021986

URL: http://svn.apache.org/viewvc?rev=1021986&view=rev
Log:
Even though CopyUtils is deprecated, bring it to 100% code coverage.

Modified:
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/CopyUtilsTest.java

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/CopyUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/CopyUtilsTest.java?rev=1021986&r1=1021985&r2=1021986&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/CopyUtilsTest.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/CopyUtilsTest.java Wed Oct
13 03:37:23 2010
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
+import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Arrays;
 
@@ -73,6 +74,11 @@ public class CopyUtilsTest extends FileB
     // Tests
     // ----------------------------------------------------------------
 
+    public void testCtor() {
+        new CopyUtils();
+        // Nothing to assert, the constructor is public and does not blow up.
+    }
+    
     public void testCopy_byteArrayToOutputStream() throws Exception {
         ByteArrayOutputStream baout = new ByteArrayOutputStream();
         OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
@@ -95,6 +101,14 @@ public class CopyUtilsTest extends FileB
         assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
     }
 
+    public void testCopy_byteArrayToWriterWithEncoding() throws Exception {
+        String inDataStr = "data";
+        String charsetName = "UTF-8";
+        StringWriter writer = new StringWriter(); 
+        CopyUtils.copy(inDataStr.getBytes(charsetName), writer, charsetName);
+        assertEquals(inDataStr, writer.toString());
+    }
+
     public void testCopy_inputStreamToOutputStream() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -126,6 +140,14 @@ public class CopyUtilsTest extends FileB
         assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
     }
 
+    public void testCopy_inputStreamToWriterWithEncoding() throws Exception {
+        String inDataStr = "data";
+        String charsetName = "UTF-8";
+        StringWriter writer = new StringWriter();
+        CopyUtils.copy(new ByteArrayInputStream(inDataStr.getBytes(charsetName)), writer,
charsetName);
+        assertEquals(inDataStr, writer.toString());
+    }
+
     public void testCopy_readerToOutputStream() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);



Mime
View raw message