soaspec 0.0.76 → 0.0.77
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/exe/soaspec +46 -0
- data/lib/soaspec/exchange.rb +1 -0
- data/lib/soaspec/exe_helpers.rb +220 -0
- data/lib/soaspec/version.rb +1 -1
- data/soaspec.gemspec +1 -0
- metadata +18 -4
- data/exe/soaspec-init +0 -243
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67969ede0a36306652d44ece28fb979980e81e72
|
4
|
+
data.tar.gz: 6ca6c9d0887c36bcbb1683299308f349c2a70180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d31d9064daa746a272fb2cac0da67f5b797f86c3258b973136f7f55f2f91678fa3f23b3fbb038a6c57ab9d431c8a21643c02d6b0d12b53189b8735dcbb09b928
|
7
|
+
data.tar.gz: 54a3005df87d30182c036ca6177818dac46b0eda51856b100aa611c5c4dde276beba4f8e010545c6d74757c316990d3f7f0ae1c31c51d6cf20e591a1779d2ad3
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.0.77
|
2
|
+
* Enhancements
|
3
|
+
* Use 'thor' for soaspec-init binary changing it to be `soaspec init`. Will update `soaspec-generate` in next version
|
4
|
+
* Put pause of 1/2 a second for each API retry. Often retry is too quick otherwise
|
5
|
+
|
1
6
|
Version 0.0.76
|
2
7
|
* Bug fix
|
3
8
|
* Fixed BLZService scenario on soaspec-virtual-server
|
data/exe/soaspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
require 'thor'
|
5
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
6
|
+
require 'savon'
|
7
|
+
require 'soaspec'
|
8
|
+
|
9
|
+
module Soaspec
|
10
|
+
# Common executable for Soaspec
|
11
|
+
class Exe < Thor
|
12
|
+
|
13
|
+
include Soaspec::ExeHelpers
|
14
|
+
|
15
|
+
desc 'soaspec [type]', 'Initialize soaspec repository'
|
16
|
+
def init
|
17
|
+
puts 'Creating files for soaspec'
|
18
|
+
|
19
|
+
create_file(filename: 'Gemfile', content: gem_content)
|
20
|
+
create_file(filename: 'Rakefile', content: rake_virtual_content)
|
21
|
+
create_file(filename: 'README.md', content: readme_content)
|
22
|
+
create_folder 'lib'
|
23
|
+
create_file(filename: 'lib/blz_service.rb', content: weather_web_service)
|
24
|
+
create_file filename: 'lib/shared_example.rb', content: shared_examples_content
|
25
|
+
create_folder 'config'
|
26
|
+
create_folder 'config/data'
|
27
|
+
create_file(filename: 'config/data/default.yml', content: default_yaml_content)
|
28
|
+
create_folder 'spec'
|
29
|
+
create_folder 'spec/test_data'
|
30
|
+
create_folder 'spec/test_data/wsdl'
|
31
|
+
create_file(filename: 'spec/spec_helper.rb', content: spec_helper_content)
|
32
|
+
create_file(filename: 'spec/soap_spec.rb', content: soap_spec_content)
|
33
|
+
create_file(filename: 'spec/test_server.rb', content: test_server_content)
|
34
|
+
create_file(filename: 'spec/test_data/wsdl/get_bank.wsdl', content: test_wsdl_content)
|
35
|
+
create_folder 'template'
|
36
|
+
create_file(filename: 'template/soap_template.xml', content: soap_template_content)
|
37
|
+
create_folder 'logs'
|
38
|
+
|
39
|
+
puts "Run 'bundle install' to install necessary gems"
|
40
|
+
puts "Run 'rake spec' to run the tests"
|
41
|
+
puts "Note: Setup runs Sinatra for Test Service on port 4567 by default. Change Rakefile 'start_test_server' task to update this"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Soaspec::Exe.start(ARGV)
|
data/lib/soaspec/exchange.rb
CHANGED
@@ -111,6 +111,7 @@ class Exchange
|
|
111
111
|
response = exchange_handler.make_request(request_params)
|
112
112
|
return response unless retry_for_success?
|
113
113
|
return response if (200..299).cover? @exchange_handler.status_code_for(response)
|
114
|
+
sleep 0.5
|
114
115
|
break response if count == retry_count
|
115
116
|
end
|
116
117
|
end
|
data/lib/soaspec/exe_helpers.rb
CHANGED
@@ -255,6 +255,226 @@ Caused by: org.apache.axis2.databinding.ADBException: Unexpected subelement getB
|
|
255
255
|
FILEEOF
|
256
256
|
end
|
257
257
|
|
258
|
+
def weather_web_service
|
259
|
+
<<-WEATH_WEB
|
260
|
+
require 'soaspec'
|
261
|
+
|
262
|
+
# This class is not part of the gem. It's an example of a class you can make
|
263
|
+
# to describe your APIs. Usually this would exist in the 'lib' directory
|
264
|
+
# Common configuration for the Savon client should go here
|
265
|
+
class BLZService < Soaspec::SoapHandler
|
266
|
+
# Add to or override default Savon client options
|
267
|
+
def savon_options
|
268
|
+
{
|
269
|
+
# wsdl: 'http://www.thomas-bayer.com/axis2/services/BLZService?wsdl' # External
|
270
|
+
wsdl: File.join('spec', 'test_data', 'wsdl', 'get_bank.wsdl')
|
271
|
+
}
|
272
|
+
end
|
273
|
+
|
274
|
+
# # Specifying that get_weather_result must be present in the SOAP response
|
275
|
+
mandatory_elements [:plz]
|
276
|
+
|
277
|
+
# Example of xpath value that must be true for all success scenarios
|
278
|
+
mandatory_xpath_values 'ns1:bezeichnung' => 'Deutsche Bank'
|
279
|
+
|
280
|
+
# Example of setting an attribute on the root XML element
|
281
|
+
root_attributes 'Version' => '1' # TODO: Create test on request for this
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
WEATH_WEB
|
286
|
+
end
|
287
|
+
|
288
|
+
def soap_spec_content
|
289
|
+
<<-SOAP_SPEC
|
290
|
+
|
291
|
+
require 'spec_helper'
|
292
|
+
|
293
|
+
Soaspec.strip_namespaces = true # This allows namespace not to be used. Be careful with this
|
294
|
+
|
295
|
+
id = '70070010'
|
296
|
+
# BLZService.new(template_name: 'soap_template') Use this instead of default_hash to use template approach
|
297
|
+
|
298
|
+
context 'Test Examples' do
|
299
|
+
context BLZService.new('Get Bank', operation: :get_bank, default_hash: { blz: id }) do
|
300
|
+
|
301
|
+
describe Exchange.new(:default) do
|
302
|
+
it { is_expected.to contain_value id }
|
303
|
+
it { is_expected.to include_in_body id }
|
304
|
+
it_behaves_like 'success scenario'
|
305
|
+
after(:all) { described_class.store(:title, 'bezeichnung') }
|
306
|
+
end
|
307
|
+
|
308
|
+
describe Exchange.new(:xpath_eg, blz: 100000) do
|
309
|
+
its(['plz']) { is_expected.to eq '100000' }
|
310
|
+
it { is_expected.to have_xpath_value '//ns1:bezeichnung' => 'Deutsche Bank' }
|
311
|
+
context 'Handle retrieving stored value' do
|
312
|
+
it { is_expected.to have_xpath_value 'bezeichnung' => described_class.retrieve(:title) }
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
describe Exchange.new(:yaml_eg, data_for(:small_id)) do
|
317
|
+
it_behaves_like 'success scenario'
|
318
|
+
end
|
319
|
+
|
320
|
+
# Retry for success more for web services that intermittently fail
|
321
|
+
describe Exchange.new(:short_hand_xpath).retry_for_success do
|
322
|
+
# Be careful. If you call a method that does not use namespaces, calling one that does may not find the element
|
323
|
+
its(['ns1:bezeichnung']) { is_expected.to eq 'Deutsche Bank' } # '//' is not required at the beginning
|
324
|
+
end
|
325
|
+
describe Exchange.new('Check existence of elements') do
|
326
|
+
it { is_expected.to have_element_at_xpath '//ns1:bezeichnung' }
|
327
|
+
it { is_expected.not_to have_element_at_xpath '//ns1:bezeichnung_pretend' }
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
error_example = BLZService.new('Error example')
|
334
|
+
error_example.operation = :get_bank
|
335
|
+
error_example.default_hash = {}
|
336
|
+
|
337
|
+
context 'Error Examples' do
|
338
|
+
context error_example do
|
339
|
+
describe Exchange.new(:no_blz_error) do
|
340
|
+
it_behaves_like 'error scenario'
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
|
346
|
+
SOAP_SPEC
|
347
|
+
end
|
348
|
+
|
349
|
+
def shared_examples_content
|
350
|
+
<<-SHARE_EG
|
351
|
+
|
352
|
+
require 'rspec'
|
353
|
+
|
354
|
+
shared_examples_for 'error scenario' do
|
355
|
+
it 'does not have status code of 200' do
|
356
|
+
expect(described_class.status_code).not_to eq 200
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
SHARE_EG
|
361
|
+
end
|
362
|
+
|
363
|
+
def soap_template_content
|
364
|
+
<<-SOAP_TEMP
|
365
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://thomas-bayer.com/blz/" xmlns:env="http://www.w3.org/2003/05/soap-envelope">
|
366
|
+
<env:Body>
|
367
|
+
<tns:getBank>
|
368
|
+
<tns:blz><%= test_values[:blz] || '70070010' %></tns:blz>
|
369
|
+
</tns:getBank>
|
370
|
+
</env:Body>
|
371
|
+
</env:Envelope>
|
372
|
+
SOAP_TEMP
|
373
|
+
end
|
374
|
+
|
375
|
+
def default_yaml_content
|
376
|
+
<<-DEF_YAML
|
377
|
+
small_id:
|
378
|
+
blz: 100
|
379
|
+
|
380
|
+
DEF_YAML
|
381
|
+
end
|
382
|
+
|
383
|
+
def test_wsdl_content
|
384
|
+
<<TEST_WSDL
|
385
|
+
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://thomas-bayer.com/blz/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://thomas-bayer.com/blz/">
|
386
|
+
<wsdl:documentation>BLZService</wsdl:documentation>
|
387
|
+
<wsdl:types>
|
388
|
+
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://thomas-bayer.com/blz/">
|
389
|
+
<xsd:element name="getBank" type="tns:getBankType"/>
|
390
|
+
<xsd:element name="getBankResponse" type="tns:getBankResponseType"/>
|
391
|
+
<xsd:complexType name="getBankType">
|
392
|
+
<xsd:sequence>
|
393
|
+
<xsd:element name="blz" type="xsd:string"/>
|
394
|
+
</xsd:sequence>
|
395
|
+
</xsd:complexType>
|
396
|
+
<xsd:complexType name="getBankResponseType">
|
397
|
+
<xsd:sequence>
|
398
|
+
<xsd:element name="details" type="tns:detailsType"/>
|
399
|
+
</xsd:sequence>
|
400
|
+
</xsd:complexType>
|
401
|
+
<xsd:complexType name="detailsType">
|
402
|
+
<xsd:sequence>
|
403
|
+
<xsd:element minOccurs="0" name="bezeichnung" type="xsd:string"/>
|
404
|
+
<xsd:element minOccurs="0" name="bic" type="xsd:string"/>
|
405
|
+
<xsd:element minOccurs="0" name="ort" type="xsd:string"/>
|
406
|
+
<xsd:element minOccurs="0" name="plz" type="xsd:string"/>
|
407
|
+
</xsd:sequence>
|
408
|
+
</xsd:complexType>
|
409
|
+
</xsd:schema>
|
410
|
+
</wsdl:types>
|
411
|
+
<wsdl:message name="getBank">
|
412
|
+
<wsdl:part name="parameters" element="tns:getBank"/>
|
413
|
+
</wsdl:message>
|
414
|
+
<wsdl:message name="getBankResponse">
|
415
|
+
<wsdl:part name="parameters" element="tns:getBankResponse"/>
|
416
|
+
</wsdl:message>
|
417
|
+
<wsdl:portType name="BLZServicePortType">
|
418
|
+
<wsdl:operation name="getBank">
|
419
|
+
<wsdl:input message="tns:getBank"/>
|
420
|
+
<!--<wsdl:output message="tns:getBankResponse" wsaw:Action="http://thomas-bayer.com/blz/BLZService/getBankResponse"/>-->
|
421
|
+
<wsdl:output message="tns:getBankResponse" wsaw:Action="http://localhost:4567/BLZService/getBankResponse"/>
|
422
|
+
</wsdl:operation>
|
423
|
+
</wsdl:portType>
|
424
|
+
<wsdl:binding name="BLZServiceSOAP11Binding" type="tns:BLZServicePortType">
|
425
|
+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
426
|
+
<wsdl:operation name="getBank">
|
427
|
+
<soap:operation style="document" soapAction=""/>
|
428
|
+
<wsdl:input>
|
429
|
+
<soap:body use="literal"/>
|
430
|
+
</wsdl:input>
|
431
|
+
<wsdl:output>
|
432
|
+
<soap:body use="literal"/>
|
433
|
+
</wsdl:output>
|
434
|
+
</wsdl:operation>
|
435
|
+
</wsdl:binding>
|
436
|
+
<wsdl:binding name="BLZServiceSOAP12Binding" type="tns:BLZServicePortType">
|
437
|
+
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
438
|
+
<wsdl:operation name="getBank">
|
439
|
+
<soap12:operation style="document" soapAction=""/>
|
440
|
+
<wsdl:input>
|
441
|
+
<soap12:body use="literal"/>
|
442
|
+
</wsdl:input>
|
443
|
+
<wsdl:output>
|
444
|
+
<soap12:body use="literal"/>
|
445
|
+
</wsdl:output>
|
446
|
+
</wsdl:operation>
|
447
|
+
</wsdl:binding>
|
448
|
+
<wsdl:binding name="BLZServiceHttpBinding" type="tns:BLZServicePortType">
|
449
|
+
<http:binding verb="POST"/>
|
450
|
+
<wsdl:operation name="getBank">
|
451
|
+
<http:operation location="BLZService/getBank"/>
|
452
|
+
<wsdl:input>
|
453
|
+
<mime:content part="getBank" type="text/xml"/>
|
454
|
+
</wsdl:input>
|
455
|
+
<wsdl:output>
|
456
|
+
<mime:content part="getBank" type="text/xml"/>
|
457
|
+
</wsdl:output>
|
458
|
+
</wsdl:operation>
|
459
|
+
</wsdl:binding>
|
460
|
+
<wsdl:service name="BLZService">
|
461
|
+
<wsdl:port name="BLZServiceSOAP11port_http" binding="tns:BLZServiceSOAP11Binding">
|
462
|
+
<!-- <soap:address location="http://www.thomas-bayer.com/axis2/services/BLZService"/> -->
|
463
|
+
<soap:address location="http://localhost:4567/BLZService"/>
|
464
|
+
</wsdl:port>
|
465
|
+
<wsdl:port name="BLZServiceSOAP12port_http" binding="tns:BLZServiceSOAP12Binding">
|
466
|
+
<!--<soap12:address location="http://www.thomas-bayer.com/axis2/services/BLZService"/>-->
|
467
|
+
<soap12:address location="http://localhost:4567/BLZService"/>
|
468
|
+
</wsdl:port>
|
469
|
+
<wsdl:port name="BLZServiceHttpport" binding="tns:BLZServiceHttpBinding">
|
470
|
+
<!--<http:address location="http://www.thomas-bayer.com/axis2/services/BLZService"/>-->
|
471
|
+
<soap:address location="http://localhost:4567/BLZService"/>
|
472
|
+
</wsdl:port>
|
473
|
+
</wsdl:service>
|
474
|
+
</wsdl:definitions>
|
475
|
+
|
476
|
+
TEST_WSDL
|
477
|
+
end
|
258
478
|
|
259
479
|
end
|
260
480
|
end
|
data/lib/soaspec/version.rb
CHANGED
data/soaspec.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soaspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.77
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -248,6 +248,20 @@ dependencies:
|
|
248
248
|
- - ">="
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: thor
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
type: :runtime
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
251
265
|
- !ruby/object:Gem::Dependency
|
252
266
|
name: xml-simple
|
253
267
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,8 +281,8 @@ description: "Helps to create RSpec specs for 'SOAP' or 'REST' apis. Easily repr
|
|
267
281
|
email:
|
268
282
|
- samuel.garratt@integrationqa.com
|
269
283
|
executables:
|
284
|
+
- soaspec
|
270
285
|
- soaspec-generate
|
271
|
-
- soaspec-init
|
272
286
|
- soaspec-virtual-server
|
273
287
|
- xml_to_yaml_file
|
274
288
|
extensions: []
|
@@ -286,8 +300,8 @@ files:
|
|
286
300
|
- README.md
|
287
301
|
- Rakefile
|
288
302
|
- Todo.md
|
303
|
+
- exe/soaspec
|
289
304
|
- exe/soaspec-generate
|
290
|
-
- exe/soaspec-init
|
291
305
|
- exe/soaspec-virtual-server
|
292
306
|
- exe/xml_to_yaml_file
|
293
307
|
- lib/soaspec.rb
|
data/exe/soaspec-init
DELETED
@@ -1,243 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
|
-
|
5
|
-
require 'savon'
|
6
|
-
require 'soaspec'
|
7
|
-
|
8
|
-
include Soaspec::ExeHelpers
|
9
|
-
|
10
|
-
puts 'Creating files for soaspec'
|
11
|
-
|
12
|
-
weather_web_service = <<-EOF
|
13
|
-
|
14
|
-
require 'soaspec'
|
15
|
-
|
16
|
-
# This class is not part of the gem. It's an example of a class you can make
|
17
|
-
# to describe your APIs. Usually this would exist in the 'lib' directory
|
18
|
-
# Common configuration for the Savon client should go here
|
19
|
-
class BLZService < Soaspec::SoapHandler
|
20
|
-
# Add to or override default Savon client options
|
21
|
-
def savon_options
|
22
|
-
{
|
23
|
-
# wsdl: 'http://www.thomas-bayer.com/axis2/services/BLZService?wsdl' # External
|
24
|
-
wsdl: File.join('spec', 'test_data', 'wsdl', 'get_bank.wsdl')
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
# # Specifying that get_weather_result must be present in the SOAP response
|
29
|
-
mandatory_elements [:plz]
|
30
|
-
|
31
|
-
# Example of xpath value that must be true for all success scenarios
|
32
|
-
mandatory_xpath_values 'ns1:bezeichnung' => 'Deutsche Bank'
|
33
|
-
|
34
|
-
# Example of setting an attribute on the root XML element
|
35
|
-
root_attributes 'Version' => '1' # TODO: Create test on request for this
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
EOF
|
40
|
-
|
41
|
-
soap_spec_content = <<-EOF
|
42
|
-
|
43
|
-
require 'spec_helper'
|
44
|
-
|
45
|
-
Soaspec.strip_namespaces = true # This allows namespace not to be used. Be careful with this
|
46
|
-
|
47
|
-
id = '70070010'
|
48
|
-
# BLZService.new(template_name: 'soap_template') Use this instead of default_hash to use template approach
|
49
|
-
|
50
|
-
context 'Test Examples' do
|
51
|
-
context BLZService.new('Get Bank', operation: :get_bank, default_hash: { blz: id }) do
|
52
|
-
|
53
|
-
describe Exchange.new(:default) do
|
54
|
-
it { is_expected.to contain_value id }
|
55
|
-
it { is_expected.to include_in_body id }
|
56
|
-
it_behaves_like 'success scenario'
|
57
|
-
after(:all) { described_class.store(:title, 'bezeichnung') }
|
58
|
-
end
|
59
|
-
|
60
|
-
describe Exchange.new(:xpath_eg, blz: 100000) do
|
61
|
-
its(['plz']) { is_expected.to eq '100000' }
|
62
|
-
it { is_expected.to have_xpath_value '//ns1:bezeichnung' => 'Deutsche Bank' }
|
63
|
-
context 'Handle retrieving stored value' do
|
64
|
-
it { is_expected.to have_xpath_value 'bezeichnung' => described_class.retrieve(:title) }
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe Exchange.new(:yaml_eg, data_for(:small_id)) do
|
69
|
-
it_behaves_like 'success scenario'
|
70
|
-
end
|
71
|
-
|
72
|
-
# Retry for success more for web services that intermittently fail
|
73
|
-
describe Exchange.new(:short_hand_xpath).retry_for_success do
|
74
|
-
# Be careful. If you call a method that does not use namespaces, calling one that does may not find the element
|
75
|
-
its(['ns1:bezeichnung']) { is_expected.to eq 'Deutsche Bank' } # '//' is not required at the beginning
|
76
|
-
end
|
77
|
-
describe Exchange.new('Check existence of elements') do
|
78
|
-
it { is_expected.to have_element_at_xpath '//ns1:bezeichnung' }
|
79
|
-
it { is_expected.not_to have_element_at_xpath '//ns1:bezeichnung_pretend' }
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
error_example = BLZService.new('Error example')
|
86
|
-
error_example.operation = :get_bank
|
87
|
-
error_example.default_hash = {}
|
88
|
-
|
89
|
-
context 'Error Examples' do
|
90
|
-
context error_example do
|
91
|
-
describe Exchange.new(:no_blz_error) do
|
92
|
-
it_behaves_like 'error scenario'
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
EOF
|
99
|
-
|
100
|
-
shared_examples_content = <<-EOF
|
101
|
-
|
102
|
-
require 'rspec'
|
103
|
-
|
104
|
-
shared_examples_for 'error scenario' do
|
105
|
-
it 'does not have status code of 200' do
|
106
|
-
expect(described_class.status_code).not_to eq 200
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
EOF
|
111
|
-
|
112
|
-
soap_template_content = <<-EOF
|
113
|
-
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://thomas-bayer.com/blz/" xmlns:env="http://www.w3.org/2003/05/soap-envelope">
|
114
|
-
<env:Body>
|
115
|
-
<tns:getBank>
|
116
|
-
<tns:blz><%= test_values[:blz] || '70070010' %></tns:blz>
|
117
|
-
</tns:getBank>
|
118
|
-
</env:Body>
|
119
|
-
</env:Envelope>
|
120
|
-
EOF
|
121
|
-
|
122
|
-
default_yaml_content = <<-EOF
|
123
|
-
small_id:
|
124
|
-
blz: 100
|
125
|
-
|
126
|
-
EOF
|
127
|
-
|
128
|
-
test_wsdl_content = <<EOF
|
129
|
-
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://thomas-bayer.com/blz/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://thomas-bayer.com/blz/">
|
130
|
-
<wsdl:documentation>BLZService</wsdl:documentation>
|
131
|
-
<wsdl:types>
|
132
|
-
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://thomas-bayer.com/blz/">
|
133
|
-
<xsd:element name="getBank" type="tns:getBankType"/>
|
134
|
-
<xsd:element name="getBankResponse" type="tns:getBankResponseType"/>
|
135
|
-
<xsd:complexType name="getBankType">
|
136
|
-
<xsd:sequence>
|
137
|
-
<xsd:element name="blz" type="xsd:string"/>
|
138
|
-
</xsd:sequence>
|
139
|
-
</xsd:complexType>
|
140
|
-
<xsd:complexType name="getBankResponseType">
|
141
|
-
<xsd:sequence>
|
142
|
-
<xsd:element name="details" type="tns:detailsType"/>
|
143
|
-
</xsd:sequence>
|
144
|
-
</xsd:complexType>
|
145
|
-
<xsd:complexType name="detailsType">
|
146
|
-
<xsd:sequence>
|
147
|
-
<xsd:element minOccurs="0" name="bezeichnung" type="xsd:string"/>
|
148
|
-
<xsd:element minOccurs="0" name="bic" type="xsd:string"/>
|
149
|
-
<xsd:element minOccurs="0" name="ort" type="xsd:string"/>
|
150
|
-
<xsd:element minOccurs="0" name="plz" type="xsd:string"/>
|
151
|
-
</xsd:sequence>
|
152
|
-
</xsd:complexType>
|
153
|
-
</xsd:schema>
|
154
|
-
</wsdl:types>
|
155
|
-
<wsdl:message name="getBank">
|
156
|
-
<wsdl:part name="parameters" element="tns:getBank"/>
|
157
|
-
</wsdl:message>
|
158
|
-
<wsdl:message name="getBankResponse">
|
159
|
-
<wsdl:part name="parameters" element="tns:getBankResponse"/>
|
160
|
-
</wsdl:message>
|
161
|
-
<wsdl:portType name="BLZServicePortType">
|
162
|
-
<wsdl:operation name="getBank">
|
163
|
-
<wsdl:input message="tns:getBank"/>
|
164
|
-
<!--<wsdl:output message="tns:getBankResponse" wsaw:Action="http://thomas-bayer.com/blz/BLZService/getBankResponse"/>-->
|
165
|
-
<wsdl:output message="tns:getBankResponse" wsaw:Action="http://localhost:4567/BLZService/getBankResponse"/>
|
166
|
-
</wsdl:operation>
|
167
|
-
</wsdl:portType>
|
168
|
-
<wsdl:binding name="BLZServiceSOAP11Binding" type="tns:BLZServicePortType">
|
169
|
-
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
170
|
-
<wsdl:operation name="getBank">
|
171
|
-
<soap:operation style="document" soapAction=""/>
|
172
|
-
<wsdl:input>
|
173
|
-
<soap:body use="literal"/>
|
174
|
-
</wsdl:input>
|
175
|
-
<wsdl:output>
|
176
|
-
<soap:body use="literal"/>
|
177
|
-
</wsdl:output>
|
178
|
-
</wsdl:operation>
|
179
|
-
</wsdl:binding>
|
180
|
-
<wsdl:binding name="BLZServiceSOAP12Binding" type="tns:BLZServicePortType">
|
181
|
-
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
182
|
-
<wsdl:operation name="getBank">
|
183
|
-
<soap12:operation style="document" soapAction=""/>
|
184
|
-
<wsdl:input>
|
185
|
-
<soap12:body use="literal"/>
|
186
|
-
</wsdl:input>
|
187
|
-
<wsdl:output>
|
188
|
-
<soap12:body use="literal"/>
|
189
|
-
</wsdl:output>
|
190
|
-
</wsdl:operation>
|
191
|
-
</wsdl:binding>
|
192
|
-
<wsdl:binding name="BLZServiceHttpBinding" type="tns:BLZServicePortType">
|
193
|
-
<http:binding verb="POST"/>
|
194
|
-
<wsdl:operation name="getBank">
|
195
|
-
<http:operation location="BLZService/getBank"/>
|
196
|
-
<wsdl:input>
|
197
|
-
<mime:content part="getBank" type="text/xml"/>
|
198
|
-
</wsdl:input>
|
199
|
-
<wsdl:output>
|
200
|
-
<mime:content part="getBank" type="text/xml"/>
|
201
|
-
</wsdl:output>
|
202
|
-
</wsdl:operation>
|
203
|
-
</wsdl:binding>
|
204
|
-
<wsdl:service name="BLZService">
|
205
|
-
<wsdl:port name="BLZServiceSOAP11port_http" binding="tns:BLZServiceSOAP11Binding">
|
206
|
-
<!-- <soap:address location="http://www.thomas-bayer.com/axis2/services/BLZService"/> -->
|
207
|
-
<soap:address location="http://localhost:4567/BLZService"/>
|
208
|
-
</wsdl:port>
|
209
|
-
<wsdl:port name="BLZServiceSOAP12port_http" binding="tns:BLZServiceSOAP12Binding">
|
210
|
-
<!--<soap12:address location="http://www.thomas-bayer.com/axis2/services/BLZService"/>-->
|
211
|
-
<soap12:address location="http://localhost:4567/BLZService"/>
|
212
|
-
</wsdl:port>
|
213
|
-
<wsdl:port name="BLZServiceHttpport" binding="tns:BLZServiceHttpBinding">
|
214
|
-
<!--<http:address location="http://www.thomas-bayer.com/axis2/services/BLZService"/>-->
|
215
|
-
<soap:address location="http://localhost:4567/BLZService"/>
|
216
|
-
</wsdl:port>
|
217
|
-
</wsdl:service>
|
218
|
-
</wsdl:definitions>
|
219
|
-
EOF
|
220
|
-
|
221
|
-
create_file(filename: 'Gemfile', content: gem_content)
|
222
|
-
create_file(filename: 'Rakefile', content: rake_virtual_content)
|
223
|
-
create_file(filename: 'README.md', content: readme_content)
|
224
|
-
create_folder 'lib'
|
225
|
-
create_file(filename: 'lib/blz_service.rb', content: weather_web_service)
|
226
|
-
create_file filename: 'lib/shared_example.rb', content: shared_examples_content
|
227
|
-
create_folder 'config'
|
228
|
-
create_folder 'config/data'
|
229
|
-
create_file(filename: 'config/data/default.yml', content: default_yaml_content)
|
230
|
-
create_folder 'spec'
|
231
|
-
create_folder 'spec/test_data'
|
232
|
-
create_folder 'spec/test_data/wsdl'
|
233
|
-
create_file(filename: 'spec/spec_helper.rb', content: spec_helper_content)
|
234
|
-
create_file(filename: 'spec/soap_spec.rb', content: soap_spec_content)
|
235
|
-
create_file(filename: 'spec/test_server.rb', content: test_server_content)
|
236
|
-
create_file(filename: 'spec/test_data/wsdl/get_bank.wsdl', content: test_wsdl_content)
|
237
|
-
create_folder 'template'
|
238
|
-
create_file(filename: 'template/soap_template.xml', content: soap_template_content)
|
239
|
-
create_folder 'logs'
|
240
|
-
|
241
|
-
puts "Run 'bundle install' to install necessary gems"
|
242
|
-
puts "Run 'rake spec' to run the tests"
|
243
|
-
puts "Note: Setup runs Sinatra for Test Service on port 4567 by default. Change Rakefile 'start_test_server' task to update this"
|