[libanyevent-rabbitmq-perl] 124/151: Update tests to work with all new features, and test some of them.

Damyan Ivanov dmn at moszumanska.debian.org
Thu Jan 16 11:03:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

dmn pushed a commit to annotated tag debian/1.12-1
in repository libanyevent-rabbitmq-perl.

commit fccb0da8ad152151f4e32878402674fb2a4336ea
Author: Chip Salzenberg <chip at topsy.com>
Date:   Tue Sep 18 13:29:59 2012 -0700

    Update tests to work with all new features, and test some of them.
---
 xt/04_anyevent.t      | 80 +++++++++++++++++++++++++++++++++++++--------------
 xt/05_multi_channel.t |  2 +-
 2 files changed, 60 insertions(+), 22 deletions(-)

diff --git a/xt/04_anyevent.t b/xt/04_anyevent.t
index 205129a..515d80a 100644
--- a/xt/04_anyevent.t
+++ b/xt/04_anyevent.t
@@ -16,7 +16,7 @@ my %conf = (
     user  => 'guest',
     pass  => 'guest',
     vhost => '/',
-    verbose => 1,
+    #verbose => 1,
 );
 
 eval {
@@ -34,7 +34,7 @@ eval {
 
 plan skip_all => 'Connection failure: '
                . $conf{host} . ':' . $conf{port} if $@;
-plan tests => 31;
+plan tests => 35;
 
 use AnyEvent::RabbitMQ;
 
@@ -56,31 +56,41 @@ $ar->connect(
         $done->send;
     },
     on_failure => failure_cb($done),
-    on_close   => sub {
+    on_return  => sub {
         my $method_frame = shift->method_frame;
-        die $method_frame->reply_code, $method_frame->reply_text
+        die "return: ", $method_frame->reply_code, $method_frame->reply_text
           if $method_frame->reply_code;
     },
-);
-$done->recv;
-
-$done = AnyEvent->condvar;
-my $ch;
-$ar->open_channel(
-    on_success => sub {
-        $ch = shift;
-        isa_ok($ch, 'AnyEvent::RabbitMQ::Channel');
-        $done->send;
-    },
-    on_failure => failure_cb($done),
     on_close   => sub {
         my $method_frame = shift->method_frame;
-        die $method_frame->reply_code, $method_frame->reply_text
+        die "close: ", $method_frame->reply_code, $method_frame->reply_text
           if $method_frame->reply_code;
     },
 );
 $done->recv;
 
+my $ch;
+$done = AnyEvent->condvar;
+open_ch($done);
+$done->recv;
+
+sub open_ch {
+    my ($cv,) = @_;
+    $ar->open_channel(
+	on_success => sub {
+            $ch = shift;
+            isa_ok($ch, 'AnyEvent::RabbitMQ::Channel');
+            $cv->send;
+        },
+        on_failure => failure_cb($cv),
+        on_close   => sub {
+            my $method_frame = shift->method_frame;
+            die $method_frame->reply_code, $method_frame->reply_text
+              if $method_frame->reply_code;
+        },
+    );
+}
+
 $done = AnyEvent->condvar;
 $ch->declare_exchange(
     exchange   => 'test_x',
@@ -296,7 +306,16 @@ pass('recover');
 # This only works for RabbitMQ >= 2.0.0
 my $can_reject = $server{product} eq 'RabbitMQ' && $server{version} >= version->parse('2.0.0');
 SKIP: {
-    skip 'We need RabbitMQ >= 2.0.0 for the reject test', 1 unless $can_reject;
+    skip 'We need RabbitMQ >= 2.0.0 for the confirm and reject test', 1 unless $can_reject;
+
+    $done = AnyEvent->condvar;
+    $ch->confirm(
+	on_success => sub { $done->send },
+    	on_failure => failure_cb($done),
+    );
+    $done->recv;
+    pass('confirm');
+
     $done = AnyEvent->condvar;
     my $reject_count = 0;
     $ch->consume(
@@ -327,9 +346,28 @@ SKIP: {
         },
         on_failure => failure_cb($done),
     );
-    publish($ch, 'RabbitMQ is powerful.', $done,);
+    my $pub_done = AnyEvent->condvar;
+    publish($ch, 'RabbitMQ is powerful.', $pub_done,);
+    $pub_done->recv;
     $done->recv;
     pass('reject');
+
+    # reopen because confirm is not compatible with transactions
+    $done = AnyEvent->condvar;
+    $ch->close(
+        on_success => sub {
+            pass('close2');
+            $done->send;
+        },
+        on_failure => failure_cb($done),
+    );
+    $done->recv;
+    undef $ch;
+
+    $done = AnyEvent->condvar;
+    open_ch($done);
+    $done->recv;
+    pass('open2');
 };
 
 $done = AnyEvent->condvar;
@@ -407,7 +445,7 @@ $done->recv;
 $done = AnyEvent->condvar;
 $ar->close(
     on_success => sub {
-        pass('close');
+        pass('close2');
         $done->send;
     },
     on_failure => failure_cb($done),
@@ -429,6 +467,7 @@ sub publish {
         exchange    => 'test_x',
         routing_key => 'test_r',
         body        => $message,
+        on_ack      => sub { $cv->send },
         on_return   => sub {
             my $response = shift;
             fail('on_return: ' . Dumper($response));
@@ -454,7 +493,6 @@ sub send_large_size_message {
         on_failure => failure_cb($done),
     );
     $done->recv;
-
     return;
 }
 
diff --git a/xt/05_multi_channel.t b/xt/05_multi_channel.t
index 774129b..2c37b11 100644
--- a/xt/05_multi_channel.t
+++ b/xt/05_multi_channel.t
@@ -97,6 +97,7 @@ sub open_channel {
     $ar->open_channel(
         on_success => sub {$done->send(shift)},
         on_failure => sub {$done->send()},
+        on_return  => sub {die 'Receive return'},
         on_close   => \&handle_close,
     );
     my $ch = $done->recv;
@@ -155,7 +156,6 @@ sub publish {
         routing_key => $queue,
         body        => $message,
         mandatory   => 1,
-        on_return   => sub {die 'Receive return'},
     );
 
     return;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libanyevent-rabbitmq-perl.git



More information about the Pkg-perl-cvs-commits mailing list