|
Marc, himself, his blogs, and you reading them
 woensdag 5 maart 2003
Junit Out of Loop
Struggling with bidirectional many-to-many relations in hibernate today I got myself into writing this hack to get junit tests be able to test across more then one thread. (useful for testing out ThreadLocalMaps I guessed?) public void testSomething throws Throwable { // code doing the preparation of the test // typically inserting stuff in a DB // some of these might set some variable, you'll need to declare final Object referenceThing; final Throwable[] exceptionSpace = new Throwable[1]; // making this an inner class makes it more readable I think Thread separateRun = new Thread() { public void run() { try { // here you perform your test code and typically // there is something like: Object calculatedThing = whateverCall(); assertEquals("Quite unexpected", referenceThing, calculatedThing); } catch (Throwable t) { exceptionSpace[0] = t; } } }; separateRun.start(); separateRun.join(); // this trick makes sure you don't miss out // on the AssertionError nested in the other thread. if (exceptionSpace[0] != null) { throw exceptionSpace[0]; } }
Bad thing is that the resulting test shows no difference in my hibernate case... have to dig in some more...
5:31:36 PM
|
|
Welcome, but don't feed the animals!
The fun thing about a blogging colleague, is that you get to see how ideas become blogs.
I actually wanted to show the world (in my blog), a recent post of my favourite hisitech employee: There was some poetry again, and loads of shared emotions: you should just have a look through the glass ;-)
So this is what happened next: Steven, the all knowing web-indexer, knew (of course) about the archive and looked up the address, and let his imagination go wild at the question 'And that while the list is still not open for public posts?'
Which makes me think about that piece of Bruggen-wisdom: "A sick mind [really] is a joy for ever."
2:59:22 PM
|
|
|
|