ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/test/test_URLhandler.pm
Revision: 1.5
Committed: Mon Nov 15 16:50:09 1999 UTC (25 years, 6 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.4: +79 -91 lines
Log Message:
Portability tests + base checking + get check OK

File Contents

# User Rev Content
1 williamc 1.1 #
2     # urlhandler test suite
3     #
4    
5 williamc 1.4 package URL::test::test_URLhandler;
6 williamc 1.1 require 5.001;
7     use URL::URLhandler;
8     @ISA = ("TestClass"); #methods both from the test class
9    
10     sub init {
11     my $self=shift;
12 williamc 1.5 $self->{testfile}=$self->datadir()."/urlfile++";
13     $self->{testcachearea}=$self->temparea()."/URLhandlercache";
14     $self->{cache}=URL::URLcache->new($self->{testcachearea});
15 williamc 1.1 }
16    
17     sub test {
18     my $self=shift;
19    
20     # test 1
21 williamc 1.4 $self->newtest("Initiating URL");
22     $self->newobject($self->{cache});
23    
24 williamc 1.5 $self->newtest("currentbase on an empty base stack");
25     $base=$self->testinterface("currentbase", "non-existent type");
26     if ( $base->base() ne "") {
27     $self->testfail("Empty base expected\n".$base->base()."\n")
28     }
29     else {
30     $self->testpass("Base OK")
31     }
32     # expect the dummmy base back
33     $self->newtest("Testing base stacking mechanism");
34     $self->testinterface("setbase", "file", { base=>"testbase", test=>1 });
35     $base=$self->testinterface("currentbase", "file");
36     $self->_testbase("testbase", $base);
37     $self->testinterface("setbase", "cvs" , { base=>"testcvsbase"});
38     $self->testinterface("setbase", "file", { base=>"testbase2" });
39     $base=$self->testinterface("currentbase", "file");
40     $self->_testbase("testbase2", $base);
41    
42     $self->newtest("Testing unsetbase destacking mechanism");
43     $self->testinterface("unsetbase", "file");
44     $base=$self->testinterface("currentbase", "file");
45     $self->_testbase("testbase", $base);
46     $self->testinterface("unsetbase", "file");
47     $base=$self->testinterface("currentbase", "file");
48     $self->_testbase("", $base);
49 williamc 1.4
50 williamc 1.5
51    
52     $self->newtest("Get Test");
53     $self->_getmethodtest();
54    
55     $self->newtest("Portabilty (relocation) Test");
56     my $secondcache=$self->temparea()."/URLcache2";
57     rename ($self->{testcachearea}, $secondcache);
58     $self->{cache2}=URL::URLcache->new($secondcache);
59     $self->newobject($self->{cache2});
60    
61     $self->_getmethodtest();
62 williamc 1.1 }
63    
64 williamc 1.5 # ------------ Supporting Routines -----------------------------
65    
66     sub _getmethodtest {
67 williamc 1.1 my $self=shift;
68 williamc 1.5 my $url="file:".$self->{testfile};
69 williamc 1.1
70 williamc 1.5 my ($fullurl,$file)=$self->testinterface("get", $url );
71     $self->verify($file, $self->{testfile});
72     if ( ! exists $self->{lastfilename} ) {
73     ($self->{lastfilename}=$file)=~s/.*\///;
74     }
75     else {
76     # test we have the same filename
77     ($filen=$file)=~s/.*\///;
78     if ($filen ne $self->{lastfilename}) {
79     $self->testfail("Expecting $self->{lastfilename} got $filen");
80     }
81     }
82     ($fullurl1,$file2)=$self->testinterface("get", "$url" );
83     if ( $fullurl1 ne $fullurl ) {
84     $self->testfail("Repeatability check failed");
85     }
86     else {
87     if ( $file2 ne $file ) {
88     $self->testfail("Repeatability check failed");
89     }
90     else {
91     $self->testpass("Repeatability check OK");
92     }
93     }
94    
95 williamc 1.1 }
96    
97 williamc 1.5 sub _testbase {
98 williamc 1.1 my $self=shift;
99 williamc 1.5 my $string=shift;
100     my $base=shift;
101 williamc 1.1
102 williamc 1.5 if ( $base->base() ne $string) {
103     $self->testfail("wrong base set\ngot ".$base->base().
104     " expecting $string\n")
105     }
106     else {
107     $self->testpass("Base OK ($string)");
108     }
109 williamc 1.1 }