Alien-ActiveMQ

 view release on metacpan or  search on metacpan

inc/Module/Install.pm  view on Meta::CPAN

	# is unreliable on some platforms and requires write permissions)
	# for now we should catch this and refuse to run.
	if ( -f $0 ) {
		my $s = (stat($0))[9];

		# If the modification time is only slightly in the future,
		# sleep briefly to remove the problem.
		my $a = $s - time;
		if ( $a > 0 and $a < 5 ) { sleep 5 }

		# Too far in the future, throw an error.
		my $t = time;
		if ( $s > $t ) { die <<"END_DIE" }

Your installer $0 has a modification time in the future ($s > $t).

This is known to create infinite loops in make.

Please correct this, then run $0 again.

END_DIE

t/script.t  view on Meta::CPAN

    my $i = TestInstall->new;
    ok $i;
    ok !$i->has_version_number, 'No version number set';
    is $i->version_number, '5.10.0', 'Defaults to new version';
}
{
    my $i = new_ok('TestInstall', [ version_number => '9.2.1' ]);
    ok $i->has_version_number, 'Version number set';
    is $i->version_number, '9.2.1', 'Gets correct version';
}
throws_ok { TestInstall->new( version_number => {} ) } qr/version_number/,
    'throws when version not string';

# Test script name
{
    my $i = new_ok('TestInstall');
    is($i->script_name, 'script.t', 'Found script name');
}
# Test URI building
{
    my $i = new_ok('TestInstall');
    my $version = $i->version_number;

t/script.t  view on Meta::CPAN

    is($i->{_got_curr}, 1, 'Called download_current');
    is($i->{_got_arch}, 1, 'Called download_archive');
}

# Test downloading via mirror
{
    my $i = new_ok('TestInstall');
    no warnings 'redefine';
    local *TestInstall::_get = sub { return ''; };
    local *TestInstall::download_uri = sub { return 'nowhere'; };
    throws_ok { $i->download_current }
            qr /Failed to download mirror location nowhere/,
            'Fetch mirror failure noticed';
}
{
    my $i = new_ok('TestInstall');
    no warnings 'redefine';
    local *TestInstall::_get = sub { return '<HTML>Not a real web page.</HTML>'; };
    local *TestInstall::download_uri = sub { return 'nowhere'; };
    throws_ok { $i->download_current }
            qr /Failed to extract mirror from nowhere/,
            'Parse mirror path failure noticed';
}
{
    my $i = new_ok('TestInstall');
    no warnings 'redefine';
    local *TestInstall::download_uri = sub { return 'nowhere'; };
    local *TestInstall::_get = sub { return '<HTML>"http://apache/archive/stuff/amq-5.20-bin.tar.gz"</HTML>'; };
    local *TestInstall::_getstore = sub { return 500; };
    local *TestInstall::tarball = sub { return 'tarball' };
    throws_ok { $i->download_current }
            qr{Failed to download mirrored file http://apache/archive/stuff/amq-5.20-bin.tar.gz},
            'Parse mirror download failure noticed';
}
{
    my $i = new_ok('TestInstall');
    no warnings 'redefine';
    local *TestInstall::download_uri = sub { return 'nowhere'; };
    local *TestInstall::_get = sub { return '<HTML>"http://apache/archive/stuff/amq-5.20-bin.tar.gz"</HTML>'; };
    local *TestInstall::_getstore = sub { return 200; };
    local *TestInstall::tarball = sub { return 'tarball' };

t/script.t  view on Meta::CPAN

{
    no warnings 'redefine';
    local *TestInstall::_dircopy =  sub {
        my ($self, $from, $to) = @_;
        return dircopy($from, $to)
    };

    my $installdir = tempdir( "install-XXXXXX", DIR => dir ($FindBin::RealBin, 'run'),
        CLEANUP => !LEAVE_TEMPFILES());

    throws_ok { _install_test_version($installdir, '5.9.8'); }
        qr/^Can't read tarball/,
        'Noticed missing tarball';

    my $i = _install_test_version($installdir, '5.9.9');
    $i =  _install_test_version($installdir, '5.1.9');
}


sub _install_test_version {
    my $installdir = shift;

t/start_stop.t  view on Meta::CPAN

    # 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 {



( run in 0.629 second using v1.01-cache-2.11-cpan-496ff517765 )