ruby-jmeter 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/examples/basic_header.rb +5 -1
  2. data/examples/basic_user_defined_variables.rb +10 -0
  3. data/lib/ruby-jmeter/dsl/access_log_sampler.rb +3 -3
  4. data/lib/ruby-jmeter/dsl/aggregate_graph.rb +3 -3
  5. data/lib/ruby-jmeter/dsl/aggregate_report.rb +3 -3
  6. data/lib/ruby-jmeter/dsl/ajp13_sampler.rb +4 -4
  7. data/lib/ruby-jmeter/dsl/assertion_results.rb +3 -3
  8. data/lib/ruby-jmeter/dsl/beanshell_assertion.rb +3 -3
  9. data/lib/ruby-jmeter/dsl/beanshell_listener.rb +3 -3
  10. data/lib/ruby-jmeter/dsl/beanshell_postprocessor.rb +3 -3
  11. data/lib/ruby-jmeter/dsl/beanshell_preprocessor.rb +3 -3
  12. data/lib/ruby-jmeter/dsl/beanshell_sampler.rb +3 -3
  13. data/lib/ruby-jmeter/dsl/beanshell_timer.rb +3 -3
  14. data/lib/ruby-jmeter/dsl/bsf_assertion.rb +3 -3
  15. data/lib/ruby-jmeter/dsl/bsf_listener.rb +3 -3
  16. data/lib/ruby-jmeter/dsl/bsf_postprocessor.rb +3 -3
  17. data/lib/ruby-jmeter/dsl/bsf_preprocessor.rb +3 -3
  18. data/lib/ruby-jmeter/dsl/bsf_sampler.rb +3 -3
  19. data/lib/ruby-jmeter/dsl/bsf_timer.rb +3 -3
  20. data/lib/ruby-jmeter/dsl/compare_assertion.rb +3 -3
  21. data/lib/ruby-jmeter/dsl/comparison_assertion_visualizer.rb +3 -3
  22. data/lib/ruby-jmeter/dsl/constant_throughput_timer.rb +3 -3
  23. data/lib/ruby-jmeter/dsl/constant_timer.rb +3 -3
  24. data/lib/ruby-jmeter/dsl/counter.rb +3 -3
  25. data/lib/ruby-jmeter/dsl/cssjquery_extractor.rb +3 -3
  26. data/lib/ruby-jmeter/dsl/csv_data_set_config.rb +3 -3
  27. data/lib/ruby-jmeter/dsl/debug_postprocessor.rb +3 -3
  28. data/lib/ruby-jmeter/dsl/debug_sampler.rb +3 -3
  29. data/lib/ruby-jmeter/dsl/distribution_graphalpha.rb +3 -3
  30. data/lib/ruby-jmeter/dsl/duration_assertion.rb +3 -3
  31. data/lib/ruby-jmeter/dsl/foreach_controller.rb +3 -3
  32. data/lib/ruby-jmeter/dsl/ftp_request.rb +3 -3
  33. data/lib/ruby-jmeter/dsl/ftp_request_defaults.rb +3 -3
  34. data/lib/ruby-jmeter/dsl/gaussian_random_timer.rb +3 -3
  35. data/lib/ruby-jmeter/dsl/generate_summary_results.rb +3 -3
  36. data/lib/ruby-jmeter/dsl/graph_results.rb +3 -3
  37. data/lib/ruby-jmeter/dsl/html_assertion.rb +3 -3
  38. data/lib/ruby-jmeter/dsl/html_link_parser.rb +3 -3
  39. data/lib/ruby-jmeter/dsl/html_parameter_mask.rb +3 -3
  40. data/lib/ruby-jmeter/dsl/http_authorization_manager.rb +3 -3
  41. data/lib/ruby-jmeter/dsl/http_cache_manager.rb +3 -3
  42. data/lib/ruby-jmeter/dsl/http_cookie_manager.rb +3 -3
  43. data/lib/ruby-jmeter/dsl/http_header_manager.rb +3 -3
  44. data/lib/ruby-jmeter/dsl/http_request.rb +4 -4
  45. data/lib/ruby-jmeter/dsl/http_request_defaults.rb +4 -4
  46. data/lib/ruby-jmeter/dsl/http_url_rewriting_modifier.rb +3 -3
  47. data/lib/ruby-jmeter/dsl/if_controller.rb +3 -3
  48. data/lib/ruby-jmeter/dsl/include_controller.rb +3 -3
  49. data/lib/ruby-jmeter/dsl/java_request.rb +3 -3
  50. data/lib/ruby-jmeter/dsl/java_request_defaults.rb +3 -3
  51. data/lib/ruby-jmeter/dsl/jdbc_connection_configuration.rb +3 -3
  52. data/lib/ruby-jmeter/dsl/jdbc_postprocessor.rb +3 -3
  53. data/lib/ruby-jmeter/dsl/jdbc_preprocessor.rb +3 -3
  54. data/lib/ruby-jmeter/dsl/jdbc_request.rb +3 -3
  55. data/lib/ruby-jmeter/dsl/jms_pointtopoint.rb +5 -5
  56. data/lib/ruby-jmeter/dsl/jms_publisher.rb +4 -4
  57. data/lib/ruby-jmeter/dsl/jms_subscriber.rb +3 -3
  58. data/lib/ruby-jmeter/dsl/jsr223_assertion.rb +3 -3
  59. data/lib/ruby-jmeter/dsl/jsr223_listener.rb +3 -3
  60. data/lib/ruby-jmeter/dsl/jsr223_postprocessor.rb +3 -3
  61. data/lib/ruby-jmeter/dsl/jsr223_preprocessor.rb +3 -3
  62. data/lib/ruby-jmeter/dsl/jsr223_sampler.rb +3 -3
  63. data/lib/ruby-jmeter/dsl/jsr223_timer.rb +3 -3
  64. data/lib/ruby-jmeter/dsl/junit_request.rb +3 -3
  65. data/lib/ruby-jmeter/dsl/keystore_configuration.rb +3 -3
  66. data/lib/ruby-jmeter/dsl/ldap_extended_request.rb +3 -3
  67. data/lib/ruby-jmeter/dsl/ldap_extended_request_defaults.rb +3 -3
  68. data/lib/ruby-jmeter/dsl/ldap_request.rb +4 -4
  69. data/lib/ruby-jmeter/dsl/ldap_request_defaults.rb +4 -4
  70. data/lib/ruby-jmeter/dsl/login_config_element.rb +3 -3
  71. data/lib/ruby-jmeter/dsl/loop_controller.rb +3 -3
  72. data/lib/ruby-jmeter/dsl/mail_reader_sampler.rb +3 -3
  73. data/lib/ruby-jmeter/dsl/mailer_visualizer.rb +3 -3
  74. data/lib/ruby-jmeter/dsl/md5hex_assertion.rb +3 -3
  75. data/lib/ruby-jmeter/dsl/module_controller.rb +3 -3
  76. data/lib/ruby-jmeter/dsl/monitor_results.rb +3 -3
  77. data/lib/ruby-jmeter/dsl/once_only_controller.rb +3 -3
  78. data/lib/ruby-jmeter/dsl/os_process_sampler.rb +5 -5
  79. data/lib/ruby-jmeter/dsl/poisson_random_timer.rb +3 -3
  80. data/lib/ruby-jmeter/dsl/random_controller.rb +3 -3
  81. data/lib/ruby-jmeter/dsl/random_order_controller.rb +3 -3
  82. data/lib/ruby-jmeter/dsl/random_variable.rb +3 -3
  83. data/lib/ruby-jmeter/dsl/recording_controller.rb +3 -3
  84. data/lib/ruby-jmeter/dsl/regex_user_parameters.rb +3 -3
  85. data/lib/ruby-jmeter/dsl/regular_expression_extractor.rb +3 -3
  86. data/lib/ruby-jmeter/dsl/response_assertion.rb +3 -3
  87. data/lib/ruby-jmeter/dsl/response_time_graph.rb +3 -3
  88. data/lib/ruby-jmeter/dsl/result_status_action_handler.rb +3 -3
  89. data/lib/ruby-jmeter/dsl/runtime_controller.rb +3 -3
  90. data/lib/ruby-jmeter/dsl/save_responses_to_a_file.rb +3 -3
  91. data/lib/ruby-jmeter/dsl/simple_config_element.rb +3 -3
  92. data/lib/ruby-jmeter/dsl/simple_controller.rb +3 -3
  93. data/lib/ruby-jmeter/dsl/simple_data_writer.rb +3 -3
  94. data/lib/ruby-jmeter/dsl/smime_assertion.rb +3 -3
  95. data/lib/ruby-jmeter/dsl/smtp_sampler.rb +3 -3
  96. data/lib/ruby-jmeter/dsl/soapxmlrpc_request.rb +3 -3
  97. data/lib/ruby-jmeter/dsl/spline_visualizer.rb +3 -3
  98. data/lib/ruby-jmeter/dsl/summary_report.rb +3 -3
  99. data/lib/ruby-jmeter/dsl/switch_controller.rb +3 -3
  100. data/lib/ruby-jmeter/dsl/synchronizing_timer.rb +3 -3
  101. data/lib/ruby-jmeter/dsl/tcp_sampler.rb +3 -3
  102. data/lib/ruby-jmeter/dsl/tcp_sampler_config.rb +3 -3
  103. data/lib/ruby-jmeter/dsl/test_action.rb +3 -3
  104. data/lib/ruby-jmeter/dsl/test_plan.rb +4 -4
  105. data/lib/ruby-jmeter/dsl/thread_group.rb +4 -4
  106. data/lib/ruby-jmeter/dsl/throughput_controller.rb +3 -3
  107. data/lib/ruby-jmeter/dsl/transaction_controller.rb +3 -3
  108. data/lib/ruby-jmeter/dsl/uniform_random_timer.rb +3 -3
  109. data/lib/ruby-jmeter/dsl/user_defined_variables.rb +3 -3
  110. data/lib/ruby-jmeter/dsl/user_parameters.rb +3 -3
  111. data/lib/ruby-jmeter/dsl/view_results_in_table.rb +3 -3
  112. data/lib/ruby-jmeter/dsl/view_results_tree.rb +3 -3
  113. data/lib/ruby-jmeter/dsl/while_controller.rb +3 -3
  114. data/lib/ruby-jmeter/dsl/xml_assertion.rb +3 -3
  115. data/lib/ruby-jmeter/dsl/xml_schema_assertion.rb +3 -3
  116. data/lib/ruby-jmeter/dsl/xpath_assertion.rb +3 -3
  117. data/lib/ruby-jmeter/dsl/xpath_extractor.rb +3 -3
  118. data/lib/ruby-jmeter/dsl.rb +6 -2
  119. data/lib/ruby-jmeter/helpers/helper.rb +20 -3
  120. data/lib/ruby-jmeter/idl.rb +3 -3
  121. data/lib/ruby-jmeter/version.rb +1 -1
  122. data/spec/dsl_spec.rb +22 -0
  123. metadata +4 -6
