[Apache-dispatch-devel] SF.net SVN: apache-dispatch: [35] trunk/t
Brought to you by:
geoffrey_young,
phred_moyer
|
From: <phr...@us...> - 2006-06-03 07:10:46
|
Revision: 35 Author: phred_moyer Date: 2006-06-03 00:10:38 -0700 (Sat, 03 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=35&view=rev Log Message: ----------- - Pre, Post, Error tests passing - Setup for filter testing - use $class instead of __PACKAGE__ to make test libs scalable. Modified Paths: -------------- trunk/lib/Apache/Dispatch/Util.pm trunk/lib/Apache/Dispatch.pm trunk/lib/Apache2/Dispatch.pm trunk/t/01plain.t trunk/t/conf/extra.last.conf.in trunk/t/lib/Apache/Foo.pm trunk/t/lib/Apache2/Foo/Bar.pm trunk/t/lib/Apache2/Foo.pm Added Paths: ----------- trunk/t/02extras.t trunk/t/03filter.t Removed Paths: ------------- trunk/t/extras.t trunk/t/filter.t Modified: trunk/lib/Apache/Dispatch/Util.pm =================================================================== --- trunk/lib/Apache/Dispatch/Util.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/lib/Apache/Dispatch/Util.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -318,13 +318,13 @@ my ($r, $prefix, $newloc, $log, $debug) = @_; my $uri = $r->uri; + + my $location; - my $location; - # change all the / to :: (my $class_and_method = $r->uri) =~ s!/!::!g; - - if ($newloc) { + + if ($newloc) { $log->info("\tmodifying location from ", $r->location, " to $newloc") if $debug > 1; ($location = $newloc) =~ s!/!::!g; @@ -381,7 +381,9 @@ #--------------------------------------------------------------------- my $pkg = shift; - my ($object, $method, $autoload, $log, $debug) = @_; + require Data::Dumper; + + my ($object, $method, $autoload, $log, $debug) = @_; my $class = ref($object); Modified: trunk/lib/Apache/Dispatch.pm =================================================================== --- trunk/lib/Apache/Dispatch.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/lib/Apache/Dispatch.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -485,7 +485,8 @@ Off - do not use Apache::Filter (Default) DispatchDebug - Set DispatchDebug to 1 or 2 to control the verbosity of debug statements. + Set DispatchDebug to 1 or 2 to control the verbosity of + debug statements. =head1 SPECIAL CODING GUIDELINES Modified: trunk/lib/Apache2/Dispatch.pm =================================================================== --- trunk/lib/Apache2/Dispatch.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/lib/Apache2/Dispatch.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -211,15 +211,15 @@ foreach my $extra (@extras) { if ($extra eq "PRE") { $prehandler = - __PACKAGE__->_check_dispatch($object, "pre_dispatch", $autoload, $log); + __PACKAGE__->_check_dispatch($object, "pre_dispatch", $autoload, $log, $debug); } elsif ($extra eq "POST") { $posthandler = - __PACKAGE__->_check_dispatch($object, "post_dispatch", $autoload, $log); + __PACKAGE__->_check_dispatch($object, "post_dispatch", $autoload, $log, $debug); } elsif ($extra eq "ERROR") { $errorhandler = - __PACKAGE__->_check_dispatch($object, "error_dispatch", $autoload, $log); + __PACKAGE__->_check_dispatch($object, "error_dispatch", $autoload, $log, $debug); } } Modified: trunk/t/01plain.t =================================================================== --- trunk/t/01plain.t 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/01plain.t 2006-06-03 07:10:38 UTC (rev 35) @@ -8,7 +8,7 @@ # Test Apache2::Foo->dispatch_index my $uri = '/plain'; -ok GET_OK $uri; +ok(GET_OK $uri, 'test passed'); # Test Apache2::Foo->dispatch_foo $uri = '/plain/foo'; Copied: trunk/t/02extras.t (from rev 32, trunk/t/extras.t) =================================================================== --- trunk/t/02extras.t (rev 0) +++ trunk/t/02extras.t 2006-06-03 07:10:38 UTC (rev 35) @@ -0,0 +1,19 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; + +plan tests => 5, \&have_lwp; + +my $uri = '/extras'; +my $res = GET $uri; +ok $res->code == 200; +ok $res->content =~ m/post_dispatch/; +ok $res->content =~ m/pre_dispatch/; + +$uri = '/extras/bad'; +$res = GET $uri; +ok $res->code == 200; +ok $res->content =~ m/Yikes(.*?)dispatch_error/i; + Copied: trunk/t/03filter.t (from rev 32, trunk/t/filter.t) =================================================================== --- trunk/t/03filter.t (rev 0) +++ trunk/t/03filter.t 2006-06-03 07:10:38 UTC (rev 35) @@ -0,0 +1,14 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; + +plan tests => 1, \&have_lwp; + +my $url = '/filtered/Bar/good'; + +eval { require Apache::Filter }; + +ok GET_OK $url; + Modified: trunk/t/conf/extra.last.conf.in =================================================================== --- trunk/t/conf/extra.last.conf.in 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/conf/extra.last.conf.in 2006-06-03 07:10:38 UTC (rev 35) @@ -26,7 +26,6 @@ DispatchRequire On DispatchExtras Pre Post DispatchDebug 2 - <IfDefine APACHE2> DispatchPrefix Apache2::Foo PerlResponseHandler Apache2::Dispatch Apache2::Foo::Filter @@ -35,15 +34,13 @@ DispatchPrefix Apache::Foo PerlHandler Apache::Dispatch Apache::Foo::Filter </IfDefine> - </Location> <Location /extras> SetHandler perl-script DispatchRequire On - DispatchExtras Pre Error + DispatchExtras Pre Post Error DispatchDebug 2 - <IfDefine APACHE2> DispatchPrefix Apache2::Foo PerlResponseHandler Apache2::Dispatch @@ -52,7 +49,6 @@ DispatchPrefix Apache::Foo PerlHandler Apache::Dispatch </IfDefine> - </Location> <Location /oo> @@ -61,7 +57,6 @@ DispatchAUTOLOAD On DispatchISA Foo::Parent DispatchDebug 2 - <IfDefine APACHE2> DispatchPrefix Apache2::Foo PerlResponseHandler Apache2::Dispatch Deleted: trunk/t/extras.t =================================================================== --- trunk/t/extras.t 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/extras.t 2006-06-03 07:10:38 UTC (rev 35) @@ -1,15 +0,0 @@ -use strict; -use warnings FATAL => 'all'; - -use Apache::Test; -use Apache::TestRequest; - -plan tests => 2, \&have_lwp; - -my $url = '/extras/Bar/pre'; - -ok GET_OK $url; - -$url = '/extras/Bar/bad'; - -ok GET_OK $url; Deleted: trunk/t/filter.t =================================================================== --- trunk/t/filter.t 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/filter.t 2006-06-03 07:10:38 UTC (rev 35) @@ -1,14 +0,0 @@ -use strict; -use warnings FATAL => 'all'; - -use Apache::Test; -use Apache::TestRequest; - -plan tests => 1, \&have_lwp; - -my $url = '/filtered/Bar/good'; - -eval { require Apache::Filter }; - -skip 1 GET_OK $url; - Modified: trunk/t/lib/Apache/Foo.pm =================================================================== --- trunk/t/lib/Apache/Foo.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/lib/Apache/Foo.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -1,51 +1,56 @@ package Apache::Foo; use Apache::Constants qw( OK SERVER_ERROR ); + use strict; +use warnings; sub dispatch_foo { - my $class = shift; - my $r = shift; - $r->log->debug(__PACKAGE__ . "->dispatch_foo()"); + my ($class, $r) = @_; + $r->log->debug("$class->dispatch_foo()"); $r->send_http_header('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_foo()"); + $r->print("$class->dispatch_foo()"); return OK; } -sub dispatch_uhoh { +sub dispatch_bad { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->dispatch_bar()"); + $r->log->debug("$class->dispatch_bad()"); return SERVER_ERROR; } sub pre_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->pre_dispatch()"); + $r->log->debug("$class->pre_dispatch()"); + + $r->send_http_header('text/plain'); + $r->print("$class->pre_dispatch()"); } sub post_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->post_dispatch()"); - $r->print($Apache::Foo::output); + $r->log->debug("$class->post_dispatch()"); + $r->print("$class->post_dispatch()"); + #$r->print($Apache::Foo::output); } sub error_dispatch { - my $class = shift; - my $r = shift; - $r->send_http_header('text/plain'); - $r->print("Yikes! Foo->dispatch_error()"); - $r->log->error("Yikes! " . __PACKAGE__ . "->dispatch_error()"); + my ($class, $r) = @_; + $r->log->error("Yikes! $class->dispatch_error()"); + + $r->send_http_header('text/plain'); + $r->print("Yikes! $class->dispatch_error()"); return OK; } sub dispatch_index { - my $class = shift; - my $r = shift; - $r->send_http_header('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_index()"); - $r->log->debug(__PACKAGE__ . "->dispatch_index()"); + my ($class, $r) = @_; + $r->log->debug("$class->dispatch_index()"); + + $r->send_http_header('text/plain'); + $r->print("$class->dispatch_index()"); return OK; } Modified: trunk/t/lib/Apache2/Foo/Bar.pm =================================================================== --- trunk/t/lib/Apache2/Foo/Bar.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/lib/Apache2/Foo/Bar.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -11,8 +11,7 @@ sub dispatch_index { # test calls to /Bar/index or / - my $self = shift; - my $r = shift; + my ($class, $r) = @_; $r->log_debug(__PACKAGE__ . "->dispatch_index()"); $r->content_type('text/plain'); @@ -31,10 +30,9 @@ } sub post_dispatch { - my $self = shift; - my $r = shift; + my ($self, $r) = @_; # delay printing headers until all processing is done - $r->content_type('text/plain'); + #$r->content_type('text/plain'); $r->print($Apache2::Foo::Foo::output); $r->log->debug(__PACKAGE__ . "->post_dispatch()"); } Modified: trunk/t/lib/Apache2/Foo.pm =================================================================== --- trunk/t/lib/Apache2/Foo.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/lib/Apache2/Foo.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -7,45 +7,47 @@ sub dispatch_foo { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->dispatch_foo()"); + $r->log->debug("$class->dispatch_foo()"); $r->content_type('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_foo()"); + $r->print("$class->dispatch_foo()"); return Apache2::Const::OK; } -sub dispatch_uhoh { +sub dispatch_bad { my ($class, $r) = @_; + $r->log->debug("$class->dispatch_bad()"); - $r->log->debug(__PACKAGE__ . "->dispatch_uhoh()"); return Apache2::Const::SERVER_ERROR; } sub pre_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->pre_dispatch()"); + $r->log->debug("$class->pre_dispatch()"); + $r->print("$class->pre_dispatch"); } sub post_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->post_dispatch()"); + $r->log->debug("$class->post_dispatch()"); + $r->print("$class->post_dispatch"); } sub error_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->error_dispatch()"); + $r->log->debug("$class->error_dispatch()"); $r->content_type('text/plain'); - $r->print("Yikes! " . __PACKAGE__ . "->dispatch_error()"); + $r->print("Yikes! $class->dispatch_error()"); return Apache2::Const::OK; } sub dispatch_index { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->dispatch_index()"); + $r->log->debug("$class->dispatch_index()"); $r->content_type('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_index()"); + $r->print("$class->dispatch_index()"); return Apache2::Const::OK; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |