"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/t/99filelock.t" (15 Sep 2009, 965 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 Test::More;
    2 use Test::Exception;
    3 use File::Temp qw[tempdir];
    4 use Cwd qw[getcwd];
    5 
    6 plan skip_all => "Optional module (Fcntl) not installed"
    7   unless eval {
    8                require Fcntl;
    9               };
   10 
   11 plan tests => 4;
   12 
   13 my $package = 'Apache::Session::Lock::File';
   14 use_ok $package;
   15 
   16 my $origdir = getcwd;
   17 my $tempdir = tempdir( DIR => '.', CLEANUP => 1 );
   18 chdir( $tempdir );
   19 
   20 my $lock    = $package->new;
   21 my $session = {
   22     data => { _session_id   => 'foo' },
   23     args => { LockDirectory => '.'   },
   24 };
   25 
   26 $lock->acquire_read_lock($session);
   27 
   28 ok -e './Apache-Session-foo.lock', 'lock file exists';
   29 
   30 undef $lock;
   31 
   32 unlink('./Apache-Session-foo.lock');
   33 
   34 $lock = $package->new;
   35 
   36 $lock->acquire_write_lock($session);
   37 
   38 ok -e './Apache-Session-foo.lock', 'lock file exists';
   39 
   40 $lock->release_all_locks($session);
   41 
   42 
   43 $lock->clean('.', 0);
   44 
   45 ok !-e './Apache-Session-foo.lock', 'lock file does not exist';
   46 
   47 chdir( $origdir );