• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JUnit Test Cases

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for this test! it is very useful and inspired.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 114
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 100
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic