use Test::More tests => 53; use strict; use SWISH::3; ok( my $s3 = SWISH::3->new( config => 't/t.conf' ), "new s3 object" ); ok( my $config = $s3->config, "get config" ); #$config->debug; #undef $config; eval { $s3->set_config(undef) }; ok( $@, "set config with undef" ); eval { $s3->set_config( bless( {}, 'not_a_config' ) ) }; ok( $@, "set config with non-Config class" ); ok( my $properties = $s3->config->get_properties, "get properties" ); my %uniq; for my $name ( sort @{ $properties->keys } ) { #diag($name); my $prop = $properties->get($name); #diag( "$name refcount = " . $prop->refcount ); ok( !$uniq{ $prop->id }++, "uniq prop id" ); is( $name, $prop->name, "prop name" ); } ok( my $metanames = $s3->config->get_metanames, "get metanames" ); %uniq = (); for my $name ( sort @{ $metanames->keys } ) { my $meta = $metanames->get($name); ok( !$uniq{ $meta->id }++, "uniq meta id" ); is( $name, $meta->name, "meta name" ); } ok( my $index = $s3->config->get_index, "get index" ); my %indexv = ( Format => 'Native', Locale => '(UTF-8|utf8)', Name => 'index.swish' ); for my $key ( sort keys %indexv ) { like( $index->get($key), qr/$indexv{$key}$/, "index $key" ); } # test merging ok( $s3->config->add('1'), "add raw xml" ); ok( my $misc = $s3->config->get_misc(), "get_misc" ); ok( $misc->get('foo'), "config directive added" ); ok( $s3->config->merge('2'), "add raw xml bar"); ok( $misc->get('bar'), "get bar");