next up previous contents
Next: LookupTable and ServerMeasure Up: The Server Previous: The Server   Contents

UserDatabase

To test this class, a small program was written to run over some sample datafiles, retrieving the records for particular users and printing the result to STDOUT. Once this was working, the code was modified to attempt to update the records, printing the before and after results of getInfo() so the result could be verified. A series of updates were attempted to check that the setInfo() method did not update a record with one with an earlier timestamp. Once the test program had run, a final check was made to ensure that the information had been saved correctly by manually viewing the database files using less . These tests were then repeated for contact lists.

It was noted that these tests were highly dependent on the state of the database at the time the test was run and were therefore not easily repeatable. However, it was decided that keeping multiple copies of the necessary data files would be quicker than writing a more complex test harness to construct test cases dynamically, and minimise the number of potential bugs in the test harness itself.

In order to test the getEventCounts() and getChangedEntries() methods, the event counts were extracted from the database using getEventCounts(). A few updates were then made to the database before the extracted event counts were passed to getChangedEntries(). The values returned by getChangedEntries() were then printed out so it could be checked that the correct entries had been returned.

The final function of the user database to be tested was the creation of a new user. The test for this was to pass in an IP address as a string, have the test program print out the representation of that IP address and the current time as 32-bit unsigned integers and then tell the database to create the user. (See appendix A.3.1.) The data files were then checked to make sure the user had been created and what UserID had been assigned. This was then manually checked against the information printed out by the test program which was extremely tedious, but helped to spot a serious problem. The order of precedence of operators meant that the original code of

unsigned long long uid = msb<<32 + ipaddr;
did not produce the expected UserID and so was changed to: = (msb«32) + ipaddr;.


next up previous contents
Next: LookupTable and ServerMeasure Up: The Server Previous: The Server   Contents
Nathan Dimmock 2001-06-20