@@ -25,7 +25,9 @@ module RubyJmeter
25
25
  # Config Elements
26
26
 
27
27
  def user_defined_variables(params, &block)
28
- params['Argument.name'] = params[:name]
28
+ if params.is_a?(Hash)
29
+ params['Argument.name'] = params[:name]
30
+ end
29
31
  super
30
32
  end
31
33
 
@@ -53,7 +55,9 @@ module RubyJmeter
53
55
  end
54
56
 
55
57
  def http_header_manager(params, &block)
56
- params['Header.name'] = params[:name]
58
+ if params.is_a?(Hash)
59
+ params['Header.name'] = params[:name]
60
+ end
57
61
  super
58
62
  end
59
63
 
@@ -17,9 +17,13 @@ module RubyJmeter
17
17
  module Helper
18
18
  def update(params)
19
19
  params.delete(:name)
20
- params.each do |name, value|
21
- node = @doc.children.xpath("//*[contains(@name,\"#{name.to_s}\")]")
22
- node.first.content = value unless node.empty?
20
+ if params.class == Array
21
+ update_collection params
22
+ else
23
+ params.each do |name, value|
24
+ node = @doc.children.xpath("//*[contains(@name,\"#{name.to_s}\")]")
25
+ node.first.content = value unless node.empty?
26
+ end
23
27
  end
