7dc644e1fb7e9c86f56ac8cc20b683b68df9e424
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / Bib1.pm
1 # $Id: Bib1.pm,v 1.18 2007-03-15 11:40:27 mike Exp $
2
3 # See the "Main" test package for documentation
4
5 package ZOOM::IRSpy::Test::Search::Bib1;
6
7 use 5.008;
8 use strict;
9 use warnings;
10
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
13
14
15 sub start {
16     my $class = shift();
17     my($conn) = @_;
18     my @attrs = ( 1..63, 1000..1036,            # Bib-1
19                   1037..1096, 1185..1209,       # Extended Bib-1
20                   1097..1111,                   # Dublin-Core
21                   1112..1184                    # GILS
22                 );
23
24     foreach my $attr (@attrs) {
25         $conn->irspy_search_pqf("\@attr 1=$attr mineral",
26                                 {'attr' => $attr}, {},
27                                 ZOOM::Event::ZEND, \&found,
28                                 exception => \&error);
29     }
30 }
31
32
33 sub found {
34     my($conn, $task, $test_args, $event) = @_;
35     my $attr = $test_args->{'attr'};
36
37     my $n = $task->{rs}->size();
38     $task->{rs}->destroy();
39     $conn->log("irspy_test", "search on access-point $attr found $n record",
40                $n==1 ? "" : "s");
41     update($conn, $attr, 1);
42
43     return ZOOM::IRSpy::Status::TASK_DONE;
44 }
45
46
47 sub error {
48     my($conn, $task, $test_args, $exception) = @_;
49     my $attr = $test_args->{'attr'};
50
51     $task->{rs}->destroy();
52     $conn->log("irspy_test", "search on access-point $attr had error: ",
53                $exception);
54     update($conn, $attr, 0);
55
56     return ZOOM::IRSpy::Status::TEST_BAD
57         if ($exception->code() == 1 || # permanent system error
58             $exception->code() == 235 || # Database does not exist
59             $exception->code() == 109); # Database unavailable
60
61     return ZOOM::IRSpy::Status::TASK_DONE;
62 }
63
64
65 sub update {
66     my ($conn, $attr, $ok) = @_;
67     $conn->record()->store_result('search', 'set'       => 'bib-1',
68                                             'ap'        => $attr,
69                                             'ok'        => $ok);
70 }
71
72
73 1;