Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Test Your Effective Locking Mechanism by Threads

 
Sudhansu Pati
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11944
212
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sudhansu Pati
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic