ResourcePool

 view release on metacpan or  search on metacpan

t/35CommandExecute.t  view on Meta::CPAN

}

sub getCalled($) {
	my ($self) = @_;
	return $self->{called};
}

package MyTestCommandReturnFalse;

push @MyTestCommandReturnFalse::ISA, qw(MyTestCommandOK);

sub execute($$) {
	my ($self, @args) = @_;
	$self->SUPER::execute(@args);
	return 0;
}

package MyTestCommandReturnArgument;

push @MyTestCommandReturnArgument::ISA, qw(MyTestCommandOK);

sub execute($$$) {
	my ($self, $resource, $arg) = @_;
	$self->SUPER::execute($resource);
	return $arg;
}

package MyTestCommandDie;

push @MyTestCommandDie::ISA, qw(MyTestCommandOK);

sub execute($$) {
	my ($self, @args) = @_;
	$self->SUPER::execute(@args);
	die;
}

package MyTestCommandNoFailoverException;

push @MyTestCommandNoFailoverException::ISA, qw(MyTestCommandOK);

sub execute($$) {
	my ($self, @args) = @_;
	$self->SUPER::execute(@args);
	die ResourcePool::Command::NoFailoverException->new;
}

package FunkyException;

push @FunkyException::ISA, qw(ResourcePool::Command::NoFailoverException);

sub new($$) {
	my $proto = shift;
	my $class = ref($proto) || $proto;
	my $self = {};
	bless($self, $class);
	$self->{ex} = shift;
	return $self;
}

sub ex($) {
	my ($self) = @_;
	return $self->{ex};
}

package MyTestCommandFunkyException;

push @MyTestCommandFunkyException::ISA, qw(MyTestCommandOK);

sub execute($$) {
    my ($self, @args) = @_;
    $self->SUPER::execute(@args);
    die FunkyException->new('very funky');
}

package MyTestCommandAllHooks;

push @MyTestCommandAllHooks::ISA, qw(MyTestCommandOK);

sub new($$$) {
	my $proto = shift;
	my $class = ref($proto) || $proto;
	my $self = {};
	bless($self, $class);
	$self->{ex} = shift;
	$self->{where} = shift;
	$self->{cnt}->{init} = 0;
	$self->{cnt}->{preExecute} = 0;
	$self->{cnt}->{execute} = 0;
	$self->{cnt}->{postExecute} = 0;
	$self->{cnt}->{cleanup} = 0;
	return $self;
}

sub init() {
	my ($self) = @_;
	$self->{cnt}->{init}++;
	if ($self->{where} eq 'init') {
		die $self->{ex};
	}
}

sub preExecute() {
	my ($self, $r) = @_;
	$self->{cnt}->{preExecute}++;
	if ($self->{where} eq 'preExecute') {
		die $self->{ex};
	}
}

sub execute() {
	my ($self, $r) = @_;
	$self->{cnt}->{execute}++;
	if ($self->{where} eq 'execute') {
		die $self->{ex};
	}
}

sub postExecute() {
	my ($self, $r) = @_;
	$self->{cnt}->{postExecute}++;



( run in 1.177 second using v1.01-cache-2.11-cpan-524268b4103 )