1#!/usr/bin/env perl
2
3BEGIN {
4  unless(grep /blib/, @INC) {
5    chdir 't' if -d 't';
6    unshift @INC, '../lib' if -d '../lib';
7  }
8}
9
10use strict;
11use Test;
12
13use SOAP::Lite;
14
15plan tests => 40;
16
17my($a, $s, $r, $serialized, $deserialized);
18
19$deserialized = SOAP::Custom::XML::Deserializer
20  -> deserialize(join '', <DATA>);
21
22ok(ref $deserialized);
23
24$r = $deserialized->valueof('/Envelope/Body');
25
26ok(ref $r);
27
28my @portfolios = $r->Report->Request->Composition->PortfolioDistribution;
29
30ok(@portfolios == 6);
31
32foreach my $portfolio (@portfolios) {
33  # test attributes
34  print $portfolio->type, " ", $portfolio->date, "\n";
35  ok($portfolio->type && $portfolio->date);
36  foreach my $row ($portfolio->Row) {
37    # test elements
38    print "  ", $row->Element, " ", $row->Value, "\n";
39    ok($row->Element && $row->Value);
40  }
41}
42
43__DATA__
44<?xml version="1.0" encoding="UTF-8"?>
45<Envelope version="1.1">
46  <Header />
47  <Body>
48    <Report>
49      <Header>
50        <ClientRef />
51        <FundCusip>61744J366</FundCusip>
52        <SepAcctDesc />
53      </Header>
54      <Request>
55        <Errors>
56          <Error>Returned no data for request: PortfolioDistribution</Error>
57          <Error>Returned no data for request: PortfolioDistribution</Error>
58          <Error>Returned no data for request: PortfolioDistribution</Error>
59          <Error>Returned no data for request: PortfolioDistribution</Error>
60          <Error>Could not retrieve PortfolioDistribution</Error>
61          <Error>Could not retrieve PortfolioDistribution</Error>
62          <Error>Could not retrieve PortfolioDistribution</Error>
63          <Error>Could not retrieve PortfolioDistribution</Error>
64        </Errors>
65        <Composition>
66          <PortfolioDistribution type="CE" date="09/30/2000" />
67          <PortfolioDistribution type="GB" date="09/30/2000" />
68          <PortfolioDistribution type="ST" date="09/30/2000">
69            <Row>
70              <Element>Common Stocks</Element>
71              <Value>0.9991</Value>
72            </Row>
73            <Row>
74              <Element>Other</Element>
75              <Value>0.0021</Value>
76            </Row>
77            <Row>
78              <Element>Cash &amp; Cash Equivalents</Element>
79              <Value>-0.0012</Value>
80            </Row>
81          </PortfolioDistribution>
82          <PortfolioDistribution type="TT" date="09/30/2000">
83            <Row>
84              <Element>General Electric Company</Element>
85              <Value>0.0458</Value>
86            </Row>
87            <Row>
88              <Element>Cisco Systems Inc</Element>
89              <Value>0.033</Value>
90            </Row>
91            <Row>
92              <Element>Microsoft Corporation</Element>
93              <Value>0.0263</Value>
94            </Row>
95            <Row>
96              <Element>Exxon Mobil Corp.</Element>
97              <Value>0.0263</Value>
98            </Row>
99            <Row>
100              <Element>Pfizer, Inc.</Element>
101              <Value>0.0231</Value>
102            </Row>
103            <Row>
104              <Element>Intel Corporation</Element>
105              <Value>0.0209</Value>
106            </Row>
107            <Row>
108              <Element>Citigroup Inc</Element>
109              <Value>0.02</Value>
110            </Row>
111            <Row>
112              <Element>Emc Corp.</Element>
113              <Value>0.0185</Value>
114            </Row>
115            <Row>
116              <Element>American International Group, Inc.</Element>
117              <Value>0.0181</Value>
118            </Row>
119            <Row>
120              <Element>Oracle Corporation</Element>
121              <Value>0.0172</Value>
122            </Row>
123          </PortfolioDistribution>
124          <PortfolioDistribution type="IB" date="09/30/2000">
125            <Row>
126              <Element>Pharmaceuticals</Element>
127              <Value>0.0941</Value>
128            </Row>
129            <Row>
130              <Element>Communications Equipment</Element>
131              <Value>0.0857</Value>
132            </Row>
133            <Row>
134              <Element>Computers &amp; Peripherals</Element>
135              <Value>0.0764</Value>
136            </Row>
137            <Row>
138              <Element>Diversified Financials</Element>
139              <Value>0.0724</Value>
140            </Row>
141            <Row>
142              <Element>Industrial Conglomerates</Element>
143              <Value>0.0581</Value>
144            </Row>
145            <Row>
146              <Element>Diversified Telecommunication Services</Element>
147              <Value>0.058</Value>
148            </Row>
149            <Row>
150              <Element>Software</Element>
151              <Value>0.056</Value>
152            </Row>
153            <Row>
154              <Element>Other</Element>
155              <Value>0.5002</Value>
156            </Row>
157            <Row>
158              <Element>Cash &amp; Cash Equivalents</Element>
159              <Value>-0.0012</Value>
160            </Row>
161          </PortfolioDistribution>
162          <PortfolioDistribution type="SB" date="09/30/2000">
163            <Row>
164              <Element>Information Technology</Element>
165              <Value>0.2964</Value>
166            </Row>
167            <Row>
168              <Element>Financials</Element>
169              <Value>0.154</Value>
170            </Row>
171            <Row>
172              <Element>Health Care</Element>
173              <Value>0.1265</Value>
174            </Row>
175            <Row>
176              <Element>Consumer Discretionary</Element>
177              <Value>0.1026</Value>
178            </Row>
179            <Row>
180              <Element>Industrials</Element>
181              <Value>0.0874</Value>
182            </Row>
183            <Row>
184              <Element>Telecommunication Services</Element>
185              <Value>0.0632</Value>
186            </Row>
187            <Row>
188              <Element>Consumer Staples</Element>
189              <Value>0.0575</Value>
190            </Row>
191            <Row>
192              <Element>Other</Element>
193              <Value>0.1136</Value>
194            </Row>
195            <Row>
196              <Element>Cash &amp; Cash Equivalents</Element>
197              <Value>-0.0012</Value>
198            </Row>
199          </PortfolioDistribution>
200        </Composition>
201      </Request>
202    </Report>
203  </Body>
204</Envelope>
205