1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use HTTPTest;
7
8
9###############################################################################
10
11my $mainpage = <<EOF;
12<html>
13<head>
14  <title>Main Page</title>
15</head>
16<body>
17  <p>
18    Some text and a link to a <a href="http://localhost:{{port}}/secondpage.html">second page</a>.
19    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
20  </p>
21</body>
22</html>
23EOF
24
25my $secondpage = <<EOF;
26<html>
27<head>
28  <title>Second Page</title>
29</head>
30<body>
31  <p>
32    Some text and a link to a <a href="http://localhost:{{port}}/thirdpage.html">third page</a>.
33    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
34  </p>
35</body>
36</html>
37EOF
38
39my $thirdpage = <<EOF;
40<html>
41<head>
42  <title>Third Page</title>
43</head>
44<body>
45  <p>
46    Some text and a link to a <a href="http://localhost:{{port}}/dummy.txt">text file</a>.
47    Also, another <a href="http://localhost:{{port}}/againnonexistent">broken link</a>.
48  </p>
49</body>
50</html>
51EOF
52
53my $dummyfile = <<EOF;
54Don't care.
55EOF
56
57# code, msg, headers, content
58my %urls = (
59    '/index.html' => {
60        code => "200",
61        msg => "Dontcare",
62        headers => {
63            "Content-type" => "text/html",
64        },
65        content => $mainpage,
66    },
67    '/secondpage.html' => {
68        code => "200",
69        msg => "Dontcare",
70        headers => {
71            "Content-type" => "text/html",
72        },
73        content => $secondpage,
74    },
75    '/thirdpage.html' => {
76        code => "200",
77        msg => "Dontcare",
78        headers => {
79            "Content-type" => "text/html",
80        },
81        content => $thirdpage,
82    },
83    '/dummy.txt' => {
84        code => "200",
85        msg => "Dontcare",
86        headers => {
87            "Content-type" => "text/plain",
88        },
89        content => $dummyfile
90    },
91);
92
93my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:{{port}}/";
94
95my $expected_error_code = 8;
96
97my %expected_downloaded_files = (
98);
99
100###############################################################################
101
102my $the_test = HTTPTest->new (name => "Test--spider-r",
103                              input => \%urls,
104                              cmdline => $cmdline,
105                              errcode => $expected_error_code,
106                              output => \%expected_downloaded_files);
107exit $the_test->run();
108
109# vim: et ts=4 sw=4
110
111