[Apache-dispatch-devel] SF.net SVN: apache-dispatch: [19] trunk/t
Brought to you by:
geoffrey_young,
phred_moyer
|
From: <phr...@us...> - 2006-04-18 08:17:46
|
Revision: 19 Author: phred_moyer Date: 2006-04-18 01:17:42 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=19&view=rev Log Message: ----------- Add a few more tests for plain. So far we cover subclasses and index handlers. No doubt there are more to come but this is all for tonight. Modified Paths: -------------- trunk/t/lib/Apache2/Foo/Bar.pm trunk/t/lib/Apache2/Foo.pm trunk/t/plain.t Modified: trunk/t/lib/Apache2/Foo/Bar.pm =================================================================== --- trunk/t/lib/Apache2/Foo/Bar.pm 2006-04-18 02:57:29 UTC (rev 18) +++ trunk/t/lib/Apache2/Foo/Bar.pm 2006-04-18 08:17:42 UTC (rev 19) @@ -31,12 +31,12 @@ here is a sample httpd.conf entry - PerlModule Apache::Dispatch - PerlModule MP2Foo + PerlLoadModule Apache2::Dispatch + PerlModule Apache2::Foo::Bar <Location /Test> SetHandler perl-script - PerlHandler Apache::Dispatch + PerlHandler Apache2::Dispatch DispatchPrefix Foo DispatchExtras Pre Post Error </Location> Modified: trunk/t/lib/Apache2/Foo.pm =================================================================== --- trunk/t/lib/Apache2/Foo.pm 2006-04-18 02:57:29 UTC (rev 18) +++ trunk/t/lib/Apache2/Foo.pm 2006-04-18 08:17:42 UTC (rev 19) @@ -1,45 +1,50 @@ package Apache2::Foo; use Apache2::Const -compile => qw( OK SERVER_ERROR ); +use Apache2::RequestIO; use strict; sub dispatch_foo { - my $class = shift; - my $r = shift; - $r->send_http_header('text/plain'); + my ($class, $r) = @_; + + $r->content_type('text/plain'); $r->print("Foo->dispatch_foo()"); - print STDERR "Foo->dispatch_foo()\n"; + $r->log->debug("Foo->dispatch_foo()"); return Apache2::Const::OK; } sub dispatch_bar { - print STDERR "Foo->dispatch_bar()\n"; + my ($class, $r) = @_; + require Data::Dumper; + $r->log->debug("ARGV is " . Data::Dumper::Dumper(\@_)); + $r->log->debug( "Foo->dispatch_bar()"); return Apache2::Const::SERVER_ERROR; } sub pre_dispatch { - print STDERR "Foo->pre_dispatch()\n"; + my ($class, $r) = @_; + $r->log->debug("Foo->pre_dispatch()"); } sub post_dispatch { - print STDERR "Foo->post_dispatch()\n"; + my ($class, $r) = @_; + $r->log->debug("Foo->post_dispatch()"); } sub error_dispatch { - my $class = shift; - my $r = shift; - $r->send_http_header('text/plain'); + my ($class, $r) = @_; + + $r->send_http_header('text/plain'); $r->print("Yikes! Foo->dispatch_error()"); - print STDERR "Yikes! Foo->dispatch_error()\n"; return Apache2::Const::OK; } sub dispatch_index { - my $class = shift; - my $r = shift; - $r->send_http_header('text/plain'); + my ($class, $r) = @_; + + $r->content_type('text/plain'); $r->print("Foo->dispatch_index()"); - print STDERR "Foo->dispatch_index()\n"; + $r->log->debug( "Foo->dispatch_index()"); return Apache2::Const::OK; } @@ -50,12 +55,12 @@ here is a sample httpd.conf entry PerlModule Apache2::Dispatch - PerlModule Foo + PerlModule Apache2::Foo <Location /Test> SetHandler perl-script PerlHandler Apache2::Dispatch - DispatchPrefix Foo + DispatchPrefix Apache2::Foo DispatchExtras Pre Post Error </Location> Modified: trunk/t/plain.t =================================================================== --- trunk/t/plain.t 2006-04-18 02:57:29 UTC (rev 18) +++ trunk/t/plain.t 2006-04-18 08:17:42 UTC (rev 19) @@ -4,8 +4,21 @@ use Apache::Test; use Apache::TestRequest; -plan tests => 1, \&have_lwp; +plan tests => 4, \&have_lwp; -my $url = '/plain/Bar/baz'; +# Test Apache2::Foo->dispatch_index +my $url = '/plain/'; +ok GET_OK $url; +# Test Apache2::Foo->dispatch_foo +$url = '/plain/foo'; ok GET_OK $url; + +# Test Apache2::Foo::Bar->dispatch_index +$url = '/plain/Bar/'; +ok GET_OK $url; + +# Test Apache2::Foo::Bar->dispatch_foo +$url = '/plain/Bar/baz'; +ok GET_OK $url; + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |