My exam has the following line:
The final program must have no dependencies on any libraries other than those of the Java 2 Platform.
Does this mean that I can't turn in a project which includes
junit modules for
testing? Of course it is possible to put all my junit tests in separate packages and then not include those packages in the code that I give to Sun. Though normally people recommend that you keep the tests with the classes. So your data package includes:
Data.java
DataTest.java
LockManager.java
LockManagerTest.java
RecordLock.java
RecordLockTest.java
HomemadeDB.java
HomemadeDBTest.java
etc.
By the way, Reza ( Hi
) I have figured out how to use junit for some of the multi-threaded testing I am going to do. You have your junit test method create a monitoring
thread which can receive notification of important events, then you create and start the threads you need for your test. Each thread does its thing while notifying the monitor of its events. The monitor thread waits for the other threads to complete all of their expected events, then evaluates whether everything happened correctly, and finally notifies the test method that its done. The test method which created all these threads waits for notification of completion from the monitor thread.
So far, I only have 1 small test, mostly as proof of concept. I create 2 threads. Each thread does a lock() on record 2, goes to sleep for 1 second and then does an unlock() on record 2.