It looks like besides testing the API we also may want to test some common techniques. e.g. for one of the recent problem reports on the modperl list, I wrote this rewrite test. Should I commit it? If so, should we start a new category of tests for common techniques. Not sure what's the best short name, 'cooks', 'recetas' or 'fill in some short name'?

BTW, Apache now requires you to set $r->filename() if you return Apache::OK from the transhandler. In this test I simply left for Apache to figure it out, but obviously we get the stat() calls perfomance hit. So it's probably better to:

sub trans {
    my $r = shift;

    $r->uri($uri_real);
    $r->args($args_real);
    $r->filename(''); # make Apache happy

    return Apache::OK;
}

and return OK.

Anyway, here is a simple test.

package TestModules::rewrite;

use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestUtil;

use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::URI ();

use Apache::Const -compile => qw(DECLINED OK);

my $uri_real = "/TestModules__rewrite_real";
my $args_real = "foo=bar&boo=tar";

sub trans {
    my $r = shift;

return Apache::DECLINED unless $r->uri eq '/TestModules__rewrite';

    $r->uri($uri_real);
    $r->args($args_real);

    return Apache::DECLINED;
}

sub response {
    my $r = shift;

plan $r, tests => 1;

my $args = $r->args();

ok t_cmp($args_real, $args, "args");

    return Apache::OK;
}

1;
__END__
<NoAutoConfig>
    PerlModule TestModules::rewrite
    PerlTransHandler TestModules::rewrite::trans
    <Location /TestModules__rewrite_real>
        SetHandler modperl
        PerlResponseHandler TestModules::rewrite::response
    </Location>
</NoAutoConfig>


-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to