• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing lock/unlock

 
GD Deepz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you guys using JUnit to test lock/unlock. Anybody have any ideas. Writing a bunch of unit test for the locking mechanism is not going to tell me much. What am I looking for? and should the test consist of.

Thanks everyone
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by GD Deepz:
How are you guys using JUnit to test lock/unlock. Anybody have any ideas. Writing a bunch of unit test for the locking mechanism is not going to tell me much. What am I looking for? and should the test consist of.

Thanks everyone


I run two kinds of tests against the locking code.

1) start multiple threads that cycle through the records and lock, delay and unlock. Keep track of the number of threads waiting for locks to be sure that there is some contention.

2) use a special client that allows you to do arbitrary operations against the data server. With this do specific tests of troublesome areas such as locking the same records from multiple clients, locking multiple records from multiple clients, locking the same record twice from the same client, unplugging the network connection,...

While doing this I use Emma to collect coverage statistics, you want the coverage on the locking to be 100%.
 
Russell Wurth
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just started looking at multithreaded testing, which JUnit doesn't do very well.

This article has some insight on using GroboUtils with JUnit to write multithreaded tests:

http://today.java.net/pub/a/today/2003/08/06/multithreadedTests.html

This is the approach I am going to take.

Russell
 
Clivant Yeo
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My way is just write a main method and start of a few threads trying to meddle with the datastore.

Cave man way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic