neo4j/neo4j — pull request #1469 by benbc (2013-11-13 13:15:34+00:00)
Title: [DEPENDS ON 1.9 MERGE] Fix tests with unclosed transactions

This PR builds on the 1.9 merge. In that merge there is a change that waits (with a timeout) for unclosed transactions when shutting down the database. Lots of our tests weren't closing their transactions cleanly, so they were hanging for 20 seconds when the database was shut down.

I believe that this PR addresses all such problems apart from org.neo4j.kernel.impl.core.TestNeo4jApiExceptions#shouldGiveNiceErrorWhenShutdownLegacy(). In that test there is a clash between two sets of guard code: NodeProxy checks whether we are in a transaction and ThreadToStatementContextBridge checks whether the database is running. The test wants to see the latter failure, but will hang if the transaction is closed; if you close the transaction then you see the former error instead. I'd be grateful for a second pair of eyes to try to work out how to deal with that.

My approach for this was to change the code in DatabaseAvailability to throw an exception if there were any transactions left open. I also had to change org.neo4j.kernel.InternalAbstractGraphDatabase#shutdown() to stop it swallowing the error. This caused all tests that left transactions open to fail.