24
28
  end
25
29
 
@@ -29,6 +33,19 @@ module RubyJmeter
29
33
  end
30
34
  end
31
35
 
36
+ def update_collection(params)
37
+ elements = @doc.at_xpath("//collectionProp/elementProp")
38
+ params.each_with_index do |param, index|
39
+ param.each do |name, value|
40
+ element = elements.element_children.xpath("//*[contains(@name,\"#{name}\")]")
41
+ element.last.content = value
42
+ end
43
+ if index != params.size - 1
44
+ @doc.at_xpath("//collectionProp") << elements.dup
45
+ end
46
+ end
47
+ end
48
+
32
49
  def enabled(params)
33
50
  #default to true unless explicitly set to false
34
51
  if params.has_key?(:enabled) && params[:enabled] == false
@@ -53,12 +53,12 @@ module RubyJmeter
53
53
  include Helper
54
54
 
55
55
  def initialize(params={})
56
- params[:name] ||= '#{klass}'
56
+ testname = params.kind_of?(Array) ? '#{klass}' : (params[:name] || '#{klass}')
57
57
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
58
- #{element.to_xml.gsub /testname=".+?"/, 'testname="#{params[:name]}"'})
58
+ #{element.to_xml.gsub /testname=".+?"/, 'testname="#{testname}"'})
59
59
  EOS
