From: mike Date: Tue, 13 Jun 2006 16:14:58 +0000 (+0000) Subject: Nine new tests for client-side CCL support. X-Git-Tag: cpan_1_22~148 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=6c5da63e648176a2460785d1a3eb78706363e1e1;p=ZOOM-Perl-moved-to-github.git Nine new tests for client-side CCL support. --- diff --git a/t/12-query.t b/t/12-query.t index fac08b3..eb4fa3d 100644 --- a/t/12-query.t +++ b/t/12-query.t @@ -1,11 +1,11 @@ -# $Id: 12-query.t,v 1.5 2005-12-22 09:23:52 mike Exp $ +# $Id: 12-query.t,v 1.6 2006-06-13 16:15:12 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 12-query.t' use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 41; BEGIN { use_ok('Net::Z3950::ZOOM') }; # Net::Z3950::ZOOM::yaz_log_init_level(Net::Z3950::ZOOM::yaz_log_mask_str("zoom")); @@ -90,7 +90,7 @@ ok($res < 0 && "can't make CQL2RPN query: error " . $errcode); Net::Z3950::ZOOM::query_destroy($q); -# Finally, do a successful client-compiled CQL search +# Do a successful client-compiled CQL search $q = Net::Z3950::ZOOM::query_create(); ok(defined $q, "create empty query"); Net::Z3950::ZOOM::connection_option_set($conn, cqlfile => @@ -102,6 +102,32 @@ ok($res == 0, "created CQL2RPN query"); check_record($conn, $q); Net::Z3950::ZOOM::query_destroy($q); +# Client-side compiled CCL: this will fail due to lack of qualifier-file +$q = Net::Z3950::ZOOM::query_create(); +ok(defined $q, "create empty query"); +$res = Net::Z3950::ZOOM::query_ccl2rpn($q, + 'ti=utah and ab=epicenter', + $conn); +$errcode = Net::Z3950::ZOOM::connection_error_x($conn, $errmsg, $addinfo, + $diagset); +ok($res < 0 && + $errcode == Net::Z3950::ZOOM::ERROR_CCL_CONFIG && + $diagset eq "ZOOM", + "can't make CCL2RPN query: error " . $errcode); +Net::Z3950::ZOOM::query_destroy($q); + +# Do a successful client-compiled CCL search +$q = Net::Z3950::ZOOM::query_create(); +ok(defined $q, "create empty query"); +Net::Z3950::ZOOM::connection_option_set($conn, cclfile => + "samples/ccl/default.bib"); +$res = Net::Z3950::ZOOM::query_ccl2rpn($q, + 'ti=utah and ab=epicenter', + $conn); +ok($res == 0, "created CCL2RPN query"); +check_record($conn, $q); +Net::Z3950::ZOOM::query_destroy($q); + Net::Z3950::ZOOM::connection_destroy($conn); ok(1, "destroyed all objects"); diff --git a/t/22-query.t b/t/22-query.t index e0b049f..11a3622 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.7 2006-06-13 16:14:58 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")); @@ -82,7 +82,7 @@ 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', @@ -91,6 +91,21 @@ 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(); + $conn->destroy(); ok(1, "destroyed all objects");