2 //=============================================================================
6 * This class implements a number of test objects to test the
9 * @author Torben Worm <tworm@cs.wustl.edu>
11 //=============================================================================
14 #include "orbsvcs/CosConcurrencyControlC.h"
15 #include "orbsvcs/CosNamingC.h"
16 #include "CC_naming_service.h"
21 // Return codes for the tests
31 * @brief Defines an abstract base class for a test
33 * This class declares an interface to run the test of the
34 * concurrency service.
39 /// Default constructor
40 CC_Test (CC_naming_service
*ns
);
45 /// Run the test times_to_run number of times. Returns CC_SUCCESS on
46 /// success CC_FAIL otherwise.
47 virtual int run (int times_to_run
= 1) = 0;
49 /// Create a new lock set using the default global lock set factory
50 /// from the naming service.
51 CosConcurrencyControl::LockSet_ptr
create_lock_set ();
53 /// Returns a human readable string from the lock mode enum.
54 char *get_lock_mode_name (CosConcurrencyControl::lock_mode mode
);
57 /// The result of the test being performed.
60 /// The naming service beeing used to register and look up locks
61 CC_naming_service
*naming_service_
;
65 * @class Test_Single_Lock_With_Mode
67 * @brief This is a simple test that checks that it is possible to set
68 * the lock in the desired mode, try it, and release it.
70 class Test_Single_Lock_With_Mode
: public CC_Test
74 * Default constructor. The naming service must be initialized
75 * before calling this method. The mode is the mode of the lock to
78 Test_Single_Lock_With_Mode (CC_naming_service
*naming_service
,
79 CosConcurrencyControl::lock_mode mode
);
82 virtual ~Test_Single_Lock_With_Mode ();
84 /// Runs the test the specified number of times.
85 virtual int run (int times_to_run
= 1);
88 /// The lock mode of the lock being tested
89 CosConcurrencyControl::lock_mode mode_
;
93 * @class Test_Setup_LockSet
95 * @brief This class creates a read lock, registeres it with the naming
96 * service and locks it.
98 class Test_Setup_LockSet
: public CC_Test
102 * Default constructor. The naming service must be initialized
103 * before calling this method. The name is the name the lock will be
104 * registered under in the naming service.
106 Test_Setup_LockSet (CC_naming_service
*naming_service_
,
110 virtual ~Test_Setup_LockSet ();
112 /// Runs the test the specified number of times.
113 virtual int run (int times_to_run
= 1);
116 /// The name of the lock
121 * @class Test_Use_Already_Created_LockSet
123 * @brief This class looks up the lock in the naming service and locks
126 class Test_Use_Already_Created_LockSet
: public CC_Test
130 * Default constructor. The naming service must be initialized
131 * before calling this method. The name is the name the lock will be
132 * looked up under in the naming service.
134 Test_Use_Already_Created_LockSet (CC_naming_service
*naming_service_
,
138 virtual ~Test_Use_Already_Created_LockSet ();
140 /// Runs the test the specified number of times.
141 virtual int run (int times_to_run
= 1);
144 /// The name of the lock
149 * @class Test_Unlock_Already_Created_LockSet
151 * @brief This class looks up the lock in the naming service and unlocks
154 class Test_Unlock_Already_Created_LockSet
: public CC_Test
158 * Default constructor. The naming service must be initialized
159 * before calling this method. The name is the name the lock will be
160 * looked up under in the naming service.
162 Test_Unlock_Already_Created_LockSet (CC_naming_service
*naming_service_
,
166 virtual ~Test_Unlock_Already_Created_LockSet ();
168 /// Runs the test the specified number of times.
169 virtual int run (int times_to_run
= 1);
172 /// The name of the lock
177 * @class Test_Release_Not_Held_Lock
179 * @brief This class tests that the LockNotHeld exception is thrown if a
180 * not held lock is released.
182 class Test_Release_Not_Held_Lock
: public CC_Test
185 /// Default constructor. The naming service must be initialized
186 /// before calling this method. The mode is the mode of the lock
187 Test_Release_Not_Held_Lock (CC_naming_service
*naming_service_
,
188 CosConcurrencyControl::lock_mode mode_
);
191 virtual ~Test_Release_Not_Held_Lock ();
193 /// Runs the test the specified number of times.
194 virtual int run (int times_to_run
= 1);
197 /// The lock mode of the lock being tested
198 CosConcurrencyControl::lock_mode mode_
;
201 #endif /* !defined (_CC_TESTS_H_) */