From: Martin Mares Date: Mon, 4 Jun 2007 15:49:53 +0000 (+0200) Subject: Rewritten test utility to use Sherlock::Object. X-Git-Tag: python-dummy-working~403 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=b5efa0af51b26aa7869d3961d4bd58a2a991c0e3;p=moe.git Rewritten test utility to use Sherlock::Object. --- 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;