aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Test Your Effective Locking Mechanism by Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Test Your Effective Locking Mechanism by Threads" Watch "Test Your Effective Locking Mechanism by Threads" New topic
Author

Test Your Effective Locking Mechanism by Threads

Sudhansu Pati
Ranch Hand

Joined: Sep 23, 2003
Posts: 77
Hi all,
I am not sure how you guys are testing your locking strategy. I have used the followed testing program. May be you should use it. Because I had to go back and change my code a lot during testing.
Create1

Create2

Delete1

Delete2

Update1

Update2

DataTest

I think this code posting is ok, because this is outside of the assignment. But I found this very useful and you may too. If you have followed different testting strategy, post your code here.
[ October 05, 2003: Message edited by: Suds Pati ]

Sudhansu<br />SCJP, SCWCD, SCBCD, SCJD, SCEA, SCDJWS
Chris Harris
Ranch Hand

Joined: Sep 21, 2003
Posts: 231
Hi Suds,
I am planning to test me code using JUnit. I am only at the start of the project so I don't currently have any thing useful to show you.
You may want to look it up at :JUnit
Hope you find it useful
Chris


SCJP 1.2, SCWCD, SCBCD
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11423
    
  85

Hi Suds,
Do you go back and manually verify that the database is OK after these tests?
I am guessing that you should see a few stack traces when you run this. Is that correct?
Chris did make a good suggestion with JUnit - it is very good, and a lot of businesses use it. Working on this assignment is a good time to learn how to use it yourself.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Sudhansu Pati
Ranch Hand

Joined: Sep 23, 2003
Posts: 77
Hi Andrew, Chris,

I am familiar with JUnit. Also I am using JBuilder which allows me to create TestCases, Test Suites on fly. JUnut will help you on functional testing. Every method can be tested with JUnit to see if the methods are returning the right value. But how would you test for deadlock, thread contention and livelock ? Can JUnit help me creating concurrent threads ?
Well, I have OptimizeIt Thread Debugger which will help me finding thread contention, dealdlock and livelock. But I have left the heavy use of tools for testing towards the end of the project.
How do I know my database status after the testing. I periodically display the entire database content in JBuilder. Also I monitor the exceptions and outputs (System.out.println()). Sometimes I use the JBuilder debugger.
Regards,
Suds
Sakke Wiik
Greenhorn

Joined: Mar 13, 2002
Posts: 10
But how would you test for deadlock, thread contention and livelock ? Can JUnit help me creating concurrent threads ?

Read this document, it explains how to use GroboUtils(http://groboutils.sourceforge.net/) for testing threads with JUnit: http://today.java.net/pub/a/today/2003/08/06/multithreadedTests.html
It also has basic dead-lock support using timers.
How do I know my database status after the testing.

Just re-read the databasefile and match it against the original. Or you could have the original stored as a static variable somewhere (or a more complex object if you for example read the databasefile into objects).
I have a BaseTest-class which I extend in my testclasses instead of TestCase, in which setUp-method I simply copy the original databasefile to a test-directory. This way each test works against a newly copied original databasefile, and after tests I could match the files if I need.
cheers,
Sakke
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Test Your Effective Locking Mechanism by Threads