Looking at this a little more, the proper cleanup of a ManifoldCF process requires that the shutdown thread be run. This thread is added as a shutdown hook to the JVM. The "alreadyClosed" flag is used to prevent it from being run more than once if more than one shutdown signal is received, since it's also executed during object finalization (so that we catch termination within Tomcat and other application servers).
So, basically, ManifoldCF.isInitialized and ManifoldCF.alreadyClosed perform this coordinated dance on a per-JVM basis. ManifoldCF system initialization is meant to occur once per JVM. Without starting and stopping a JVM, it's therefore not a realistic test. Is there any way for Maven to run each test class in its own JVM, or does it insist on running them all within one? If there is no such possibility, we can look to adding a manual shutdown thread invocation in a reset method. There are lots of potential problems with this approach in that dangling temporary threads that are waiting forever on sockets etc might be left around from previous tests, and other JVM static state such as the cache might also not get cleared, but the tests would probably execute nonetheless. Karl On Mon, Jul 18, 2011 at 8:26 AM, Karl Wright <[email protected]> wrote: > I think the likely difference is that ant is running each test in its > own JVM, and Maven is not. > > Now, it is straightforward enough to add functionality that resets the > ManifoldCF core classes, and tie that into the tests. However, that > is not how ManifoldCF will be used in practice. The concern I have is > that there are other static variables (for instance, the cache > manager) which are never "reset", but would be if we need to "start > from scratch" again inside the same JVM every time a test is run. > Identifying all such cases may take some time. > > Karl > > > On Mon, Jul 18, 2011 at 8:04 AM, Karl Wright <[email protected]> wrote: >> These tests run fine under ant, but the ant build invokes test files >> explicitly. I'm not quite sure what Ant's behavior is here, and how >> exactly it differs from Maven's. >> >> Karl >> >> On Mon, Jul 18, 2011 at 7:41 AM, Tobias Rübner <[email protected]> wrote: >>> The unit tests are currently not working. >>> The first test in a module creates the properties and logging files and >>> initializes the framework. >>> All following tests are also creating those files, but because the framework >>> is already initialized, they are useless. >>> >>> This depends on the static behaviour of ManifoldCF.isInitialized. >>> After a test is done the ManifoldCF Object should also be reseted. >>> >> >
