1 # $Id: Ping.pm,v 1.24 2007-05-03 14:43:31 mike Exp $
3 # See the "Main" test package for documentation
5 package ZOOM::IRSpy::Test::Ping;
11 use ZOOM::IRSpy::Test;
12 our @ISA = qw(ZOOM::IRSpy::Test);
14 use ZOOM::IRSpy::Utils qw(isodate);
17 my $conv = new Text::Iconv("LATIN1", "UTF8");
24 $conn->irspy_connect(undef, {},
25 ZOOM::Event::ZEND, \&connected,
26 exception => \¬_connected);
31 my($conn, $__UNUSED_task, $__UNUSED_udata, $__UNUSED_event) = @_;
33 $conn->log("irspy_test", "connected");
34 $conn->record()->store_result("probe", ok => 1);
36 foreach my $opt (qw(search present delSet resourceReport
37 triggerResourceCtrl resourceCtrl
38 accessCtrl scan sort extendedServices
39 level_1Segmentation level_2Segmentation
40 concurrentOperations namedResultSets
41 encapsulation resultCount negotiationModel
42 duplicationDetection queryType104
43 pQESCorrection stringSchema)) {
44 #print STDERR "\$conn->option('init_opt_$opt') = '", $conn->option("init_opt_$opt"), "'\n";
45 $conn->record()->store_result('init_opt', option => $opt)
46 if $conn->option("init_opt_$opt");
49 foreach my $opt (qw(serverImplementationId
50 serverImplementationName
51 serverImplementationVersion)) {
52 my $val = $conn->option($opt);
53 next if !defined $val; # not defined for SRU, for example
55 # There doesn't seem to be a reliable way to tell what
56 # character set the server uses for these. At least one
57 # server (z3950.bcl.jcyl.es:210/AbsysCCFL) returns an ISO
58 # 8859-1 string containing an o-acute, which breaks the XML
59 # parser if we just insert it naively. It seems reasonable,
60 # though, to guess that the great majority of servers will use
61 # ASCII, Latin-1 or Unicode. The first of these is a subset
62 # of the second, so that brings it to down to two. The
63 # strategy is simply this: assume it's ASCII-Latin-1, and try
64 # to convert to UTF-8. If that conversion works, fine; if
65 # not, assume it's because the string was already UTF-8, so
67 Text::Iconv->raise_error(1);
70 $maybe = $conv->convert($val);
71 }; if (!$@ && $maybe ne $val) {
72 $conn->log("irspy", "converted '$val' from Latin-1 to UTF-8");
75 $conn->record()->store_result($opt, value => $val);
78 return ZOOM::IRSpy::Status::TEST_GOOD;
83 my($conn, $__UNUSED_task, $__UNUSED_udata, $exception) = @_;
85 $conn->log("irspy_test", "not connected: $exception");
86 $conn->record()->store_result("probe",
88 errcode => $exception->code(),
89 errmsg => $exception->message(),
90 addinfo => $exception->addinfo(),
91 diagset => $exception->diagset());
93 return ZOOM::IRSpy::Status::TEST_BAD;