Change so that ActiveMQ is only started if not already running
t0m [Thu, 21 May 2009 01:11:30 +0000 (02:11 +0100)]
t/Catalyst-Engine-Stomp.t

index 9c4f148..ea2e699 100644 (file)
@@ -11,24 +11,30 @@ use Data::Dumper;
 use Alien::ActiveMQ;
 my $ACTIVEMQ_VERSION = '5.2.0';
 
-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;
-}
-my $mq = Alien::ActiveMQ->run_server($ACTIVEMQ_VERSION);
-
-my $stomp;
+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()) {