aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to simulate multiple clients for testing 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 "How to simulate multiple clients for testing" Watch "How to simulate multiple clients for testing" New topic
Author

How to simulate multiple clients for testing

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Originally posted by Chiji Nwankwo:
Hi,
Does anyone know how I can simulate multiple clients from the same machine, in order to test my lock and unlock mechanism is working properly.
Thanks,
Chiji

Here's ya go.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

What you will want to do is create a new class that just has a main method
Have it make a connection to the RMI Server, get your connection Object, and then call some lock calls. Yuo can use loops to make the client wait, or use a wait() with time to wait.
Have a second class like the first above, then have it lock some records. Have it lock the same as the one above and some new ones.
Have many System.out.println() calls to display when a lock is made and when unlock is called.
When you run them, you will have two dos windows open. And try to execute them at about the same time. It will take a second to switch to the other window to start up the next class.
I wish I still had my test client code, but unfortunately I don't.
you could also try a search on this forum and I think there have been some test client code around somewhere.
Good Luck
Mark
Chiji Nwankwo
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Hi,
I thought this might come in handy for any one trying to simulate multiple remote clients, it worked for me.

Disclaimer:
Please only use this code as an example of how you might want to simulate multiple clients. This works in my current circumstances and might not necessarily be ideal for you. I can not be held liable, so use this at your own risk.

I hope this can help you.
Regards,
Chiji


SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

Have many System.out.println() calls to display when a lock is made and when unlock is called.

In addition to this, I think it is equally important to test multiple booking. Even though the following sequence works:
lock(5, client1)->lock(5,client2)waits->unlock(5, client1)->lock(5,client2)succeeds->unlock(5,client2)
Doesn't mean that this sequence will work as well:
client1.book(for record 5) -> client2.book(for record 5) waits -> client1.book(for record 5) ends -> client2.book(for record 5) starts and ends.
Eugene.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to simulate multiple clients for testing