Forums Register Login

Testing lock/unlock

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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%.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
My way is just write a main method and start of a few threads trying to meddle with the datastore.

Cave man way.
Hey cool! They got a blimp! But I have a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 565 times.
Similar Threads
Can I add new methods to Data??
Modify Issues
Testing and JUnit
How to test Lock/Unlock
locking
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:56:10.