i have written 4 JUnitTest cases. 1st test calls our one main method of another class where the some file processing happens. in Success case all these files (10 files ) moves to Success dir (in JUnit test case 3rd, i am checking this ). If some of fiels fails in processing it moves to ERROR dir (in JUnit test case 2nd, i am checking this).
But problem is, In Success directory there could be previously processed files. so to find latest created folder in this Success folder i am ussing following code.
problem is i am not getting name of recently created folder in the list at line 1 , bcz of this my 3rd test is failing. Please advice me on it. old folder name is coming as value of lastMod varaible
The code in lines 3 - 15 you've posted looks all right, but I may be confused. You say it's failing at line 1, but that line wouldn't have any effect on the rest of the code. Also line 1 is call to a static method in DefaultBatcherServiceBean, so not only can we not tell why it's failing, we don't even know what it's supposed to do.
In other words, after line 15, lastModifedFolder should hold the subdirectory of archive_dir with the most recent modification date, but actualArcFiles will hold exactly what it did before you ran the line 3 - 15 code.
After lines 1 and line 7 , i have put two system.out, where i am printing length of arrays "actualArcFiles" and "files" . both these lines giving me 1 less than actually it should be (means. before executing my test case if there are 20 subdirectories in Success dir. it should show me lenthg of these arrays 21 but it shows me 20), bcz of this iam getting old subdirectory name. and my JUnit test case is failing.
I think above explanation gives you insight on my problem.