Change so that ActiveMQ is only started if not already running
[catagits/Catalyst-Engine-STOMP.git] / t / Catalyst-Engine-Stomp.t
index 0739f29..ea2e699 100644 (file)
@@ -8,26 +8,41 @@ use Net::Stomp;
 use YAML::XS qw/ Dump Load /;
 use Data::Dumper;
 
-my $stomp;
+use Alien::ActiveMQ;
+my $ACTIVEMQ_VERSION = '5.2.0';
+
+my ($stomp, $mq);
 eval {
     $stomp = Net::Stomp->new( { hostname => 'localhost', port => 61613 } );
 };
 if ($@) {
-    plan 'skip_all' => 'No ActiveMQ server listening on 61613: ' . $@;
-    exit;
-}
-else {
-    plan tests => 12;
+
+    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
 $SIG{CHLD} = 'IGNORE';
 unless (fork()) {
-       system("CATALYST_DEBUG=0 $^X -Ilib -Itestapp/lib testapp/script/testapp_stomp.pl --oneshot");
+       system("$^X -Ilib -Itestapp/lib testapp/script/stomptestapp_stomp.pl --oneshot");
        exit 0;
 }
 print STDERR "server started, waiting for spinup...";
-sleep 10;
+sleep 20;
 
 # Now be a client to that server
 print STDERR "testing\n";