X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=sc-emulator.pl;h=319bdf57caa94d08e829f87f6accdde564994058;hb=40e0f366a9116d2c0d0cfe5a4213ff32e0f5b1a6;hp=9bdf08a1af0260b5cc8915e0a087d58536b764ee;hpb=8993376bfa0215ff5f359d01ad8689dc3dc894aa;p=Biblio-SIP2.git diff --git a/sc-emulator.pl b/sc-emulator.pl index 9bdf08a..319bdf5 100755 --- a/sc-emulator.pl +++ b/sc-emulator.pl @@ -3,47 +3,37 @@ use warnings; use strict; -use IO::Socket::INET; -use autodie; - our $user = 'sip2-user'; our $password = 'sip2-paasswd'; our $patron = 200000000042; -our $barcode = 1301132799; +our $barcode = 1302029710; our $loc = 'FFZG'; require 'config.pl' if -e 'config.pl'; -use SIP2; - -our $sock = IO::Socket::INET->new( '10.60.0.251:6001' ); - - -sub sip2 { - my ( $send, $patt ) = @_; - SIP2::dump_message '>>>>', $send; - print $sock "$send\r\n"; - $sock->flush; +use lib 'lib'; +use SIP2::SC; -# local $/ = "\r"; - - my $in = <$sock>; - SIP2::dump_message '<<<<', $in; - die "expected $patt" unless $in =~ $patt; -} +my $sc = SIP2::SC->new( $ENV{ACS} || '10.60.0.251:6001' ); # login -sip2 "9300CN$user|CO$password|" => qr/^941/; +$sc->message("9300CN$user|CO$password|"); # SC Status -sip2 "9900302.00" => qr/^98/; +$sc->message("9900302.00"); -# Patron Information -sip2 "6300020091214 085452 AO$loc|AA$patron|AC$password|" => qr/^64/; +$sc->message("6300020091214 085452 AO$loc|AA$patron|AC$password|"); # Checkout -sip2 "11YN20091214 124436 AO$loc|AA$patron|AB$barcode|AC$password|BON|BIN|" => qw/12/; +$sc->message("11YN20091214 124436 AO$loc|AA$patron|AB$barcode|AC$password|BON|BIN|"); # Checkin -sip2 "09N20091214 08142820091214 081428AP|AO$loc|AB$barcode|AC|BIN|" => qr/^10/; +$sc->message("09N20091214 08142820091214 081428AP|AO$loc|AB$barcode|AC|BIN|"); + + +# checkout - invalid barcode +$sc->message("09N20091216 15320820091216 153208AP|AOFFZG|AB200903160190|ACviva2koha|BIN|"); + +# status +$sc->message("9900302.00");