2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 16; |
use Test::More tests => 7; |
6 |
use Test::Exception; |
use Test::Exception; |
7 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
8 |
use File::Temp qw/tempdir/; |
use File::Temp qw/tempdir/; |
10 |
use blib; |
use blib; |
11 |
|
|
12 |
BEGIN { |
BEGIN { |
13 |
|
use_ok( 'WebPAC::Output::Estraier' ); |
14 |
use_ok( 'WebPAC::Search::Estraier' ); |
use_ok( 'WebPAC::Search::Estraier' ); |
15 |
use_ok( 'Log::Log4perl' ); |
use_ok( 'Log::Log4perl' ); |
16 |
} |
} |
18 |
Log::Log4perl::init('./conf/log.conf'); |
Log::Log4perl::init('./conf/log.conf'); |
19 |
ok(my $log = Log::Log4perl->get_logger('WebPAC.test'), "get_logger"); |
ok(my $log = Log::Log4perl->get_logger('WebPAC.test'), "get_logger"); |
20 |
|
|
21 |
ok(my $est = new WebPAC::Search::Estraier( |
my $config = { |
22 |
url => 'http://localhost:1978/node/webpac2', |
masterurl => 'http://localhost:1978/', |
23 |
user => 'admin', |
user => 'admin', |
24 |
passwd => 'admin', |
passwd => 'admin', |
25 |
|
database => 'webpac2test', |
26 |
encoding => 'iso-8859-2', |
encoding => 'iso-8859-2', |
27 |
log => $log, |
log => $log, |
28 |
), "new"); |
debug => 1, |
29 |
|
}; |
30 |
|
|
31 |
|
ok(my $est = new WebPAC::Output::Estraier( %{ $config } ), "new WebPAC::Output::Estraier"); |
32 |
|
|
33 |
|
ok(my $list = $est->est_master( action => 'nodelist' ), "nodelist"); |
34 |
|
|
35 |
|
like($list , qr/$config->{database}/, "$list has $config->{database}"); |
36 |
|
|
37 |
|
ok($est = new WebPAC::Search::Estraier( %{ $config } ), "new WebPAC::Search::Estraier"); |
38 |
|
|
39 |
my $query = 'ivan'; |
my $query = 'ivan'; |
40 |
my $max = 3; |
my $max = 3; |
41 |
|
|
42 |
ok(my @res = $est->search( |
ok(my @res = $est->search( |
43 |
query => $query, |
phrase => $query, |
44 |
|
get_attr => [ qw/PersonalName TitleProper/ ], |
45 |
max => $max, |
max => $max, |
|
attr => [ qw/PersonalName/ ], |
|
46 |
), "search $query, max: $max"); |
), "search $query, max: $max"); |
47 |
|
|
48 |
cmp_ok($#res, '==', $max, "$max hits"); |
cmp_ok(($#res + 1), '==', $max, "$max hits"); |
49 |
|
|
50 |
diag Dumper(\@res); |
diag Dumper(\@res); |
51 |
|
|