Initail import package wget: A utility for retrieving files using the HTTP or FTP...
[external/wget.git] / tests / FTPTest.pm
1 package FTPTest;
2
3 use strict;
4 use warnings;
5
6 use FTPServer;
7 use WgetTest;
8
9 our @ISA = qw(WgetTest);
10 my $VERSION = 0.01;
11
12
13 {
14     my %_attr_data = ( # DEFAULT
15     );
16
17     sub _default_for
18     {
19         my ($self, $attr) = @_;
20         return $_attr_data{$attr} if exists $_attr_data{$attr};
21         return $self->SUPER::_default_for($attr);
22     }
23
24     sub _standard_keys
25     {
26         my ($self) = @_;
27         ($self->SUPER::_standard_keys(), keys %_attr_data);
28     }
29 }
30
31
32 sub _setup_server {
33     my $self = shift;
34
35     $self->{_server} = FTPServer->new (input => $self->{_input},
36                                        server_behavior =>
37                                            $self->{_server_behavior},
38                                        LocalAddr => 'localhost',
39                                        ReuseAddr => 1,
40                                        rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!";
41 }
42
43
44 sub _launch_server {
45     my $self = shift;
46     my $synch_func = shift;
47
48     $self->{_server}->run ($synch_func);
49 }
50
51 sub _substitute_port {
52     my $self = shift;
53     my $ret = shift;
54     $ret =~ s/{{port}}/$self->{_server}->sockport/eg;
55     return $ret;
56 }
57
58 1;
59
60 # vim: et ts=4 sw=4
61