File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626import static org .junit .jupiter .api .Assertions .assertSame ;
2727import static org .junit .jupiter .api .Assertions .assertThrows ;
2828import static org .junit .jupiter .api .Assertions .assertTrue ;
29+ import static org .junit .jupiter .api .Assertions .fail ;
2930
3031import java .io .BufferedInputStream ;
3132import java .io .BufferedOutputStream ;
@@ -147,15 +148,11 @@ public void setUp() {
147148 if (!testFile .getParentFile ().exists ()) {
148149 throw new IOException ("Cannot create file " + testFile + " as the parent directory does not exist" );
149150 }
150- final BufferedOutputStream output = new BufferedOutputStream (Files .newOutputStream (testFilePath ));
151- try {
151+ try (BufferedOutputStream output = new BufferedOutputStream (Files .newOutputStream (testFilePath ))) {
152152 TestUtils .generateTestData (output , FILE_SIZE );
153- } finally {
154- IOUtils .closeQuietly (output );
155153 }
156- } catch (final IOException ioe ) {
157- throw new RuntimeException (
158- "Can't run this test because the environment could not be built: " + ioe .getMessage ());
154+ } catch (final IOException e ) {
155+ fail ("Can't run this test because the environment could not be built: " + e .getMessage ());
159156 }
160157 // Create and init a byte array as input data
161158 iarr = new byte [200 ];
You can’t perform that action at this time.
0 commit comments