You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by kr...@apache.org on 2015/12/09 20:50:31 UTC

svn commit: r1718944 [3/6] - in /commons/proper/io/trunk/src/test/java/org/apache/commons/io: ./ comparator/ filefilter/ input/ monitor/ output/ testtools/

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java?rev=1718944&r1=1718943&r2=1718944&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java Wed Dec  9 19:50:30 2015
@@ -16,12 +16,24 @@
  */
 package org.apache.commons.io;
 
+import org.apache.commons.io.testtools.FileBasedTestCase;
+import org.apache.commons.io.testtools.TestUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.BufferedOutputStream;
 import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.apache.commons.io.testtools.FileBasedTestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * This is used to test FilenameUtils for correctness.
@@ -40,35 +52,78 @@ public class FilenameUtilsTestCase exten
     private final int testFile1Size;
     private final int testFile2Size;
 
-    public FilenameUtilsTestCase(final String name) {
-        super(name);
-
+    public FilenameUtilsTestCase() {
         testFile1 = new File(getTestDirectory(), "file1-test.txt");
         testFile2 = new File(getTestDirectory(), "file1a-test.txt");
 
-        testFile1Size = (int)testFile1.length();
-        testFile2Size = (int)testFile2.length();
+        testFile1Size = (int) testFile1.length();
+        testFile2Size = (int) testFile2.length();
     }
 
-    /** @see junit.framework.TestCase#setUp() */
-    @Override
-    protected void setUp() throws Exception {
-        getTestDirectory().mkdirs();
-        createFile(testFile1, testFile1Size);
-        createFile(testFile2, testFile2Size);
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    @Before
+    public void setUp() throws Exception {
+        getTestDirectory();
+        if (!testFile1.getParentFile().exists()) {
+            throw new IOException("Cannot create file " + testFile1
+                    + " as the parent directory does not exist");
+        }
+        final BufferedOutputStream output3 =
+                new BufferedOutputStream(new FileOutputStream(testFile1));
+        try {
+            TestUtils.generateTestData(output3, (long) testFile1Size);
+        } finally {
+            IOUtils.closeQuietly(output3);
+        }
+        if (!testFile2.getParentFile().exists()) {
+            throw new IOException("Cannot create file " + testFile2
+                    + " as the parent directory does not exist");
+        }
+        final BufferedOutputStream output2 =
+                new BufferedOutputStream(new FileOutputStream(testFile2));
+        try {
+            TestUtils.generateTestData(output2, (long) testFile2Size);
+        } finally {
+            IOUtils.closeQuietly(output2);
+        }
         FileUtils.deleteDirectory(getTestDirectory());
-        getTestDirectory().mkdirs();
-        createFile(testFile1, testFile1Size);
-        createFile(testFile2, testFile2Size);
+        getTestDirectory();
+        if (!testFile1.getParentFile().exists()) {
+            throw new IOException("Cannot create file " + testFile1
+                    + " as the parent directory does not exist");
+        }
+        final BufferedOutputStream output1 =
+                new BufferedOutputStream(new FileOutputStream(testFile1));
+        try {
+            TestUtils.generateTestData(output1, (long) testFile1Size);
+        } finally {
+            IOUtils.closeQuietly(output1);
+        }
+        if (!testFile2.getParentFile().exists()) {
+            throw new IOException("Cannot create file " + testFile2
+                    + " as the parent directory does not exist");
+        }
+        final BufferedOutputStream output =
+                new BufferedOutputStream(new FileOutputStream(testFile2));
+        try {
+            TestUtils.generateTestData(output, (long) testFile2Size);
+        } finally {
+            IOUtils.closeQuietly(output);
+        }
     }
 
-    /** @see junit.framework.TestCase#tearDown() */
-    @Override
-    protected void tearDown() throws Exception {
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    @After
+    public void tearDown() throws Exception {
         FileUtils.deleteDirectory(getTestDirectory());
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testNormalize() throws Exception {
         assertEquals(null, FilenameUtils.normalize(null));
         assertEquals(null, FilenameUtils.normalize(":"));
@@ -218,6 +273,7 @@ public class FilenameUtilsTestCase exten
         assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalize("//server/"));
     }
 
+    @Test
     public void testNormalize_with_nullbytes() throws Exception {
         try {
             assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("a\\b/c\u0000.txt"));
@@ -230,11 +286,12 @@ public class FilenameUtilsTestCase exten
         }
     }
 
+    @Test
     public void testNormalizeUnixWin() throws Exception {
 
         // Normalize (Unix Separator)
-        assertEquals("/a/c/",    FilenameUtils.normalize("/a/b/../c/", true));
-        assertEquals("/a/c/",    FilenameUtils.normalize("\\a\\b\\..\\c\\", true));
+        assertEquals("/a/c/", FilenameUtils.normalize("/a/b/../c/", true));
+        assertEquals("/a/c/", FilenameUtils.normalize("\\a\\b\\..\\c\\", true));
 
         // Normalize (Windows Separator)
         assertEquals("\\a\\c\\", FilenameUtils.normalize("/a/b/../c/", false));
@@ -242,6 +299,7 @@ public class FilenameUtilsTestCase exten
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testNormalizeNoEndSeparator() throws Exception {
         assertEquals(null, FilenameUtils.normalizeNoEndSeparator(null));
         assertEquals(null, FilenameUtils.normalizeNoEndSeparator(":"));
@@ -391,11 +449,12 @@ public class FilenameUtilsTestCase exten
         assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalizeNoEndSeparator("//server/"));
     }
 
+    @Test
     public void testNormalizeNoEndSeparatorUnixWin() throws Exception {
 
         // Normalize (Unix Separator)
-        assertEquals("/a/c",   FilenameUtils.normalizeNoEndSeparator("/a/b/../c/", true));
-        assertEquals("/a/c",   FilenameUtils.normalizeNoEndSeparator("\\a\\b\\..\\c\\", true));
+        assertEquals("/a/c", FilenameUtils.normalizeNoEndSeparator("/a/b/../c/", true));
+        assertEquals("/a/c", FilenameUtils.normalizeNoEndSeparator("\\a\\b\\..\\c\\", true));
 
         // Normalize (Windows Separator)
         assertEquals("\\a\\c", FilenameUtils.normalizeNoEndSeparator("/a/b/../c/", false));
@@ -403,6 +462,7 @@ public class FilenameUtilsTestCase exten
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testConcat() {
         assertEquals(null, FilenameUtils.concat("", null));
         assertEquals(null, FilenameUtils.concat(null, null));
@@ -442,6 +502,7 @@ public class FilenameUtilsTestCase exten
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testSeparatorsToUnix() {
         assertEquals(null, FilenameUtils.separatorsToUnix(null));
         assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("/a/b/c"));
@@ -451,6 +512,7 @@ public class FilenameUtilsTestCase exten
         assertEquals("D:/a/b/c", FilenameUtils.separatorsToUnix("D:\\a\\b\\c"));
     }
 
+    @Test
     public void testSeparatorsToWindows() {
         assertEquals(null, FilenameUtils.separatorsToWindows(null));
         assertEquals("\\a\\b\\c", FilenameUtils.separatorsToWindows("\\a\\b\\c"));
@@ -460,6 +522,7 @@ public class FilenameUtilsTestCase exten
         assertEquals("D:\\a\\b\\c", FilenameUtils.separatorsToWindows("D:/a/b/c"));
     }
 
+    @Test
     public void testSeparatorsToSystem() {
         if (WINDOWS) {
             assertEquals(null, FilenameUtils.separatorsToSystem(null));
@@ -479,6 +542,7 @@ public class FilenameUtilsTestCase exten
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testGetPrefixLength() {
         assertEquals(-1, FilenameUtils.getPrefixLength(null));
         assertEquals(-1, FilenameUtils.getPrefixLength(":"));
@@ -519,8 +583,9 @@ public class FilenameUtilsTestCase exten
         assertEquals(9, FilenameUtils.getPrefixLength("//server/a/b/c.txt"));
         assertEquals(-1, FilenameUtils.getPrefixLength("\\\\\\a\\b\\c.txt"));
         assertEquals(-1, FilenameUtils.getPrefixLength("///a/b/c.txt"));
-}
+    }
 
+    @Test
     public void testIndexOfLastSeparator() {
         assertEquals(-1, FilenameUtils.indexOfLastSeparator(null));
         assertEquals(-1, FilenameUtils.indexOfLastSeparator("noseperator.inthispath"));
@@ -528,6 +593,7 @@ public class FilenameUtilsTestCase exten
         assertEquals(3, FilenameUtils.indexOfLastSeparator("a\\b\\c"));
     }
 
+    @Test
     public void testIndexOfExtension() {
         assertEquals(-1, FilenameUtils.indexOfExtension(null));
         assertEquals(-1, FilenameUtils.indexOfExtension("file"));
@@ -540,6 +606,7 @@ public class FilenameUtilsTestCase exten
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testGetPrefix() {
         assertEquals(null, FilenameUtils.getPrefix(null));
         assertEquals(null, FilenameUtils.getPrefix(":"));
@@ -577,6 +644,7 @@ public class FilenameUtilsTestCase exten
         assertEquals("~user\\", FilenameUtils.getPrefix("~user\\a\\b\\c.txt"));
     }
 
+    @Test
     public void testGetPrefix_with_nullbyte() {
         try {
             assertEquals("~user\\", FilenameUtils.getPrefix("~u\u0000ser\\a\\b\\c.txt"));
@@ -585,6 +653,7 @@ public class FilenameUtilsTestCase exten
         }
     }
 
+    @Test
     public void testGetPath() {
         assertEquals(null, FilenameUtils.getPath(null));
         assertEquals("", FilenameUtils.getPath("noseperator.inthispath"));
@@ -621,16 +690,13 @@ public class FilenameUtilsTestCase exten
         assertEquals("a/b/", FilenameUtils.getPath("~user/a/b/c.txt"));
     }
 
+    @Test(expected = IllegalArgumentException.class)
     public void testGetPath_with_nullbyte() {
-        try {
-            assertEquals("a/b/", FilenameUtils.getPath("~user/a/\u0000b/c.txt"));
-        } catch (IllegalArgumentException ignore) {
-
-        }
-        ;
+        assertEquals("a/b/", FilenameUtils.getPath("~user/a/\u0000b/c.txt"));
     }
 
 
+    @Test
     public void testGetPathNoEndSeparator() {
         assertEquals(null, FilenameUtils.getPath(null));
         assertEquals("", FilenameUtils.getPath("noseperator.inthispath"));
@@ -667,6 +733,7 @@ public class FilenameUtilsTestCase exten
         assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("~user/a/b/c.txt"));
     }
 
+    @Test
     public void testGetPathNoEndSeparator_with_null_byte() {
         try {
             assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("~user/a\u0000/b/c.txt"));
@@ -675,6 +742,7 @@ public class FilenameUtilsTestCase exten
         }
     }
 
+    @Test
     public void testGetFullPath() {
         assertEquals(null, FilenameUtils.getFullPath(null));
         assertEquals("", FilenameUtils.getFullPath("noseperator.inthispath"));
@@ -709,6 +777,7 @@ public class FilenameUtilsTestCase exten
         assertEquals("~user/a/b/", FilenameUtils.getFullPath("~user/a/b/c.txt"));
     }
 
+    @Test
     public void testGetFullPathNoEndSeparator() {
         assertEquals(null, FilenameUtils.getFullPathNoEndSeparator(null));
         assertEquals("", FilenameUtils.getFullPathNoEndSeparator("noseperator.inthispath"));
@@ -746,21 +815,23 @@ public class FilenameUtilsTestCase exten
     /**
      * Test for https://issues.apache.org/jira/browse/IO-248
      */
+    @Test
     public void testGetFullPathNoEndSeparator_IO_248() {
 
         // Test single separator
-        assertEquals("/",  FilenameUtils.getFullPathNoEndSeparator("/"));
+        assertEquals("/", FilenameUtils.getFullPathNoEndSeparator("/"));
         assertEquals("\\", FilenameUtils.getFullPathNoEndSeparator("\\"));
 
         // Test one level directory
-        assertEquals("/",  FilenameUtils.getFullPathNoEndSeparator("/abc"));
+        assertEquals("/", FilenameUtils.getFullPathNoEndSeparator("/abc"));
         assertEquals("\\", FilenameUtils.getFullPathNoEndSeparator("\\abc"));
 
         // Test one level directory
-        assertEquals("/abc",  FilenameUtils.getFullPathNoEndSeparator("/abc/xyz"));
+        assertEquals("/abc", FilenameUtils.getFullPathNoEndSeparator("/abc/xyz"));
         assertEquals("\\abc", FilenameUtils.getFullPathNoEndSeparator("\\abc\\xyz"));
     }
 
+    @Test
     public void testGetName() {
         assertEquals(null, FilenameUtils.getName(null));
         assertEquals("noseperator.inthispath", FilenameUtils.getName("noseperator.inthispath"));
@@ -770,6 +841,7 @@ public class FilenameUtilsTestCase exten
         assertEquals("c", FilenameUtils.getName("a\\b\\c"));
     }
 
+    @Test
     public void testInjectionFailure() {
         try {
             assertEquals("c", FilenameUtils.getName("a\\b\\\u0000c"));
@@ -778,6 +850,7 @@ public class FilenameUtilsTestCase exten
         }
     }
 
+    @Test
     public void testGetBaseName() {
         assertEquals(null, FilenameUtils.getBaseName(null));
         assertEquals("noseperator", FilenameUtils.getBaseName("noseperator.inthispath"));
@@ -788,6 +861,7 @@ public class FilenameUtilsTestCase exten
         assertEquals("file.txt", FilenameUtils.getBaseName("file.txt.bak"));
     }
 
+    @Test
     public void testGetBaseName_with_nullByte() {
         try {
             assertEquals("file.txt", FilenameUtils.getBaseName("fil\u0000e.txt.bak"));
@@ -796,6 +870,7 @@ public class FilenameUtilsTestCase exten
         }
     }
 
+    @Test
     public void testGetExtension() {
         assertEquals(null, FilenameUtils.getExtension(null));
         assertEquals("ext", FilenameUtils.getExtension("file.ext"));
@@ -812,6 +887,7 @@ public class FilenameUtilsTestCase exten
         assertEquals("ext", FilenameUtils.getExtension("../filename.ext"));
     }
 
+    @Test
     public void testRemoveExtension() {
         assertEquals(null, FilenameUtils.removeExtension(null));
         assertEquals("file", FilenameUtils.removeExtension("file.ext"));
@@ -829,6 +905,7 @@ public class FilenameUtilsTestCase exten
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testEquals() {
         assertTrue(FilenameUtils.equals(null, null));
         assertFalse(FilenameUtils.equals(null, ""));
@@ -839,6 +916,7 @@ public class FilenameUtilsTestCase exten
         assertFalse(FilenameUtils.equals("a\\b\\file.txt", "a/b/file.txt"));
     }
 
+    @Test
     public void testEqualsOnSystem() {
         assertTrue(FilenameUtils.equalsOnSystem(null, null));
         assertFalse(FilenameUtils.equalsOnSystem(null, ""));
@@ -850,6 +928,7 @@ public class FilenameUtilsTestCase exten
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testEqualsNormalized() {
         assertTrue(FilenameUtils.equalsNormalized(null, null));
         assertFalse(FilenameUtils.equalsNormalized(null, ""));
@@ -861,6 +940,7 @@ public class FilenameUtilsTestCase exten
         assertFalse(FilenameUtils.equalsNormalized("a/b/", "a/b"));
     }
 
+    @Test
     public void testEqualsNormalizedOnSystem() {
         assertTrue(FilenameUtils.equalsNormalizedOnSystem(null, null));
         assertFalse(FilenameUtils.equalsNormalizedOnSystem(null, ""));
@@ -875,27 +955,29 @@ public class FilenameUtilsTestCase exten
     /**
      * Test for https://issues.apache.org/jira/browse/IO-128
      */
+    @Test
     public void testEqualsNormalizedError_IO_128() {
         try {
             FilenameUtils.equalsNormalizedOnSystem("//file.txt", "file.txt");
             fail("Invalid normalized first file");
-        } catch(final NullPointerException e) {
+        } catch (final NullPointerException e) {
             // expected result
         }
         try {
             FilenameUtils.equalsNormalizedOnSystem("file.txt", "//file.txt");
             fail("Invalid normalized second file");
-        } catch(final NullPointerException e) {
+        } catch (final NullPointerException e) {
             // expected result
         }
         try {
             FilenameUtils.equalsNormalizedOnSystem("//file.txt", "//file.txt");
             fail("Invalid normalized both filse");
-        } catch(final NullPointerException e) {
+        } catch (final NullPointerException e) {
             // expected result
         }
     }
 
+    @Test
     public void testEquals_fullControl() {
         assertFalse(FilenameUtils.equals("file.txt", "FILE.TXT", true, IOCase.SENSITIVE));
         assertTrue(FilenameUtils.equals("file.txt", "FILE.TXT", true, IOCase.INSENSITIVE));
@@ -904,6 +986,7 @@ public class FilenameUtilsTestCase exten
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void testIsExtension() {
         assertFalse(FilenameUtils.isExtension(null, (String) null));
         assertFalse(FilenameUtils.isExtension("file.txt", (String) null));
@@ -936,6 +1019,7 @@ public class FilenameUtilsTestCase exten
         assertFalse(FilenameUtils.isExtension("a.b\\file.txt", "TXT"));
     }
 
+    @Test
     public void testIsExtension_injection() {
         try {
             FilenameUtils.isExtension("a.b\\fi\u0000le.txt", "TXT");
@@ -944,80 +1028,82 @@ public class FilenameUtilsTestCase exten
         }
     }
 
+    @Test
     public void testIsExtensionArray() {
         assertFalse(FilenameUtils.isExtension(null, (String[]) null));
         assertFalse(FilenameUtils.isExtension("file.txt", (String[]) null));
         assertTrue(FilenameUtils.isExtension("file", (String[]) null));
         assertFalse(FilenameUtils.isExtension("file.txt", new String[0]));
-        assertTrue(FilenameUtils.isExtension("file.txt", new String[] {"txt"}));
-        assertFalse(FilenameUtils.isExtension("file.txt", new String[] {"rtf"}));
-        assertTrue(FilenameUtils.isExtension("file", new String[] {"rtf", ""}));
-        assertTrue(FilenameUtils.isExtension("file.txt", new String[] {"rtf", "txt"}));
+        assertTrue(FilenameUtils.isExtension("file.txt", new String[]{"txt"}));
+        assertFalse(FilenameUtils.isExtension("file.txt", new String[]{"rtf"}));
+        assertTrue(FilenameUtils.isExtension("file", new String[]{"rtf", ""}));
+        assertTrue(FilenameUtils.isExtension("file.txt", new String[]{"rtf", "txt"}));
 
         assertFalse(FilenameUtils.isExtension("a/b/file.txt", (String[]) null));
         assertFalse(FilenameUtils.isExtension("a/b/file.txt", new String[0]));
-        assertTrue(FilenameUtils.isExtension("a/b/file.txt", new String[] {"txt"}));
-        assertFalse(FilenameUtils.isExtension("a/b/file.txt", new String[] {"rtf"}));
-        assertTrue(FilenameUtils.isExtension("a/b/file.txt", new String[] {"rtf", "txt"}));
+        assertTrue(FilenameUtils.isExtension("a/b/file.txt", new String[]{"txt"}));
+        assertFalse(FilenameUtils.isExtension("a/b/file.txt", new String[]{"rtf"}));
+        assertTrue(FilenameUtils.isExtension("a/b/file.txt", new String[]{"rtf", "txt"}));
 
         assertFalse(FilenameUtils.isExtension("a.b/file.txt", (String[]) null));
         assertFalse(FilenameUtils.isExtension("a.b/file.txt", new String[0]));
-        assertTrue(FilenameUtils.isExtension("a.b/file.txt", new String[] {"txt"}));
-        assertFalse(FilenameUtils.isExtension("a.b/file.txt", new String[] {"rtf"}));
-        assertTrue(FilenameUtils.isExtension("a.b/file.txt", new String[] {"rtf", "txt"}));
+        assertTrue(FilenameUtils.isExtension("a.b/file.txt", new String[]{"txt"}));
+        assertFalse(FilenameUtils.isExtension("a.b/file.txt", new String[]{"rtf"}));
+        assertTrue(FilenameUtils.isExtension("a.b/file.txt", new String[]{"rtf", "txt"}));
 
         assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", (String[]) null));
         assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new String[0]));
-        assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new String[] {"txt"}));
-        assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new String[] {"rtf"}));
-        assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new String[] {"rtf", "txt"}));
+        assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"txt"}));
+        assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"rtf"}));
+        assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"rtf", "txt"}));
 
         assertFalse(FilenameUtils.isExtension("a.b\\file.txt", (String[]) null));
         assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[0]));
