ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/test/test_URLhandler.pm
Revision: 1.2
Committed: Wed Aug 25 08:41:40 1999 UTC (25 years, 8 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.1: +2 -2 lines
Log Message:
Update all for get interface

File Contents

# User Rev Content
1 williamc 1.1 #
2     # urlhandler test suite
3     #
4    
5     package test_URLhandler;
6     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     $self->{testfile}="urlfile++";
13     }
14    
15     sub test {
16     my $self=shift;
17    
18     # test 1
19     $self->newtest("Testing default cacheing mechanism with cvs test");
20     $self->newobject();
21     $self->test_cvs();
22     # test 2
23     $self->newtest("Testing file url mechanism");
24     $self->test_file();
25     }
26    
27     sub test_cvs {
28     my $self=shift;
29    
30     # now set a cvs base - for a pserver
31     $hashvars={
32     "base" => "cmscvs.cern.ch:/cvs_server/repositories/SCRAM" ,
33     "auth" => "pserver",
34     "user" => "anonymous",
35     "passkey" => "AA_:yZZ3e"
36     };
37     $self->testinterface("setbase", "cvs" , $hashvars );
38    
39     # now test the url mechanism
40     $self->testinterface("get", "cvs:test");
41     $self->verifydir($self->{object}->{cache}."/test");
42     $self->verifydir($self->{object}->{cache}."/test/CVS");
43     #clean up
44     use File::Path;
45     rmtree($self->{object}->{cache}."/test") or die "$!";
46     $self->testinterface("unsetbase","cvs");
47     return;
48     }
49    
50     sub test_file {
51     my $self=shift;
52     my $varhash;
53     my $varhash2;
54     my $base="$ENV{SCRAM_HOME}/src";
55     $varhash = {
56     "base" => "$base"
57     };
58     $varhash2 = {
59     "base" => "$ENV{SCRAM_HOME}/"
60     };
61     # now set a file base
62     $self->newtest("File base test");
63     $self->testinterface("setbase","file", $varhash );
64     $self->_getmethodtest("file:URL/test/testdata/".
65     $self->{testfile});
66     # different base
67     $self->newtest("Multiple file base test");
68     $self->testinterface("setbase","file", $varhash2 );
69     $self->_getmethodtest("file:src/URL/test/testdata/".
70     $self->{testfile});
71     # get rid of the last base and try again
72     $self->newtest("base restoration test");
73     $self->testinterface("unsetbase","file");
74     $self->_getmethodtest("file:URL/test/testdata/".
75     $self->{testfile});
76     # get rid of all bases and try a full path
77     $self->newtest("No Bases test");
78     $self->testinterface("unsetbase","file");
79     $self->_getmethodtest("file:$base/Utilities/test/testdata/".
80     $self->{testfile});
81     }
82    
83     # ------------ Supporting Routines -----------------------------
84    
85     sub _getmethodtest {
86     my $self=shift;
87     my $url=shift;
88     my $filename=$self->newfilename();
89     my $file;
90    
91 williamc 1.2 $self->testinterface("get", "$url" );
92     $self->verify("$self->{object}->{cache}/urlfile++",
93 williamc 1.1 $self->datadir()."/$self->{testfile}");
94     unlink $filename;
95     }
96