Fixing uncaught exceptions.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Record / Fetch.pm
1 # $Id: Fetch.pm,v 1.2 2006-10-25 08:40:53 sondberg Exp $
2
3 # See the "Main" test package for documentation
4
5 package ZOOM::IRSpy::Test::Record::Fetch;
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 @syntax = ( 'canmarc',
19                    'danmarc',
20                    'grs-1',
21                    'ibermarc',
22                    'intermarc',
23                    'jpmarc',
24                    'librismarc',
25                    'mab',
26                    'normarc',
27                    'opac',
28                    'picamarc',
29                    'rusmarc',
30                    'summary',
31                    'sutrs',
32                    'swemarc',
33                    'ukmarc',
34                    'unimarc',
35                    'usmarc',
36                    'xml'
37                 );
38
39     foreach my $syn (@syntax) {
40         $conn->option('preferredRecordSyntax' => $syn);
41         $conn->option('start'   => 0);
42         $conn->option('count'   => 1);
43
44         ## Here I want to get a use attribute from the session, which we've
45         ## managed to search for in the Search/Bib1 or Search/Dan1 tests. But
46         ## how? So far we search for title: 1=4
47         $conn->irspy_search_pqf("\@attr 1=4 mineral",
48                                 {'syntax' => $syn},
49                                 ZOOM::Event::RECV_RECORD, \&record,
50                                 exception => \&error);
51     }
52 }
53
54
55 sub record {
56     my($conn, $task, $test_args, $event) = @_;
57     my $syn = $test_args->{'syntax'};
58
59     $conn->log("irspy_test", "Successfully retrieved a $syn record");
60     $conn->record()->store_result('record_fetch',
61                                   'syntax'   => $syn,
62                                   'ok'       => 1);
63
64     return ZOOM::IRSpy::Status::TASK_DONE;
65 }
66
67
68 sub error {
69     my($conn, $task, $test_args, $exception) = @_;
70     my $syn = $test_args->{'syntax'};
71
72     $conn->log("irspy_test", "Retrieval of $syn record failed:", $exception);
73     $conn->record()->store_result('record_fetch',
74                                   'syntax'       => $syn,
75                                   'ok'        => 0);
76     return ZOOM::IRSpy::Status::TASK_DONE;
77 }
78
79
80 1;