• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Testing lock/unlock

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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%.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Are you here to take over the surface world? Because this tiny ad will stop you!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic