use Test::More tests => 26;
use strict;
use warnings;
use_ok( 'WebService::Lucene::Results' );
use XML::Atom::Feed;
use HTTP::Response;
use WWW::OpenSearch;
use WWW::OpenSearch::Description;
use WWW::OpenSearch::Response;
{
my $xml = <<'';
Test2006-02-24T12:29:19-04:00Lucene Web Servicehttp://localhost:8080/lucene/test/Test Document 12006-01-26T16:37:44-04:00http://localhost:8080/lucene/test/1/Test Document 1
id
1
text
Test Document 1
updated
1138307864402
my $feed = XML::Atom::Feed->new( \$xml );
my $results = WebService::Lucene::Results->new_from_feed( $feed );
isa_ok( $results, 'WebService::Lucene::Results' );
isa_ok( $results->object, 'XML::Atom::Feed' );
ok( !defined $results->pager );
# iterator
{
my $documents = $results->documents;
isa_ok( $documents, 'WebService::Lucene::Iterator' );
my $count = 0;
while ( my $doc = $documents->next ) {
$count++;
if ( $count == 1 ) {
is( $doc->id, 1 );
is( $doc->text, 'Test Document 1' );
}
}
is( $count, 1 );
}
# list
{
my @documents = $results->documents;
is( scalar @documents, 1 );
is( $documents[ 0 ]->id, 1 );
is( $documents[ 0 ]->text, 'Test Document 1' );
}
{
my $link = $results->_get_link( 'self' );
is( $link, 'http://localhost:8080/lucene/test/' );
}
{
my $link = $results->_get_link( 'last' );
is( $link, 'http://localhost:8080/lucene/test/?page=1' );
}
}
{
my $xml = <<'';
20110Search results for query 'test' on index 'Test Index'2006-02-27T22:58:26-04:00Lucene Web Servicehttp://localhost:8080/lucene/test/?query=testTest Document 12006-01-26T16:37:44-04:00http://localhost:8080/lucene/test/1/Test Document 11.0