1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7
8use SOAP::Lite
9  on_fault => sub {
10    my $soap = shift;
11    my $res = shift;
12    ref $res ? warn(join " ", "SOAP FAULT:", $res->faultstring, "\n")
13             : warn(join " ", "TRANSPORT ERROR:", $soap->transport->status, "\n");
14    return new SOAP::SOM;
15  }
16;
17
18my ($a, $s, $r);
19
20my $proxy = 'http://services.soaplite.com/echo.cgi';
21
22# ------------------------------------------------------
23use SOAP::Test;
24
25$s = SOAP::Lite->uri('http://something/somewhere')->proxy($proxy)->on_fault(sub{});
26eval { $s->transport->timeout($SOAP::Test::TIMEOUT = $SOAP::Test::TIMEOUT) };
27$r = $s->test_connection;
28
29unless (defined $r && defined $r->envelope) {
30  print "1..0 # Skip: ", $s->transport->status, "\n";
31  exit;
32}
33# ------------------------------------------------------
34
35plan tests => 16;
36
37{
38  print "Memory leaks test(s)...\n";
39
40  SOAP::Lite->self(undef);
41
42  my %calls = ();
43
44  SOAP::Lite->import(trace => [objects => sub {
45#    warn join ', ' , caller(2);
46    my @caller = caller(2);
47    $calls{$2}{$1}++ if ($caller[3] =~ /^(.+)::([^\:]+)$/);
48  }]);
49  {
50    my $soap = SOAP::Lite
51      -> uri("Echo")
52      -> proxy($proxy)
53      -> echo;
54	use Data::Dumper;
55#	find_cycle $soap;
56  }
57  use Data::Dumper;
58
59
60  foreach (keys %{$calls{new}}) {
61    print "default parser: $_\n";
62    ok(exists $calls{DESTROY}{$_});
63  }
64
65
66  SKIP: {
67      eval "require XML::Parser::Lite; 1;";
68      skip "XML::Parser::Lite is required for this test", 8 if $@;
69
70      %calls = ();
71      {
72          local $SOAP::Constants::DO_NOT_USE_XML_PARSER = 1;
73          my $soap = SOAP::Lite
74          -> uri("Echo")
75          -> proxy($proxy)
76          -> echo;
77      }
78      foreach (keys %{$calls{new}}) {
79          print "XML::Parser::Lite: $_\n";
80          ok(exists $calls{DESTROY}{$_});
81      }
82  }
83
84  # SOAP::Lite->import(trace => '-objects');
85}
86
87
88