Apache::testold

Apache::testold facilitates testing of Apache::* modules.
Download

Apache::testold Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Ken Williams
  • Publisher web site:
  • http://search.cpan.org/~kwilliams/Module-Build-0.2808/lib/Module/Build/Compat.pm

Apache::testold Tags


Apache::testold Description

Apache::testold facilitates testing of Apache::* modules. Apache::testold facilitates testing of Apache::* modules.SYNOPSIS # In Makefile.PL use Apache::testold; my %params = Apache::testold->get_test_params(); Apache::testold->write_httpd_conf(%params, include => $more_directives); *MY::test = sub { Apache::testold->MM_test(%params) }; # In t/*.t script (or test.pl) use Apache::testold qw(skip_test have_httpd); skip_test unless have_httpd; (Some more methods of Doug's that I haven't reviewed or documented yet)This module helps authors of Apache::* modules write test suites that can query an actual running Apache server with mod_perl and their modules loaded into it. Its functionality is generally separated into methods that go in a Makefile.PL to configure, start, and stop the server, and methods that go in one of the test scripts to make HTTP queries and manage the results.METHODSget_test_params()This will ask the user a few questions about where the httpd binary is, and what user/group/port should be used when running the server. It will return a hash of the information it discovers. This hash is suitable for passing to the write_httpd_conf() method.write_httpd_conf(%params)This will write a basic httpd.conf file suitable for starting a HTTP server during the 'make test' stage. A hash of key/value pairs that affect the written file can be passed as arguments. The following keys are recognized:conf_file The path to the file that will be created. Default is 't/httpd.conf'.port The port that the Apache server will listen on.user The user that the Apache server will run as.group The group that the Apache server will run as.include Any additional text you want added at the end of the config file. Typically you'll have some PerlModule and Perl*Handler directives to pass control to the module you're testing. The blib/ directories will be added to the @INC path when searching for modules, so that's nice.MM_test(%params)This method helps write a Makefile that supports running a web server during the 'make test' stage. When you execute 'make test', 'make' will run 'make start_httpd', 'make run_tests', and 'make kill_httpd' in sequence. You can also run these commands independently if you want.Pass the hash of parameters returned by get_test_params() as an argument to MM_test().To patch into the ExtUtils::MakeMaker wizardry (voodoo?), typically you'll do the following in your Makefile.PL: *MY::test = sub { Apache::testold->MM_test(%params) };fetch Apache::testold->fetch($request); Apache::testold->fetch($user_agent, $request);Call this method in a test script in order to fetch a page from the running web server. If you pass two arguments, the first should be an LWP::UserAgent object, and the second should specify the request to make of the server. If you only pass one argument, it specifies the request to make.The request can be specified either by a simple string indicating the URI to fetch, or by a hash reference, which gives you more control over the request. The following keys are recognized in the hash:uri The URI to fetch from the server. If the URI does not begin with "http", we prepend "http://localhost:$PORT" so that we make requests of the test server.method The request method to use. Default is 'GET'.content The request content body. Typically used to simulate HTML fill-out form submission for POST requests. Default is null.headers A hash of headers you want sent with the request. You might use this to send cookies or provide some application-specific header.If you don't provide a 'headers' parameter and you set the 'method' to 'POST', then we assume that you're trying to simulate HTML form submission and we add a 'Content_Type' header with a value of 'application/x-www-form-urlencoded'.In a scalar context, fetch() returns the content of the web server's response. In a list context, fetch() returns the content and the HTTP::Response object itself. This can be handy if you need to check the response headers, or the HTTP return code, or whatever.static_modules Example: $mods = Apache::testold->static_modules('/path/to/httpd');This method returns a hashref whose keys are all the modules statically compiled into the given httpd binary. The corresponding values are all 1. Requirements: · Perl


Apache::testold Related Software