From b5efa0af51b26aa7869d3961d4bd58a2a991c0e3 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 4 Jun 2007 17:49:53 +0200 Subject: [PATCH] Rewritten test utility to use Sherlock::Object. --- submit/test.pl | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/submit/test.pl b/submit/test.pl index 0cc8be9..677346c 100755 --- a/submit/test.pl +++ b/submit/test.pl @@ -6,6 +6,9 @@ use warnings; use IO::Socket::INET; use IO::Socket::SSL; # qw(debug3); +use lib "lib/perl5"; +use Sherlock::Object; + my $sk = new IO::Socket::INET( # PeerAddr => "nikam.ms.mff.cuni.cz:443", PeerAddr => "localhost:8888", @@ -56,17 +59,31 @@ sub printobj($) { } } -sendobj({ 'U' => 'testuser' }); -recvobj(); +sub req($) { + my $x = shift @_; + $x->write($sk); + print $sk "\n"; +} + +sub reply() { + my $x = new Sherlock::Object; + $x->read($sk) or die "Incomplete reply"; + $x->get('+') or die "-" . $x->get('-') . "\n"; + return $x; +} + +my $req; +my $reply; -#sendobj({ '!' => 'SUBMIT', 'T' => 'plans', 'S' => 100, 'X' => 'c' }); -#recvobj(); -#print $sk "<"; -#foreach my $x (1..98) { print $sk "."; } -#print $sk ">"; -#recvobj(); +$req = new Sherlock::Object; +$req->set("U" => "testuser"); +req($req); +$reply = reply(); -sendobj({ '!' => 'STATUS' }); -printobj(recvobj()); +$req = new Sherlock::Object; +$req->set("!" => "STATUS"); +req($req); +$reply = reply(); +$reply->write(*STDOUT); close $sk; -- 2.39.2