-        assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new String[] {"txt"}));
-        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[] {"rtf"}));
-        assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new String[] {"rtf", "txt"}));
+        assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"txt"}));
+        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"rtf"}));
+        assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"rtf", "txt"}));
 
-        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[] {"TXT"}));
-        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[] {"TXT", "RTF"}));
+        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"TXT"}));
+        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"TXT", "RTF"}));
     }
 
+    @Test
     public void testIsExtensionCollection() {
         assertFalse(FilenameUtils.isExtension(null, (Collection<String>) null));
         assertFalse(FilenameUtils.isExtension("file.txt", (Collection<String>) null));
         assertTrue(FilenameUtils.isExtension("file", (Collection<String>) null));
         assertFalse(FilenameUtils.isExtension("file.txt", new ArrayList<String>()));
-        assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList<String>(Arrays.asList(new String[] {"txt"}))));
-        assertFalse(FilenameUtils.isExtension("file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf"}))));
-        assertTrue(FilenameUtils.isExtension("file", new ArrayList<String>(Arrays.asList(new String[] {"rtf", ""}))));
-        assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf", "txt"}))));
+        assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList<String>(Arrays.asList(new String[]{"txt"}))));
+        assertFalse(FilenameUtils.isExtension("file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf"}))));
+        assertTrue(FilenameUtils.isExtension("file", new ArrayList<String>(Arrays.asList(new String[]{"rtf", ""}))));
+        assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf", "txt"}))));
 
         assertFalse(FilenameUtils.isExtension("a/b/file.txt", (Collection<String>) null));
         assertFalse(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<String>()));
