The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
# -*-perl-*-

# $Id: factory.t 361 2008-04-05 13:23:31Z jonasbn $

use strict;
use lib 't';
use TestUtil;
use Test::More  tests => 7;
use Test::Exception;

require_ok( 'Workflow::Factory' );

my $factory = Workflow::Factory->instance();
is( ref( $factory ), 'Workflow::Factory',
    'Return from instance() correct type' );
my $other_factory = Workflow::Factory->instance();
is( $other_factory, $factory,
    'Another call to instance() returns same object' );
my $factory_new = eval { Workflow::Factory->new() };
is( ref( $@ ), 'Workflow::Exception',
    'Call to new() throws proper exception' );

my $i_factory = Workflow::Factory->import( 'FACTORY' );
is( $i_factory, $factory,
    'Imported factory returns the same object' );

lives_ok { $factory->add_config_from_file( workflow  => 'workflow.xml',
                                    action    => [ 'workflow_action.xml', 'workflow_action_type.xml', 'workflow_action.perl',  ],
                                    validator => [ 'workflow_validator.xml', 'workflow_validator.perl' ],
                                    condition => 'workflow_condition.xml') };

lives_ok { $factory->add_config_from_file( workflow  =>  [ 'workflow.xml', 'workflow.perl' ],
                                    action    => 'workflow_action.xml',
                                    validator => 'workflow_validator.xml',
                                    condition => [ 'workflow_condition.xml', 'workflow_condition.perl' ]) };