ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/test/test_URLhandler.pm
Revision: 1.6
Committed: Fri Dec 17 08:46:09 1999 UTC (25 years, 5 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.5: +3 -0 lines
Log Message:
Working Unit

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.6
63     #clean up
64     $self->cleantemp();
65 williamc 1.1 }
66    
67 williamc 1.5 # ------------ Supporting Routines -----------------------------
68    
69     sub _getmethodtest {
70 williamc 1.1 my $self=shift;
71 williamc 1.5 my $url="file:".$self->{testfile};
72 williamc 1.1
73 williamc 1.5 my ($fullurl,$file)=$self->testinterface("get", $url );
74     $self->verify($file, $self->{testfile});
75     if ( ! exists $self->{lastfilename} ) {
76     ($self->{lastfilename}=$file)=~s/.*\///;
77     }
78     else {
79     # test we have the same filename
80     ($filen=$file)=~s/.*\///;
81     if ($filen ne $self->{lastfilename}) {
82     $self->testfail("Expecting $self->{lastfilename} got $filen");
83     }
84     }
85     ($fullurl1,$file2)=$self->testinterface("get", "$url" );
86     if ( $fullurl1 ne $fullurl ) {
87     $self->testfail("Repeatability check failed");
88     }
89     else {
90     if ( $file2 ne $file ) {
91     $self->testfail("Repeatability check failed");
92     }
93     else {
94     $self->testpass("Repeatability check OK");
95     }
96     }
97    
98 williamc 1.1 }
99    
100 williamc 1.5 sub _testbase {
101 williamc 1.1 my $self=shift;
102 williamc 1.5 my $string=shift;
103     my $base=shift;
104 williamc 1.1
105 williamc 1.5 if ( $base->base() ne $string) {
106     $self->testfail("wrong base set\ngot ".$base->base().
107     " expecting $string\n")
108     }
109     else {
110     $self->testpass("Base OK ($string)");
111     }
112 williamc 1.1 }