You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joshua Shapiro <jo...@gmail.com> on 2006/09/10 06:55:57 UTC

Testing a Handler

Hello,

I have inherited an application that makes use of mod_perl.  I have
never used it before and am currently trying to understand it.  I am
trying to setup a simple CLI utility that will allow me to test the
functionality of the website offline and eventually set up unit tests.
 I am trying

  #!/usr/bin/perl

  use MyApp;
  use Apache::FakeRequest;

  $req = Apache::FakeRequest->new();
  MyApp::handler($request);

but the output I keep getting is,

  Content-type: text/html

  <h1>Software error:</h1>
  <pre>Undefined subroutine &amp;MyApp::handler called at ./test.pl line 8.
  </pre>
  <p>
  For help, please send mail to this site's webmaster, giving this
error message
  and the time and date of the error.

  </p>
  [Sat Sep  9 22:52:58 2006] test.pl: Undefined subroutine
&MyApp::handler called at ./test.pl line 8.


What am I missing?

Thanks,
Joshua Shapiro

Re: Testing a Handler

Posted by Joshua Shapiro <jo...@gmail.com>.
I got it,  It was just a package naming issue. Sorry for the
inconvenience, (it was late, I was tired...)

Josh



On 9/10/06, Jay Scherrer <ja...@scherrer.com> wrote:
> Joshua Shapiro wrote:
> > Hello,
> >
> > I have inherited an application that makes use of mod_perl.  I have
> > never used it before and am currently trying to understand it.  I am
> > trying to setup a simple CLI utility that will allow me to test the
> > functionality of the website offline and eventually set up unit tests.
> > I am trying
> >
> >  #!/usr/bin/perl
> >
> >  use MyApp;
> >  use Apache::FakeRequest;
> >
> >  $req = Apache::FakeRequest->new();
> >  MyApp::handler($request);
> >
> > but the output I keep getting is,
> >
> >  Content-type: text/html
> >
> >  <h1>Software error:</h1>
> >  <pre>Undefined subroutine &amp;MyApp::handler called at ./test.pl
> > line 8.
> >  </pre>
> >  <p>
> >  For help, please send mail to this site's webmaster, giving this
> > error message
> >  and the time and date of the error.
> >
> >  </p>
> >  [Sat Sep  9 22:52:58 2006] test.pl: Undefined subroutine
> > &MyApp::handler called at ./test.pl line 8.
> >
> >
> > What am I missing?
> >
> > Thanks,
> > Joshua Shapiro
> >
> Should read:
> my $req = Apache::FakeRequest->new();
>  MyApp::handler($req);
> instead of :
> $req = Apache::FakeRequest->new();
>  MyApp::handler($request);
>
> Jay Scherrer
>

Re: Testing a Handler

Posted by Jay Scherrer <ja...@scherrer.com>.
Joshua Shapiro wrote:
> Hello,
>
> I have inherited an application that makes use of mod_perl.  I have
> never used it before and am currently trying to understand it.  I am
> trying to setup a simple CLI utility that will allow me to test the
> functionality of the website offline and eventually set up unit tests.
> I am trying
>
>  #!/usr/bin/perl
>
>  use MyApp;
>  use Apache::FakeRequest;
>
>  $req = Apache::FakeRequest->new();
>  MyApp::handler($request);
>
> but the output I keep getting is,
>
>  Content-type: text/html
>
>  <h1>Software error:</h1>
>  <pre>Undefined subroutine &amp;MyApp::handler called at ./test.pl 
> line 8.
>  </pre>
>  <p>
>  For help, please send mail to this site's webmaster, giving this
> error message
>  and the time and date of the error.
>
>  </p>
>  [Sat Sep  9 22:52:58 2006] test.pl: Undefined subroutine
> &MyApp::handler called at ./test.pl line 8.
>
>
> What am I missing?
>
> Thanks,
> Joshua Shapiro
>
Should read:
my $req = Apache::FakeRequest->new();
 MyApp::handler($req);
instead of :
$req = Apache::FakeRequest->new();
 MyApp::handler($request);

Jay Scherrer

Re: Testing a Handler

Posted by to...@tuxteam.de.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, Sep 09, 2006 at 10:55:57PM -0600, Joshua Shapiro wrote:
> Hello,
> 
> I have inherited an application that makes use of mod_perl.  I have
> never used it before and am currently trying to understand it.  I am
> trying to setup a simple CLI utility that will allow me to test the
> functionality of the website offline and eventually set up unit tests.
> I am trying
> 
>  #!/usr/bin/perl
> 
>  use MyApp;
       ^^^^^^
>  use Apache::FakeRequest;
> 
>  $req = Apache::FakeRequest->new();
>  MyApp::handler($request);
          ^^^^^^^
> 
> but the output I keep getting is,
[...]
>  <pre>Undefined subroutine &amp;MyApp::handler called at ./test.pl line 8.
[...]

For this to work there should be a function "handler" defined in the
module "MyApp.pm". Seems there is'nt?

HTH
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFA6JRBcgs9XrR2kYRAhrTAJ9ewXkOcWSs6iCy6JFDTTBgESwpvACeJ6/B
jCWed6wkux3ad5mixfjGAMM=
=7+OI
-----END PGP SIGNATURE-----