Apache-Roaming

 view release on metacpan or  search on metacpan

t/20liprefs.t  view on Meta::CPAN

if (!$pid) {
    # This is the child
    $ENV{'PERL5LIB'} = 'blib/arch:blib/lib';
    my @opts = ($cfg->{'httpd_path'}, '-d', $cfg->{'t_dir'}, '-f',
		$cfg->{'httpd_conf'}, '-X');
    print "Starting httpd: ", join(" ", @opts), "\n";
    exec @opts;
}


print "1..39\n";
alarm 120;

print "Creating a user agent.\n";
my $ua = LWP::UserAgent->new();
Test($ua);

sleep 5;
my $contents = 'abcdef';
my $testfile = File::Spec->catdir($cfg->{'roaming_dir'}, "foo bar", "test");
unlink $testfile;
Request($ua, 'PUT', '/roaming/foo bar/test', 'text/plain', $contents);
TestContents($testfile, $contents);

my $block = '';
for (my $i = 0;  $i < 256;  $i++) {
    $block .= chr($i);
}
my $contents2 = $block x 40;
my $testfile2 = File::Spec->catdir($cfg->{'roaming_dir'}, "foo bar", "test2");
unlink $testfile2;
Request($ua, 'PUT', '/roaming/foo bar/test2', 'text/plain', $contents2);
TestContents($testfile2, $contents2);

my $res = Request($ua, 'GET', '/roaming/foo bar/test');
Test($res->content()  and  ($res->content() eq $contents));
$res = Request($ua, 'GET', '/roaming/foo bar/test2');
Test($res->content()  and  ($res->content() eq $contents2));


my $testfile3 = File::Spec->catdir($cfg->{'roaming_dir'}, "foo bar", "test3");
unlink $testfile3;
Request($ua, 'MOVE', '/roaming/foo bar/test', undef, undef,
	'New-uri' => '/roaming/foo bar/test3');
$res = Request($ua, 'GET', '/roaming/foo bar/test3');
Test($res->content()  and  ($res->content() eq $contents));
Test(!-f $testfile);
my $testfile4 = File::Spec->catdir($cfg->{'roaming_dir'}, "foo bar", "test3");
unlink $testfile4;
Request($ua, 'MOVE', '/roaming/foo bar/test2', undef, undef,
 	'New-uri' => '/roaming/foo bar/test4');
$res = Request($ua, 'GET', '/roaming/foo bar/test4');
Test($res->content()  and  ($res->content() eq $contents2));
Test(!-f $testfile2);

Request($ua, 'DELETE', '/roaming/foo bar/test3');
Test(!-f $testfile3);
Request($ua, 'DELETE', '/roaming/foo bar/test4');
Test(!-f $testfile4);

$res = Request($ua, 'GET', '/roaming/foo bar/liprefs');
print $res->content();

sleep 5;


END {
    my $status = $?;
    KillHttpd();
    $? = $status;
}



( run in 1.375 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )