"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/t/99filestore.t" (15 Sep 2009, 1677 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 => 7;
   12 
   13 my $package = 'Apache::Session::Store::File';
   14 use_ok $package;
   15 
   16 my $origdir = getcwd;
   17 my $tempdir = tempdir( DIR => '.', CLEANUP => 1 );
   18 chdir( $tempdir );
   19 
   20 my $session = {
   21     serialized => 12345,
   22     data => { _session_id => 'test1'},
   23 };
   24 
   25 $Apache::Session::Store::File::Directory = '.';
   26 $Apache::Session::Store::File::Directory = '.';
   27 
   28 my $store = Apache::Session::Store::File->new;
   29 
   30 $store->insert($session);
   31 
   32 ok( -e "./test1", "Store file exists" );
   33 
   34 undef $store;
   35 
   36 open (TEST, '<./test1');
   37 
   38 my $store_contents = do { local $/; <TEST> };
   39 
   40 ok( $store_contents eq $session->{serialized} && $store_contents == 12345,
   41     "Store contents are okay" );
   42 
   43 close TEST;
   44 
   45 $store = Apache::Session::Store::File->new;
   46 $session->{serialized} = '';
   47 $store->materialize($session);
   48 
   49 ok( $session->{serialized} == 12345, 'restoring from file worked' );
   50 
   51 $session->{serialized} = 'hi';
   52 $store->update($session);
   53 undef $store;
   54 
   55 open (TEST, '<./test1');
   56 
   57 undef $store_contents;
   58 $store_contents = do { local $/; <TEST> };
   59 
   60 ok( $store_contents eq $session->{serialized} && $store_contents eq 'hi',
   61     'Store contents are okay' );
   62 
   63 close TEST;
   64 
   65 undef $store;
   66 $store = Apache::Session::Store::File->new;
   67 $store->remove($session);
   68 
   69 ok( !-e "./test1", 'Session removed properly' );
   70 
   71 dies_ok {
   72     $store->materialize($session);
   73 } "could not materialize nonexistent session";    
   74 
   75 chdir( $origdir );