a7f35196b190c61ff9de30e7953524fb2adb5fee
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / DBDate.pm
1 # $Id: DBDate.pm,v 1.3 2006-11-29 18:18:38 mike Exp $
2
3 # This plugin tests searching on BIB-1 access-point 1011 (Date/time
4 # added to db), the significance of which is that this search
5 # "succeeds" on some of our test databases
6 # (e.g. bagel.indexdata.com:210/marc) and fails on others
7 # (e.g. z3950.loc.gov:7090/Voyager gives error 114 "Unsupported Use
8 # attribute").  This allows us to test IRSpy's differing behaviour
9 # when a test succeeds or fails.
10
11 package ZOOM::IRSpy::Test::Search::DBDate;
12
13 use 5.008;
14 use strict;
15 use warnings;
16
17 use ZOOM::IRSpy::Test;
18 our @ISA = qw(ZOOM::IRSpy::Test);
19
20 use ZOOM::IRSpy::Utils qw(isodate);
21
22
23 sub start {
24     my $class = shift();
25     my($conn) = @_;
26
27     $conn->irspy_search_pqf('@attr 1=1011 mineral', undef, {},
28                             ZOOM::Event::RECV_SEARCH, \&found,
29                             "exception", \&error);
30 }
31
32
33 sub found {
34     my($conn, $task, $__UNUSED_udata, $event) = @_;
35
36     my $n = $task->{rs}->size();
37     $conn->log("irspy_test",
38                "DB-date search found $n record", $n==1 ? "" : "s");
39     my $rec = $conn->record();
40     $rec->append_entry("irspy:status", "<irspy:search_dbdate ok='1'>" .
41                        isodate(time()) . "</irspy:search_dbdate>");
42
43     return ZOOM::IRSpy::Status::TASK_DONE;
44 }
45
46
47 sub error {
48     my($conn, $task, $__UNUSED_udata, $exception) = @_;
49
50     $conn->log("irspy_test", "DB-date search had error: $exception");
51     my $rec = $conn->record();
52     $rec->append_entry("irspy:status", "<irspy:search_dbdate ok='0'>" .
53                        isodate(time()) . "</irspy:search_dbdate>");
54     return ZOOM::IRSpy::Status::TEST_BAD;
55 }
56
57
58 1;