3 # Tests which expect a STOMP server like ActiveMQ to exist on
4 # localhost:61613, which is what you get if you just get the ActiveMQ
5 # distro and run its out-of-the-box config.
8 use YAML::XS qw/ Dump Load /;
12 my $ACTIVEMQ_VERSION = '5.2.0';
14 unless (Alien::ActiveMQ->is_version_installed($ACTIVEMQ_VERSION)) {
15 plan 'skip_all' => 'No ActiveMQ server installed by Alien::ActiveMQ, try running the "install-activemq" command';
18 my $mq = Alien::ActiveMQ->run_server($ACTIVEMQ_VERSION);
22 $stomp = Net::Stomp->new( { hostname => 'localhost', port => 61613 } );
25 plan 'skip_all' => 'No ActiveMQ server listening on 61613: ' . $@;
32 # First fire off the server
33 $SIG{CHLD} = 'IGNORE';
35 system("$^X -Ilib -Itestapp/lib testapp/script/stomptestapp_stomp.pl --oneshot");
38 print STDERR "server started, waiting for spinup...";
41 # Now be a client to that server
42 print STDERR "testing\n";
43 ok($stomp, 'Net::Stomp object');
45 my $frame = $stomp->connect();
46 ok($frame, 'connect to MQ server ok');
48 my $reply_to = sprintf '%s:1', $frame->headers->{session};
49 ok($frame->headers->{session}, 'got a session');
50 ok(length $reply_to > 2, 'valid-looking reply_to queue');
52 ok($stomp->subscribe( { destination => '/temp-queue/reply' } ), 'subscribe to temp queue');
55 payload => { foo => 1, bar => 2 },
56 reply_to => $reply_to,
59 my $text = Dump($message);
60 ok($text, 'compose message');
62 $stomp->send( { destination => '/queue/testcontroller', body => $text } );
64 my $reply_frame = $stomp->receive_frame();
65 ok($reply_frame, 'got a reply');
66 ok($reply_frame->headers->{destination} eq "/remote-temp-queue/$reply_to", 'came to correct temp queue');
67 ok($reply_frame->body, 'has a body');
69 my $response = Load($reply_frame->body);
70 ok($response, 'YAML response ok');
71 ok($response->{type} eq 'testaction_response', 'correct type');
73 ok($stomp->disconnect, 'disconnected');