stas        2003/01/19 23:56:17

  Added:       t/preconnection note.t
               t/preconnection/TestPreConnection note.pm
  Log:
  add a simple test to verify that PreConnection handlers are working
  
  Revision  Changes    Path
  1.1                  modperl-2.0/t/preconnection/note.t
  
  Index: note.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  use Apache::TestRequest;
  
  my $module = "TestPreConnection::note";
  Apache::TestRequest::module($module);
  my $hostport = Apache::TestRequest::hostport(Apache::Test::config());
  my $location = "http://$hostport/$module";;
  t_debug("connecting to $location");
  plan tests => 1;
  
  ok t_cmp(
      'ok', 
      GET_BODY($location),
      "connection notes");
  
  
  
  1.1                  modperl-2.0/t/preconnection/TestPreConnection/note.pm
  
  Index: note.pm
  ===================================================================
  package TestPreConnection::note;
  
  use strict;
  use warnings;# FATAL => 'all';
  
  use Apache::Connection ();
  
  use Apache::Const -compile => qw(OK);
  
  sub handler {
      my Apache::Connection $c = shift;
  
      $c->notes->set(preconnection => 'ok');
  
      return Apache::OK;
  }
  
  use constant BUFF_LEN => 1024;
  
  sub response {
      my $r = shift;
  
      $r->content_type('text/plain');
      $r->print($r->connection->notes->get('preconnection') || '');
  
      return Apache::OK
  }
  
  1;
  __END__
  <NoAutoConfig>
    <VirtualHost TestPreConnection::note>
      PerlPreConnectionHandler TestPreConnection::note
    
      <Location /TestPreConnection::note>
        SetHandler modperl
        PerlResponseHandler TestPreConnection::note::response
      </Location>
    </VirtualHost>
  </NoAutoConfig>
  
  
  
  
  


Reply via email to