Dimirti Slyus

Greenhorn
+ Follow
since Jun 29, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dimirti Slyus

Hi,
I am very new to fitnesse.
I installed new version and it seems to work fine for simple tests.
What I am interested in is the in-container tests. We have application using EJB2 with all usual architecture (10 years old or so). Proxies, Services, DAO etc.
The idea is to write the acceptance tests. The only way to test now is to use container as it needs to instanciate java beans.
The only tool I found was "patang" that kind of working. The problem is that it only works with very old version of Fitnesse. 2007ish I think.
Could anyone suggest the combination of Fitnesse+... to be able to avail of all features of fitnesse and to be able to test in container or EJB2s.
Thanks a lot!

Dmitry
14 years ago
Hi All,
Having read all the replies I still did not get the answer on the question:
Should the update method(for example) of Data class have calls to lock and unlock methods.
My implementation of Data class' read, update and delete methods is:
lock -> do action -> unlock.
For this implementation the lock and unlock methods should actually be private. In this case client application will not worry about possibility of calling the lock/unlock methods itself as the methods are called internally. But we have been given the interface by Sun...
Obviously the original test posted here did not work for me when I tried doUpdate method because thread will lock record from doUpdate method and call my read method that tries to lock record again and can not because it is currently locked by the same thread ...
Yes, I can describe, as mentioned in one of the pprevious posts above, in my choices.txt that application does not suppose to call lock and unlock methods itself and i will limit this from the GUI side but I am not sure how Sun's automated tests work. So can anyone who passed the exam comment on my solution please ?
Hey!
I have implemented the deleted records cache only. It saves some reads from datafile when you try to verify if record exists or not. Also it helps to re-use deleted records. you need to synchronize on the cache object of course.

Dmitry

how you will create new record by reusing deleted entry? as of now you are not allowing to lock deleted record. If you don't lock deleted record (e.g. 11) two threads can create new record at same record i.e. 11 .



Thanks for your post, Ken.

Agree but creating the record does not require locking. I will explain.
Let's say CLIENT_1 calls Data.create method.
The Data class will call database.create method
My database class has cached deleted records. So the database.create will:
1. Lock the cache.
2. check if there is deleted record in cache. If it is it will use the recNom for writing the record. If not it will use the last record +1.
3. synchronize on the database and write the new record.
4. delete entry from deleted records cache.
5. Unlock the cache and return recNo.

CLIENT_2 will try to create record by calling the same Data.create that will call database.create.
Now it will stop waiting for the lock to be released from the 1st step. After cache is released it will not contain deleted record used by the first client. Therefore this client will use another record or new one - step 2.

Did I miss anything ?
Hi guys! sorry I was not here for couple of days.
Here is my lock method of the Data class:

public long lock(int recNo) throws RecordNotFoundException {
long cookie = lockManager.lock(recNo);
boolean recordExist = database.exist(recNo);
if (recordExist) {
return cookie;
}
else {
lockManager.unlock(recNo, cookie);
throw new RecordNotFoundException();
}

}

where:
lockManager.lock(recNo) generates random cookie number, adds the entry into the map or waits if the record is locked.
database.exist(recNo) just checks if record exsists and not deleted.

do you see any potential holes in here ? Thanks
Hi ! My first post here...


... //check if exists, throw RecordNotFoundException if not
... //add to the map



The code is from your LockManager class, right ?
My question is: how are you going to check "check if exists" ? will you have a reference to your FileAccess class from LockManager class ? or I got something wrong here ... Thanks