X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=t%2F22-query.t;h=5da0ceb147d2c939f334b1c425a7836ea71d5a48;hb=46006e099fa9feecc5e92b727cf5c3a7f43d4a1d;hp=e0b049fc502e599fa16b942c11d79e279f7e059c;hpb=f694f18bcdf9ab24fc1df2e4b7b663f827f32c14;p=ZOOM-Perl-moved-to-github.git diff --git a/t/22-query.t b/t/22-query.t index e0b049f..5da0ceb 100644 --- a/t/22-query.t +++ b/t/22-query.t @@ -1,11 +1,11 @@ -# $Id: 22-query.t,v 1.6 2005-12-22 09:25:14 mike Exp $ +# $Id: 22-query.t,v 1.11 2006-11-02 17:48:26 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 22-query.t' use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 41; BEGIN { use_ok('ZOOM') }; #ZOOM::Log::init_level(ZOOM::Log::mask_str("zoom")); @@ -51,11 +51,12 @@ ok(1, "destroyed complex query"); # no other uses of query objects -- but we need to establish a # connection for it to work on first. -my $host = "indexdata.com/gils"; +my $host = "z3950.indexdata.com/gils"; my $conn; -eval { $conn = new ZOOM::Connection($host, 0) }; +eval { $conn = new ZOOM::Connection($host, 0, + preferredRecordSyntax => "usmarc") }; ok(!$@, "connection to '$host'"); -$conn->option(preferredRecordSyntax => "usmarc"); + ok(1, "[no need to create empty query]"); eval { $q = new ZOOM::Query::PQF('@and @attr 1=4 utah @attr 1=62 epicenter') }; @@ -82,12 +83,27 @@ ok($@ && $@->isa("ZOOM::Exception") && $@->code() == ZOOM::Error::CQL_TRANSFORM && $@->diagset() eq "ZOOM", "can't make CQL2RPN query: error " . $@->code()); -# Finally, do a successful client-compiled CQL search +# Do a successful client-compiled CQL search ok(1, "[no need to create empty query]"); $conn->option(cqlfile => "samples/cql/pqf.properties"); eval { $q = new ZOOM::Query::CQL2RPN('title=utah and description=epicenter', $conn) }; -ok(!$@, "created CQL2RPN query: \@=$@"); +ok(!$@, "created CQL2RPN query"); +check_record($conn, $q); +$q->destroy(); + +# Client-side compiled CCL: this will fail due to lack of config-file +ok(1, "[no need to create empty query]"); +eval { $q = new ZOOM::Query::CCL2RPN('ti=utah and ab=epicenter', $conn) }; +ok($@ && $@->isa("ZOOM::Exception") && + $@->code() == ZOOM::Error::CCL_CONFIG && $@->diagset() eq "ZOOM", + "can't make CCL2RPN query: error " . $@->code()); + +# Do a successful client-compiled CCL search +ok(1, "[no need to create empty query]"); +$conn->option(cclfile => "samples/ccl/default.bib"); +eval { $q = new ZOOM::Query::CCL2RPN('ti=utah and ab=epicenter', $conn) }; +ok(!$@, "created CCL2RPN query"); check_record($conn, $q); $q->destroy();