ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/test/test_URLhandler.pm
Revision: 1.8
Committed: Fri Aug 4 07:59:07 2000 UTC (24 years, 9 months ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: v102p1, V1_0_1, V1_0_0, V1_pre0, SCRAM_V1, SCRAMV1_IMPORT, V0_19_7, V0_19_6, V0_19_6p1, V0_19_5, SFATEST, V0_19_4, V0_19_4_pre3, V0_19_4_pre2, V0_19_4_pre1, V0_19_3, V0_19_2, V0_19_1, V0_19_0, V0_18_5, V0_18_4, V0_18_2, V0_18_1, ProtoEnd
Branch point for: V1_pre1, SCRAM_V1_BRANCH, V0_19_4_B, HPWbranch
Changes since 1.7: +36 -15 lines
Log Message:
New class tests

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 williamc 1.7 @ISA = ("Utilities::TestClass"); #methods both from the test class
9 williamc 1.1
10     sub init {
11     my $self=shift;
12 williamc 1.8 $self->{filebasetest}="file:".$self->datadir()."/";
13     $self->{testfile}="urlfile++";
14 williamc 1.5 $self->{testcachearea}=$self->temparea()."/URLhandlercache";
15     $self->{cache}=URL::URLcache->new($self->{testcachearea});
16 williamc 1.1 }
17    
18     sub test {
19     my $self=shift;
20    
21     # test 1
22 williamc 1.4 $self->newtest("Initiating URL");
23     $self->newobject($self->{cache});
24    
25 williamc 1.5 $self->newtest("currentbase on an empty base stack");
26     $base=$self->testinterface("currentbase", "non-existent type");
27 williamc 1.8 if ( defined $base) {
28 williamc 1.5 $self->testfail("Empty base expected\n".$base->base()."\n")
29     }
30     else {
31     $self->testpass("Base OK")
32     }
33     # expect the dummmy base back
34     $self->newtest("Testing base stacking mechanism");
35 williamc 1.8 my $filebase1="file:/root?var1=1";
36     my $filebase2="file:/anotherroot?var2=1";
37     my $cvsbase1="cvs://someserver/root?module=hello";
38     $self->testinterface("setbase", $filebase1);
39 williamc 1.5 $base=$self->testinterface("currentbase", "file");
40 williamc 1.8 $self->_testbase($filebase1, $base);
41     $self->testinterface("setbase", $cvsbase1);
42     $self->testinterface("setbase", $filebase2 );
43 williamc 1.5 $base=$self->testinterface("currentbase", "file");
44 williamc 1.8 $self->_testbase($filebase2, $base);
45     $base=$self->testinterface("currentbase", "cvs");
46     $self->_testbase($cvsbase1, $base);
47 williamc 1.5
48     $self->newtest("Testing unsetbase destacking mechanism");
49     $self->testinterface("unsetbase", "file");
50     $base=$self->testinterface("currentbase", "file");
51 williamc 1.8 $self->_testbase($filebase1, $base);
52 williamc 1.5 $self->testinterface("unsetbase", "file");
53     $base=$self->testinterface("currentbase", "file");
54 williamc 1.8 if ( ! defined $base ) {
55     $self->testpass("No base returned as expected");
56     }
57     else {
58     $self->testfail("Recieved a base when stack should be empty");
59     $self->_testbase("", $base);
60     }
61     $base=$self->testinterface("currentbase", "cvs");
62     $self->_testbase($cvsbase1, $base);
63     $self->testinterface("unsetbase", "cvs");
64     $base=$self->testinterface("currentbase", "cvs");
65     if ( ! defined $base ) {
66     $self->testpass("No base returned as expected");
67     }
68     else {
69     $self->testfail("Recieved a base when stack should be empty");
70     $self->_testbase("", $base);
71     }
72 williamc 1.5
73    
74     $self->newtest("Get Test");
75     $self->_getmethodtest();
76    
77     $self->newtest("Portabilty (relocation) Test");
78     my $secondcache=$self->temparea()."/URLcache2";
79     rename ($self->{testcachearea}, $secondcache);
80     $self->{cache2}=URL::URLcache->new($secondcache);
81     $self->newobject($self->{cache2});
82    
83     $self->_getmethodtest();
84 williamc 1.6
85 williamc 1.1 }
86    
87 williamc 1.5 # ------------ Supporting Routines -----------------------------
88    
89     sub _getmethodtest {
90 williamc 1.1 my $self=shift;
91 williamc 1.5 my $url="file:".$self->{testfile};
92 williamc 1.1
93 williamc 1.8 $self->testinterface("setbase",$self->{filebasetest});
94 williamc 1.5 my ($fullurl,$file)=$self->testinterface("get", $url );
95 williamc 1.8 $self->verify($file, $self->datadir()."/".$self->{testfile});
96 williamc 1.5 if ( ! exists $self->{lastfilename} ) {
97     ($self->{lastfilename}=$file)=~s/.*\///;
98     }
99     else {
100     # test we have the same filename
101     ($filen=$file)=~s/.*\///;
102     if ($filen ne $self->{lastfilename}) {
103     $self->testfail("Expecting $self->{lastfilename} got $filen");
104     }
105     }
106     ($fullurl1,$file2)=$self->testinterface("get", "$url" );
107     if ( $fullurl1 ne $fullurl ) {
108     $self->testfail("Repeatability check failed");
109     }
110     else {
111     if ( $file2 ne $file ) {
112     $self->testfail("Repeatability check failed");
113     }
114     else {
115     $self->testpass("Repeatability check OK");
116     }
117     }
118    
119 williamc 1.1 }
120    
121 williamc 1.5 sub _testbase {
122 williamc 1.1 my $self=shift;
123 williamc 1.5 my $string=shift;
124     my $base=shift;
125 williamc 1.1
126 williamc 1.8 if ( $base->url() ne $string) {
127     $self->testfail("wrong base set\ngot ".$base->url().
128 williamc 1.5 " expecting $string\n")
129     }
130     else {
131     $self->testpass("Base OK ($string)");
132     }
133 williamc 1.1 }