1 |
williamc |
1.1 |
#
|
2 |
|
|
# CVS url handler test suite
|
3 |
|
|
#
|
4 |
|
|
|
5 |
|
|
package URL::test::test_URLclass;
|
6 |
|
|
require 5.001;
|
7 |
|
|
use URL::URLbase;
|
8 |
|
|
@ISA = ("TestClass"); #methods both from the test class
|
9 |
|
|
|
10 |
|
|
sub init {
|
11 |
|
|
my $self=shift;
|
12 |
|
|
$type1=URL::URLbase->new({ base=>'Ahello' });
|
13 |
|
|
$type2=URL::URLbase->new({ base=>'Bhello', var1=>"val1", var2=>"val2" });
|
14 |
|
|
$type3=URL::URLbase->new({ base=>'Chello', "param1++"=>"wrong", var2=>val2 });
|
15 |
|
|
$type4=URL::URLbase->new({}); # an empty base
|
16 |
|
|
}
|
17 |
|
|
|
18 |
|
|
sub test {
|
19 |
|
|
my $self=shift;
|
20 |
|
|
|
21 |
|
|
# test 1
|
22 |
|
|
$self->newtest("Testing simple url");
|
23 |
|
|
$urlA="A:test";
|
24 |
|
|
$urlB="B:test?param1++=H¶m2=T";
|
25 |
|
|
$self->newobject($urlA);
|
26 |
|
|
$self->expect("A");
|
27 |
|
|
$self->testinterface("type");
|
28 |
|
|
$self->clearexpect();
|
29 |
|
|
$self->_urlbasictest($urlA);
|
30 |
|
|
$self->newtest("full url without parameters");
|
31 |
|
|
$self->expect("A://test");
|
32 |
|
|
$self->testinterface("url");
|
33 |
|
|
$self->clearexpect();
|
34 |
|
|
$self->newtest("url without parameters - expanded");
|
35 |
|
|
$self->testinterface("expandurl", $type1);
|
36 |
|
|
$self->expect("A://Ahello/test");
|
37 |
|
|
$self->testinterface("url");
|
38 |
|
|
$self->clearexpect();
|
39 |
|
|
$self->testinterface("expandurl", $type2);
|
40 |
|
|
$self->expect("A://Bhello/test?var1=val1&var2=val2");
|
41 |
|
|
$self->testinterface("url");
|
42 |
|
|
$self->clearexpect();
|
43 |
|
|
$self->newtest("url with parameters");
|
44 |
|
|
$self->newobject($urlB);
|
45 |
|
|
$self->_urlbasictest($urlB);
|
46 |
|
|
$self->newtest("full url with parameters");
|
47 |
|
|
$self->expect("B://test?param1++=H¶m2=T");
|
48 |
|
|
$self->testinterface("url");
|
49 |
|
|
$self->clearexpect();
|
50 |
|
|
$self->testinterface("expandurl", $type2);
|
51 |
|
|
$self->expect
|
52 |
williamc |
1.3 |
("B://Bhello/test?param1++=H¶m2=T&var1=val1&var2=val2");
|
53 |
williamc |
1.1 |
$self->testinterface("url");
|
54 |
|
|
$self->clearexpect();
|
55 |
|
|
$self->testinterface("expandurl", $type3);
|
56 |
|
|
$self->expect
|
57 |
williamc |
1.3 |
("B://Chello/test?param1++=H¶m2=T&var2=val2");
|
58 |
williamc |
1.1 |
$self->testinterface("url");
|
59 |
|
|
$self->clearexpect();
|
60 |
|
|
|
61 |
|
|
$self->newtest("empty base test");
|
62 |
|
|
$self->testinterface("expandurl", $type4);
|
63 |
|
|
$self->expect("B://test?param1++=H¶m2=T");
|
64 |
|
|
$self->testinterface("url");
|
65 |
|
|
$self->clearexpect();
|
66 |
|
|
$self->newtest("Initialised with a full url");
|
67 |
williamc |
1.3 |
my $urlC="C://Bhello:/test?param1++=H?&passkey=AA_:yZZ3e&var1=val1";
|
68 |
williamc |
1.2 |
$self->_urlbasictest($urlC);
|
69 |
williamc |
1.1 |
$self->newobject($urlC);
|
70 |
|
|
$self->expect($urlC);
|
71 |
|
|
$self->testinterface("url");
|
72 |
|
|
$self->clearexpect();
|
73 |
|
|
$self->newtest("file test");
|
74 |
|
|
$self->expect("test");
|
75 |
|
|
$self->testinterface("file");
|
76 |
williamc |
1.2 |
$self->clearexpect();
|
77 |
|
|
|
78 |
|
|
$self->newtest("parameter test");
|
79 |
williamc |
1.3 |
$self->expect("H?");
|
80 |
williamc |
1.2 |
$self->testinterface("param","param1++");
|
81 |
williamc |
1.1 |
$self->clearexpect();
|
82 |
|
|
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
sub _urlbasictest {
|
86 |
|
|
my $self=shift;
|
87 |
|
|
my $url=shift;
|
88 |
|
|
$self->newtest("Basic test for url $url");
|
89 |
|
|
$self->newobject($url);
|
90 |
|
|
$self->expect($url);
|
91 |
|
|
$self->testinterface("origurl");
|
92 |
|
|
$self->clearexpect();
|
93 |
|
|
}
|