Hi!
Unfortunately this class you're trying to get under test has even multiple problems which makes it very tricky to test. I doubt that it's even possible to reasonably test it if you don't have the chance to refactor it.
The main problems I see from a quick look are:
- It's an
EJB class which may need a JUnit add-on like ejb3unit depending on what you want to test.
- It's designed to be used with multi-threading which is a challenge on its own if you want to create useful concurrency tests.
- You have dependencies for file/database I/O hard-coded into the code.
- The overall design is not really OO and not very well-suited for testing.
That said I'd recommend you to restructure and refactor this code and try to put in test cases in parallel as good as possible. Try to break dependencies so that you can substitute database and file access with fake or mock objects etc. Refactor this big methods into smaller units/methods so that you are able to test one piece of specific functionality within each test method. Unfortunately it's hard to give you more concrete advices because there may be many different way to get this piece of code into a structure which is easier to test.
If it's likely that you will have to deal more often with code of that kind in the near future I would recommend reading
"Working Effectively with Legacy Code" ;-) Michael Feathers shows lots of tricks how to get such code into better shape and make it testable.
Good Luck
Marco