Commit | Line | Data |
8edb2b46 |
1 | use strict; |
2 | use warnings; |
bf8937b7 |
3 | use 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 | |
9 | use Net::Stomp; |
10 | use YAML::XS qw/ Dump Load /; |
11 | use Data::Dumper; |
12 | |
13 | use FindBin; |
8edb2b46 |
14 | use lib "$FindBin::Bin/lib"; |
15 | use TestServer; |
16 | |
17 | my $stomp = start_server(); |
bf8937b7 |
18 | |
19 | plan tests => 11; |
20 | |
21 | my $frame = $stomp->connect(); |
22 | ok($frame, 'connect to MQ server ok'); |
23 | |
24 | my $reply_to = sprintf '%s:1', $frame->headers->{session}; |
25 | ok($frame->headers->{session}, 'got a session'); |
26 | ok(length $reply_to > 2, 'valid-looking reply_to queue'); |
27 | |
28 | ok($stomp->subscribe( { destination => '/temp-queue/reply' } ), 'subscribe to temp queue'); |
29 | |
30 | my $message = { |
31 | payload => { foo => 1, bar => 2 }, |
32 | reply_to => $reply_to, |
33 | type => 'testaction', |
34 | }; |
35 | my $text = Dump($message); |
36 | ok($text, 'compose message'); |
37 | |
38 | $stomp->send( { destination => '/queue/testcontroller', body => $text } ); |
39 | |
40 | my $reply_frame = $stomp->receive_frame(); |
41 | ok($reply_frame, 'got a reply'); |
42 | ok($reply_frame->headers->{destination} eq "/remote-temp-queue/$reply_to", 'came to correct temp queue'); |
43 | ok($reply_frame->body, 'has a body'); |
44 | |
45 | my $response = Load($reply_frame->body); |
46 | ok($response, 'YAML response ok'); |
47 | ok($response->{type} eq 'testaction_response', 'correct type'); |
48 | |
49 | ok($stomp->disconnect, 'disconnected'); |
50 | |