Bump required version of Alien::ActiveMQ
[catagits/Catalyst-Engine-STOMP.git] / t / Catalyst-Engine-Stomp.t
index e96c028..ea2e699 100644 (file)
@@ -1,5 +1,4 @@
-use Test::More tests => 14;
-use Test::Fork;
+use Test::More;
 
 # Tests which expect a STOMP server like ActiveMQ to exist on
 # localhost:61613, which is what you get if you just get the ActiveMQ
@@ -9,15 +8,44 @@ use Net::Stomp;
 use YAML::XS qw/ Dump Load /;
 use Data::Dumper;
 
+use Alien::ActiveMQ;
+my $ACTIVEMQ_VERSION = '5.2.0';
+
+my ($stomp, $mq);
+eval {
+    $stomp = Net::Stomp->new( { hostname => 'localhost', port => 61613 } );
+};
+if ($@) {
+
+    unless (Alien::ActiveMQ->is_version_installed($ACTIVEMQ_VERSION)) {
+        plan 'skip_all' => 'No ActiveMQ server installed by Alien::ActiveMQ, try running the "install-activemq" command'; 
+        exit;
+    }
+
+    $mq = Alien::ActiveMQ->run_server($ACTIVEMQ_VERSION);
+
+    eval {
+        $stomp = Net::Stomp->new( { hostname => 'localhost', port => 61613 } );
+    };
+    if ($@) {
+        plan 'skip_all' => 'No ActiveMQ server listening on 61613: ' . $@;
+        exit;
+    }
+}
+
+plan tests => 12;
+
 # First fire off the server
-my $child_pid = fork_ok(1, sub {
-  ok(system("$^X -Ilib -Itestapp/lib testapp/script/testapp_stomp.pl --oneshot"));
-  #sleep 3;
-});
+$SIG{CHLD} = 'IGNORE';
+unless (fork()) {
+       system("$^X -Ilib -Itestapp/lib testapp/script/stomptestapp_stomp.pl --oneshot");
+       exit 0;
+}
+print STDERR "server started, waiting for spinup...";
+sleep 20;
 
 # Now be a client to that server
-
-my $stomp = Net::Stomp->new( { hostname => 'localhost', port => 61613 } );
+print STDERR "testing\n";
 ok($stomp, 'Net::Stomp object');
 
 my $frame = $stomp->connect();