Changeset 6584 for trunk/DataStore/t/05_product.t
- Timestamp:
- Mar 14, 2006, 1:24:05 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/DataStore/t/05_product.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStore/t/05_product.t
r6538 r6584 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 05_product.t,v 1. 1 2006-03-08 00:02:43jhoblitt Exp $5 # $Id: 05_product.t,v 1.2 2006-03-14 23:24:05 jhoblitt Exp $ 6 6 7 7 use strict; … … 10 10 use lib qw( ./lib ./t ); 11 11 12 use Test::More tests => 10;12 use Test::More tests => 21; 13 13 14 14 =head1 NAME … … 99 99 # ->request() 100 100 101 use Net::HTTPServer; 102 103 sub bar 104 { 105 my $req = shift; # Net::HTTPServer::Request object 106 my $res = $req->Response(); # Net::HTTPServer::Response object 107 108 my $string = <<END; 109 # filesetID|time registered |type |telescope pointing |etime|f|airmass| 110 otis0123456|2006-01-01T00:03:04Z|object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 111 otis0123456|2006-01-01T00:03:04Z|object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 112 otis0123456|2006-01-01T00:03:04Z|object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 113 otis0123456|2006-01-01T00:03:04Z|object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 114 END 115 116 $res->Print($string); 117 118 return $res; 119 } 120 121 $|++; 122 123 $SIG{CHLD} = 'IGNORE'; 124 my $pid = open(my $child, "-|"); 125 126 unless ($pid) { 127 my $server = new Net::HTTPServer( port => 'scan' ); 128 129 # send port number to parent 130 print $server->Start(), "\n"; 131 132 $server->RegisterURL('/', \&bar); 133 $server->Process(); # Run forever 134 135 exit -1; 136 } 137 138 my $port = <$child>; 139 chomp $port; 140 141 { 142 my $dsp = DataStore::Product->new( uri => "http://localhost:$port/" ); 143 144 isa_ok($dsp->request, 'DataStore::Response'); 145 } 146 147 { 148 my $dsp = DataStore::Product->new( uri => "http://localhost:$port/" ); 149 150 my $dsr = $dsp->request; 151 152 ok($dsr->is_success, "response->is_success() is correct"); 153 is($dsr->code, 200, "response->code() is correct"); 154 is($dsr->status_line, "200 OK", "response->status_line() is correct"); 155 is(ref $dsr->data, 'ARRAY', "response->data is arrayref is correct"); 156 isa_ok($dsr->request, 'DataStore::Record'); 157 158 my $data = $dsr->data; 159 is(scalar @$data, 4, "data has the correct number of rows"); 160 isa_ok(@$data[0], 'DataStore::FileSet', "data has correct type of rows"); 161 isa_ok(@$data[1], 'DataStore::FileSet', "data has correct type of rows"); 162 isa_ok(@$data[2], 'DataStore::FileSet', "data has correct type of rows"); 163 isa_ok(@$data[3], 'DataStore::FileSet', "data has correct type of rows"); 164 } 165 166 # cleanup HTTP server 167 kill 9, $pid;
Note:
See TracChangeset
for help on using the changeset viewer.
