File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JUnit Test Cases

 
Chris Be
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

1. Database interface functionality, non-threaded:


2. A fully fledged concurrency test.

 
Daniel Vogt
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for this test! it is very useful and inspired.
 
Tomasz Wilk
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


[ October 01, 2007: Message edited by: Chris Be ]
 
Naveen Narayanan
Ranch Hand
Posts: 114
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Chris Be
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Sean Beecroft
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chris Bicnal
Ranch Hand
Posts: 94
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean,

How did you modify these classes to work with B&S, could you share your code?

Thanks,

Chris
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic