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

# Content
1 #
2 # urlhandler test suite
3 #
4
5 package URL::test::test_URLhandler;
6 require 5.001;
7 use URL::URLhandler;
8 @ISA = ("Utilities::TestClass"); #methods both from the test class
9
10 sub init {
11 my $self=shift;
12 $self->{filebasetest}="file:".$self->datadir()."/";
13 $self->{testfile}="urlfile++";
14 $self->{testcachearea}=$self->temparea()."/URLhandlercache";
15 $self->{cache}=URL::URLcache->new($self->{testcachearea});
16 }
17
18 sub test {
19 my $self=shift;
20
21 # test 1
22 $self->newtest("Initiating URL");
23 $self->newobject($self->{cache});
24
25 $self->newtest("currentbase on an empty base stack");
26 $base=$self->testinterface("currentbase", "non-existent type");
27 if ( defined $base) {
28 $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 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 $base=$self->testinterface("currentbase", "file");
40 $self->_testbase($filebase1, $base);
41 $self->testinterface("setbase", $cvsbase1);
42 $self->testinterface("setbase", $filebase2 );
43 $base=$self->testinterface("currentbase", "file");
44 $self->_testbase($filebase2, $base);
45 $base=$self->testinterface("currentbase", "cvs");
46 $self->_testbase($cvsbase1, $base);
47
48 $self->newtest("Testing unsetbase destacking mechanism");
49 $self->testinterface("unsetbase", "file");
50 $base=$self->testinterface("currentbase", "file");
51 $self->_testbase($filebase1, $base);
52 $self->testinterface("unsetbase", "file");
53 $base=$self->testinterface("currentbase", "file");
54 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
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
85 }
86
87 # ------------ Supporting Routines -----------------------------
88
89 sub _getmethodtest {
90 my $self=shift;
91 my $url="file:".$self->{testfile};
92
93 $self->testinterface("setbase",$self->{filebasetest});
94 my ($fullurl,$file)=$self->testinterface("get", $url );
95 $self->verify($file, $self->datadir()."/".$self->{testfile});
96 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 }
120
121 sub _testbase {
122 my $self=shift;
123 my $string=shift;
124 my $base=shift;
125
126 if ( $base->url() ne $string) {
127 $self->testfail("wrong base set\ngot ".$base->url().
128 " expecting $string\n")
129 }
130 else {
131 $self->testpass("Base OK ($string)");
132 }
133 }