Manual Pages for UNIX Darwin command on man Apache::testold
MyWebUniversity

Manual Pages for UNIX Darwin command on man Apache::testold

Apache::testold(3) User Contributed Perl Documentation Apache::testold(3)

NAME

Apache::testold - Facilitates testing of Apache::* modules

SYNOPSIS

# In Makefile.PL

use Apache::testold;

my %params = Apache::testold->gettestparams();

Apache::testold->writehttpdconf(%params, include => $moredirectives);

*MY::test = sub { Apache::testold->MMtest(%params) };

# In t/*.t script (or test.pl)

use Apache::testold qw(skiptest havehttpd);

skiptest unless havehttpd; (Some more methods of Doug's that I haven't reviewed or documented yet)

DESCRIPTION

This module helps authors of Apache::* modules write test suites that

can query an actual running Apache server with modperl and their mod-

ules 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. MMEETTHHOODDSS gettestparams() 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 suit-

able for passing to the "writehttpdconf()" method.

wwrriitteehhttttppddccoonnff((%%ppaarraammss))

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: * conffile 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" direc-

tives to pass control to the module you're testing. The "blib/"

directories will be added to the @INC path when searching for mod-

ules, so that's nice.

MMMMtteesstt((%%ppaarraammss))

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 starthttpd', 'make runtests', and 'make killhttpd' in sequence. You can also run these commands independently if you want.

Pass the hash of parameters returned by "gettestparams()" as an argu-

ment to "MMtest()". To patch into the ExtUtils::MakeMaker wizardry (voodoo?), typically you'll do the following in your Makefile.PL:

*MY::test = sub { Apache::testold->MMtest(%params) };

ffeettcchh

Apache::testold->fetch($request);

Apache::testold->fetch($useragent, $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 submis-

sion and we add a 'ContentType' header with a value of 'applica-

tion/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. ssttaattiiccmmoodduulleess

Example: $mods = Apache::testold->staticmodules('/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. EEXXAAMMPPLLEESS

No good examples yet. Example submissions are welcome. In the mean-

time, see

, which I'm retrofitting to use Apache::testold.

TTOO DDOO The MMtest method doesn't try to be very smart, it just writes the text that seems to work in my configuration. I am morally against using the 'make' command for installing Perl modules (though of course I do it anyway), so I haven't looked into this very much. Send bug reports or better (patches). I've got lots of code in my Apache::AuthCookie module (etc.) that assists in actually making the queries of the running server. I plan to add that to this module, but first I need to compare what's already here that does the same stuff. KKUUDDOOSS To Doug MacEachern for writing the first version of this module. To caelum@debian.org (Rafael Kitover) for contributing the code to

parse existing httpd.conf files for -enable-shared=max and DSOs.

CCAAVVEEAATTSS Except for making sure that the modperl distribution itself can run 'make test' okay, I haven't tried very hard to keep compatibility with older versions of this module. In particular MMtest() has changed and probably isn't usable in the old ways, since some of its assumptions are gone. But none of this was ever documented, and MMtest() doesn't seem to actually be used anywhere in the modperl disribution, so I don't feel so bad about it. AUTHOR Doug MacEachern (original version) Ken Williams (latest changes and this documentation)

perl v5.8.6 2000-03-30 Apache::testold(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™