-        assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<String>(Arrays.asList(new String[] {"txt"}))));
-        assertFalse(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf"}))));
-        assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf", "txt"}))));
+        assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<String>(Arrays.asList(new String[]{"txt"}))));
+        assertFalse(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf"}))));
+        assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf", "txt"}))));
 
         assertFalse(FilenameUtils.isExtension("a.b/file.txt", (Collection<String>) null));
         assertFalse(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<String>()));
-        assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<String>(Arrays.asList(new String[] {"txt"}))));
-        assertFalse(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf"}))));
-        assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf", "txt"}))));
+        assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<String>(Arrays.asList(new String[]{"txt"}))));
+        assertFalse(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf"}))));
+        assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf", "txt"}))));
 
         assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", (Collection<String>) null));
         assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<String>()));
-        assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<String>(Arrays.asList(new String[] {"txt"}))));
-        assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf"}))));
-        assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf", "txt"}))));
+        assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<String>(Arrays.asList(new String[]{"txt"}))));
+        assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf"}))));
+        assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf", "txt"}))));
 
         assertFalse(FilenameUtils.isExtension("a.b\\file.txt", (Collection<String>) null));
         assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>()));
-        assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[] {"txt"}))));
-        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf"}))));
-        assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[] {"rtf", "txt"}))));
+        assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[]{"txt"}))));
+        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf"}))));
+        assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[]{"rtf", "txt"}))));
 
