2626
2727import org .apache .commons .io .output .ByteArrayOutputStream ;
2828import org .apache .commons .io .testtools .FileBasedTestCase ;
29+ import org .apache .commons .io .testtools .TestUtils ;
2930import org .apache .commons .io .testtools .YellOnCloseInputStream ;
3031import org .apache .commons .io .testtools .YellOnFlushAndCloseOutputStream ;
32+ import org .junit .After ;
33+ import org .junit .Before ;
34+ import org .junit .Test ;
35+
36+ import static org .junit .Assert .assertEquals ;
37+ import static org .junit .Assert .assertTrue ;
3138
3239@ SuppressWarnings ("deprecation" ) // these are test cases for the deprecated CopyUtils
3340
@@ -49,34 +56,20 @@ public class CopyUtilsTest extends FileBasedTestCase {
4956 private static final int FILE_SIZE = 1024 * 4 + 1 ;
5057
5158
52- private final byte [] inData = generateTestData (FILE_SIZE );
53-
54- public CopyUtilsTest (final String testName ) {
55- super (testName );
56- }
57-
58- // ----------------------------------------------------------------
59- // Setup
60- // ----------------------------------------------------------------
61-
62- @ Override
63- public void setUp () throws Exception {
64- }
65-
66- @ Override
67- public void tearDown () throws Exception {
68- }
59+ private final byte [] inData = TestUtils .generateTestData ((long ) FILE_SIZE );
6960
7061 // ----------------------------------------------------------------
7162 // Tests
7263 // ----------------------------------------------------------------
7364
65+ @ Test
7466 public void testCtor () {
7567 new CopyUtils ();
7668 // Nothing to assert, the constructor is public and does not blow up.
7769 }
7870
79- public void testCopy_byteArrayToOutputStream () throws Exception {
71+ @ Test
72+ public void copy_byteArrayToOutputStream () throws Exception {
8073 final ByteArrayOutputStream baout = new ByteArrayOutputStream ();
8174 final OutputStream out = new YellOnFlushAndCloseOutputStream (baout , false , true );
8275
@@ -86,7 +79,8 @@ public void testCopy_byteArrayToOutputStream() throws Exception {
8679 assertTrue ("Content differs" , Arrays .equals (inData , baout .toByteArray ()));
8780 }
8881
89- public void testCopy_byteArrayToWriter () throws Exception {
82+ @ Test
83+ public void copy_byteArrayToWriter () throws Exception {
9084 final ByteArrayOutputStream baout = new ByteArrayOutputStream ();
9185 final OutputStream out = new YellOnFlushAndCloseOutputStream (baout , false , true );
9286 final Writer writer = new java .io .OutputStreamWriter (out , "US-ASCII" );
@@ -98,6 +92,7 @@ public void testCopy_byteArrayToWriter() throws Exception {
9892 assertTrue ("Content differs" , Arrays .equals (inData , baout .toByteArray ()));
9993 }
10094
95+ @ Test
10196 public void testCopy_byteArrayToWriterWithEncoding () throws Exception {
10297 final String inDataStr = "data" ;
10398 final String charsetName = "UTF-8" ;
@@ -107,6 +102,7 @@ public void testCopy_byteArrayToWriterWithEncoding() throws Exception {
107102 }
108103
109104 @ SuppressWarnings ("resource" ) // 'in' is deliberately not closed
105+ @ Test
110106 public void testCopy_inputStreamToOutputStream () throws Exception {
111107 InputStream in = new ByteArrayInputStream (inData );
112108 in = new YellOnCloseInputStream (in );
@@ -123,7 +119,8 @@ public void testCopy_inputStreamToOutputStream() throws Exception {
123119 }
124120
125121 @ SuppressWarnings ("resource" ) // 'in' is deliberately not closed
126- public void testCopy_inputStreamToWriter () throws Exception {
122+ @ Test
123+ public void copy_inputStreamToWriter () throws Exception {
127124 InputStream in = new ByteArrayInputStream (inData );
128125 in = new YellOnCloseInputStream (in );
129126
@@ -139,7 +136,8 @@ public void testCopy_inputStreamToWriter() throws Exception {
139136 assertTrue ("Content differs" , Arrays .equals (inData , baout .toByteArray ()));
140137 }
141138
142- public void testCopy_inputStreamToWriterWithEncoding () throws Exception {
139+ @ Test
140+ public void copy_inputStreamToWriterWithEncoding () throws Exception {
143141 final String inDataStr = "data" ;
144142 final String charsetName = "UTF-8" ;
145143 final StringWriter writer = new StringWriter ();
@@ -148,6 +146,7 @@ public void testCopy_inputStreamToWriterWithEncoding() throws Exception {
148146 }
149147
150148 @ SuppressWarnings ("resource" ) // 'in' is deliberately not closed
149+ @ Test
151150 public void testCopy_readerToOutputStream () throws Exception {
152151 InputStream in = new ByteArrayInputStream (inData );
153152 in = new YellOnCloseInputStream (in );
@@ -169,7 +168,8 @@ public void testCopy_readerToOutputStream() throws Exception {
169168 }
170169
171170 @ SuppressWarnings ("resource" ) // 'in' is deliberately not closed
172- public void testCopy_readerToWriter () throws Exception {
171+ @ Test
172+ public void copy_readerToWriter () throws Exception {
173173 InputStream in = new ByteArrayInputStream (inData );
174174 in = new YellOnCloseInputStream (in );
175175 final Reader reader = new java .io .InputStreamReader (in , "US-ASCII" );
@@ -188,7 +188,8 @@ public void testCopy_readerToWriter() throws Exception {
188188 assertTrue ("Content differs" , Arrays .equals (inData , baout .toByteArray ()));
189189 }
190190
191- public void testCopy_stringToOutputStream () throws Exception {
191+ @ Test
192+ public void copy_stringToOutputStream () throws Exception {
192193 final String str = new String (inData , "US-ASCII" );
193194
194195 final ByteArrayOutputStream baout = new ByteArrayOutputStream ();
@@ -206,7 +207,8 @@ public void testCopy_stringToOutputStream() throws Exception {
206207 assertTrue ("Content differs" , Arrays .equals (inData , baout .toByteArray ()));
207208 }
208209
209- public void testCopy_stringToWriter () throws Exception {
210+ @ Test
211+ public void copy_stringToWriter () throws Exception {
210212 final String str = new String (inData , "US-ASCII" );
211213
212214 final ByteArrayOutputStream baout = new ByteArrayOutputStream ();
0 commit comments