Add boilderplate POD
[catagits/Catalyst-Engine-STOMP.git] / t / 11_bad-action.t
CommitLineData
8edb2b46 1use strict;
2use warnings;
bf8937b7 3use Test::More;
4
5# Tests which expect a STOMP server like ActiveMQ to exist on
6# localhost:61613, which is what you get if you just get the ActiveMQ
7# distro and run its out-of-the-box config.
8
bf8937b7 9use YAML::XS qw/ Dump Load /;
10use Data::Dumper;
11
12use FindBin;
8edb2b46 13use lib "$FindBin::Bin/lib";
14use TestServer;
15
16my $stomp = start_server();
bf8937b7 17
18plan tests => 12;
19
20my $frame = $stomp->connect();
21ok($frame, 'connect to MQ server ok');
22
23my $reply_to = sprintf '%s:1', $frame->headers->{session};
24ok($frame->headers->{session}, 'got a session');
25ok(length $reply_to > 2, 'valid-looking reply_to queue');
26
27ok($stomp->subscribe( { destination => '/temp-queue/reply' } ), 'subscribe to temp queue');
28
29# Test what happens when the action crashes
30my $message = {
31 payload => { foo => 1, bar => 2 },
32 reply_to => $reply_to,
33 type => 'badaction',
34 };
35my $text = Dump($message);
36ok($text, 'compose message for badaction');
37
38$stomp->send( { destination => '/queue/testcontroller', body => $text } );
39
40my $reply_frame = $stomp->receive_frame();
41ok($reply_frame, 'got a reply');
42ok($reply_frame->headers->{destination} eq "/remote-temp-queue/$reply_to", 'came to correct temp queue');
43ok($reply_frame->body, 'has a body');
44
45my $response = Load($reply_frame->body);
46ok($response, 'YAML response ok');
47ok($response->{status} eq 'ERROR', 'is an error');
48ok($response->{error} =~ /oh noes/);
49
50ok($stomp->disconnect, 'disconnected');
51