@@ -90,65 +90,61 @@ public void testToString() {
9090
9191 /**
9292 * Test checkAndNotify() method
93+ * @throws Exception
9394 */
9495 @ Test
95- public void testDirectory () {
96- try {
97- checkAndNotify ();
98- checkCollectionsEmpty ("A" );
99- final File testDirA = new File (testDir , "test-dir-A" );
100- final File testDirB = new File (testDir , "test-dir-B" );
101- final File testDirC = new File (testDir , "test-dir-C" );
102- testDirA .mkdir ();
103- testDirB .mkdir ();
104- testDirC .mkdir ();
105- final File testDirAFile1 = touch (new File (testDirA , "A-file1.java" ));
106- final File testDirAFile2 = touch (new File (testDirA , "A-file2.txt" )); // filter should ignore this
107- final File testDirAFile3 = touch (new File (testDirA , "A-file3.java" ));
108- File testDirAFile4 = touch (new File (testDirA , "A-file4.java" ));
109- final File testDirBFile1 = touch (new File (testDirB , "B-file1.java" ));
110-
111- checkAndNotify ();
112- checkCollectionSizes ("B" , 3 , 0 , 0 , 4 , 0 , 0 );
113- assertTrue ("B testDirA" , listener .getCreatedDirectories ().contains (testDirA ));
114- assertTrue ("B testDirB" , listener .getCreatedDirectories ().contains (testDirB ));
115- assertTrue ("B testDirC" , listener .getCreatedDirectories ().contains (testDirC ));
116- assertTrue ("B testDirAFile1" , listener .getCreatedFiles ().contains (testDirAFile1 ));
117- assertFalse ("B testDirAFile2" , listener .getCreatedFiles ().contains (testDirAFile2 ));
118- assertTrue ("B testDirAFile3" , listener .getCreatedFiles ().contains (testDirAFile3 ));
119- assertTrue ("B testDirAFile4" , listener .getCreatedFiles ().contains (testDirAFile4 ));
120- assertTrue ("B testDirBFile1" , listener .getCreatedFiles ().contains (testDirBFile1 ));
121-
122- checkAndNotify ();
123- checkCollectionsEmpty ("C" );
124-
125- testDirAFile4 = touch (testDirAFile4 );
126- FileUtils .deleteDirectory (testDirB );
127- checkAndNotify ();
128- checkCollectionSizes ("D" , 0 , 0 , 1 , 0 , 1 , 1 );
129- assertTrue ("D testDirB" , listener .getDeletedDirectories ().contains (testDirB ));
130- assertTrue ("D testDirAFile4" , listener .getChangedFiles ().contains (testDirAFile4 ));
131- assertTrue ("D testDirBFile1" , listener .getDeletedFiles ().contains (testDirBFile1 ));
132-
133- FileUtils .deleteDirectory (testDir );
134- checkAndNotify ();
135- checkCollectionSizes ("E" , 0 , 0 , 2 , 0 , 0 , 3 );
136- assertTrue ("E testDirA" , listener .getDeletedDirectories ().contains (testDirA ));
137- assertTrue ("E testDirAFile1" , listener .getDeletedFiles ().contains (testDirAFile1 ));
138- assertFalse ("E testDirAFile2" , listener .getDeletedFiles ().contains (testDirAFile2 ));
139- assertTrue ("E testDirAFile3" , listener .getDeletedFiles ().contains (testDirAFile3 ));
140- assertTrue ("E testDirAFile4" , listener .getDeletedFiles ().contains (testDirAFile4 ));
141-
142- testDir .mkdir ();
143- checkAndNotify ();
144- checkCollectionsEmpty ("F" );
145-
146- checkAndNotify ();
147- checkCollectionsEmpty ("G" );
148- } catch (final Exception e ) {
149- e .printStackTrace ();
150- fail ("Threw " + e );
151- }
96+ public void testDirectory () throws Exception {
97+ checkAndNotify ();
98+ checkCollectionsEmpty ("A" );
99+ final File testDirA = new File (testDir , "test-dir-A" );
100+ final File testDirB = new File (testDir , "test-dir-B" );
101+ final File testDirC = new File (testDir , "test-dir-C" );
102+ testDirA .mkdir ();
103+ testDirB .mkdir ();
104+ testDirC .mkdir ();
105+ final File testDirAFile1 = touch (new File (testDirA , "A-file1.java" ));
106+ final File testDirAFile2 = touch (new File (testDirA , "A-file2.txt" )); // filter should ignore this
107+ final File testDirAFile3 = touch (new File (testDirA , "A-file3.java" ));
108+ File testDirAFile4 = touch (new File (testDirA , "A-file4.java" ));
109+ final File testDirBFile1 = touch (new File (testDirB , "B-file1.java" ));
110+
111+ checkAndNotify ();
112+ checkCollectionSizes ("B" , 3 , 0 , 0 , 4 , 0 , 0 );
113+ assertTrue ("B testDirA" , listener .getCreatedDirectories ().contains (testDirA ));
114+ assertTrue ("B testDirB" , listener .getCreatedDirectories ().contains (testDirB ));
115+ assertTrue ("B testDirC" , listener .getCreatedDirectories ().contains (testDirC ));
116+ assertTrue ("B testDirAFile1" , listener .getCreatedFiles ().contains (testDirAFile1 ));
117+ assertFalse ("B testDirAFile2" , listener .getCreatedFiles ().contains (testDirAFile2 ));
118+ assertTrue ("B testDirAFile3" , listener .getCreatedFiles ().contains (testDirAFile3 ));
119+ assertTrue ("B testDirAFile4" , listener .getCreatedFiles ().contains (testDirAFile4 ));
120+ assertTrue ("B testDirBFile1" , listener .getCreatedFiles ().contains (testDirBFile1 ));
121+
122+ checkAndNotify ();
123+ checkCollectionsEmpty ("C" );
124+
125+ testDirAFile4 = touch (testDirAFile4 );
126+ FileUtils .deleteDirectory (testDirB );
127+ checkAndNotify ();
128+ checkCollectionSizes ("D" , 0 , 0 , 1 , 0 , 1 , 1 );
129+ assertTrue ("D testDirB" , listener .getDeletedDirectories ().contains (testDirB ));
130+ assertTrue ("D testDirAFile4" , listener .getChangedFiles ().contains (testDirAFile4 ));
131+ assertTrue ("D testDirBFile1" , listener .getDeletedFiles ().contains (testDirBFile1 ));
132+
133+ FileUtils .deleteDirectory (testDir );
134+ checkAndNotify ();
135+ checkCollectionSizes ("E" , 0 , 0 , 2 , 0 , 0 , 3 );
136+ assertTrue ("E testDirA" , listener .getDeletedDirectories ().contains (testDirA ));
137+ assertTrue ("E testDirAFile1" , listener .getDeletedFiles ().contains (testDirAFile1 ));
138+ assertFalse ("E testDirAFile2" , listener .getDeletedFiles ().contains (testDirAFile2 ));
139+ assertTrue ("E testDirAFile3" , listener .getDeletedFiles ().contains (testDirAFile3 ));
140+ assertTrue ("E testDirAFile4" , listener .getDeletedFiles ().contains (testDirAFile4 ));
141+
142+ testDir .mkdir ();
143+ checkAndNotify ();
144+ checkCollectionsEmpty ("F" );
145+
146+ checkAndNotify ();
147+ checkCollectionsEmpty ("G" );
152148 }
153149
154150 /**
0 commit comments