aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes [URLYBird] Locking Test Cases 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 "[URLYBird] Locking Test Cases" Watch "[URLYBird] Locking Test Cases" New topic
Author

[URLYBird] Locking Test Cases

Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
Ok. I have almost completed the assignment and am in the process of creating Test Cases to verify my locking. I cant think of any more test cases (for locking). Can you?

Currently I have the following test cases :

Test Case 1:

Start Server. Open Client (Lets call this A). Select "Show All Hotels". Select record number #2. Double click on it so that it brings up the "Please enter the customer id to book this record".

Now open another instance of the client (Lets call this B). Select "Show All Hotels". Select record number #2. Double click on it so that it brings up the "Please enter the customer id to book this record".

Now go back to Client A. Enter "11" as the customer id and complete booking. **Expected Result: Record is booked and Client A's view is refreshed**

Now go back to Client B. Enter "13" as the customer id and complete booking. **Expected Result: Record is not booked. An error message that says that the record has been booked to customer id 11 is displayed. Client B's view is refreshed **


Test Case 2:

Pre-requisite: **Modify the code so the bookRecord() sleeps for 3 min after acquiring a lock***.

Start Server. Open Client (Lets call this A). Select "Show All Hotels". Select record number #3. Double click on it so that it brings up the "Please enter the customer id to book this record".Book this record.

**Expected Result: Thread sleeps for 3 min and then books the record. Client A's view is refreshed**


Open another instance of the client (Lets call this B). Select "Show All Hotels". Select record number #3. Double click on it so that it brings up the "Please enter the customer id to book this record". Book this record.

**Expected Result : Thread waits until it can get the lock to the record. Gets the lock, sleeps for 3 min. Then tries to book the record.An error message that says that the record has been booked to customer id 11 is displayed. Client B's view is refreshed ****


I cant think of any more test cases (for locking). Can you?

Regards
Mike Corleone

[ April 02, 2006: Message edited by: Mike Corleone ]
[ April 02, 2006: Message edited by: Mike Corleone ]

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
I'd recommend stress testing too. I had a client identifier field in the database that I used for this. The basic idea is that you have loads of threads each doing a for loop trying to add 1 to the value stored in the customer id field for each record in turn. Before doing the addition, the tread must obtain the record lock, and release it afterwards.

If at the end of the test run, every customer id has been incremented to the total number of threads, all is probably ok. If your locking solution is broken, you will probably get some lost updates occurring, and some customer id values will be too low.

I used groboutils to allow me to fire off hundreds of threads, under Junit control.

Hope that helps,
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11525
    
100

Hi Mike,

I will probably come back to this later and think about it some more, but what about:
  • Client 1 locks record #3 (then sleeps for a while)
  • Client 2 tries to lock record #3 - has to wait
  • Client 1 deletes record #3
  • Client 1 releases lock on record #3
  • What happens from that point onwards?

    Regards, Andrew


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

    Joined: Nov 30, 2004
    Posts: 284

    Hi Mike:
    What about:
    Client A locks record X
    Client B tries to lock record X
    Client C tries to lock record X
    Client B crashes
    Client A releases the lock...
    Regards


    SCJP, OCMJD, OCMJEA
    Richard Green
    Ranch Hand

    Joined: Aug 25, 2005
    Posts: 536
    Client 1 deletes record #3

    Good point. but thats not possible as my client GUI doesnt allow the user to delete a record. (It was never a part of the requirements).

    What about:
    Client A locks record X
    Client B tries to lock record X
    Client C tries to lock record X
    Client B crashes
    Client A releases the lock...

    Good one.

    Daniel Dalton

    Thanks mate.
    B Chen
    Ranch Hand

    Joined: Dec 27, 2005
    Posts: 89
    Originally posted by Oricio Ocle:

    Client B crashes


    This would be a case of orphaned locks? Probably out of scope of assignment.


    SCJD<br />SCJP 1.4
    Oricio Ocle
    Ranch Hand

    Joined: Nov 30, 2004
    Posts: 284

    Mike wrote:
    Good point. but thats not possible as my client GUI doesnt allow the user to delete a record. (It was never a part of the requirements).

    Be aware, your specs require you to implement a specified interface. So I would consider this case too.
    B Chen wrote:
    This would be a case of orphaned locks? Probably out of scope of assignment.

    Orphaned locks are probably out of the scope, ... or not.
    But this is not an orphaned lock case.
    Look at that other:

    Regards
    Oricio Ocle
    Ranch Hand

    Joined: Nov 30, 2004
    Posts: 284

    Hello again Mike.
    my client GUI doesnt allow the user to delete a record

    For testing purposes it would recommend you give your GUI all the functionality

    Regards
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: [URLYBird] Locking Test Cases