1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Test::Fatal;
BEGIN {
use_ok('HTTP::Headers::ActionPack');
}
my $pack = HTTP::Headers::ActionPack->new;
isa_ok($pack, 'HTTP::Headers::ActionPack');
{
my $media_type = $pack->create_header( 'Content-Type' => 'application/xml;charset=UTF-8' );
isa_ok($media_type, 'HTTP::Headers::ActionPack::MediaType');
is($media_type->as_string, 'application/xml; charset="UTF-8"', '... got the right string');
my $links = $pack->create_header( 'Link' => '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"');
isa_ok($links, 'HTTP::Headers::ActionPack::LinkList');
is($links->as_string, '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"', '... got the right string');
}
{
my $media_type = $pack->create_header( 'Content-Type' => [ 'application/xml', charset => 'UTF-8' ] );
isa_ok($media_type, 'HTTP::Headers::ActionPack::MediaType');
is($media_type->as_string, 'application/xml; charset="UTF-8"', '... got the right string');
my $links = $pack->create_header( 'Link' => [
$pack->create( 'LinkHeader' => [ '</test/tree/1_2>', tag => "child" ] ),
$pack->create( 'LinkHeader' => [ '</test/tree/1_1>', tag => "child" ] ),
$pack->create( 'LinkHeader' => [ '</test/tree>', rel => "up" ] ),
]);
isa_ok($links, 'HTTP::Headers::ActionPack::LinkList');
is($links->as_string, '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"', '... got the right string');
}
{
my $media_type = $pack->create( 'MediaType' => 'application/xml;charset=UTF-8' );
isa_ok($media_type, 'HTTP::Headers::ActionPack::MediaType');
is($media_type->as_string, 'application/xml; charset="UTF-8"', '... got the right string');
my $links = $pack->create_header( 'Link' => '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"');
isa_ok($links, 'HTTP::Headers::ActionPack::LinkList');
is($links->as_string, '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"', '... got the right string');
}
{
my $media_type = $pack->create( 'MediaType' => [ 'application/xml', charset => 'UTF-8' ] );
isa_ok($media_type, 'HTTP::Headers::ActionPack::MediaType');
is($media_type->as_string, 'application/xml; charset="UTF-8"', '... got the right string');
my $links = $pack->create_header( 'Link' => [
$pack->create( 'LinkHeader' => [ '</test/tree/1_2>', tag => "child" ] ),
$pack->create( 'LinkHeader' => [ '</test/tree/1_1>', tag => "child" ] ),
$pack->create( 'LinkHeader' => [ '</test/tree>', rel => "up" ] ),
]);
isa_ok($links, 'HTTP::Headers::ActionPack::LinkList');
is($links->as_string, '</test/tree/1_2>; tag="child", </test/tree/1_1>; tag="child", </test/tree>; rel="up"', '... got the right string');
}
done_testing;
|