SOAP-Lite
view release on metacpan or search on metacpan
lib/SOAP/Test.pm view on Meta::CPAN
# ======================================================================
#
# Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com)
# SOAP::Lite is free software; you can redistribute it
# and/or modify it under the same terms as Perl itself.
#
# ======================================================================
package SOAP::Test;
use 5.006;
our $VERSION = '1.27'; # VERSION
our $TIMEOUT = 5;
# ======================================================================
package # hide from PAUSE
My::PingPong; # we'll use this package in our tests
sub new {
my $self = shift;
my $class = ref($self) || $self;
bless {_num=>shift} => $class;
}
sub next {
my $self = shift;
$self->{_num}++;
}
sub value {
my $self = shift;
$self->{_num};
}
# ======================================================================
package SOAP::Test::Server;
use strict;
use Test;
use SOAP::Lite;
sub run_for {
my $proxy = shift or die "Proxy/endpoint is not specified";
# ------------------------------------------------------
my $s = SOAP::Lite->uri('http://something/somewhere')->proxy($proxy)->on_fault(sub{});
eval { $s->transport->timeout($SOAP::Test::TIMEOUT) };
my $r = $s->test_connection;
unless (defined $r && defined $r->envelope) {
print "1..0 # Skip: ", $s->transport->status, "\n";
exit;
}
# ------------------------------------------------------
plan tests => 53;
eval q!use SOAP::Lite on_fault => sub{ref $_[1] ? $_[1] : new SOAP::SOM}; 1! or die;
print STDERR "Perl SOAP server test(s)...\n";
$s = SOAP::Lite
-> uri('urn:/My/Examples')
-> proxy($proxy);
ok($s->getStateName(1)->result eq 'Alabama');
ok($s->getStateNames(1,4,6,13)->result =~ /^Alabama\s+Arkansas\s+Colorado\s+Illinois\s*$/);
$r = $s->getStateList([1,2,3,4])->result;
ok(ref $r && $r->[0] eq 'Alabama');
$r = $s->getStateStruct({item1 => 1, item2 => 4})->result;
ok(ref $r && $r->{item2} eq 'Arkansas');
print $s->transport->status, "\n";
{
my $autoresult = $s->autoresult;
$s->autoresult(1);
ok($s->getStateName(1) eq 'Alabama');
$s->autoresult($autoresult);
}
( run in 0.589 second using v1.01-cache-2.11-cpan-5a3173703d6 )