#!/usr/bin/perl -w
-## $Id: ztest.pl,v 1.13 2004-05-28 20:27:16 sondberg Exp $
+## $Id: ztest.pl,v 1.17 2007-03-08 14:51:32 mike Exp $
## ------------------------------------------------------------------
##
## Copyright (c) 2000-2004, Index Data.
##
use ExtUtils::testlib;
+use Data::Dumper;
use Net::Z3950::SimpleServer;
use Net::Z3950::OID;
use strict;
}
+
+sub my_sort_handler {
+ my ($args) = @_;
+
+ print "Sort handler called\n";
+ print Dumper( $args );
+}
+
sub my_scan_handler {
my $args = shift;
my $term = $args->{TERM};
}
+my $_fail_frequency = 0;
+my $_counter = 0;
+
sub my_search_handler {
my $args = shift;
+
my $data = [{
name => "Peter Dornan",
title => "Spokesman",
$args->{HITS} = $hits;
$session->{$set_id} = $data;
$session->{__HITS} = $hits;
+ if ($_fail_frequency != 0 && ++$_counter % $_fail_frequency == 0) {
+ print "Exiting to be nasty to client\n";
+ exit(1);
+ }
}
}
}
+Net::Z3950::SimpleServer::yazlog("hello");
my $handler = new Net::Z3950::SimpleServer(
INIT => "main::my_init_handler",
SEARCH => "main::my_search_handler",
SCAN => "main::my_scan_handler",
+ SORT => "main::my_sort_handler",
FETCH => "main::my_fetch_handler" );
+if (@ARGV >= 2 && $ARGV[0] eq "-n") {
+ $_fail_frequency = $ARGV[1];
+ shift;
+ shift;
+}
$handler->launch_server("ztest.pl", @ARGV);