AnyEvent-RabbitMQ
view release on metacpan or search on metacpan
xt/04_anyevent.t view on Meta::CPAN
use Test::More;
use Test::Exception;
use Data::Dumper;
use version 0.77;
use FindBin;
my %server = (
product => undef,
version => undef,
);
my %conf = (
host => 'localhost',
port => 5672,
user => 'guest',
pass => 'guest',
vhost => '/',
# verbose => 1,
);
eval {
use IO::Socket::INET;
my $socket = IO::Socket::INET->new(
Proto => 'tcp',
PeerAddr => $conf{host},
PeerPort => $conf{port},
Timeout => 1,
) or die 'Error connecting to AMQP Server!';
close $socket;
};
plan skip_all => 'Connection failure: '
. $conf{host} . ':' . $conf{port} if $@;
use AnyEvent::RabbitMQ;
my $ar = AnyEvent::RabbitMQ->new(verbose => $conf{verbose});
lives_ok sub {
$ar->load_xml_spec()
}, 'load xml spec';
my @nagle = ([], [nodelay => 0], [nodelay => 1]);
for my $opt (@nagle) {
my $done = AnyEvent->condvar;
my $z = AnyEvent::RabbitMQ->new(verbose => $conf{verbose});
$z->connect(
(map {$_ => $conf{$_}} qw(host port user pass vhost)),
timeout => 1,
on_success => sub {
my $ar = shift;
isa_ok($ar, 'AnyEvent::RabbitMQ');
$done->send;
},
on_failure => failure_cb($done),
on_return => sub {
my $method_frame = shift->method_frame;
die "return: ", $method_frame->reply_code, $method_frame->reply_text
if $method_frame->reply_code;
( run in 0.591 second using v1.01-cache-2.11-cpan-39bf76dae61 )