Changeset 15020
- Timestamp:
- Sep 25, 2007, 1:37:44 PM (19 years ago)
- Location:
- trunk/DataStore
- Files:
-
- 5 edited
-
lib/DataStore/FileSet/Parser.pm (modified) (2 diffs)
-
lib/DataStore/Product.pm (modified) (2 diffs)
-
t/02_fileset_parse.t (modified) (3 diffs)
-
t/05_product.t (modified) (12 diffs)
-
t/08_response.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStore/lib/DataStore/FileSet/Parser.pm
r7951 r15020 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Parser.pm,v 1.1 3 2006-07-22 01:17:33 smalleExp $3 # $Id: Parser.pm,v 1.14 2007-09-25 23:37:44 jhoblitt Exp $ 4 4 5 5 package DataStore::FileSet::Parser; … … 89 89 'is valid http uri' => 90 90 sub { is_uri($_[0]) and $_[0] =~ /^http:/ }, 91 'uri ends with / ' => sub { $_[0] =~ m|/$| },91 'uri ends with /index.txt' => sub { $_[0] =~ m|/index.txt$| }, 92 92 }, 93 default => 'http://example.org/ ',93 default => 'http://example.org/index.txt', 94 94 }, 95 95 }, 96 96 ); 97 97 98 my $self = bless \%p, ref $class || $class; 98 my $self = bless {}, ref $class || $class; 99 100 $p{base_uri} =~ qr|(.*?/)index.txt|; 101 102 $self->{base_uri} = $1; 99 103 100 104 return $self; -
trunk/DataStore/lib/DataStore/Product.pm
r7951 r15020 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Product.pm,v 1. 8 2006-07-22 01:17:33 smalleExp $3 # $Id: Product.pm,v 1.9 2007-09-25 23:37:44 jhoblitt Exp $ 4 4 5 5 package DataStore::Product; … … 102 102 type => SCALAR, 103 103 callbacks => { 104 ' is valid uri dirname' => sub { $_[0] =~ m|/$| },104 'uri ends with /index.txt' => sub { $_[0] =~ m|/index.txt$| }, 105 105 } 106 106 }, -
trunk/DataStore/t/02_fileset_parse.t
r8722 r15020 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 02_fileset_parse.t,v 1. 8 2006-08-31 22:58:34 jhoblitt Exp $5 # $Id: 02_fileset_parse.t,v 1.9 2007-09-25 23:37:44 jhoblitt Exp $ 6 6 7 7 use strict; … … 115 115 END 116 116 my $parser = DataStore::FileSet::Parser->new( 117 base_uri => 'http://foo.com/ '117 base_uri => 'http://foo.com/index.txt' 118 118 ); 119 119 my @results = $parser->parse($example1); … … 132 132 END 133 133 my $parser = DataStore::FileSet::Parser->new( 134 base_uri => 'http://foo.com/ '134 base_uri => 'http://foo.com/index.txt' 135 135 ); 136 136 my $results = $parser->parse($example1); -
trunk/DataStore/t/05_product.t
r8722 r15020 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 05_product.t,v 1. 5 2006-08-31 22:58:34 jhoblitt Exp $5 # $Id: 05_product.t,v 1.6 2007-09-25 23:37:44 jhoblitt Exp $ 6 6 7 7 use strict; … … 10 10 use lib qw( ./lib ./t ); 11 11 12 use Test::More tests => 2 2;12 use Test::More tests => 23; 13 13 14 14 =head1 NAME … … 32 32 33 33 { 34 my $dsp = DataStore::Product->new( uri => 'http://example.org/ ' );34 my $dsp = DataStore::Product->new( uri => 'http://example.org/index.txt' ); 35 35 36 36 isa_ok($dsp, 'DataStore::Product'); … … 39 39 { 40 40 my $dsp = DataStore::Product->new( 41 uri => 'http://example.org/ ',41 uri => 'http://example.org/index.txt', 42 42 last_fileset => '12buckelyourshoe', 43 43 ); … … 47 47 48 48 eval { 49 my $dsp = DataStore::Product->new( uri => 'http://example.org/ ', foo => 1 );49 my $dsp = DataStore::Product->new( uri => 'http://example.org/index.txt', foo => 1 ); 50 50 }; 51 51 like($@, qr/not listed in the validation options/, … … 54 54 eval { 55 55 my $dsp = DataStore::Product->new( 56 uri => 'http://example.org/ ',56 uri => 'http://example.org/index.txt', 57 57 last_fileset => '12buckelyourshoe', 58 58 foo => 1, … … 65 65 my $dsp = DataStore::Product->new( uri => 'http://example.org' ); 66 66 }; 67 like($@, qr/ is valid uri dirname/,68 '->new() fails when uri param does not end with / ');67 like($@, qr/uri ends with \/index.txt/, 68 '->new() fails when uri param does not end with /index.txt'); 69 69 70 70 eval { 71 my $dsp = DataStore::Product->new( uri => '://example.org' ); 71 my $dsp = DataStore::Product->new( uri => 'http://example.org/index.html' ); 72 }; 73 like($@, qr/uri ends with \/index.txt/, 74 '->new() fails when uri param does not end with /index.txt'); 75 76 eval { 77 my $dsp = DataStore::Product->new( uri => '://example.org/index.txt' ); 72 78 }; 73 79 like($@, qr/is valid http uri/, … … 76 82 eval { 77 83 my $dsp = DataStore::Product->new( 78 uri => 'http://example.org/ ',84 uri => 'http://example.org/index.txt', 79 85 last_fileset => '++12buckelyourshoe', 80 86 ); … … 130 136 print $server->Start(), "\n"; 131 137 132 $server->RegisterURL('/ ', \&bar);138 $server->RegisterURL('/index.txt', \&bar); 133 139 $server->Process(); # Run forever 134 140 … … 140 146 141 147 { 142 my $dsp = DataStore::Product->new( uri => "http://localhost:$port/ " );148 my $dsp = DataStore::Product->new( uri => "http://localhost:$port/index.txt" ); 143 149 144 150 isa_ok($dsp->request, 'DataStore::Response'); … … 146 152 147 153 { 148 my $dsp = DataStore::Product->new( uri => "http://localhost:$port/ " );154 my $dsp = DataStore::Product->new( uri => "http://localhost:$port/index.txt" ); 149 155 150 156 my $dsr = $dsp->request; … … 168 174 169 175 eval { 170 my $dsp = DataStore::Product->new( uri => 'http://example.org/ ' );176 my $dsp = DataStore::Product->new( uri => 'http://example.org/index.txt' ); 171 177 172 178 $dsp->request( foo => 1 ); -
trunk/DataStore/t/08_response.t
r7951 r15020 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 08_response.t,v 1. 2 2006-07-22 01:17:34 smalleExp $5 # $Id: 08_response.t,v 1.3 2007-09-25 23:37:44 jhoblitt Exp $ 6 6 7 7 use strict; … … 43 43 status_line => 'foo', 44 44 data => 'bar', 45 request => DataStore::Product->new( uri => 'http://example.org/ ' ),45 request => DataStore::Product->new( uri => 'http://example.org/index.txt' ), 46 46 ); 47 47 … … 55 55 status_line => 'foo', 56 56 data => 'bar', 57 request => DataStore::Product->new( uri => 'http://example.org/ ' ),57 request => DataStore::Product->new( uri => 'http://example.org/index.txt' ), 58 58 foo => 1, 59 59 );
Note:
See TracChangeset
for help on using the changeset viewer.
