1 # $Id: Ping.pm,v 1.22 2007-03-02 12:17:33 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);
30 sub connected { maybe_connected(@_, 1) }
31 sub not_connected { maybe_connected(@_, 0) }
34 my($conn, $task, $__UNUSED_udata, $event, $ok) = @_;
36 $conn->log("irspy_test", ($ok ? "" : "not "), "connected");
37 my $rec = $conn->record();
38 $rec->append_entry("irspy:status", "<irspy:probe ok='$ok'>" .
39 isodate(time()) . "</irspy:probe>");
42 foreach my $opt (qw(search present delSet resourceReport
43 triggerResourceCtrl resourceCtrl
44 accessCtrl scan sort extendedServices
45 level_1Segmentation level_2Segmentation
46 concurrentOperations namedResultSets
47 encapsulation resultCount negotiationModel
48 duplicationDetection queryType104
49 pQESCorrection stringSchema)) {
50 #print STDERR "\$conn->option('init_opt_$opt') = '", $conn->option("init_opt_$opt"), "'\n";
51 $conn->record()->store_result('init_opt', option => $opt)
52 if $conn->option("init_opt_$opt");
55 foreach my $opt (qw(serverImplementationId
56 serverImplementationName
57 serverImplementationVersion)) {
58 # There doesn't seem to be a reliable way to tell what
59 # character set the server uses for these. At least one
60 # server (z3950.bcl.jcyl.es:210/AbsysCCFL) returns an ISO
61 # 8859-1 string containing an o-acute, which breaks the
62 # XML parser if we just insert it naively. It seems
63 # reasonable, though, to guess that the great majority of
64 # servers will use ASCII, Latin-1 or Unicode. The first
65 # of these is a subset of the second, so that brings it to
66 # down to two. The strategy is simply this: assume it's
67 # ASCII-Latin-1, and try to convert to UTF-8. If that
68 # conversion works, fine; if not, assume it's because the
69 # string was already UTF-8, so use it as is.
70 my $val = $conn->option($opt);
71 Text::Iconv->raise_error(1);
74 $maybe = $conv->convert($val);
75 }; if (!$@ && $maybe ne $val) {
76 $conn->log("irspy", "converted '$val' from Latin-1 to UTF-8");
79 $conn->record()->store_result($opt, value => $val);
84 return $ok ? ZOOM::IRSpy::Status::TEST_GOOD :
85 ZOOM::IRSpy::Status::TEST_BAD;