Alien-ActiveMQ
view release on metacpan or search on metacpan
t/start_stop.t view on Meta::CPAN
'Found console start');
is($amq->_output_data->[-1],
'Killing ApacheMQ...',
'Found amq shutdown');
}
# Verify we still start as a class method, too.
{
my $stomp = Test::MockModule->new( 'Net::Stomp' );
my $try = 0;
# This simulates a couple of retries while the server starts.
# It also lets the process actually run.
$stomp->mock(new => sub {
$try++;
if($try < 2) {
die "Not ready.";
}
return 1;
});
no warnings qw/ redefine /;
local *Alien::ActiveMQ::_dist_dir = sub {
return $main::_dist_dir;
};
my $_output_data = [];
local *Alien::ActiveMQ::_output = sub {
my $class = shift;
push @{$_output_data}, @_;
};
my $amq = Alien::ActiveMQ->new;
is(Alien::ActiveMQ->get_version_dir('5.1.9'), $_dist_dir->subdir('5.1.9'),
'Class found older version');
{
my $server = Alien::ActiveMQ->run_server('5.1.9');
ok($server, 'Got a working amq')
}
is($_output_data->[0],
"Running " . $_dist_dir->file('5.1.9', 'bin', 'activemq'),
'Found console start');
is($_output_data->[-1],
'Killing ApacheMQ...',
'Found amq shutdown');
}
# Deal with a version that won't start - bad Java or otherwise
{
my $stomp = Test::MockModule->new( 'Net::Stomp' );
my $try = 0;
# This simulates retries forever.
$stomp->mock(new => sub {
$try++;
die "No connection";
});
my $amq = Alien::ActiveMQ::Mock->new;
is($amq->get_version_dir('5.9.9'), $_dist_dir->subdir('5.9.9'),
'Found newer version');
{
throws_ok { my $server = $amq->run_server('5.9.9'); }
qr /Can't connect to ActiveMQ after trying 3 seconds./,
'Server would not start';
}
use Data::Dumper;
is($try, 4, 'Found retries');
}
# Install one of our test versions.
sub _install_test_version {
my $version = shift;
my $i = new_ok('Alien::ActiveMQ::Install',
[
version_number => $version,
tarball => file($_data_dir, "notamq-$version-bin.tar.gz"),
install_dir => dir($_dist_dir, $version),
]);
ok($i->run, "Install version $version okay");
ok(-r file($_dist_dir, $version, 'bin', 'activemq'), 'Activemq binary installed');
return $i;
}
done_testing();
( run in 0.326 second using v1.01-cache-2.11-cpan-fa01517f264 )