soap: Add some new tests. right now they are failing
This commit is contained in:
parent
47ccf4d718
commit
2cd1c0a8be
684
SoapCoreTests.st
684
SoapCoreTests.st
|
@ -1,3 +1,687 @@
|
|||
TestCase subclass: SoapActionTestCase [
|
||||
|
||||
<comment: nil>
|
||||
<category: 'SOAP-TestCases'>
|
||||
|
||||
testIntent [
|
||||
<category: 'testing'>
|
||||
| act |
|
||||
act := SoapAction intent: 'urn:targetObjectURI:fooBar'.
|
||||
self should:
|
||||
[act printString = ('SOAPAction: ' , '"urn:targetObjectURI:fooBar"'
|
||||
, (String with: Character cr with: Character lf))]
|
||||
]
|
||||
|
||||
testIntentByRequestURI [
|
||||
<category: 'testing'>
|
||||
| act |
|
||||
act := SoapAction intentByRequestURI.
|
||||
self should:
|
||||
[act printString
|
||||
= ('SOAPAction: ' , '""' , (String with: Character cr with: Character lf))]
|
||||
]
|
||||
|
||||
testNoIntent [
|
||||
<category: 'testing'>
|
||||
| act |
|
||||
act := SoapAction noIntent.
|
||||
self should:
|
||||
[act printString
|
||||
= ('SOAPAction: ' , (String with: Character cr with: Character lf))]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
|
||||
TestCase subclass: SoapDecoderTestCase [
|
||||
|
||||
<comment: nil>
|
||||
<category: 'SOAP-TestCases'>
|
||||
|
||||
arrayOfArrayXML [
|
||||
<category: 'fixtures'>
|
||||
^'<m:reverseArray
|
||||
xmlns:m="http://www.mars.dti.ne.jp/~umejava/smalltalk/soapOpera/rpc/"
|
||||
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<SOAP-ENC:Array xsi:type="SOAP-ENC:Array"
|
||||
SOAP-ENC:arrayType="SOAP-ENC:Array[2]">
|
||||
<item xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[0]">
|
||||
</item>
|
||||
<item xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[3]">
|
||||
<item xsi:type="xsd:int">17974494715439249409</item>
|
||||
<item xsi:type="xsd:string">aV34fTn/QoILMlilPla2Pw==</item>
|
||||
<item xsi:type="xsd:string">20030913T14:26:28 +200</item>
|
||||
</item>
|
||||
</SOAP-ENC:Array>
|
||||
</m:reverseArray>
|
||||
'
|
||||
]
|
||||
|
||||
arrayReturnEnvelopeDocumentStyleXML [
|
||||
<category: 'fixtures'>
|
||||
^'<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="urn:my.test.com">
|
||||
<env:Body>
|
||||
<ns0:DataVersionArrayElement>
|
||||
<ns0:dataVersion>
|
||||
<ns0:country>US</ns0:country>
|
||||
<ns0:build>379</ns0:build>
|
||||
</ns0:dataVersion>
|
||||
<ns0:dataVersion>
|
||||
<ns0:country>CA</ns0:country>
|
||||
<ns0:build>376</ns0:build>
|
||||
</ns0:dataVersion>
|
||||
</ns0:DataVersionArrayElement>
|
||||
</env:Body>
|
||||
</env:Envelope>'
|
||||
]
|
||||
|
||||
arrayWithEmptyStringXML [
|
||||
<category: 'fixtures'>
|
||||
^' <m:reverseArray
|
||||
xmlns:m="http://www.mars.dti.ne.jp/~umejava/smalltalk/soapOpera/rpc/"
|
||||
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<anArray SOAP-ENC:arrayType="xsd:anyType[3]">
|
||||
<item xsi:type="xsd:string">Hello</item>
|
||||
<item xsi:type="xsd:string"></item>
|
||||
<item xsi:type="xsd:string">Dolphin</item>
|
||||
</anArray>
|
||||
</m:reverseArray>
|
||||
'
|
||||
]
|
||||
|
||||
complexDataXML [
|
||||
"Google API like complex XML"
|
||||
|
||||
<category: 'fixtures'>
|
||||
^' <return xsi:type="ns1:GoogleSearchResult" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
|
||||
<documentFiltering xsi:type="xsd:boolean">false</documentFiltering>
|
||||
<estimatedTotalResultsCount xsi:type="xsd:int">1</estimatedTotalResultsCount>
|
||||
<directoryCategories xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Array" ns2:arrayType="ns1:DirectoryCategory[0]"></directoryCategories>
|
||||
<searchTime xsi:type="xsd:double">0.194871</searchTime>
|
||||
<resultElements xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Array" ns3:arrayType="ns1:ResultElement[1]">
|
||||
<item xsi:type="ns1:ResultElement">
|
||||
<cachedSize xsi:type="xsd:string">2k</cachedSize>
|
||||
<hostName xsi:type="xsd:string">somehost</hostName>
|
||||
<snippet xsi:type="xsd:string">snippet...</snippet>
|
||||
<directoryCategory xsi:type="ns1:DirectoryCategory">
|
||||
<specialEncoding xsi:type="xsd:string"></specialEncoding>
|
||||
<fullViewableName xsi:type="xsd:string"></fullViewableName>
|
||||
</directoryCategory>
|
||||
<relatedInformationPresent xsi:type="xsd:boolean">true</relatedInformationPresent>
|
||||
<directoryTitle xsi:type="xsd:string"></directoryTitle>
|
||||
<summary xsi:type="xsd:string"></summary>
|
||||
<URL xsi:type="xsd:string">http://www.squeak.org</URL>
|
||||
<title xsi:type="xsd:string">Squeak home page</title>
|
||||
</item>
|
||||
</resultElements>
|
||||
<endIndex xsi:type="xsd:int">1</endIndex>
|
||||
<searchTips xsi:type="xsd:string"></searchTips>
|
||||
<searchComments xsi:type="xsd:string"></searchComments>
|
||||
<startIndex xsi:type="xsd:int">1</startIndex>
|
||||
<estimateIsExact xsi:type="xsd:boolean">true</estimateIsExact>
|
||||
<searchQuery xsi:type="xsd:string">squeak</searchQuery>
|
||||
</return>'
|
||||
]
|
||||
|
||||
dotNetSharedValuesEnvelopeXML [
|
||||
<category: 'fixtures'>
|
||||
^'<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:types="urn:WebBookingEngine" xmlns:tns="urn:WebBookingEngine"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<types:FindPropertiesIdByLocationResponse>
|
||||
<FindPropertiesIdByLocationResult
|
||||
href="#id1"></FindPropertiesIdByLocationResult>
|
||||
</types:FindPropertiesIdByLocationResponse>
|
||||
<soapenc:Array id="id1" soapenc:arrayType="xsd:int[37]">
|
||||
<Item>22039</Item>
|
||||
<Item>22933</Item>
|
||||
<Item>23177</Item>
|
||||
<Item>23249</Item>
|
||||
<Item>23393</Item>
|
||||
</soapenc:Array>
|
||||
</soap:Body>
|
||||
</soap:Envelope>'
|
||||
]
|
||||
|
||||
dotNetSharedValuesEnvelopeXML2 [
|
||||
<category: 'fixtures'>
|
||||
^'<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:types="http://tempuri.org/" xmlns:tns="http://tempuri.org/"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<types:FindCustomersResponse>
|
||||
<FindCustomersResult href="#id1"></FindCustomersResult>
|
||||
</types:FindCustomersResponse>
|
||||
<soapenc:Array id="id1" soapenc:arrayType="types:Customer[2]">
|
||||
<Item href="#id2"></Item>
|
||||
<Item href="#id3"></Item>
|
||||
</soapenc:Array>
|
||||
<types:Customer id="id2" xsi:type="types:Customer">
|
||||
<Name xsi:type="xsd:string">Ume</Name>
|
||||
<Age xsi:type="xsd:int">36</Age>
|
||||
<DateOfBirth
|
||||
xsi:type="xsd:dateTime">1970-11-22T00:00:00.0000000-07:00</DateOfBirth>
|
||||
</types:Customer>
|
||||
<types:Customer id="id3" xsi:type="types:Customer">
|
||||
<Name xsi:type="xsd:string">Ramon</Name>
|
||||
<Age xsi:type="xsd:int">31</Age>
|
||||
<DateOfBirth
|
||||
xsi:type="xsd:dateTime">1995-11-22T00:00:00.0000000-07:00</DateOfBirth>
|
||||
</types:Customer>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
||||
'
|
||||
]
|
||||
|
||||
dotNetSharedValuesEnvelopeXML3 [
|
||||
<category: 'fixtures'>
|
||||
^'<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:types="http://tempuri.org/" xmlns:tns="http://tempuri.org/"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<types:GoResponse>
|
||||
<GoResult href="#id1"></GoResult>
|
||||
<aSimpleOutParam xsi:type="xsd:int">42</aSimpleOutParam>
|
||||
<aMultiValOutParam href="#id2"></aMultiValOutParam>
|
||||
</types:GoResponse>
|
||||
<soapenc:Array id="id1" soapenc:arrayType="xsd:string[10]">
|
||||
<Item>632900993212352500</Item>
|
||||
<Item>632900993212508750</Item>
|
||||
</soapenc:Array>
|
||||
<soapenc:Array id="id2" soapenc:arrayType="xsd:int[3]">
|
||||
<Item>1</Item>
|
||||
<Item>2</Item>
|
||||
<Item>3</Item>
|
||||
</soapenc:Array>
|
||||
</soap:Body>
|
||||
</soap:Envelope>'
|
||||
]
|
||||
|
||||
multiReturnEnvelopeDocumentStyleXML [
|
||||
<category: 'fixtures'>
|
||||
^'<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<soapenv:Header>
|
||||
</soapenv:Header>
|
||||
<soapenv:Body>
|
||||
<ns:sampleResponse xmlns:ns="http://service.spring/xsd">
|
||||
<ns:return>
|
||||
<id xmlns="http://bean.spring/xsd">5</id>
|
||||
<number xmlns="http://bean.spring/xsd">65413</number>
|
||||
<address1 xmlns="http://bean.spring/xsd">Brno-Chrlice</address1>
|
||||
<address2 xmlns="http://bean.spring/xsd">Brno-msto</address2>
|
||||
</ns:return>
|
||||
<ns:return>
|
||||
<id xmlns="http://bean.spring/xsd">1</id>
|
||||
<number xmlns="http://bean.spring/xsd">65384</number>
|
||||
<address1 xmlns="http://bean.spring/xsd">Liberec</address1>
|
||||
<address2 xmlns="http://bean.spring/xsd">Chrastava</address2>
|
||||
</ns:return>
|
||||
</ns:sampleResponse>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>'
|
||||
]
|
||||
|
||||
oneSizeArrayReturnEnvelopeDocumentStyleXML [
|
||||
<category: 'fixtures'>
|
||||
^'<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="urn:my.test.com">
|
||||
<env:Body>
|
||||
<ns0:DataVersionArrayElement>
|
||||
<ns0:dataVersion>
|
||||
<ns0:country>US</ns0:country>
|
||||
<ns0:build>379</ns0:build>
|
||||
</ns0:dataVersion>
|
||||
</ns0:DataVersionArrayElement>
|
||||
</env:Body>
|
||||
</env:Envelope>'
|
||||
]
|
||||
|
||||
sharedValuesXML [
|
||||
<category: 'fixtures'>
|
||||
^'<return xsi:type="e:SearchResult" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
|
||||
<e:Book>
|
||||
<title>My Life and Work</title>
|
||||
<author href="#Person-1"/>
|
||||
</e:Book>
|
||||
<e:Person id="Person-1">
|
||||
<name>Henry Ford</name>
|
||||
<address href="#Address-2"/>
|
||||
</e:Person>
|
||||
<e:Address id="Address-2">
|
||||
<email>mailto:henryford@hotmail.com</email>
|
||||
<web>http://www.henryford.com</web>
|
||||
</e:Address>
|
||||
</return>'
|
||||
]
|
||||
|
||||
singleReturnEnvelopeDocumentStyleXML [
|
||||
<category: 'fixtures'>
|
||||
^'<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<soapenv:Header>
|
||||
</soapenv:Header>
|
||||
<soapenv:Body>
|
||||
<ns:sampleResponse xmlns:ns="http://service.spring/xsd">
|
||||
<ns:return>bareString</ns:return>
|
||||
</ns:sampleResponse>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>'
|
||||
]
|
||||
|
||||
testDecodeAnyArray [
|
||||
<category: 'testing'>
|
||||
| dec ret |
|
||||
dec := SoapDecoder new.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable name: 'anyArr1' value: #(1 '2' 3.0))
|
||||
asXmlElement.
|
||||
self should: [ret = #(1 '2' 3.0)]
|
||||
]
|
||||
|
||||
testDecodeArrayOfArray [
|
||||
<category: 'testing'>
|
||||
| dec arrayElem ret |
|
||||
dec := SoapDecoder new.
|
||||
arrayElem := SoapWrapElement fromXml: self arrayOfArrayXML.
|
||||
ret := dec decodeXmlElement: arrayElem.
|
||||
ret inspect.
|
||||
self should: [(ret at: #Array) isKindOf: Array].
|
||||
self should: [((ret at: #Array) at: 1) = #()].
|
||||
self should:
|
||||
[((ret at: #Array) at: 2)
|
||||
= #(17974494715439249409 'aV34fTn/QoILMlilPla2Pw==' '20030913T14:26:28 +200')]
|
||||
]
|
||||
|
||||
testDecodeArrayReturnEnvelopeDocumentStyleXML [
|
||||
"self debug: #testDecodeArrayReturnEnvelopeDocumentStyleXML"
|
||||
|
||||
<category: 'testing'>
|
||||
| envelopeBuilder returnEnvelope message resp value dict1 dict2 |
|
||||
SoapDecoder arrayTypeDict at: 'DataVersionArrayElement' put: Array.
|
||||
envelopeBuilder := SoapEnvelopeBuilder new.
|
||||
returnEnvelope := envelopeBuilder
|
||||
buildSoapEnvelopeFromXmlString: self arrayReturnEnvelopeDocumentStyleXML.
|
||||
message := SoapMessage envelope: returnEnvelope.
|
||||
resp := SoapResponse fromSoapMessage: message.
|
||||
resp style: #document.
|
||||
value := resp returnValue.
|
||||
SoapDecoder arrayTypeDict removeKey: 'DataVersionArrayElement'.
|
||||
self should: [value size = 2].
|
||||
dict1 := value first.
|
||||
self should: [(dict1 at: 'build') = '379'].
|
||||
self should: [(dict1 at: 'country') = 'US'].
|
||||
dict2 := value second.
|
||||
self should: [(dict2 at: 'build') = '376'].
|
||||
self should: [(dict2 at: 'country') = 'CA']
|
||||
]
|
||||
|
||||
testDecodeArrayWithEmptyString [
|
||||
<category: 'testing'>
|
||||
| dec arrayElem ret |
|
||||
dec := SoapDecoder new.
|
||||
arrayElem := SoapWrapElement fromXml: self arrayWithEmptyStringXML.
|
||||
ret := dec decodeXmlElement: arrayElem.
|
||||
self should: [(ret at: #anArray) isKindOf: Array].
|
||||
self should: [((ret at: #anArray) at: 2) = '']
|
||||
]
|
||||
|
||||
testDecodeBase64Binary [
|
||||
<category: 'testing'>
|
||||
| dec ret bytes |
|
||||
dec := SoapDecoder new.
|
||||
bytes := ByteArray
|
||||
with: 1
|
||||
with: 2
|
||||
with: 3
|
||||
with: 4.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'binbin'
|
||||
value: bytes
|
||||
type: #ByteArray) asXmlElement.
|
||||
self should: [ret = bytes]
|
||||
]
|
||||
|
||||
testDecodeBoolean [
|
||||
"self debug: #testDecodeBoolean"
|
||||
|
||||
<category: 'testing'>
|
||||
| dec ret |
|
||||
dec := SoapDecoder new.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'arg1'
|
||||
value: 'true'
|
||||
type: #Boolean) asXmlElement.
|
||||
self should: [ret = true].
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'arg1'
|
||||
value: '1'
|
||||
type: #Boolean) asXmlElement.
|
||||
self should: [ret = true].
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'arg1'
|
||||
value: 'false'
|
||||
type: #Boolean) asXmlElement.
|
||||
self should: [ret = false].
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'arg1'
|
||||
value: '0'
|
||||
type: #Boolean) asXmlElement.
|
||||
self should: [ret = false]
|
||||
]
|
||||
|
||||
testDecodeComplexData [
|
||||
<category: 'testing'>
|
||||
"self debug: #testDecodeComplexData"
|
||||
|
||||
| dec complexElem ret resultElements resultElement directoryCategory |
|
||||
dec := SoapDecoder new.
|
||||
complexElem := SoapWrapElement fromXml: self complexDataXML.
|
||||
ret := dec decodeXmlElement: complexElem.
|
||||
self should: [ret isKindOf: Dictionary].
|
||||
self should: [(ret at: #startIndex) = 1].
|
||||
self should: [(ret at: #searchTime) = 0.194871].
|
||||
self should: [(ret at: #searchQuery) = 'squeak'].
|
||||
resultElements := ret at: #resultElements.
|
||||
self should: [resultElements isKindOf: Array].
|
||||
self should: [resultElements size = 1].
|
||||
resultElement := resultElements first.
|
||||
self should: [resultElement isKindOf: Dictionary].
|
||||
self should: [(resultElement at: #URL) = 'http://www.squeak.org'].
|
||||
self should: [(resultElement at: #title) = 'Squeak home page'].
|
||||
directoryCategory := resultElement at: #directoryCategory.
|
||||
self should: [directoryCategory isKindOf: Dictionary].
|
||||
self should: [(directoryCategory at: #fullViewableName) = '']
|
||||
]
|
||||
|
||||
testDecodeDotNetSharedValuesXMLEnvelope [
|
||||
"self debug: #testDecodeDotNetSharedValuesXMLEnvelope"
|
||||
|
||||
<category: 'testing'>
|
||||
| originalUseDotNetStyleSharedValues envelopeBuilder returnEnvelope message resp value |
|
||||
|
||||
[originalUseDotNetStyleSharedValues := SoapResponse
|
||||
useDotNetStyleSharedValues.
|
||||
SoapResponse useDotNetStyleSharedValues: true.
|
||||
envelopeBuilder := SoapEnvelopeBuilder new.
|
||||
returnEnvelope := envelopeBuilder
|
||||
buildSoapEnvelopeFromXmlString: self dotNetSharedValuesEnvelopeXML.
|
||||
message := SoapMessage envelope: returnEnvelope.
|
||||
resp := SoapResponse fromSoapMessage: message.
|
||||
value := resp returnValue.
|
||||
self should:
|
||||
[value
|
||||
= #(22039 22933 23177 23249 23393 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil)]]
|
||||
ensure:
|
||||
[SoapResponse
|
||||
useDotNetStyleSharedValues: originalUseDotNetStyleSharedValues]
|
||||
]
|
||||
|
||||
testDecodeDotNetSharedValuesXMLEnvelope2 [
|
||||
"self debug: #testDecodeDotNetSharedValuesXMLEnvelope2"
|
||||
|
||||
<category: 'testing'>
|
||||
| originalUseDotNetStyleSharedValues envelopeBuilder returnEnvelope message resp value |
|
||||
self should: [Smalltalk hasClassNamed: #SoapSampleCustomer].
|
||||
SoapSampleCustomer initialize.
|
||||
|
||||
[originalUseDotNetStyleSharedValues := SoapResponse
|
||||
useDotNetStyleSharedValues.
|
||||
SoapResponse useDotNetStyleSharedValues: true.
|
||||
envelopeBuilder := SoapEnvelopeBuilder new.
|
||||
returnEnvelope := envelopeBuilder
|
||||
buildSoapEnvelopeFromXmlString: self dotNetSharedValuesEnvelopeXML2.
|
||||
message := SoapMessage envelope: returnEnvelope.
|
||||
resp := SoapResponse fromSoapMessage: message.
|
||||
value := resp returnValue.
|
||||
self should: [value size = 2].
|
||||
self should: [value first name = 'Ume'].
|
||||
self should: [value first age = 36].
|
||||
self should:
|
||||
[value first dateOfBirth
|
||||
= (DateAndTime fromString: '1970-11-22T00:00:00-07:00')].
|
||||
self should: [value second name = 'Ramon'].
|
||||
self should: [value second age = 31].
|
||||
self should:
|
||||
[value second dateOfBirth
|
||||
= (DateAndTime fromString: '1995-11-22T00:00:00-07:00')]]
|
||||
ensure:
|
||||
[SoapResponse
|
||||
useDotNetStyleSharedValues: originalUseDotNetStyleSharedValues]
|
||||
]
|
||||
|
||||
testDecodeDotNetSharedValuesXMLEnvelope3 [
|
||||
"self debug: #testDecodeDotNetSharedValuesXMLEnvelope3"
|
||||
|
||||
<category: 'testing'>
|
||||
| originalUseDotNetStyleSharedValues envelopeBuilder returnEnvelope message resp value outparams |
|
||||
|
||||
[originalUseDotNetStyleSharedValues := SoapResponse
|
||||
useDotNetStyleSharedValues.
|
||||
SoapResponse useDotNetStyleSharedValues: true.
|
||||
envelopeBuilder := SoapEnvelopeBuilder new.
|
||||
returnEnvelope := envelopeBuilder
|
||||
buildSoapEnvelopeFromXmlString: self dotNetSharedValuesEnvelopeXML3.
|
||||
message := SoapMessage envelope: returnEnvelope.
|
||||
resp := SoapResponse fromSoapMessage: message.
|
||||
value := resp returnValue.
|
||||
self should: [value size = 10].
|
||||
self should: [value first = '632900993212352500'].
|
||||
self should: [value second = '632900993212508750'].
|
||||
outparams := resp outparameters.
|
||||
self should: [outparams size = 2].
|
||||
self should: [outparams first = 42].
|
||||
self should: [outparams second = #(1 2 3)]]
|
||||
ensure:
|
||||
[SoapResponse
|
||||
useDotNetStyleSharedValues: originalUseDotNetStyleSharedValues]
|
||||
]
|
||||
|
||||
testDecodeEmptyString [
|
||||
<category: 'testing'>
|
||||
| dec ret |
|
||||
dec := SoapDecoder new.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'arg1'
|
||||
value: ''
|
||||
type: #String) asXmlElement.
|
||||
self should: [ret = '']
|
||||
]
|
||||
|
||||
testDecodeFloatArray [
|
||||
<category: 'testing'>
|
||||
| dec ret |
|
||||
dec := SoapDecoder new.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable name: 'floatArr1'
|
||||
value: #(1.1 2.2 3.3000000000000003)) asXmlElement.
|
||||
self should: [ret = #(1.1 2.2 3.3000000000000003)]
|
||||
]
|
||||
|
||||
testDecodeInteger [
|
||||
<category: 'testing'>
|
||||
| dec ret |
|
||||
dec := SoapDecoder new.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'arg1'
|
||||
value: '1234567'
|
||||
type: #Integer) asXmlElement.
|
||||
self should: [ret = 1234567]
|
||||
]
|
||||
|
||||
testDecodeIntegerArray [
|
||||
<category: 'testing'>
|
||||
| dec ret |
|
||||
dec := SoapDecoder new.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'intArr1'
|
||||
value: #(1 2 3)
|
||||
type: #Array) asXmlElement.
|
||||
self should: [ret = #(1 2 3)]
|
||||
]
|
||||
|
||||
testDecodeIsSafe [
|
||||
<category: 'testing'>
|
||||
|
||||
]
|
||||
|
||||
testDecodeMultiReturnEnvelopeDocumentStyleXML [
|
||||
"self debug: #testDecodeMultiReturnEnvelopeDocumentStyleXML"
|
||||
|
||||
<category: 'testing'>
|
||||
| envelopeBuilder returnEnvelope message resp value dict1 dict2 |
|
||||
envelopeBuilder := SoapEnvelopeBuilder new.
|
||||
returnEnvelope := envelopeBuilder
|
||||
buildSoapEnvelopeFromXmlString: self multiReturnEnvelopeDocumentStyleXML.
|
||||
message := SoapMessage envelope: returnEnvelope.
|
||||
resp := SoapResponse fromSoapMessage: message.
|
||||
resp style: #document.
|
||||
value := resp returnValue.
|
||||
self should: [value size = 2].
|
||||
dict1 := value first.
|
||||
self should: [(dict1 at: 'id') = '5'].
|
||||
self should: [(dict1 at: 'number') = '65413'].
|
||||
self should: [(dict1 at: 'address1') = 'Brno-Chrlice'].
|
||||
self should: [(dict1 at: 'address2') = 'Brno-msto'].
|
||||
dict2 := value second.
|
||||
self should: [(dict2 at: 'id') = '1'].
|
||||
self should: [(dict2 at: 'number') = '65384'].
|
||||
self should: [(dict2 at: 'address1') = 'Liberec'].
|
||||
self should: [(dict2 at: 'address2') = 'Chrastava']
|
||||
]
|
||||
|
||||
testDecodeNil [
|
||||
"self debug: #testDecodeNil"
|
||||
|
||||
<category: 'testing'>
|
||||
| originalUseNull dec ret |
|
||||
|
||||
[originalUseNull := SoapEncoder useXsiNullAttribute.
|
||||
dec := SoapDecoder new.
|
||||
SoapEncoder useXsiNullAttribute: true.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapWrapElement fromXml: '<value xsd:null="true" />').
|
||||
self should: [ret = nil]]
|
||||
ensure: [SoapEncoder useXsiNullAttribute: originalUseNull]
|
||||
]
|
||||
|
||||
testDecodeOneSizeArrayReturnEnvelopeDocumentStyleXML [
|
||||
"self debug: #testDecodeOneSizeArrayReturnEnvelopeDocumentStyleXML"
|
||||
|
||||
<category: 'testing'>
|
||||
| envelopeBuilder returnEnvelope message resp value dict1 |
|
||||
SoapDecoder arrayTypeDict at: 'DataVersionArrayElement' put: Array.
|
||||
envelopeBuilder := SoapEnvelopeBuilder new.
|
||||
returnEnvelope := envelopeBuilder buildSoapEnvelopeFromXmlString: self
|
||||
oneSizeArrayReturnEnvelopeDocumentStyleXML.
|
||||
message := SoapMessage envelope: returnEnvelope.
|
||||
resp := SoapResponse fromSoapMessage: message.
|
||||
resp style: #document.
|
||||
value := resp returnValue.
|
||||
SoapDecoder arrayTypeDict removeKey: 'DataVersionArrayElement'.
|
||||
self should: [value size = 1].
|
||||
dict1 := value first.
|
||||
self should: [(dict1 at: 'build') = '379'].
|
||||
self should: [(dict1 at: 'country') = 'US']
|
||||
]
|
||||
|
||||
testDecodeSharedValues [
|
||||
"self debug: #testDecodeSharedValues"
|
||||
|
||||
<category: 'testing'>
|
||||
| xml elem dec address book person |
|
||||
xml := SoapDecoderTestCase new sharedValuesXML.
|
||||
elem := SoapWrapElement fromXml: xml.
|
||||
dec := SoapDecoder new.
|
||||
elem := dec decodeXmlElement: elem.
|
||||
address := elem at: 'Address'.
|
||||
book := elem at: 'Book'.
|
||||
person := elem at: 'Person'.
|
||||
self should: [(book at: 'author') = person].
|
||||
self should: [(person at: 'address') = address]
|
||||
]
|
||||
|
||||
testDecodeSingleReturnEnvelopeDocumentStyleXML [
|
||||
"self debug: #testDecodeSingleReturnEnvelopeDocumentStyleXML"
|
||||
|
||||
<category: 'testing'>
|
||||
| envelopeBuilder returnEnvelope message resp value |
|
||||
envelopeBuilder := SoapEnvelopeBuilder new.
|
||||
returnEnvelope := envelopeBuilder
|
||||
buildSoapEnvelopeFromXmlString: self singleReturnEnvelopeDocumentStyleXML.
|
||||
message := SoapMessage envelope: returnEnvelope.
|
||||
resp := SoapResponse fromSoapMessage: message.
|
||||
resp style: #document.
|
||||
value := resp returnValue.
|
||||
self should: [value = 'bareString']
|
||||
]
|
||||
|
||||
testDecodeString [
|
||||
<category: 'testing'>
|
||||
| dec ret |
|
||||
dec := SoapDecoder new.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'arg1'
|
||||
value: 'Smalltalk'
|
||||
type: #String) asXmlElement.
|
||||
self should: [ret = 'Smalltalk']
|
||||
]
|
||||
|
||||
testDecodeStringArray [
|
||||
<category: 'testing'>
|
||||
| dec ret |
|
||||
dec := SoapDecoder new.
|
||||
ret := dec
|
||||
decodeXmlElement: (SoapVariable
|
||||
name: 'stringArr1'
|
||||
value: #('a' 'b' '<c>')
|
||||
type: #Array) asXmlElement.
|
||||
self should: [ret = #('a' 'b' '<c>')]
|
||||
]
|
||||
|
||||
testDefaultTypesDecodeIsSafe [
|
||||
"self debug: #testDefaultTypesDecodeIsSafe"
|
||||
|
||||
<category: 'testing'>
|
||||
| classes |
|
||||
classes := SoapDecoder typeDict values asSet
|
||||
collect: [:each | Smalltalk at: each].
|
||||
classes do:
|
||||
[:each |
|
||||
| inst |
|
||||
inst := [Integer readFrom: '1+2*3'] on: Error do: [:ex | ex "Handled"].
|
||||
(each isKindOf: Number)
|
||||
ifTrue: [self assert: (inst = 0 or: [inst isKindOf: Error])]
|
||||
ifFalse: [self assert: ((inst isKindOf: each) or: [inst isKindOf: Error])].
|
||||
self deny: inst = 9]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
|
||||
TestCase subclass: SoapBodyTestCase [
|
||||
|
||||
<comment: nil>
|
||||
|
|
Reference in New Issue