Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to simulate multiple clients for testing

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic