1 |
williamc |
1.1 |
#
|
2 |
|
|
# URLcache test suite
|
3 |
|
|
#
|
4 |
|
|
|
5 |
|
|
package URL::test::test_URLcache;
|
6 |
|
|
use URL::URLcache;
|
7 |
|
|
require 5.001;
|
8 |
williamc |
1.3 |
@ISA = ("Utilities::TestClass"); #methods both from the test class
|
9 |
williamc |
1.1 |
|
10 |
|
|
sub test {
|
11 |
|
|
my $self=shift;
|
12 |
|
|
|
13 |
|
|
# test 1
|
14 |
|
|
$self->newtest("New Object");
|
15 |
|
|
$self->newobject($self->temparea()."/cacheindex");
|
16 |
williamc |
1.2 |
$self->newtest("Request filename when empty");
|
17 |
|
|
$filename=$self->testinterface("filename", "url-nonexistant");
|
18 |
|
|
print "returned $filename\n";
|
19 |
williamc |
1.1 |
$self->newtest("Store some urls");
|
20 |
|
|
$self->testinterface("store", "url1", "file1");
|
21 |
|
|
$self->testinterface("store", "url2", "file2");
|
22 |
|
|
$self->testinterface("store", "url3", "file3");
|
23 |
williamc |
1.2 |
|
24 |
|
|
$self->newtest("filestore test");
|
25 |
|
|
$self->expect($self->temparea()."/cacheindex/files");
|
26 |
|
|
$self->testinterface("filestore");
|
27 |
|
|
$self->clearexpect();
|
28 |
|
|
$self->{myfilestore}=$self->testinterface("filestore");;
|
29 |
|
|
|
30 |
williamc |
1.1 |
$self->newtest("Close Down and Restore");
|
31 |
|
|
# kill off the old object and attempt a restore
|
32 |
|
|
undef $self->{object};
|
33 |
|
|
$self->newobject($self->temparea()."/cacheindex");
|
34 |
|
|
$self->datacheck();
|
35 |
|
|
|
36 |
|
|
# Test the filename function
|
37 |
|
|
$self->newtest("test filename(url) interface");
|
38 |
williamc |
1.2 |
$self->expect($self->{myfilestore}."/file1");
|
39 |
williamc |
1.1 |
$self->testinterface("filename", "url1");
|
40 |
|
|
$self->clearexpect();
|
41 |
|
|
my $temp=$self->testinterface("filename", "url-random");
|
42 |
|
|
$self->testinterface("store", "url-random", $temp);
|
43 |
|
|
$self->expect($temp);
|
44 |
|
|
$temp=$self->testinterface("filename", "url-random");
|
45 |
|
|
$self->clearexpect();
|
46 |
|
|
|
47 |
|
|
# Test the update function
|
48 |
|
|
$self->newtest("test sequence number change on updates");
|
49 |
|
|
$self->expect(1);
|
50 |
|
|
$self->testinterface("updatenumber", "url1");
|
51 |
|
|
$self->clearexpect();
|
52 |
|
|
$numb=$self->testinterface("store", "url1", "file1");
|
53 |
|
|
$self->expect($numb+1);
|
54 |
|
|
$self->testinterface("updatenumber", "url1");
|
55 |
|
|
$self->clearexpect();
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
sub datacheck {
|
59 |
|
|
my $self=shift;
|
60 |
|
|
$self->newtest("Get a URL");
|
61 |
williamc |
1.2 |
$self->expect($self->{myfilestore}."/file2");
|
62 |
|
|
print $self->{myfilestore}."/file2";
|
63 |
williamc |
1.1 |
$self->testinterface("file","url2");
|
64 |
|
|
$self->clearexpect();
|
65 |
|
|
}
|