-        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[] {"TXT"}))));
-        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[] {"TXT", "RTF"}))));
+        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[]{"TXT"}))));
+        assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>(Arrays.asList(new String[]{"TXT", "RTF"}))));
     }
 
 }

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java?rev=1718944&r1=1718943&r2=1718944&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java Wed Dec  9 19:50:30 2015
@@ -16,23 +16,25 @@
  */
 package org.apache.commons.io;
 
+import org.junit.Test;
+
 import java.io.File;
 import java.util.Locale;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
-public class FilenameUtilsWildcardTestCase extends TestCase {
+public class FilenameUtilsWildcardTestCase {
 
     private static final boolean WINDOWS = File.separatorChar == '\\';
 
-    public FilenameUtilsWildcardTestCase(final String name) {
-        super(name);
-    }
-
     //-----------------------------------------------------------------------
     // Testing:
     //   FilenameUtils.wildcardMatch(String,String)
 
+    @Test
     public void testMatch() {
         assertFalse(FilenameUtils.wildcardMatch(null, "Foo"));
         assertFalse(FilenameUtils.wildcardMatch("Foo", null));
@@ -58,6 +60,7 @@ public class FilenameUtilsWildcardTestCa
         assertFalse(FilenameUtils.wildcardMatch("FOOBAR", "Foo*"));
     }
 
+    @Test
     public void testMatchOnSystem() {
         assertFalse(FilenameUtils.wildcardMatchOnSystem(null, "Foo"));
         assertFalse(FilenameUtils.wildcardMatchOnSystem("Foo", null));
@@ -81,6 +84,7 @@ public class FilenameUtilsWildcardTestCa
         assertEquals(WINDOWS, FilenameUtils.wildcardMatchOnSystem("FOOBAR", "Foo*"));
     }
 
+    @Test
     public void testMatchCaseSpecified() {
         assertFalse(FilenameUtils.wildcardMatch(null, "Foo", IOCase.SENSITIVE));
         assertFalse(FilenameUtils.wildcardMatch("Foo", null, IOCase.SENSITIVE));
@@ -115,24 +119,18 @@ public class FilenameUtilsWildcardTestCa
         assertEquals(WINDOWS, FilenameUtils.wildcardMatch("FOOBAR", "Foo*", IOCase.SYSTEM));
     }
 
+    @Test
     public void testSplitOnTokens() {
-        assertArrayEquals( new String[] { "Ad", "*", "er" }, FilenameUtils.splitOnTokens("Ad*er") );
-        assertArrayEquals( new String[] { "Ad", "?", "er" }, FilenameUtils.splitOnTokens("Ad?er") );
-        assertArrayEquals( new String[] { "Test", "*", "?", "One" }, FilenameUtils.splitOnTokens("Test*?One") );
-        assertArrayEquals( new String[] { "Test", "?", "*", "One" }, FilenameUtils.splitOnTokens("Test?*One") );
-        assertArrayEquals( new String[] { "*" }, FilenameUtils.splitOnTokens("****") );
-        assertArrayEquals( new String[] { "*", "?", "?", "*" }, FilenameUtils.splitOnTokens("*??*") );
-        assertArrayEquals( new String[] { "*", "?", "*", "?", "*" }, FilenameUtils.splitOnTokens("*?**?*") );
-        assertArrayEquals( new String[] { "*", "?", "*", "?", "*" }, FilenameUtils.splitOnTokens("*?***?*") );
-        assertArrayEquals( new String[] { "h", "?", "?", "*" }, FilenameUtils.splitOnTokens("h??*") );
-        assertArrayEquals( new String[] { "" }, FilenameUtils.splitOnTokens("") );
-    }
-
-    private void assertArrayEquals(final Object[] a1, final Object[] a2) {
-        assertEquals(a1.length, a2.length);
-        for(int i=0; i<a1.length; i++) {
-            assertEquals(a1[i], a2[i]);
-        }
+        assertArrayEquals(new String[] { "Ad", "*", "er" }, FilenameUtils.splitOnTokens("Ad*er"));
+        assertArrayEquals(new String[] { "Ad", "?", "er" }, FilenameUtils.splitOnTokens("Ad?er"));
+        assertArrayEquals(new String[] { "Test", "*", "?", "One" }, FilenameUtils.splitOnTokens("Test*?One"));
+        assertArrayEquals(new String[] { "Test", "?", "*", "One" }, FilenameUtils.splitOnTokens("Test?*One"));
+        assertArrayEquals(new String[] { "*" }, FilenameUtils.splitOnTokens("****"));
+        assertArrayEquals(new String[] { "*", "?", "?", "*" }, FilenameUtils.splitOnTokens("*??*"));
+        assertArrayEquals(new String[] { "*", "?", "*", "?", "*" }, FilenameUtils.splitOnTokens("*?**?*"));
+        assertArrayEquals(new String[] { "*", "?", "*", "?", "*" }, FilenameUtils.splitOnTokens("*?***?*"));
+        assertArrayEquals(new String[] { "h", "?", "?", "*" }, FilenameUtils.splitOnTokens("h??*"));
+        assertArrayEquals(new String[] { "" }, FilenameUtils.splitOnTokens(""));
     }
 
     private void assertMatch(final String text, final String wildcard, final boolean expected) {
@@ -140,6 +138,7 @@ public class FilenameUtilsWildcardTestCa
     }
 
     // A separate set of tests, added to this batch
+    @Test
     public void testMatch2() {
         assertMatch("log.txt", "log.txt", true);
         assertMatch("log.txt1", "log.txt", false);
@@ -189,6 +188,7 @@ public class FilenameUtilsWildcardTestCa
     /**
      * See https://issues.apache.org/jira/browse/IO-246
      */
+    @Test
     public void test_IO_246() {
 
         // Tests for "*?"
@@ -213,6 +213,7 @@ public class FilenameUtilsWildcardTestCa
         assertMatch("aaa", "*a", true);
     }
 
+    @Test
     public void testLocaleIndependence() {
         final Locale orig = Locale.getDefault();
 

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java?rev=1718944&r1=1718943&r2=1718944&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java Wed Dec  9 19:50:30 2015
@@ -16,21 +16,19 @@
  */
 package org.apache.commons.io;
 
-import java.io.IOException;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import java.io.IOException;
 
-import org.apache.commons.io.output.ByteArrayOutputStream;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 
 /**
  * @version $Id$
  */
-public class HexDumpTest extends TestCase {
-
-    public HexDumpTest(final String name) {
-        super(name);
-    }
+public class HexDumpTest {
 
     private char toHex(final int n) {
         final char[] hexChars =
@@ -42,6 +40,7 @@ public class HexDumpTest extends TestCas
         return hexChars[n % 16];
     }
 
+    @Test
     public void testDump()
             throws IOException {
         final byte[] testArray = new byte[256];

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java?rev=1718944&r1=1718943&r2=1718944&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java Wed Dec  9 19:50:30 2015
@@ -23,6 +23,13 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
 import org.apache.commons.io.testtools.FileBasedTestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * This is used to test IOCase for correctness.
@@ -33,20 +40,8 @@ public class IOCaseTestCase extends File
 
     private static final boolean WINDOWS = File.separatorChar == '\\';
 
-    public IOCaseTestCase(final String name) {
-        super(name);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-    }
-
     //-----------------------------------------------------------------------
+    @Test
     public void test_forName() throws Exception {
         assertEquals(IOCase.SENSITIVE, IOCase.forName("Sensitive"));
         assertEquals(IOCase.INSENSITIVE, IOCase.forName("Insensitive"));
@@ -54,37 +49,42 @@ public class IOCaseTestCase extends File
         try {
             IOCase.forName("Blah");
             fail();
-        } catch (final IllegalArgumentException ex) {}
+        } catch (final IllegalArgumentException ignore) {}
         try {
             IOCase.forName(null);
             fail();
-        } catch (final IllegalArgumentException ex) {}
+        } catch (final IllegalArgumentException ignore) {}
     }
 
+    @Test
     public void test_serialization() throws Exception {
         assertSame(IOCase.SENSITIVE, serialize(IOCase.SENSITIVE));
         assertSame(IOCase.INSENSITIVE, serialize(IOCase.INSENSITIVE));
         assertSame(IOCase.SYSTEM, serialize(IOCase.SYSTEM));
     }
 
+    @Test
     public void test_getName() throws Exception {
         assertEquals("Sensitive", IOCase.SENSITIVE.getName());
         assertEquals("Insensitive", IOCase.INSENSITIVE.getName());
         assertEquals("System", IOCase.SYSTEM.getName());
     }
 
+    @Test
     public void test_toString() throws Exception {
         assertEquals("Sensitive", IOCase.SENSITIVE.toString());
         assertEquals("Insensitive", IOCase.INSENSITIVE.toString());
         assertEquals("System", IOCase.SYSTEM.toString());
     }
 
+    @Test
     public void test_isCaseSensitive() throws Exception {
         assertTrue(IOCase.SENSITIVE.isCaseSensitive());
         assertFalse(IOCase.INSENSITIVE.isCaseSensitive());
         assertEquals(!WINDOWS, IOCase.SYSTEM.isCaseSensitive());
     }
     //-----------------------------------------------------------------------
+    @Test
     public void test_checkCompare_functionality() throws Exception {
         assertTrue(IOCase.SENSITIVE.checkCompareTo("ABC", "") > 0);
         assertTrue(IOCase.SENSITIVE.checkCompareTo("", "ABC") < 0);
@@ -96,17 +96,18 @@ public class IOCaseTestCase extends File
         try {
             IOCase.SENSITIVE.checkCompareTo("ABC", null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkCompareTo(null, "ABC");
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkCompareTo(null, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
     }
 
+    @Test
     public void test_checkCompare_case() throws Exception {
         assertEquals(0, IOCase.SENSITIVE.checkCompareTo("ABC", "ABC"));
         assertTrue(IOCase.SENSITIVE.checkCompareTo("ABC", "abc") < 0);
@@ -123,6 +124,7 @@ public class IOCaseTestCase extends File
 
 
     //-----------------------------------------------------------------------
+    @Test
     public void test_checkEquals_functionality() throws Exception {
         assertFalse(IOCase.SENSITIVE.checkEquals("ABC", ""));
         assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "A"));
@@ -137,17 +139,18 @@ public class IOCaseTestCase extends File
         try {
             IOCase.SENSITIVE.checkEquals("ABC", null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkEquals(null, "ABC");
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkEquals(null, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
     }
 
+    @Test
     public void test_checkEquals_case() throws Exception {
         assertTrue(IOCase.SENSITIVE.checkEquals("ABC", "ABC"));
         assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "Abc"));
@@ -160,6 +163,7 @@ public class IOCaseTestCase extends File
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void test_checkStartsWith_functionality() throws Exception {
         assertTrue(IOCase.SENSITIVE.checkStartsWith("ABC", ""));
         assertTrue(IOCase.SENSITIVE.checkStartsWith("ABC", "A"));
@@ -174,17 +178,18 @@ public class IOCaseTestCase extends File
         try {
             IOCase.SENSITIVE.checkStartsWith("ABC", null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkStartsWith(null, "ABC");
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkStartsWith(null, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
     }
 
+    @Test
     public void test_checkStartsWith_case() throws Exception {
         assertTrue(IOCase.SENSITIVE.checkStartsWith("ABC", "AB"));
         assertFalse(IOCase.SENSITIVE.checkStartsWith("ABC", "Ab"));
@@ -197,6 +202,7 @@ public class IOCaseTestCase extends File
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void test_checkEndsWith_functionality() throws Exception {
         assertTrue(IOCase.SENSITIVE.checkEndsWith("ABC", ""));
         assertFalse(IOCase.SENSITIVE.checkEndsWith("ABC", "A"));
@@ -211,17 +217,18 @@ public class IOCaseTestCase extends File
         try {
             IOCase.SENSITIVE.checkEndsWith("ABC", null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkEndsWith(null, "ABC");
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkEndsWith(null, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
     }
 
+    @Test
     public void test_checkEndsWith_case() throws Exception {
         assertTrue(IOCase.SENSITIVE.checkEndsWith("ABC", "BC"));
         assertFalse(IOCase.SENSITIVE.checkEndsWith("ABC", "Bc"));
@@ -234,6 +241,7 @@ public class IOCaseTestCase extends File
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void test_checkIndexOf_functionality() throws Exception {
 
         // start
@@ -275,17 +283,18 @@ public class IOCaseTestCase extends File
         try {
             IOCase.SENSITIVE.checkIndexOf("ABC", 0, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkIndexOf(null, 0, "ABC");
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkIndexOf(null, 0, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
     }
 
+    @Test
     public void test_checkIndexOf_case() throws Exception {
         assertEquals(1,  IOCase.SENSITIVE.checkIndexOf("ABC", 0, "BC"));
         assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABC", 0, "Bc"));
@@ -298,6 +307,7 @@ public class IOCaseTestCase extends File
     }
 
     //-----------------------------------------------------------------------
+    @Test
     public void test_checkRegionMatches_functionality() throws Exception {
         assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, ""));
         assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "A"));
@@ -322,29 +332,30 @@ public class IOCaseTestCase extends File
         try {
             IOCase.SENSITIVE.checkRegionMatches("ABC", 0, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkRegionMatches(null, 0, "ABC");
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkRegionMatches(null, 0, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkRegionMatches("ABC", 1, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkRegionMatches(null, 1, "ABC");
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
         try {
             IOCase.SENSITIVE.checkRegionMatches(null, 1, null);
             fail();
-        } catch (final NullPointerException ex) {}
+        } catch (final NullPointerException ignore) {}
     }
 
+    @Test
     public void test_checkRegionMatches_case() throws Exception {
         assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "AB"));
         assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "Ab"));

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java?rev=1718944&r1=1718943&r2=1718944&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java Wed Dec  9 19:50:30 2015
@@ -20,17 +20,22 @@ package org.apache.commons.io;
 import java.io.IOException;
 
 import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
 
 /**
  * Tests IOExceptionWithCause
  * 
  * @version $Id$
  */
-public class IOExceptionWithCauseTestCase extends TestCase {
+public class IOExceptionWithCauseTestCase {
 
     /**
      * Tests the {@link IOExceptionWithCause#IOExceptionWithCause(String,Throwable)} constructor.
      */
+    @Test
     public void testIOExceptionStringThrowable() {
         final Throwable cause = new IllegalArgumentException("cause");
         final IOException exception = new IOException("message", cause);
@@ -40,6 +45,8 @@ public class IOExceptionWithCauseTestCas
     /**
      * Tests the {@link IOExceptionWithCause#IOExceptionWithCause(Throwable)} constructor.
      */
+
+    @Test
     public void testIOExceptionThrowable() {
         final Throwable cause = new IllegalArgumentException("cause");
         final IOException exception = new IOException(cause);

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java?rev=1718944&r1=1718943&r2=1718944&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java Wed Dec  9 19:50:30 2015
@@ -16,23 +16,22 @@
  */
 package org.apache.commons.io;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Arrays;
-
 import org.apache.commons.io.input.NullInputStream;
 import org.apache.commons.io.input.NullReader;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.io.output.NullOutputStream;
 import org.apache.commons.io.output.NullWriter;
 import org.apache.commons.io.testtools.FileBasedTestCase;
+import org.apache.commons.io.testtools.TestUtils;
 import org.apache.commons.io.testtools.YellOnCloseInputStream;
 import org.apache.commons.io.testtools.YellOnFlushAndCloseOutputStream;
+import org.junit.Test;
+
+import java.io.*;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * JUnit tests for IOUtils copy methods.
@@ -52,26 +51,11 @@ public class IOUtilsCopyTestCase extends
     private static final int FILE_SIZE = 1024 * 4 + 1;
 
 
-    private final byte[] inData = generateTestData(FILE_SIZE);
-
-    public IOUtilsCopyTestCase(final String testName) {
-        super(testName);
-    }
-
-    // ----------------------------------------------------------------
-    // Setup
-    // ----------------------------------------------------------------
-
-    @Override
-    public void setUp() throws Exception {
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-    }
+    private final byte[] inData = TestUtils.generateTestData((long) FILE_SIZE);
 
     //-----------------------------------------------------------------------
     @SuppressWarnings("resource") // 'in' is deliberately not closed
+    @Test
     public void testCopy_inputStreamToOutputStream() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -87,6 +71,7 @@ public class IOUtilsCopyTestCase extends
         assertEquals(inData.length,count);
     }
 
+    @Test
     public void testCopy_inputStreamToOutputStreamWithBufferSize() throws Exception {
         testCopy_inputStreamToOutputStreamWithBufferSize(1);
         testCopy_inputStreamToOutputStreamWithBufferSize(2);
@@ -121,25 +106,22 @@ public class IOUtilsCopyTestCase extends
         assertEquals(inData.length,count);
     }
 
+    @Test(expected = NullPointerException.class)
     public void testCopy_inputStreamToOutputStream_nullIn() throws Exception {
         final OutputStream out = new ByteArrayOutputStream();
-        try {
-            IOUtils.copy((InputStream) null, out);
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy((InputStream) null, out);
     }
 
+    @Test(expected = NullPointerException.class)
     public void testCopy_inputStreamToOutputStream_nullOut() throws Exception {
         final InputStream in = new ByteArrayInputStream(inData);
-        try {
-            IOUtils.copy(in, (OutputStream) null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy(in, (OutputStream) null);
     }
 
     /*
      * Test Copying file > 2GB  - see issue# IO-84
      */
+    @Test
     public void testCopy_inputStreamToOutputStream_IO84() throws Exception {
         final long size = (long)Integer.MAX_VALUE + (long)1;
         final InputStream  in  = new NullInputStream(size);
@@ -157,6 +139,7 @@ public class IOUtilsCopyTestCase extends
 
     //-----------------------------------------------------------------------
     @SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed
+    @Test
     public void testCopy_inputStreamToWriter() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -175,27 +158,24 @@ public class IOUtilsCopyTestCase extends
     }
 
     @SuppressWarnings("deprecation") // deliberately testing deprecated method
+    @Test(expected = NullPointerException.class)
     public void testCopy_inputStreamToWriter_nullIn() throws Exception {
         final ByteArrayOutputStream baout = new ByteArrayOutputStream();
         final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
         final Writer writer = new OutputStreamWriter(out, "US-ASCII");
-        try {
-            IOUtils.copy((InputStream) null, writer);
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy((InputStream) null, writer);
     }
 
     @SuppressWarnings("deprecation") // deliberately testing deprecated method
+    @Test(expected = NullPointerException.class)
     public void testCopy_inputStreamToWriter_nullOut() throws Exception {
         final InputStream in = new ByteArrayInputStream(inData);
-        try {
-            IOUtils.copy(in, (Writer) null); // deliberately testing deprecated method
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy(in, (Writer) null); // deliberately testing deprecated method
     }
 
     //-----------------------------------------------------------------------
     @SuppressWarnings("resource") // 'in' is deliberately not closed
+    @Test
     public void testCopy_inputStreamToWriter_Encoding() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -214,25 +194,22 @@ public class IOUtilsCopyTestCase extends
         assertTrue("Content differs", Arrays.equals(inData, bytes));
     }
 
+    @Test(expected = NullPointerException.class)
     public void testCopy_inputStreamToWriter_Encoding_nullIn() throws Exception {
         final ByteArrayOutputStream baout = new ByteArrayOutputStream();
         final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
         final Writer writer = new OutputStreamWriter(out, "US-ASCII");
-        try {
-            IOUtils.copy(null, writer, "UTF8");
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy(null, writer, "UTF8");
     }
 
+    @Test(expected = NullPointerException.class)
     public void testCopy_inputStreamToWriter_Encoding_nullOut() throws Exception {
         final InputStream in = new ByteArrayInputStream(inData);
-        try {
-            IOUtils.copy(in, null, "UTF8");
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy(in, null, "UTF8");
     }
 
     @SuppressWarnings("resource") // 'in' is deliberately not closed
+    @Test
     public void testCopy_inputStreamToWriter_Encoding_nullEncoding() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -252,6 +229,7 @@ public class IOUtilsCopyTestCase extends
 
     //-----------------------------------------------------------------------
     @SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed
+    @Test
     public void testCopy_readerToOutputStream() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -273,28 +251,25 @@ public class IOUtilsCopyTestCase extends
     }
 
     @SuppressWarnings("deprecation")
+    @Test(expected = NullPointerException.class)
     public void testCopy_readerToOutputStream_nullIn() throws Exception { // deliberately testing deprecated method
         final ByteArrayOutputStream baout = new ByteArrayOutputStream();
         final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
-        try {
-            IOUtils.copy((Reader) null, out);
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy((Reader) null, out);
     }
 
     @SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed
+    @Test(expected = NullPointerException.class)
     public void testCopy_readerToOutputStream_nullOut() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
         final Reader reader = new InputStreamReader(in, "US-ASCII");
-        try {
-            IOUtils.copy(reader, (OutputStream) null); // deliberately testing deprecated method
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy(reader, (OutputStream) null); // deliberately testing deprecated method
     }
 
     //-----------------------------------------------------------------------
     @SuppressWarnings("resource") // 'in' is deliberately not closed
+    @Test
     public void testCopy_readerToOutputStream_Encoding() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -312,27 +287,24 @@ public class IOUtilsCopyTestCase extends
         assertTrue("Content differs", Arrays.equals(inData, bytes));
     }
 
+    @Test(expected = NullPointerException.class)
     public void testCopy_readerToOutputStream_Encoding_nullIn() throws Exception {
         final ByteArrayOutputStream baout = new ByteArrayOutputStream();
         final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
-        try {
-            IOUtils.copy(null, out, "UTF16");
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy(null, out, "UTF16");
     }
 
     @SuppressWarnings("resource") // 'in' is deliberately not closed
+    @Test(expected = NullPointerException.class)
     public void testCopy_readerToOutputStream_Encoding_nullOut() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
         final Reader reader = new InputStreamReader(in, "US-ASCII");
-        try {
-            IOUtils.copy(reader, null, "UTF16");
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy(reader, null, "UTF16");
     }
 
     @SuppressWarnings("resource") // 'in' is deliberately not closed
+    @Test
     public void testCopy_readerToOutputStream_Encoding_nullEncoding() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -351,6 +323,7 @@ public class IOUtilsCopyTestCase extends
 
     //-----------------------------------------------------------------------
     @SuppressWarnings("resource") // 'in' is deliberately not closed
+    @Test
     public void testCopy_readerToWriter() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
@@ -368,30 +341,27 @@ public class IOUtilsCopyTestCase extends
         assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
     }
 
+    @Test(expected = NullPointerException.class)
     public void testCopy_readerToWriter_nullIn() throws Exception {
         final ByteArrayOutputStream baout = new ByteArrayOutputStream();
         final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
         final Writer writer = new OutputStreamWriter(out, "US-ASCII");
-        try {
-            IOUtils.copy((Reader) null, writer);
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy((Reader) null, writer);
     }
 
     @SuppressWarnings("resource") // 'in' is deliberately not closed
+    @Test(expected = NullPointerException.class)
     public void testCopy_readerToWriter_nullOut() throws Exception {
         InputStream in = new ByteArrayInputStream(inData);
         in = new YellOnCloseInputStream(in);
         final Reader reader = new InputStreamReader(in, "US-ASCII");
-        try {
-            IOUtils.copy(reader, (Writer) null);
-            fail();
-        } catch (final NullPointerException ex) {}
+        IOUtils.copy(reader, (Writer) null);
     }
 
     /*
      * Test Copying file > 2GB  - see issue# IO-84
      */
+    @Test
     public void testCopy_readerToWriter_IO84() throws Exception {
         final long size = (long)Integer.MAX_VALUE + (long)1;
         final Reader reader = new NullReader(size);