1# Tests for Connector::Proxy::Config::Std 2# 3 4use strict; 5use warnings; 6use English; 7 8use Test::More tests => 23; 9 10use Log::Log4perl; 11Log::Log4perl->easy_init( { level => 'ERROR' } ); 12 13# diag "LOAD MODULE\n"; 14 15BEGIN { 16 use_ok( 'Connector::Proxy::Config::Std' ); 17} 18 19require_ok( 'Connector::Proxy::Config::Std' ); 20 21 22# diag "Connector::Proxy::Config::Std tests\n"; 23########################################################################### 24my $conn = Connector::Proxy::Config::Std->new( 25 { 26 LOCATION => 't/config/config.ini', 27 PREFIX => 'test', 28 }); 29 30is($conn->get('abc'), '1111'); 31is($conn->get('def'), '2222'); 32 33is($conn->get('nonexistent'), undef); 34 35# try full path access 36is($conn->PREFIX(''), ''); 37 38# and repeat above tests 39is($conn->get('test.entry.foo'), '1234'); 40is($conn->get('test.entry.bar'), '5678'); 41 42# diag "Test get_meta functionality\n"; 43is($conn->get_meta('')->{TYPE}, 'connector', 'Toplevel'); 44is($conn->get_meta('list.test')->{TYPE}, 'list', 'Array'); 45is($conn->get_meta('test.entry')->{TYPE}, 'hash', 'Hash'); 46is($conn->get_meta('test.entry.foo')->{TYPE}, 'scalar', 'Scalar'); 47is($conn->get_meta('test.entry.nonexisting'), undef, 'undef'); 48 49 50# diag "Test List functionality\n"; 51my @data = $conn->get_list('list.test'); 52 53is( $conn->get_size('list.test'), 4, 'size'); 54is( ref \@data, 'ARRAY', 'ref'); 55is( shift @data, 'first', 'element'); 56 57# diag "Test Hash functionality\n"; 58my @keys = $conn->get_keys('test.entry'); 59is( ref \@keys, 'ARRAY', 'keys'); 60is( ref $conn->get_hash('test.entry'), 'HASH', 'hash'); 61is( $conn->get_hash('test.entry')->{bar}, '5678', 'element'); 62#a.very.long.path 63ok ($conn->exists('test.entry'), 'Section Exists'); 64ok ($conn->exists('test.entry.foo'), 'Node Exists'); 65ok ($conn->exists( [ 'test', 'entry', 'foo' ] ), 'Node Exists Array'); 66ok (!$conn->exists('test.noentry'), 'Not exists'); 67 68 69