Ran into a similar problem. Don't know if it helps with JUnit tests but it did for me with deployed apps. I posted the answer at:
...