• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLyBird 1.2.3 Locking test

 
Daniel Grout
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've come up with some spag code for a junit test for a multi user locking test....anybody got any comments? (I know it's awfull code but it is 02:13 here and I'm fresh out of Dr Pepper)



getExample() is a little helper method to generate some test data.

This should return Xx (repeated however many times) eg: XxXxXxXx

Dunno - I'm tired but comments would be warmly welcomed.

Cheers
Dan
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel

I don't know what you want to test?

Your test is thread safe because you have synchronize block inside of the run method, the synchronize ensure you that only one thread will operate (be in) the block. With other words your workflow looks like this :
thread 1 -> lock-operate-release ,after this
thread 2 -> lock-operate-release, after this
....
thread 3 -> lock-operate-release.

What you need is something where the lock and release are access in the same time by more than one thread.

Regards M
P.S. keep a Dr Pepper for me also
 
Chris Be
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this one:
http://www.coderanch.com/t/189353/java-developer-SCJD/certification/JUnit-Test-Cases
[ September 06, 2007: Message edited by: Chris Be ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic