FileManagement package

Lots of work this past week on the FileManagement package.  Not yet finished, but getting close.  Note that JavaDoc comments are in need of tweaking and should not be trusted.
An exception generated in a test is an automatic fail… good point.  If I know to catch it, and it wasn’t expected, I think I like the idea of Assert.fail’ing it with a description of what was caught and where though.  Helps with identifying exactly where in the test the problem occurred.

 

From: Spencer Marks [mailto:notifications@github.com] 
Sent: Monday, June 23, 2014 9:55 AM
To: JeffBlodgett/FileSieve
Cc: Jeff Blodgett
Subject: Re: [FileSieve] FileManagement package (#5)

 

In src/test/java/FileSieve/BusinessLogic/FileManagement/ConcurrentFileManagerTest.java:

> +            // Ignore exceptions
> +        }
> +    }
> +
> +    @Test
> +    public void testDeletePathname() {
> +        Path folderFile1 = new File(folder + "/testFile1.txt").toPath();
> +        Path folderFile2 = new File(folder + "/testFile2.txt").toPath();
> +        Path subFolderFile1 = new File(subFolder + "/testDeletePathname1.txt").toPath();
> +        Path subFolderFile2 = new File(subFolder + "/testDeletePathname2.txt").toPath();
> +
> +        try {
> +            Assert.assertFalse("Attempted deletion of non-existent file should return false", fileManager.deletePathname(file));
> +        } catch (SecurityException | IOException e) {
> +            Assert.fail(e.getClass().getSimpleName() + " while attempting to delete non-existent file \"" + file.toFile().getName() + "\" in temp folder");
> +        }

That's good but it should happen in the setup method. Also, if an exception is generated while a test is exception it automatically fails. Spencer

…

On 23 Jun 2014, at 9:47, Jeff Blodgett wrote: > + // Ignore exceptions > + } > + } > + > + @Test <https://github.com/Test>  > + public void testDeletePathname() { > + Path folderFile1 = new File(folder + > "/testFile1.txt").toPath(); > + Path folderFile2 = new File(folder + > "/testFile2.txt").toPath(); > + Path subFolderFile1 = new File(subFolder + > "/testDeletePathname1.txt").toPath(); > + Path subFolderFile2 = new File(subFolder + > "/testDeletePathname2.txt").toPath(); > + > + try { > + Assert.assertFalse("Attempted deletion of non-existent > file should return false", fileManager.deletePathname(file)); > + } catch (SecurityException | IOException e) { > + Assert.fail(e.getClass().getSimpleName() + " while > attempting to delete non-existent file \"" + file.toFile().getName() > + "\" in temp folder"); > + } In these tests that have been written thus far, it’s not that I wanted to assert that an exception was thrown but rather I wanted the test to fail if the temp files or folders I’m creating for the purpose of the tests cannot be created. - Jeff From: Spencer Marks [mailto:notifications@github.com] Sent: Monday, June 23, 2014 7:41 AM To: JeffBlodgett/FileSieve Cc: Jeff Blodgett Subject: Re: [FileSieve] FileManagement package (#5 <https://github.com/JeffBlodgett/FileSieve/pull/5> ) In src/test/java/FileSieve/BusinessLogic/FileManagement/ConcurrentFileManagerTest.java: > + // Ignore exceptions > + } > + } > + > + @Test <https://github.com/Test>  > + public void testDeletePathname() { > + Path folderFile1 = new File(folder + > "/testFile1.txt").toPath(); > + Path folderFile2 = new File(folder + > "/testFile2.txt").toPath(); > + Path subFolderFile1 = new File(subFolder + > "/testDeletePathname1.txt").toPath(); > + Path subFolderFile2 = new File(subFolder + > "/testDeletePathname2.txt").toPath(); > + > + try { > + Assert.assertFalse("Attempted deletion of non-existent > file should return false", fileManager.deletePathname(file)); > + } catch (SecurityException | IOException e) { > + Assert.fail(e.getClass().getSimpleName() + " while > attempting to delete non-existent file \"" + file.toFile().getName() > + "\" in temp folder"); > + } if you want to assert a specific exception was thrown use the annotation like this: @Test <https://github.com/Test>  <https://github.com/Test> (expected=IndexOutOfBoundsException.class) public void testIndexOutOfBoundsException() { ArrayList emptyList = new ArrayList(); Object o = emptyList.get(0); } — Reply to this email directly or view it on GitHub <https://github.com/JeffBlodgett/FileSieve/pull/5/files#r14070883> . <https://github.com/notifications/beacon/7633920__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcxOTE0Mjg3OCwiZGF0YSI6eyJpZCI6MzQ2NTg1MTl9fQ==--65d7ad8e4514684740cc01c4c84ba383e1b184f8.gif> --- Reply to this email directly or view it on GitHub: https://github.com/JeffBlodgett/FileSieve/pull/5/files#r14075542 

—
Reply to this email directly or view it on GitHub <https://github.com/JeffBlodgett/FileSieve/pull/5/files#r14075932> .  <https://github.com/notifications/beacon/7633920__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcxOTE1MDkwNCwiZGF0YSI6eyJpZCI6MzQ2NTg1MTl9fQ==--55847abfb4ce5d77851b90ef984415c08c33b63d..gif>