5a5385c17f29dd99ba39951bf6e13a011eff6f33
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Test / Search / CQL.pm
1 # $Id: CQL.pm,v 1.1 2007-05-01 15:32:16 mike Exp $
2
3 # See the "Main" test package for documentation
4
5 package ZOOM::IRSpy::Test::Search::CQL;
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
19     ### More indexes could be added here
20     my @indexes = qw(cql.serverChoice cql.anywhere cql.allRecords
21                      rec.id
22                      net.host net.port
23                      dc.title dc.creator dc.description
24                      zeerex.numberOfRecords zeerex.set
25                      );
26
27     foreach my $index (@indexes) {
28         $conn->irspy_search(cql => "$index=mineral",
29                             { index => $index }, {},
30                             ZOOM::Event::ZEND, \&found,
31                             exception => \&error);
32     }
33 }
34
35
36 sub found {
37     my($conn, $task, $udata, $event) = @_;
38     my $index = $udata->{"index"};
39
40     my $n = $task->{rs}->size();
41     $task->{rs}->destroy();
42     $conn->log("irspy_test",
43                "CQL search on '$index' found $n record", $n==1 ? "" : "s");
44     $conn->record()->store_result("search_cql", index => $index, ok => 1);
45     return ZOOM::IRSpy::Status::TASK_DONE;
46 }
47
48
49 sub error {
50     my($conn, $task, $udata, $exception) = @_;
51     my $index = $udata->{"index"};
52
53     $task->{rs}->destroy();
54     $conn->log("irspy_test", "CQL search on '$index' had error: $exception");
55     $conn->record()->store_result("search_cql", index => $index, ok => 0);
56     return ZOOM::IRSpy::Status::TEST_BAD
57         if $exception->code() == 11; # Unsupported query type
58
59     return ZOOM::IRSpy::Status::TASK_DONE;
60 }
61
62
63 1;