Even though CopyUtils is deprecated, bring it to 100% code coverage.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1021986 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/commons/io/CopyUtilsTest.java b/src/test/java/org/apache/commons/io/CopyUtilsTest.java
index 87a78fe..415aca7 100644
--- a/src/test/java/org/apache/commons/io/CopyUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/CopyUtilsTest.java
@@ -20,6 +20,7 @@
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 @@
// 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 @@
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 @@
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);