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 /;
13 $stomp = Net::Stomp->new( { hostname => 'localhost', port => 61613 } );
16 plan 'skip_all' => 'No ActiveMQ server listening on 61613: ' . $@;
23 # First fire off the server
24 $SIG{CHLD} = 'IGNORE';
26 system("CATALYST_DEBUG=0 $^X -Ilib -Itestapp/lib testapp/script/testapp_stomp.pl --oneshot");
29 print STDERR "server started, waiting for spinup...";
32 # Now be a client to that server
33 print STDERR "testing\n";
34 ok($stomp, 'Net::Stomp object');
36 my $frame = $stomp->connect();
37 ok($frame, 'connect to MQ server ok');
39 my $reply_to = sprintf '%s:1', $frame->headers->{session};
40 ok($frame->headers->{session}, 'got a session');
41 ok(length $reply_to > 2, 'valid-looking reply_to queue');
43 ok($stomp->subscribe( { destination => '/temp-queue/reply' } ), 'subscribe to temp queue');
46 payload => { foo => 1, bar => 2 },
47 reply_to => $reply_to,
50 my $text = Dump($message);
51 ok($text, 'compose message');
53 $stomp->send( { destination => '/queue/testcontroller', body => $text } );
55 my $reply_frame = $stomp->receive_frame();
56 ok($reply_frame, 'got a reply');
57 ok($reply_frame->headers->{destination} eq "/remote-temp-queue/$reply_to", 'came to correct temp queue');
58 ok($reply_frame->body, 'has a body');
60 my $response = Load($reply_frame->body);
61 ok($response, 'YAML response ok');
62 ok($response->{type} eq 'testaction_response', 'correct type');
64 ok($stomp->disconnect, 'disconnected');