projects
/
simpleserver-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set global handle before calling start_server()
[simpleserver-moved-to-github.git]
/
ztest.pl
diff --git
a/ztest.pl
b/ztest.pl
index
1376453
..
ea330b0
100755
(executable)
--- a/
ztest.pl
+++ b/
ztest.pl
@@
-1,6
+1,6
@@
#!/usr/bin/perl -w
#!/usr/bin/perl -w
-## $Id: ztest.pl,v 1.14 2005-11-09 09:35:47 adam Exp $
+## $Id: ztest.pl,v 1.17 2007-03-08 14:51:32 mike Exp $
## ------------------------------------------------------------------
##
## Copyright (c) 2000-2004, Index Data.
## ------------------------------------------------------------------
##
## Copyright (c) 2000-2004, Index Data.
@@
-29,6
+29,7
@@
##
use ExtUtils::testlib;
##
use ExtUtils::testlib;
+use Data::Dumper;
use Net::Z3950::SimpleServer;
use Net::Z3950::OID;
use strict;
use Net::Z3950::SimpleServer;
use Net::Z3950::OID;
use strict;
@@
-58,6
+59,14
@@
sub my_init_handler {
}
}
+
+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};
sub my_scan_handler {
my $args = shift;
my $term = $args->{TERM};
@@
-91,8
+100,12
@@
sub my_scan_handler {
}
}
+my $_fail_frequency = 0;
+my $_counter = 0;
+
sub my_search_handler {
my $args = shift;
sub my_search_handler {
my $args = shift;
+
my $data = [{
name => "Peter Dornan",
title => "Spokesman",
my $data = [{
name => "Peter Dornan",
title => "Spokesman",
@@
-122,6
+135,10
@@
sub my_search_handler {
$args->{HITS} = $hits;
$session->{$set_id} = $data;
$session->{__HITS} = $hits;
$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);
+ }
}
}
@@
-154,6
+171,12
@@
my $handler = new Net::Z3950::SimpleServer(
INIT => "main::my_init_handler",
SEARCH => "main::my_search_handler",
SCAN => "main::my_scan_handler",
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" );
FETCH => "main::my_fetch_handler" );
+if (@ARGV >= 2 && $ARGV[0] eq "-n") {
+ $_fail_frequency = $ARGV[1];
+ shift;
+ shift;
+}
$handler->launch_server("ztest.pl", @ARGV);
$handler->launch_server("ztest.pl", @ARGV);