Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff ============================================================================== --- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java (original) +++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java Fri Nov 30 20:51:39 2012 @@ -36,7 +36,7 @@ import org.apache.commons.io.testtools.F */ public class FileSystemUtilsTestCase extends FileBasedTestCase { - public FileSystemUtilsTestCase(String name) { + public FileSystemUtilsTestCase(final String name) { super(name); } @@ -65,12 +65,12 @@ public class FileSystemUtilsTestCase ext } else { cmd = new String[] {"df", "/"}; } - Process proc = Runtime.getRuntime().exec(cmd); + final Process proc = Runtime.getRuntime().exec(cmd); boolean kilobyteBlock = true; BufferedReader r = null; try { r = new BufferedReader(new InputStreamReader(proc.getInputStream())); - String line = r.readLine(); + final String line = r.readLine(); Assert.assertNotNull("Unexpected null line", line); if (line.indexOf("512") >= 0) { kilobyteBlock = false; @@ -81,8 +81,9 @@ public class FileSystemUtilsTestCase ext // now perform the test @SuppressWarnings("deprecation") + final long free = FileSystemUtils.freeSpace("/"); - long kb = FileSystemUtils.freeSpaceKb("/"); + final long kb = FileSystemUtils.freeSpaceKb("/"); if (kilobyteBlock) { assertEquals(free, kb, 256d); } else { @@ -90,53 +91,54 @@ public class FileSystemUtilsTestCase ext } } else { @SuppressWarnings("deprecation") + final long bytes = FileSystemUtils.freeSpace(""); - long kb = FileSystemUtils.freeSpaceKb(""); + final long kb = FileSystemUtils.freeSpaceKb(""); assertEquals((double) bytes / 1024, kb, 256d); } } //----------------------------------------------------------------------- public void testGetFreeSpaceOS_String_NullPath() throws Exception { - FileSystemUtils fsu = new FileSystemUtils(); + final FileSystemUtils fsu = new FileSystemUtils(); try { fsu.freeSpaceOS(null, 1, false, -1); fail(); - } catch (IllegalArgumentException ex) {} + } catch (final IllegalArgumentException ex) {} try { fsu.freeSpaceOS(null, 1, true, -1); fail(); - } catch (IllegalArgumentException ex) {} + } catch (final IllegalArgumentException ex) {} } public void testGetFreeSpaceOS_String_InitError() throws Exception { - FileSystemUtils fsu = new FileSystemUtils(); + final FileSystemUtils fsu = new FileSystemUtils(); try { fsu.freeSpaceOS("", -1, false, -1); fail(); - } catch (IllegalStateException ex) {} + } catch (final IllegalStateException ex) {} try { fsu.freeSpaceOS("", -1, true, -1); fail(); - } catch (IllegalStateException ex) {} + } catch (final IllegalStateException ex) {} } public void testGetFreeSpaceOS_String_Other() throws Exception { - FileSystemUtils fsu = new FileSystemUtils(); + final FileSystemUtils fsu = new FileSystemUtils(); try { fsu.freeSpaceOS("", 0, false, -1); fail(); - } catch (IllegalStateException ex) {} + } catch (final IllegalStateException ex) {} try { fsu.freeSpaceOS("", 0, true, -1); fail(); - } catch (IllegalStateException ex) {} + } catch (final IllegalStateException ex) {} } public void testGetFreeSpaceOS_String_Windows() throws Exception { - FileSystemUtils fsu = new FileSystemUtils() { + final FileSystemUtils fsu = new FileSystemUtils() { @Override - protected long freeSpaceWindows(String path, long timeout) throws IOException { + protected long freeSpaceWindows(final String path, final long timeout) throws IOException { return 12345L; } }; @@ -145,9 +147,9 @@ public class FileSystemUtilsTestCase ext } public void testGetFreeSpaceOS_String_Unix() throws Exception { - FileSystemUtils fsu = new FileSystemUtils() { + final FileSystemUtils fsu = new FileSystemUtils() { @Override - protected long freeSpaceUnix(String path, boolean kb, boolean posix, long timeout) throws IOException { + protected long freeSpaceUnix(final String path, final boolean kb, final boolean posix, final long timeout) throws IOException { return kb ? 12345L : 54321; } }; @@ -159,7 +161,7 @@ public class FileSystemUtilsTestCase ext public void testGetFreeSpaceWindows_String_ParseCommaFormatBytes() throws Exception { // this is the format of response when calling dir /c // we have now switched to dir /-c, so we should never get this - String lines = + final String lines = " Volume in drive C is HDD\n" + " Volume Serial Number is XXXX-YYYY\n" + "\n" + @@ -171,13 +173,13 @@ public class FileSystemUtilsTestCase ext "17/08/2005 21:44 <DIR> Desktop\n" + " 7 File(s) 180,260 bytes\n" + " 10 Dir(s) 41,411,551,232 bytes free"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); assertEquals(41411551232L, fsu.freeSpaceWindows("", -1)); } //----------------------------------------------------------------------- public void testGetFreeSpaceWindows_String_EmptyPath() throws Exception { - String lines = + final String lines = " Volume in drive C is HDD\n" + " Volume Serial Number is XXXX-YYYY\n" + "\n" + @@ -189,12 +191,12 @@ public class FileSystemUtilsTestCase ext "17/08/2005 21:44 <DIR> Desktop\n" + " 7 File(s) 180260 bytes\n" + " 10 Dir(s) 41411551232 bytes free"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c "); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c "); assertEquals(41411551232L, fsu.freeSpaceWindows("", -1)); } public void testGetFreeSpaceWindows_String_NormalResponse() throws Exception { - String lines = + final String lines = " Volume in drive C is HDD\n" + " Volume Serial Number is XXXX-YYYY\n" + "\n" + @@ -206,12 +208,12 @@ public class FileSystemUtilsTestCase ext "17/08/2005 21:44 <DIR> Desktop\n" + " 7 File(s) 180260 bytes\n" + " 10 Dir(s) 41411551232 bytes free"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\""); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\""); assertEquals(41411551232L, fsu.freeSpaceWindows("C:", -1)); } public void testGetFreeSpaceWindows_String_StripDrive() throws Exception { - String lines = + final String lines = " Volume in drive C is HDD\n" + " Volume Serial Number is XXXX-YYYY\n" + "\n" + @@ -223,12 +225,12 @@ public class FileSystemUtilsTestCase ext "17/08/2005 21:44 <DIR> Desktop\n" + " 7 File(s) 180260 bytes\n" + " 10 Dir(s) 41411551232 bytes free"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\\somedir\""); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\\somedir\""); assertEquals(41411551232L, fsu.freeSpaceWindows("C:\\somedir", -1)); } public void testGetFreeSpaceWindows_String_quoted() throws Exception { - String lines = + final String lines = " Volume in drive C is HDD\n" + " Volume Serial Number is XXXX-YYYY\n" + "\n" + @@ -240,91 +242,91 @@ public class FileSystemUtilsTestCase ext "17/08/2005 21:44 <DIR> Desktop\n" + " 7 File(s) 180260 bytes\n" + " 10 Dir(s) 41411551232 bytes free"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\\somedir\""); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\\somedir\""); assertEquals(41411551232L, fsu.freeSpaceWindows("\"C:\\somedir\"", -1)); } public void testGetFreeSpaceWindows_String_EmptyResponse() throws Exception { - String lines = ""; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final String lines = ""; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceWindows("C:", -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } public void testGetFreeSpaceWindows_String_EmptyMultiLineResponse() throws Exception { - String lines = "\n\n"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final String lines = "\n\n"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceWindows("C:", -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } public void testGetFreeSpaceWindows_String_InvalidTextResponse() throws Exception { - String lines = "BlueScreenOfDeath"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final String lines = "BlueScreenOfDeath"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceWindows("C:", -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } public void testGetFreeSpaceWindows_String_NoSuchDirectoryResponse() throws Exception { - String lines = + final String lines = " Volume in drive C is HDD\n" + " Volume Serial Number is XXXX-YYYY\n" + "\n" + " Directory of C:\\Documents and Settings\\empty" + "\n"; - FileSystemUtils fsu = new MockFileSystemUtils(1, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(1, lines); try { fsu.freeSpaceWindows("C:", -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } //----------------------------------------------------------------------- public void testGetFreeSpaceUnix_String_EmptyPath() throws Exception { - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + "xxx:/home/users/s 14428928 12956424 1472504 90% /home/users/s"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceUnix("", false, false, -1); fail(); - } catch (IllegalArgumentException ex) {} + } catch (final IllegalArgumentException ex) {} try { fsu.freeSpaceUnix("", true, false, -1); fail(); - } catch (IllegalArgumentException ex) {} + } catch (final IllegalArgumentException ex) {} try { fsu.freeSpaceUnix("", true, true, -1); fail(); - } catch (IllegalArgumentException ex) {} + } catch (final IllegalArgumentException ex) {} try { fsu.freeSpaceUnix("", false, true, -1); fail(); - } catch (IllegalArgumentException ex) {} + } catch (final IllegalArgumentException ex) {} } public void testGetFreeSpaceUnix_String_NormalResponseLinux() throws Exception { // from Sourceforge 'GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)' - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + "/dev/xxx 497944 308528 189416 62% /"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); assertEquals(189416L, fsu.freeSpaceUnix("/", false, false, -1)); } public void testGetFreeSpaceUnix_String_NormalResponseFreeBSD() throws Exception { // from Apache 'FreeBSD 6.1-RELEASE (SMP-turbo)' - String lines = + final String lines = "Filesystem 1K-blocks Used Avail Capacity Mounted on\n" + "/dev/xxxxxx 128990 102902 15770 87% /"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); assertEquals(15770L, fsu.freeSpaceUnix("/", false, false, -1)); } @@ -332,162 +334,162 @@ public class FileSystemUtilsTestCase ext public void testGetFreeSpaceUnix_String_NormalResponseKbLinux() throws Exception { // from Sourceforge 'GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)' // df, df -k and df -kP are all identical - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + "/dev/xxx 497944 308528 189416 62% /"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); assertEquals(189416L, fsu.freeSpaceUnix("/", true, false, -1)); } public void testGetFreeSpaceUnix_String_NormalResponseKbFreeBSD() throws Exception { // from Apache 'FreeBSD 6.1-RELEASE (SMP-turbo)' // df and df -k are identical, but df -kP uses 512 blocks (not relevant as not used) - String lines = + final String lines = "Filesystem 1K-blocks Used Avail Capacity Mounted on\n" + "/dev/xxxxxx 128990 102902 15770 87% /"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); assertEquals(15770L, fsu.freeSpaceUnix("/", true, false, -1)); } public void testGetFreeSpaceUnix_String_NormalResponseKbSolaris() throws Exception { // from IO-91 - ' SunOS et 5.10 Generic_118822-25 sun4u sparc SUNW,Ultra-4' // non-kb response does not contain free space - see IO-91 - String lines = + final String lines = "Filesystem kbytes used avail capacity Mounted on\n" + "/dev/dsk/x0x0x0x0 1350955 815754 481163 63%"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); assertEquals(481163L, fsu.freeSpaceUnix("/dev/dsk/x0x0x0x0", true, false, -1)); } public void testGetFreeSpaceUnix_String_LongResponse() throws Exception { - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + "xxx-yyyyyyy-zzz:/home/users/s\n" + " 14428928 12956424 1472504 90% /home/users/s"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); assertEquals(1472504L, fsu.freeSpaceUnix("/home/users/s", false, false, -1)); } public void testGetFreeSpaceUnix_String_LongResponseKb() throws Exception { - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + "xxx-yyyyyyy-zzz:/home/users/s\n" + " 14428928 12956424 1472504 90% /home/users/s"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); assertEquals(1472504L, fsu.freeSpaceUnix("/home/users/s", true, false, -1)); } public void testGetFreeSpaceUnix_String_EmptyResponse() throws Exception { - String lines = ""; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final String lines = ""; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceUnix("/home/users/s", false, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", false, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } public void testGetFreeSpaceUnix_String_InvalidResponse1() throws Exception { - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + " 14428928 12956424 100"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceUnix("/home/users/s", false, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", false, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } public void testGetFreeSpaceUnix_String_InvalidResponse2() throws Exception { - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + "xxx:/home/users/s 14428928 12956424 nnnnnnn 90% /home/users/s"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceUnix("/home/users/s", false, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", false, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } public void testGetFreeSpaceUnix_String_InvalidResponse3() throws Exception { - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + "xxx:/home/users/s 14428928 12956424 -1 90% /home/users/s"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceUnix("/home/users/s", false, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", false, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } public void testGetFreeSpaceUnix_String_InvalidResponse4() throws Exception { - String lines = + final String lines = "Filesystem 1K-blocks Used Available Use% Mounted on\n" + "xxx-yyyyyyy-zzz:/home/users/s"; - FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); try { fsu.freeSpaceUnix("/home/users/s", false, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, false, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", false, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} try { fsu.freeSpaceUnix("/home/users/s", true, true, -1); fail(); - } catch (IOException ex) {} + } catch (final IOException ex) {} } //----------------------------------------------------------------------- @@ -495,16 +497,16 @@ public class FileSystemUtilsTestCase ext private final int exitCode; private final byte[] bytes; private final String cmd; - public MockFileSystemUtils(int exitCode, String lines) { + public MockFileSystemUtils(final int exitCode, final String lines) { this(exitCode, lines, null); } - public MockFileSystemUtils(int exitCode, String lines, String cmd) { + public MockFileSystemUtils(final int exitCode, final String lines, final String cmd) { this.exitCode = exitCode; this.bytes = lines.getBytes(); this.cmd = cmd; } @Override - Process openProcess(String[] params) { + Process openProcess(final String[] params) { if (cmd != null) { assertEquals(cmd, params[params.length - 1]); }
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff ============================================================================== --- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java (original) +++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java Fri Nov 30 20:51:39 2012 @@ -31,7 +31,7 @@ import org.apache.commons.io.testtools.F public class FileUtilsCleanDirectoryTestCase extends FileBasedTestCase { final File top = getLocalTestDirectory(); - public FileUtilsCleanDirectoryTestCase(String name) { + public FileUtilsCleanDirectoryTestCase(final String name) { super(name); } @@ -100,7 +100,7 @@ public class FileUtilsCleanDirectoryTest try { FileUtils.cleanDirectory(top); fail("expected IOException"); - } catch (IOException e) { + } catch (final IOException e) { assertEquals("Failed to list contents of " + top.getAbsolutePath(), e.getMessage()); } @@ -119,16 +119,16 @@ public class FileUtilsCleanDirectoryTest try { FileUtils.cleanDirectory(top); fail("expected IOException"); - } catch (IOException e) { + } catch (final IOException e) { assertEquals("Unable to delete file: " + file.getAbsolutePath(), e.getMessage()); } } - private boolean chmod(File file, int mode, boolean recurse) + private boolean chmod(final File file, final int mode, final boolean recurse) throws InterruptedException { // TODO: Refactor this to FileSystemUtils - List<String> args = new ArrayList<String>(); + final List<String> args = new ArrayList<String>(); args.add("chmod"); if (recurse) { @@ -143,10 +143,10 @@ public class FileUtilsCleanDirectoryTest try { proc = Runtime.getRuntime().exec( args.toArray(new String[args.size()])); - } catch (IOException e) { + } catch (final IOException e) { return false; } - int result = proc.waitFor(); + final int result = proc.waitFor(); return result == 0; } Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff ============================================================================== --- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java (original) +++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java Fri Nov 30 20:51:39 2012 @@ -30,7 +30,7 @@ public class FileUtilsCleanSymlinksTestC final File top = getTestDirectory(); - public FileUtilsCleanSymlinksTestCase(String name) { + public FileUtilsCleanSymlinksTestCase(final String name) { super(name); } @@ -225,9 +225,9 @@ public class FileUtilsCleanSymlinksTestC assertFalse(FileUtils.isSymlink(realChild)); } - private void setupSymlink(File res, File link) throws Exception { + private void setupSymlink(final File res, final File link) throws Exception { // create symlink - List<String> args = new ArrayList<String>(); + final List<String> args = new ArrayList<String>(); args.add("ln"); args.add("-s"); Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff ============================================================================== --- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java (original) +++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java Fri Nov 30 20:51:39 2012 @@ -41,7 +41,7 @@ public class FileUtilsDirectoryContainsT private File file3; final File top = getTestDirectory(); - public FileUtilsDirectoryContainsTestCase(String name) { + public FileUtilsDirectoryContainsTestCase(final String name) { super(name); } @@ -122,7 +122,7 @@ public class FileUtilsDirectoryContainsT try { assertFalse(FileUtils.directoryContains(dir, file1)); fail("Expected " + IllegalArgumentException.class.getName()); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // expected } } @@ -132,7 +132,7 @@ public class FileUtilsDirectoryContainsT try { assertTrue(FileUtils.directoryContains(file1, file1)); fail("Expected " + IllegalArgumentException.class.getName()); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // expected } } @@ -165,7 +165,7 @@ public class FileUtilsDirectoryContainsT assertFalse(file.exists()); try { assertTrue(FileUtils.directoryContains(dir, file)); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // expected } } Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff ============================================================================== --- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java (original) +++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java Fri Nov 30 20:51:39 2012 @@ -30,10 +30,10 @@ public class FileUtilsFileNewerTestCase private static final int FILE1_SIZE = 1; private static final int FILE2_SIZE = 1024 * 4 + 1; - private File m_testFile1; - private File m_testFile2; + private final File m_testFile1; + private final File m_testFile2; - public FileUtilsFileNewerTestCase(String name) { + public FileUtilsFileNewerTestCase(final String name) { super(name); m_testFile1 = new File(getTestDirectory(), "file1-test.txt"); @@ -67,7 +67,7 @@ public class FileUtilsFileNewerTestCase throw new IllegalStateException("The m_testFile1 should exist"); } - long fileLastModified = m_testFile1.lastModified(); + final long fileLastModified = m_testFile1.lastModified(); final long TWO_SECOND = 2000; testIsFileNewer("two second earlier is not newer" , m_testFile1, fileLastModified + TWO_SECOND, false); @@ -83,7 +83,7 @@ public class FileUtilsFileNewerTestCase * @see FileUtils#isFileNewer(File, File) */ public void testIsFileNewerImaginaryFile() { - File imaginaryFile = new File(getTestDirectory(), "imaginaryFile"); + final File imaginaryFile = new File(getTestDirectory(), "imaginaryFile"); if (imaginaryFile.exists()) { throw new IllegalStateException("The imaginary File exists"); } @@ -113,11 +113,11 @@ public class FileUtilsFileNewerTestCase * @see FileUtils#isFileNewer(File, Date) * @see FileUtils#isFileNewer(File, File) */ - protected void testIsFileNewer(String description, File file, long time, boolean wantedResult) { + protected void testIsFileNewer(final String description, final File file, final long time, final boolean wantedResult) { assertEquals(description + " - time", wantedResult, FileUtils.isFileNewer(file, time)); assertEquals(description + " - date", wantedResult, FileUtils.isFileNewer(file, new Date(time))); - File temporaryFile = m_testFile2; + final File temporaryFile = m_testFile2; temporaryFile.setLastModified(time); assertEquals("The temporary file hasn't the right last modification date", time, temporaryFile.lastModified()); @@ -133,7 +133,7 @@ public class FileUtilsFileNewerTestCase try { FileUtils.isFileNewer(null,0); fail("File not specified"); - } catch (IllegalArgumentException e) {} + } catch (final IllegalArgumentException e) {} } /** @@ -145,7 +145,7 @@ public class FileUtilsFileNewerTestCase try { FileUtils.isFileNewer(m_testFile1, (Date) null); fail("Date not specified"); - } catch (IllegalArgumentException e) {} + } catch (final IllegalArgumentException e) {} } /** @@ -157,6 +157,6 @@ public class FileUtilsFileNewerTestCase try { FileUtils.isFileNewer(m_testFile1, (File) null); fail("Reference file not specified"); - } catch (IllegalArgumentException e) {} + } catch (final IllegalArgumentException e) {} } } Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsListFilesTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsListFilesTestCase.java?rev=1415850&r1=1415849&r2=1415850&view=diff ============================================================================== --- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsListFilesTestCase.java (original) +++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsListFilesTestCase.java Fri Nov 30 20:51:39 2012 @@ -30,7 +30,7 @@ import org.apache.commons.io.testtools.F */ public class FileUtilsListFilesTestCase extends FileBasedTestCase { - public FileUtilsListFilesTestCase(String name) { + public FileUtilsListFilesTestCase(final String name) { super(name); } @@ -81,20 +81,20 @@ public class FileUtilsListFilesTestCase */ @Override protected void tearDown() throws Exception { - File dir = getLocalTestDirectory(); + final File dir = getLocalTestDirectory(); FileUtils.deleteDirectory(dir); } - private Collection<String> filesToFilenames(Collection<File> files) { - Collection<String> filenames = new ArrayList<String>(files.size()); - for (File file : files) { + private Collection<String> filesToFilenames(final Collection<File> files) { + final Collection<String> filenames = new ArrayList<String>(files.size()); + for (final File file : files) { filenames.add(file.getName()); } return filenames; } - private Collection<String> filesToFilenames(Iterator<File> files) { - Collection<String> filenames = new ArrayList<String>(); + private Collection<String> filesToFilenames(final Iterator<File> files) { + final Collection<String> filenames = new ArrayList<String>(); while (files.hasNext()) { filenames.add(files.next().getName()); } @@ -102,7 +102,7 @@ public class FileUtilsListFilesTestCase } public void testIterateFilesByExtension() throws Exception { - String[] extensions = { "xml", "txt" }; + final String[] extensions = { "xml", "txt" }; Iterator<File> files = FileUtils.iterateFiles(getLocalTestDirectory(), extensions, false); Collection<String> filenames = filesToFilenames(files); @@ -126,7 +126,7 @@ public class FileUtilsListFilesTestCase } public void testListFilesByExtension() throws Exception { - String[] extensions = {"xml", "txt"}; + final String[] extensions = {"xml", "txt"}; Collection<File> files = FileUtils.listFiles(getLocalTestDirectory(), extensions, false); assertEquals(1, files.size()); @@ -194,7 +194,7 @@ public class FileUtilsListFilesTestCase try { FileUtils.listFiles(getLocalTestDirectory(), (IOFileFilter)null, (IOFileFilter)null); fail("Expected error about null parameter"); - } catch (NullPointerException e) { + } catch (final NullPointerException e) { // expected } }
