SADI::Service::UnitTest - A module that encapsulates unit test information for sadi services.


SADI documentation Contained in the SADI distribution.

Index


Code Index:

NAME

Top

SADI::Service::UnitTest - A module that encapsulates unit test information for sadi services.

SYNOPSIS

Top

 use SADI::Service::UnitTest;

 # create a new blank SADI UnitTest object
 my $data = SADI::Service::UnitTest->new ();

 # create a new primed SADI UnitTest object
 $data = SADI::Service::UnitTest->new (
     regex  => '(\w+)+',
     xpath  => '/xml/text()',
     input  => '<xml/>',
     output => '<xml/>',
 );

 # get the unit test regex
 my $regex = $data->regex;
 # set the regex statement for this test
 $data->regex($regex);

 # get the unit test xpath statement
 my $xpath = $data->xpath;
 # set the xpath statement for this test
 $data->regex($xpath);

 # get input for this test
 my $input = $data->input;
 # set the input for this test
 $data->input($input);

 # get expected output for this test
 my $output = $data->output;
 # set the expected output for this test
 $data->output($output);

DESCRIPTION

Top

An object representing a SADI service unit test.

AUTHORS

Top

 Edward Kawas (edward.kawas [at] gmail [dot] com)

ACCESSIBLE ATTRIBUTES

Top

Details are in SADI::Base. Here just a list of them (additionally to the attributes from the parent classes)

input

The input for this unit test. Input is required, because without it, there can be no test

output

The expected output of this service given the specified input.

regex

A regular expression that should match the output of the service given the specified input.

xpath

An xpath expression that should yield return results given the specified input.


SADI documentation Contained in the SADI distribution.
#-----------------------------------------------------------------
# SADI::Service::UnitTest
# Author: Edward Kawas <edward.kawas@gmail.com>,
#
# For copyright and disclaimer see below.
#
# $Id: UnitTest.pm,v 1.1 2010-03-08 19:29:11 ubuntu Exp $
#-----------------------------------------------------------------
package SADI::Service::UnitTest;

use SADI::Base;
use base ("SADI::Base");
use strict;

# add versioning to this module
use vars qw /$VERSION/;
$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /: (\d+)\.(\d+)/;

#-----------------------------------------------------------------
# A list of allowed attribute names. See SADI::Base for details.
#-----------------------------------------------------------------

{
	my %_allowed = (
		input       => { type => SADI::Base->STRING },
		output      => { type => SADI::Base->STRING },
		regex       => { type => SADI::Base->STRING },
		xpath       => { type => SADI::Base->STRING },
	);

	sub _accessible {
		my ( $self, $attr ) = @_;
		exists $_allowed{$attr} or $self->SUPER::_accessible($attr);
	}

	sub _attr_prop {
		my ( $self, $attr_name, $prop_name ) = @_;
		my $attr = $_allowed{$attr_name};
		return ref($attr) ? $attr->{$prop_name} : $attr if $attr;
		return $self->SUPER::_attr_prop( $attr_name, $prop_name );
	}
}

#-----------------------------------------------------------------
# init
#-----------------------------------------------------------------
sub init {
	my ($self) = shift;
	$self->SUPER::init();

	# set any defaults here 

}

1;

__END__