This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Two test cases that may come in handy . Note: They may need to be adjusted to match your particular database interface, or implementation. Any suggestions welcome.
I find them usefull too. But I don't agree with one thing. ConcurrencyTest fails if a read method throws exception. It is possible and legal to get this if a record was previously deleted. Therefore it can be considered as invalid (deleted) record and i.e. RecordNotFoundException has to be thrown.
Regards, Tomek
Chris Be
Ranch Hand
Joined: Sep 11, 2006
Posts: 36
posted
0
Originally posted by Tomasz Wilk: [qb]ConcurrencyTest fails if a read method throws exception. It is possible and legal to get this if a record was previously deleted. Therefore it can be considered as invalid (deleted) record and i.e. RecordNotFoundException has to be thrown. /qb]
Tomek,
I think you may have overlooked some critical test code sections. ConcurrencyTest does not fail at all upon encountering a RecordNotFoundException. To the contrary, it acknowledges that the attempt to access the record was due to an invalid record accessed, and decrements the failure count required to pass the test.
Chris , I am not sure right/wrong , but have a doubt �
Probably lockRecord can throw RecordNotFoundException , if a thread attempt to modify a deleted record ..(previously deleted one) Can I suggest lockRecord also in try catch block and return it in a controlled manner so that it doesn�t be considered a failure �
Expecting your comments
SCJP 5.0, SCJD, SCWCD
Chris Be
Ranch Hand
Joined: Sep 11, 2006
Posts: 36
posted
0
Originally posted by Naveen Narayanan: Chris , I am not sure right/wrong , but have a doubt � Expecting your comments
Yes SIR!
Well, you are suggesting the typical log-and-rethrow exception handling anti-pattern. Exception handling is worth taking much time to study (e.g. here), since done badly, it is a black hole swallowing up valuable resources during software maintenance. [ November 15, 2007: Message edited by: Chris Be ]
I've had to modify this test for the BS. It is more comprehensive then my own concurrency testing. As a result I may have found a dead lock in my code.