"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/t/99flex.t" (18 Aug 2010, 4663 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use strict;
    2 use Test::More;
    3 #use Test::Exception;
    4 use File::Temp qw[tempdir];
    5 use Cwd qw[getcwd];
    6 use Config;
    7 
    8 #plan skip_all => "Only for perl 5.8 or later"
    9 #  unless eval {
   10 #   require 5.008;
   11    #perl 5.6 does not likes this test. See RT#16539.
   12 #  };
   13 #use Module::Mask;my $mask = new Module::Mask ('Storable');
   14 plan skip_all => "Optional modules (Fcntl, Digest::MD5) not installed"
   15   unless eval {
   16                require Fcntl;
   17                require Digest::MD5;
   18               };
   19 
   20 plan tests => 7;
   21 
   22 my $package = 'Apache::Session::Flex';
   23 use_ok $package;
   24 
   25 #$Apache::Session::Lock::File::LockDirectory=$tempdir;
   26 my $tempdir = tempdir( DIR => '.', CLEANUP => 1 );
   27 #my $origdir = getcwd;
   28 #chdir( $tempdir );
   29 
   30 {
   31     my $session = tie my %session, $package, undef, {
   32         Store     => 'File',
   33         Lock      => 'File',
   34         Generate  => 'MD5',
   35         Serialize => 'Storable',
   36         Directory     => $tempdir,
   37         LockDirectory => $tempdir,
   38     };
   39     isa_ok $session->{object_store}, 'Apache::Session::Store::File';
   40     isa_ok $session->{lock_manager}, 'Apache::Session::Lock::File';
   41     is ref($session->{generate}),    'CODE', 'generate is CODE';
   42     is ref($session->{serialize}),   'CODE', 'serialize is CODE';
   43     is ref($session->{unserialize}), 'CODE', 'unserialize is CODE';
   44     tied(%session)->delete;
   45     #untie %session;
   46 }
   47 
   48 =for cmt
   49 SKIP: { #Flex that uses IPC
   50     skip "semget not implemented",5 unless $Config{d_semget};
   51     skip "semctl not implemented",5 unless $Config{d_semctl};
   52     skip "Cygserver is not running",5 
   53      if $^O eq 'cygwin' && (!exists $ENV{'CYGWIN'} || $ENV{'CYGWIN'} !~ /server/i);
   54     skip "*BSD & Solaris do not like anonymous semaphores",5
   55      if $^O =~ /bsd|solaris/i;
   56     skip "Optional modules (IPC::Semaphore, IPC::SysV, MIME::Base64, DB_File) not installed",5
   57      unless eval {
   58                require IPC::Semaphore;
   59                require IPC::SysV;
   60                require MIME::Base64;
   61                require DB_File;
   62               };
   63 
   64     diag( "Using IPC::Semaphore $IPC::Semaphore::VERSION, IPC::SysV $IPC::SysV::VERSION, DB_File $DB_File::VERSION" );
   65     require Apache::Session::Lock::Semaphore;
   66     $Apache::Session::Lock::Semaphore::sem_key=undef;
   67     $Apache::Session::Lock::Semaphore::sem_key=$Apache::Session::Lock::Semaphore::sem_key;
   68     my $session = tie my %session, $package, undef, {
   69         Store     => 'DB_File',
   70         Lock      => 'Semaphore',
   71         Generate  => 'MD5',
   72         Serialize => 'Base64',
   73 #        SemaphoreKey => undef,
   74 #        SemaphoreKey => 31817,
   75     }; #Apache::Session::save in TIEHASH does acquire_write_lock
   76 
   77     isa_ok $session->{object_store}, 'Apache::Session::Store::DB_File';
   78     isa_ok $session->{lock_manager}, 'Apache::Session::Lock::Semaphore';
   79     is ref($session->{generate}),    'CODE', 'generate is CODE';
   80     is ref($session->{serialize}),   'CODE', 'serialize is CODE';
   81     is ref($session->{unserialize}), 'CODE', 'unserialize is CODE';
   82     $session->{lock_manager}->remove();
   83 }
   84 =cut
   85 
   86 {
   87     {
   88         package Apache::Session::Store::Test;
   89         use base 'Apache::Session::Store::File';
   90     }
   91 
   92     {
   93         package Apache::Session::Lock::Test;
   94         use base 'Apache::Session::Lock::File';
   95     }
   96 
   97     {
   98         package Apache::Session::Generate::Test;
   99 
  100         # This wack double assignment prevents "... used only once"
  101         # warnings.
  102         *Apache::Session::Generate::Test::generate =
  103         *Apache::Session::Generate::Test::generate =
  104             \&Apache::Session::Generate::MD5::generate;
  105         *Apache::Session::Generate::Test::validate =
  106         *Apache::Session::Generate::Test::validate =
  107             \&Apache::Session::Generate::MD5::validate;
  108     }
  109 
  110     {
  111         package Apache::Session::Serialize::Test;
  112 
  113         *Apache::Session::Serialize::Test::serialize =
  114         *Apache::Session::Serialize::Test::serialize =
  115             \&Apache::Session::Serialize::Storable::serialize;
  116         *Apache::Session::Serialize::Test::unserialize =
  117         *Apache::Session::Serialize::Test::unserialize =
  118             \&Apache::Session::Serialize::Storable::unserialize;
  119     }
  120 
  121     my $session = tie my %session, $package, undef, {
  122         Store     => 'Test',
  123         Lock      => 'Test',
  124         Generate  => 'Test',
  125         Serialize => 'Test',
  126         Directory     => $tempdir,
  127         LockDirectory => $tempdir,
  128     };
  129     isa_ok $session->{object_store}, 'Apache::Session::Store::Test';
  130     tied(%session)->delete;
  131     $session->{lock_manager}->clean('.', 0);
  132 }
  133 
  134 #chdir( $origdir );