60
60
  update params
61
- update_at_xpath params if params[:update_at_xpath]
61
+ update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
62
62
  end
63
63
  end
64
64
 
@@ -1,3 +1,3 @@
1
1
  module RubyJmeter
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
data/spec/dsl_spec.rb CHANGED
@@ -65,6 +65,28 @@ describe "DSL" do
65
65
  end
66
66
  end
67
67
 
68
+
69
+ describe 'header manager multiple values' do
70
+ let(:doc) do
71
+ test do
72
+ header [ { name: 'Accept', value: '1' }, { name: 'Accept', value: '2' }]
73
+ end.to_doc
74
+ end
75
+
76
+ let(:fragment) { doc.search("//HeaderManager") }
77
+
78
+
79
+ it 'should match on accept for fragment_first' do
80
+ fragment.search(".//stringProp[@name='Header.name']").first.text.should == 'Accept'
81
+ fragment.search(".//stringProp[@name='Header.value']").first.text.should == '1'
82
+ end
83
+
84
+ it 'should match on accept for fragment_last' do
85
+ fragment.search(".//stringProp[@name='Header.name']").last.text.should == 'Accept'
86
+ fragment.search(".//stringProp[@name='Header.value']").last.text.should == '2'
87
+ end
88
+ end
89
+
68
90
  describe 'test plan' do
69
91
  it 'should allow to take params' do
70
92
  test_plan = test({"TestPlan.serialize_threadgroups" => "false"}) {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-jmeter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-10 00:00:00.000000000 Z
12
+ date: 2013-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -78,6 +78,7 @@ files:
78
78
  - examples/basic_think_time.rb
79
79
  - examples/basic_throughput_controller.rb
80
80
  - examples/basic_throughput_shaping_timer.rb
81
+ - examples/basic_user_defined_variables.rb
81
82
  - examples/etsy_login_browse.rb
82
83
  - lib/ruby-jmeter.rb
83
84
  - lib/ruby-jmeter/DSL.md
@@ -245,7 +246,4 @@ rubygems_version: 1.8.23
245
246
  signing_key:
246
247
  specification_version: 3
247
248
  summary: This is a Ruby based DSL for writing JMeter test plans
248
- test_files:
249
- - spec/dsl_spec.rb
250
- - spec/spec_helper.rb
251
- - spec/stub.rb
249
+ test_files: []