APP-REST-RestTestSuite

 view release on metacpan or  search on metacpan

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN



=cut

sub get_test_cases {
    my ( $self, %args ) = @_;

    if ( $self->{test_cases} ) {
        return %{ $self->{test_cases} };
    } else {
        return undef;
    }
}

=head2 get_log_file_handle


=cut

sub get_log_file_handle {
    my ( $self, %args ) = @_;

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

}

=head2 validate_test_cases


=cut

sub validate_test_cases {
    my ($self) = shift;

    my $err = undef;

    unless (@_) {
        $err = "There is no test cases defined to execute.\n";
    } elsif ( ( (@_) % 2 ) == 1 ) {
        $err =
            "Test cases are not properly configured in '"
          . $self->get_config_file()
          . "'\nDefine test cases properly.\nPlease see the README file for more info.\n";
    }
    return $err if ($err);

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

    my %test_cases = @_;

    my $ua = LWP::UserAgent->new;

    $ua->agent("RTAT/$VERSION");
    $ua->timeout(90);    # in seconds
    $ua->default_header('Accept' => '*/*'); # to get cross platform support


    my ( $config, $total, $total_response_time, $skip, $pass, $fail ) = (0) x 6;
    my ( $uri, $method, $req_content_type, $req_body, $status ) = (undef) x 5;
    my ( $request,  $response ) = (undef) x 2;
    my ( $username, $password ) = (undef) x 2;

    $username = $self->{username};
    $password = $self->{password};

    my $fh     = $self->get_log_file_handle();
    my $err_fh = $self->get_err_log_file_handle();

    if ( $self->{html_log_required}
        && ( $self->{html_log_required} =~ /yes/i ) )
    {

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

    my $pua = APP::REST::ParallelMyUA->new();

    $pua->agent("RTAT/$VERSION");
    $pua->in_order(1);      # handle requests in order of registration
    $pua->duplicates(0);    # ignore duplicates
    $pua->timeout(60);      # in seconds
    $pua->redirect(1);      # follow redirects
    $pua->default_header('Accept' => '*/*'); # to get cross platform support

    my ( $config, $total, $total_response_time, $skip, $pass, $fail ) = (0) x 6;
    my ( $uri, $method, $req_content_type, $req_body, $status ) = (undef) x 5;
    my ( $request,  $response ) = (undef) x 2;
    my ( $username, $password ) = (undef) x 2;

    $username = $self->{username};
    $password = $self->{password};

    my $fh = $self->get_log_file_handle();

    if ( $self->{html_log_required}
        && ( $self->{html_log_required} =~ /yes/i ) )
    {
        print $fh

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

}

sub _init_read_config {
    my ( $self, %args ) = @_;

    my $fh = $self->get_config_file_handle();

    my @buffer           = ();
    my @start_end_buffer = ();

    my ( $start_case, $end_case, $test_no ) = (undef) x 3;
    my ( $start_common,    $end_common )    = (undef) x 2;
    my ( $start_http_code, $end_http_code ) = (undef) x 2;
    my ( $start_tag, $lines_between, $end_tag ) = (undef) x 3;

    my $separator = ":";    # separator used in config file for key/value pair
    my %start_end_hash;

    my $file = $self->{file};

    while (<$fh>) {

        push (@{$file->{config_file_content}} , $_);
        _trim( chomp($_) );

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

            : ERR_LOG_FILE
        )
    );
    $self->{file}->{log_file}     = $log_file;
    $self->{file}->{err_log_file} = $error_log_file;
}

sub _open_fh {
    my ( $self, %args ) = @_;

    my ( $fh, $err ) = (undef) x 2;

    my $file = $args{FILE};
    my $mode = $args{MODE};

    if ( $mode =~ m/READ/i ) {
        open( $fh, '<', "$file" ) or ( $err = 'yes' );
    } elsif ( $mode =~ m/WRITE/i ) {
        open( $fh, '>', "$file" ) or ( $err = 'yes' );
    } elsif ( $mode =~ m/APPEND/i ) {
        open( $fh, '>>', "$file" ) or ( $err = 'yes' );

lib/APP/REST/RestTestSuite.pm  view on Meta::CPAN

        print $fh "\n\nTest execution time => ";
        print $fh $args{exec_time};
        print $fh " milli seconds";
        print $fh "\n", LINE, "\n";
    }

}

sub _compare_arrays {
    my ( $first, $second ) = @_;
    no warnings;    # silence spurious -w undef complaints
    return 0 unless @$first == @$second;
    for ( my $i = 0 ; $i < @$first ; $i++ ) {
        return 0 if $first->[$i] ne $second->[$i];
    }
    return 1;
}

=head1 AUTHOR

Mithun Radhakrishnan, C<< <rkmithun at cpan.org> >>



( run in 1.916 second using v1.01-cache-2.11-cpan-d80b1682f3f )