John Drago > Apache2-ASP-1.56_2 > Apache2::ASP::Test::UserAgent

Download:
Apache2-ASP-1.56_2.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View Bugs
Report a bug
Source   Latest Release: Apache2-ASP-2.42

NAME ^

Apache2::ASP::Test::UserAgent - User-agent for testing Apache2::ASP web applications

SYNOPOSIS ^

  use Apache2::ASP::Test::UserAgent;
  
  my $ua = Apache2::ASP::Test::UserAgent->new( $asp );
  
  my $response = $ua->get( '/index.asp' );
  
  my $response = $ua->post( '/handlers/FormHandler', [
    username  => 'admin',
    password  => 's3cr3t',
  ]);
  
  my $response = $ua->upload( '/handlers/UploadHandler', [
    title     => 'this is my file',
    filename  => ['/path/to/file.txt']
  ]);
  
  # $response is a regular HTTP::Response object, so...:
  if( $response->is_success )
  {
    # Everything worked out OK.
  }
  else
  {
    # Request failed.
  }# end if()
  
  # Deal with forms:
  use HTML::Form;
  my $response = $ua->get( '/some-form.asp' );
  my $form = HTML::Form->parse( $response->content, '/some-form.asp' );
  $form->find_input( 'username' )->value( 'admin' );
  $form->find_input( 'password' )->value( 's3cr3t' );
  my $after_response = $ua->submit_form( $form );

DESCRIPTION ^

Apache2::ASP::Test::UserAgent offers the ability to test your web applications without requiring a running Apache webserver or direct human interaction.

Simply by using Devel::Cover you can easily generate code-coverage reports on your ASP scripts. Such coverage reports can be used to tell you what code is executed during your tests.

IMPORTANT BUG ^

After creating an instance of Apache2::ASP::Test::UserAgent you cannot print to STDOUT.

However you can warn just fine.

PUBLIC PROPERTIES ^

asp ^

Returns the Apache2::ASP object currently in use by the Apache2::ASP::Test::UserAgent object.

PUBLIC METHODS ^

new( $asp )

Constructor. The $asp argument should be an Apache2::ASP::Base object.

Returns a new Apache2::ASP::Test::UserAgent object.

add_cookie( $name, $value )

Appends a cookie to be sent on all future requests.

get( $url )

Makes a GET request to $url via Apache2::ASP::Base.

Content-encoding is application/x-www-form-urlencoded.

Returns an HTTP::Response object.

post( $url, $content )

Makes a POST request to $url via Apache2::ASP::Base, sending $content as its request data.

Content-encoding is application/x-www-form-urlencoded.

Returns an HTTP::Response object.

upload( $url, $content )

Makes a POST request to $url via Apache2::ASP::Base, sending $content as its request data.

Content-encoding is multipart/form-data.

Returns an HTTP::Response object.

submit_form( $form )

$form should be a valid HTML::Form object. The $form is submitted via its click() method, and the resulting HTTP::Request object is processed.

Returns a HTTP::Response object.

BUGS ^

It's possible that some bugs have found their way into this release.

Use RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-ASP to submit bug reports.

HOMEPAGE ^

Please visit the Apache2::ASP homepage at http://www.devstack.com/ to see examples of Apache2::ASP in action.

AUTHOR ^

John Drago mailto:jdrago_999@yahoo.com

COPYRIGHT AND LICENSE ^

Copyright 2007 John Drago, All rights reserved.

This software is free software. It may be used and distributed under the same terms as Perl itself.