gridinit-jmeter 0.3.2 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. data/Gemfile +2 -1
  2. data/README.md +51 -72
  3. data/examples/basic_assertion.rb +6 -6
  4. data/examples/basic_auth.rb +5 -5
  5. data/examples/basic_cache.rb +5 -5
  6. data/examples/basic_cookies.rb +5 -5
  7. data/examples/basic_extract.rb +4 -10
  8. data/examples/basic_gc_results.rb +12 -9
  9. data/examples/basic_google.rb +3 -3
  10. data/examples/basic_grid.rb +3 -6
  11. data/examples/basic_header.rb +12 -10
  12. data/examples/basic_ldap_ext.rb +11 -12
  13. data/examples/basic_post.rb +5 -6
  14. data/examples/basic_query_params.rb +3 -3
  15. data/examples/basic_think_time.rb +7 -4
  16. data/examples/basic_throughput_shaping_timer.rb +4 -4
  17. data/examples/etsy_login_browse.rb +21 -21
  18. data/lib/gridinit-jmeter/DSL.md +237 -0
  19. data/lib/gridinit-jmeter/{idl → dsl}/access_log_sampler.rb +4 -2
  20. data/lib/gridinit-jmeter/{idl → dsl}/aggregate_graph.rb +4 -2
  21. data/lib/gridinit-jmeter/{idl → dsl}/aggregate_report.rb +4 -2
  22. data/lib/gridinit-jmeter/{idl → dsl}/ajp13_sampler.rb +5 -3
  23. data/lib/gridinit-jmeter/{idl → dsl}/assertion_results.rb +4 -2
  24. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_assertion.rb +4 -2
  25. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_listener.rb +4 -2
  26. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_postprocessor.rb +4 -2
  27. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_preprocessor.rb +4 -2
  28. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_sampler.rb +4 -2
  29. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_timer.rb +4 -2
  30. data/lib/gridinit-jmeter/{idl → dsl}/bsf_assertion.rb +4 -2
  31. data/lib/gridinit-jmeter/{idl → dsl}/bsf_listener.rb +4 -2
  32. data/lib/gridinit-jmeter/{idl → dsl}/bsf_postprocessor.rb +4 -2
  33. data/lib/gridinit-jmeter/{idl → dsl}/bsf_preprocessor.rb +4 -2
  34. data/lib/gridinit-jmeter/{idl → dsl}/bsf_sampler.rb +4 -2
  35. data/lib/gridinit-jmeter/{idl → dsl}/bsf_timer.rb +4 -2
  36. data/lib/gridinit-jmeter/{idl → dsl}/compare_assertion.rb +4 -2
  37. data/lib/gridinit-jmeter/{idl → dsl}/comparison_assertion_visualizer.rb +4 -2
  38. data/lib/gridinit-jmeter/{idl → dsl}/constant_throughput_timer.rb +4 -2
  39. data/lib/gridinit-jmeter/{idl → dsl}/constant_timer.rb +4 -2
  40. data/lib/gridinit-jmeter/{idl → dsl}/counter.rb +4 -2
  41. data/lib/gridinit-jmeter/{idl → dsl}/cssjquery_extractor.rb +4 -2
  42. data/lib/gridinit-jmeter/{idl → dsl}/csv_data_set_config.rb +4 -2
  43. data/lib/gridinit-jmeter/{idl → dsl}/debug_postprocessor.rb +4 -2
  44. data/lib/gridinit-jmeter/{idl → dsl}/debug_sampler.rb +4 -2
  45. data/lib/gridinit-jmeter/{idl → dsl}/distribution_graphalpha.rb +4 -2
  46. data/lib/gridinit-jmeter/{idl → dsl}/duration_assertion.rb +4 -2
  47. data/lib/gridinit-jmeter/{idl → dsl}/foreach_controller.rb +4 -2
  48. data/lib/gridinit-jmeter/{idl → dsl}/ftp_request.rb +4 -2
  49. data/lib/gridinit-jmeter/{idl → dsl}/ftp_request_defaults.rb +4 -2
  50. data/lib/gridinit-jmeter/{idl → dsl}/gaussian_random_timer.rb +4 -2
  51. data/lib/gridinit-jmeter/{idl → dsl}/generate_summary_results.rb +4 -2
  52. data/lib/gridinit-jmeter/{idl → dsl}/graph_results.rb +4 -2
  53. data/lib/gridinit-jmeter/{idl → dsl}/html_assertion.rb +4 -2
  54. data/lib/gridinit-jmeter/{idl → dsl}/html_link_parser.rb +4 -2
  55. data/lib/gridinit-jmeter/{idl → dsl}/html_parameter_mask.rb +4 -2
  56. data/lib/gridinit-jmeter/dsl/http_authorization_manager.rb +36 -0
  57. data/lib/gridinit-jmeter/{idl → dsl}/http_cache_manager.rb +4 -2
  58. data/lib/gridinit-jmeter/{idl → dsl}/http_cookie_manager.rb +5 -2
  59. data/lib/gridinit-jmeter/{idl → dsl}/http_header_manager.rb +10 -3
  60. data/lib/gridinit-jmeter/{idl → dsl}/http_request.rb +5 -3
  61. data/lib/gridinit-jmeter/{idl → dsl}/http_request_defaults.rb +15 -4
  62. data/lib/gridinit-jmeter/{idl → dsl}/http_url_rewriting_modifier.rb +4 -2
  63. data/lib/gridinit-jmeter/{idl → dsl}/if_controller.rb +5 -2
  64. data/lib/gridinit-jmeter/{idl → dsl}/include_controller.rb +4 -2
  65. data/lib/gridinit-jmeter/{idl → dsl}/java_request.rb +4 -2
  66. data/lib/gridinit-jmeter/{idl → dsl}/java_request_defaults.rb +4 -2
  67. data/lib/gridinit-jmeter/{idl → dsl}/jdbc_connection_configuration.rb +4 -2
  68. data/lib/gridinit-jmeter/{idl → dsl}/jdbc_postprocessor.rb +4 -2
  69. data/lib/gridinit-jmeter/{idl → dsl}/jdbc_preprocessor.rb +4 -2
  70. data/lib/gridinit-jmeter/{idl → dsl}/jdbc_request.rb +4 -2
  71. data/lib/gridinit-jmeter/{idl → dsl}/jms_pointtopoint.rb +6 -4
  72. data/lib/gridinit-jmeter/{idl → dsl}/jms_publisher.rb +5 -3
  73. data/lib/gridinit-jmeter/{idl → dsl}/jms_subscriber.rb +4 -2
  74. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_assertion.rb +4 -2
  75. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_listener.rb +4 -2
  76. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_postprocessor.rb +4 -2
  77. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_preprocessor.rb +4 -2
  78. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_sampler.rb +4 -2
  79. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_timer.rb +4 -2
  80. data/lib/gridinit-jmeter/{idl → dsl}/junit_request.rb +4 -2
  81. data/lib/gridinit-jmeter/{idl → dsl}/keystore_configuration.rb +4 -2
  82. data/lib/gridinit-jmeter/{idl → dsl}/ldap_extended_request.rb +4 -2
  83. data/lib/gridinit-jmeter/{idl → dsl}/ldap_extended_request_defaults.rb +4 -2
  84. data/lib/gridinit-jmeter/{idl → dsl}/ldap_request.rb +5 -3
  85. data/lib/gridinit-jmeter/{idl → dsl}/ldap_request_defaults.rb +13 -4
  86. data/lib/gridinit-jmeter/{idl → dsl}/login_config_element.rb +4 -2
  87. data/lib/gridinit-jmeter/{idl → dsl}/loop_controller.rb +4 -2
  88. data/lib/gridinit-jmeter/{idl → dsl}/mail_reader_sampler.rb +4 -2
  89. data/lib/gridinit-jmeter/{idl → dsl}/mailer_visualizer.rb +4 -2
  90. data/lib/gridinit-jmeter/{idl → dsl}/md5hex_assertion.rb +4 -2
  91. data/lib/gridinit-jmeter/{idl → dsl}/module_controller.rb +4 -2
  92. data/lib/gridinit-jmeter/{idl → dsl}/monitor_results.rb +4 -2
  93. data/lib/gridinit-jmeter/{idl → dsl}/once_only_controller.rb +4 -2
  94. data/lib/gridinit-jmeter/{idl → dsl}/os_process_sampler.rb +6 -4
  95. data/lib/gridinit-jmeter/{idl → dsl}/poisson_random_timer.rb +4 -2
  96. data/lib/gridinit-jmeter/{idl → dsl}/random_controller.rb +4 -2
  97. data/lib/gridinit-jmeter/{idl → dsl}/random_order_controller.rb +4 -2
  98. data/lib/gridinit-jmeter/{idl → dsl}/random_variable.rb +4 -2
  99. data/lib/gridinit-jmeter/{idl → dsl}/recording_controller.rb +4 -2
  100. data/lib/gridinit-jmeter/{idl → dsl}/regex_user_parameters.rb +4 -2
  101. data/lib/gridinit-jmeter/{idl → dsl}/regular_expression_extractor.rb +5 -2
  102. data/lib/gridinit-jmeter/{idl → dsl}/response_assertion.rb +8 -3
  103. data/lib/gridinit-jmeter/{idl → dsl}/response_time_graph.rb +4 -2
  104. data/lib/gridinit-jmeter/{idl → dsl}/result_status_action_handler.rb +4 -2
  105. data/lib/gridinit-jmeter/{idl → dsl}/runtime_controller.rb +4 -2
  106. data/lib/gridinit-jmeter/{idl → dsl}/save_responses_to_a_file.rb +4 -2
  107. data/lib/gridinit-jmeter/{idl → dsl}/simple_config_element.rb +4 -2
  108. data/lib/gridinit-jmeter/{idl → dsl}/simple_controller.rb +4 -2
  109. data/lib/gridinit-jmeter/{idl → dsl}/simple_data_writer.rb +4 -2
  110. data/lib/gridinit-jmeter/{idl → dsl}/smime_assertion.rb +4 -2
  111. data/lib/gridinit-jmeter/{idl → dsl}/smtp_sampler.rb +4 -2
  112. data/lib/gridinit-jmeter/{idl → dsl}/soapxmlrpc_request.rb +4 -2
  113. data/lib/gridinit-jmeter/{idl → dsl}/spline_visualizer.rb +4 -2
  114. data/lib/gridinit-jmeter/{idl → dsl}/summary_report.rb +4 -2
  115. data/lib/gridinit-jmeter/{idl → dsl}/switch_controller.rb +4 -2
  116. data/lib/gridinit-jmeter/{idl → dsl}/synchronizing_timer.rb +4 -2
  117. data/lib/gridinit-jmeter/{idl → dsl}/tcp_sampler.rb +4 -2
  118. data/lib/gridinit-jmeter/{idl → dsl}/tcp_sampler_config.rb +4 -2
  119. data/lib/gridinit-jmeter/{idl → dsl}/test_action.rb +4 -2
  120. data/lib/gridinit-jmeter/{idl → dsl}/test_plan.rb +5 -3
  121. data/lib/gridinit-jmeter/{idl → dsl}/thread_group.rb +5 -3
  122. data/lib/gridinit-jmeter/{idl → dsl}/throughput_controller.rb +5 -3
  123. data/lib/gridinit-jmeter/{idl → dsl}/transaction_controller.rb +6 -3
  124. data/lib/gridinit-jmeter/{idl → dsl}/uniform_random_timer.rb +4 -2
  125. data/lib/gridinit-jmeter/dsl/user_defined_variables.rb +35 -0
  126. data/lib/gridinit-jmeter/{idl → dsl}/user_parameters.rb +4 -2
  127. data/lib/gridinit-jmeter/{idl → dsl}/view_results_in_table.rb +4 -2
  128. data/lib/gridinit-jmeter/{idl → dsl}/view_results_tree.rb +4 -2
  129. data/lib/gridinit-jmeter/{idl → dsl}/while_controller.rb +4 -2
  130. data/lib/gridinit-jmeter/{idl → dsl}/xml_assertion.rb +4 -2
  131. data/lib/gridinit-jmeter/{idl → dsl}/xml_schema_assertion.rb +4 -2
  132. data/lib/gridinit-jmeter/{idl → dsl}/xpath_assertion.rb +4 -2
  133. data/lib/gridinit-jmeter/{idl → dsl}/xpath_extractor.rb +4 -2
  134. data/lib/gridinit-jmeter/dsl.rb +170 -187
  135. data/lib/gridinit-jmeter/helpers/helper.rb +43 -0
  136. data/lib/gridinit-jmeter/helpers/parser.rb +109 -0
  137. data/lib/gridinit-jmeter/idl.rb +16 -6
  138. data/lib/gridinit-jmeter/idl.xml +54 -11
  139. data/lib/gridinit-jmeter/{listeners → plugins}/gc_console_status_logger.rb +0 -0
  140. data/lib/gridinit-jmeter/{listeners → plugins}/gc_latencies_over_time.rb +0 -0
  141. data/lib/gridinit-jmeter/{listeners → plugins}/gc_response_codes_per_second.rb +0 -0
  142. data/lib/gridinit-jmeter/{listeners → plugins}/gc_response_times_distribution.rb +0 -0
  143. data/lib/gridinit-jmeter/{listeners → plugins}/gc_response_times_over_time.rb +0 -0
  144. data/lib/gridinit-jmeter/{listeners → plugins}/gc_response_times_percentiles.rb +0 -0
  145. data/lib/gridinit-jmeter/{listeners → plugins}/gc_transactions_per_second.rb +0 -0
  146. data/lib/gridinit-jmeter/{timers/gc_throughput_shaping_timer.rb → plugins/gc_variable_throughput_timer.rb} +1 -1
  147. data/lib/gridinit-jmeter/version.rb +1 -1
  148. data/lib/gridinit-jmeter.rb +6 -105
  149. data/spec/dsl_spec.rb +377 -82
  150. metadata +131 -174
  151. data/examples/basic_proxy.rb +0 -8
  152. data/examples/basic_results.rb +0 -22
  153. data/examples/basic_run.rb +0 -12
  154. data/examples/basic_simple_data_writer.rb +0 -14
  155. data/examples/basic_stdout.rb +0 -8
  156. data/examples/basic_test_data.rb +0 -15
  157. data/examples/basic_testplan.jmx +0 -138
  158. data/examples/basic_testplan.rb +0 -44
  159. data/examples/jbhifi_now_search.rb +0 -94
  160. data/lib/gridinit-jmeter/assertions/response_assertion.rb +0 -55
  161. data/lib/gridinit-jmeter/config/auth_manager.rb +0 -26
  162. data/lib/gridinit-jmeter/config/cache_manager.rb +0 -20
  163. data/lib/gridinit-jmeter/config/cookie_manager.rb +0 -21
  164. data/lib/gridinit-jmeter/config/counter_config.rb +0 -24
  165. data/lib/gridinit-jmeter/config/header_manager.rb +0 -26
  166. data/lib/gridinit-jmeter/config/random_variable.rb +0 -24
  167. data/lib/gridinit-jmeter/config/request_defaults.rb +0 -31
  168. data/lib/gridinit-jmeter/config/user_defined_variable.rb +0 -25
  169. data/lib/gridinit-jmeter/controllers/if_controller.rb +0 -20
  170. data/lib/gridinit-jmeter/controllers/interleave.rb +0 -18
  171. data/lib/gridinit-jmeter/controllers/loop_controller.rb +0 -19
  172. data/lib/gridinit-jmeter/controllers/once_only.rb +0 -17
  173. data/lib/gridinit-jmeter/controllers/random_order.rb +0 -16
  174. data/lib/gridinit-jmeter/controllers/simple.rb +0 -17
  175. data/lib/gridinit-jmeter/controllers/switch.rb +0 -20
  176. data/lib/gridinit-jmeter/controllers/throughput.rb +0 -26
  177. data/lib/gridinit-jmeter/controllers/transaction.rb +0 -19
  178. data/lib/gridinit-jmeter/controllers/while_controller.rb +0 -18
  179. data/lib/gridinit-jmeter/helpers/dsl_helper.rb +0 -21
  180. data/lib/gridinit-jmeter/idl/http_authorization_manager.rb +0 -26
  181. data/lib/gridinit-jmeter/idl/user_defined_variables.rb +0 -26
  182. data/lib/gridinit-jmeter/listeners/aggregate_report.rb +0 -47
  183. data/lib/gridinit-jmeter/listeners/graph_visualizer.rb +0 -46
  184. data/lib/gridinit-jmeter/listeners/response_time_graph_visualizer.rb +0 -47
  185. data/lib/gridinit-jmeter/listeners/simple_data_writer.rb +0 -51
  186. data/lib/gridinit-jmeter/listeners/stat_visualizer.rb +0 -46
  187. data/lib/gridinit-jmeter/listeners/summary_report.rb +0 -46
  188. data/lib/gridinit-jmeter/listeners/table_visualizer.rb +0 -46
  189. data/lib/gridinit-jmeter/listeners/view_results_full_visualizer.rb +0 -57
  190. data/lib/gridinit-jmeter/post_processors/regex_extractor.rb +0 -34
  191. data/lib/gridinit-jmeter/post_processors/xpath_extractor.rb +0 -23
  192. data/lib/gridinit-jmeter/pre_processors/bean_shell_pre_processor.rb +0 -23
  193. data/lib/gridinit-jmeter/samplers/http_sampler.rb +0 -99
  194. data/lib/gridinit-jmeter/samplers/ldap_ext_sampler.rb +0 -36
  195. data/lib/gridinit-jmeter/samplers/soap_sampler.rb +0 -26
  196. data/lib/gridinit-jmeter/test_plan/test_plan.rb +0 -23
  197. data/lib/gridinit-jmeter/threads/thread_group.rb +0 -30
  198. data/lib/gridinit-jmeter/timers/gaussian_random_timer.rb +0 -18
data/spec/dsl_spec.rb CHANGED
@@ -1,162 +1,457 @@
1
1
  require "spec_helper"
2
+ require "pry-debugger"
2
3
 
3
4
  describe "DSL" do
4
5
 
5
- it "test plan should respond to thread groups" do
6
- test {}.should respond_to :threads
6
+ describe 'aliased DSL methods' do
7
+ it "test plan should respond to aliased methods" do
8
+ test {}.should respond_to :variables
9
+ test {}.should respond_to :defaults
10
+ test {}.should respond_to :cookies
11
+ test {}.should respond_to :cache
12
+ test {}.should respond_to :header
13
+ test {}.should respond_to :auth
14
+ end
15
+ end
16
+
17
+
18
+ describe 'write to stdout and file' do
19
+ it "should output a test plan to stdout" do
20
+ $stdout.should_receive(:puts).with(/jmeterTestPlan/i)
21
+ test do
22
+ end.out
23
+ end
24
+
25
+ it "should output a test plan to jmx file" do
26
+ file = mock('file')
27
+ File.should_receive(:open).with("jmeter.jmx", "w").and_yield(file)
28
+ file.should_receive(:write).with(/jmeterTestPlan/i)
29
+ test do
30
+ end.jmx
31
+ end
32
+ end
33
+
34
+
35
+ describe 'user agent' do
36
+ let(:doc) do
37
+ test do
38
+ with_user_agent :chrome
39
+ threads
40
+ end.to_doc
41
+ end
42
+
43
+ let(:fragment) { doc.search("//HeaderManager").first }
44
+
45
+ it 'should match on user_agent' do
46
+ fragment.search(".//stringProp[@name='Header.name']").text.should == 'User-Agent'
47
+ fragment.search(".//stringProp[@name='Header.value']").text.should ==
48
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5'
49
+ end
50
+ end
51
+
52
+
53
+ describe 'thread groups' do
54
+ let(:doc) do
55
+ test do
56
+ threads count: 101, continue_forever: true, duration: 69
57
+ end.to_doc
58
+ end
59
+
60
+ let(:fragment) { doc.search("//ThreadGroup").first }
61
+
62
+ it 'should match on num_threads' do
63
+ fragment.search(".//stringProp[@name='ThreadGroup.num_threads']").text.should == '101'
64
+ end
65
+
66
+ it 'should match on continue_forever' do
67
+ fragment.search(".//boolProp[@name='LoopController.continue_forever']").text.should == 'true'
68
+ end
69
+
70
+ it 'should match on loops' do
71
+ fragment.search(".//stringProp[@name='LoopController.loops']").text.should == '-1'
72
+ end
73
+
74
+ it 'should match on duration' do
75
+ fragment.search(".//stringProp[@name='ThreadGroup.duration']").text.should == '69'
76
+ end
7
77
  end
8
78
 
9
- it "test plan should respond to transactions" do
10
- test {}.should respond_to :transaction
79
+
80
+ describe 'thread groups old syntax' do
81
+ let(:doc) do
82
+ test do
83
+ threads 101, continue_forever: true, duration: 69
84
+ end.to_doc
85
+ end
86
+
87
+ let(:fragment) { doc.search("//ThreadGroup").first }
88
+
89
+ it 'should match on num_threads' do
90
+ fragment.search(".//stringProp[@name='ThreadGroup.num_threads']").text.should == '101'
91
+ end
92
+
93
+ it 'should match on continue_forever' do
94
+ fragment.search(".//boolProp[@name='LoopController.continue_forever']").text.should == 'true'
95
+ end
96
+
97
+ it 'should match on loops' do
98
+ fragment.search(".//stringProp[@name='LoopController.loops']").text.should == '-1'
99
+ end
100
+
101
+ it 'should match on duration' do
102
+ fragment.search(".//stringProp[@name='ThreadGroup.duration']").text.should == '69'
103
+ end
104
+ end
105
+
106
+
107
+ describe 'transaction controller' do
108
+ let(:doc) do
109
+ test do
110
+ threads do
111
+ transaction name: "TC_01", parent: true, include_timers: true
112
+ end
113
+ end.to_doc
114
+ end
115
+
116
+ let(:fragment) { doc.search("//TransactionController").first }
117
+
118
+ it 'should match on parent' do
119
+ fragment.search(".//boolProp[@name='TransactionController.parent']").text.should == 'true'
120
+ end
121
+
122
+ it 'should match on includeTimers' do
123
+ fragment.search(".//boolProp[@name='TransactionController.includeTimers']").text.should == 'true'
124
+ end
125
+ end
126
+
127
+
128
+ describe 'visit' do
129
+ let(:doc) do
130
+ test do
131
+ threads do
132
+ transaction name: "TC_01", parent: true, include_timers: true do
133
+ visit url: "/home?location=melbourne", always_encode: true
134
+ end
135
+ end
136
+ end.to_doc
137
+ end
138
+
139
+ let(:fragment) { doc.search("//HTTPSamplerProxy").first }
140
+
141
+ it 'should match on path' do
142
+ fragment.search(".//stringProp[@name='HTTPSampler.path']").text.should == '/home'
143
+ end
144
+
145
+ it 'should match on always_encode' do
146
+ fragment.search(".//boolProp[@name='HTTPArgument.always_encode']").text.should == 'true'
147
+ end
148
+ end
149
+
150
+
151
+ describe 'visit old syntax' do
152
+ let(:doc) do
153
+ test do
154
+ threads do
155
+ visit "/home?location=melbourne", always_encode: true
156
+ end
157
+ end.to_doc
158
+ end
159
+
160
+ let(:fragment) { doc.search("//HTTPSamplerProxy").first }
161
+
162
+ it 'should match on path' do
163
+ fragment.search(".//stringProp[@name='HTTPSampler.path']").text.should == '/home'
164
+ end
165
+ end
166
+
167
+
168
+ describe 'https' do
169
+ let(:doc) do
170
+ test do
171
+ threads do
172
+ transaction name: "TC_01", parent: true, include_timers: true do
173
+ visit url: "https://example.com"
174
+ end
175
+ end
176
+ end.to_doc
177
+ end
178
+
179
+ let(:fragment) { doc.search("//HTTPSamplerProxy").first }
180
+
181
+ it 'should match on protocol' do
182
+ fragment.search(".//stringProp[@name='HTTPSampler.protocol']").text.should == 'https'
183
+ end
11
184
  end
12
185
 
13
- it "test plan should respond to visit" do
14
- test {}.should respond_to :visit
186
+
187
+ describe 'xhr' do
188
+ let(:doc) do
189
+ test do
190
+ threads do
191
+ transaction name: "TC_02", parent: true, include_timers: true do
192
+ visit url: "/" do
193
+ with_xhr
194
+ end
195
+ end
196
+ end
197
+ end.to_doc
198
+ end
199
+
200
+ let(:fragment) { doc.search("//HeaderManager").first }
201
+
202
+ it 'should match on XHR' do
203
+ fragment.search(".//stringProp[@name='Header.value']").text.should == 'XMLHttpRequest'
204
+ end
15
205
  end
16
206
 
17
- it "test plan should respond to soap" do
18
- test {}.should respond_to :soap
207
+
208
+ describe 'submit' do
209
+ let(:doc) do
210
+ test do
211
+ threads do
212
+ transaction name: "TC_03", parent: true, include_timers: true do
213
+ submit url: "/", fill_in: { username: 'tim', password: 'password' }
214
+ end
215
+ end
216
+ end.to_doc
217
+ end
218
+
219
+ let(:fragment) { doc.search("//HTTPSamplerProxy").first }
220
+
221
+ it 'should match on POST' do
222
+ fragment.search(".//stringProp[@name='HTTPSampler.method']").text.should == 'POST'
223
+ end
19
224
  end
20
225
 
21
- it "test plan should respond to submit" do
22
- test {}.should respond_to :submit
226
+
227
+ describe 'If' do
228
+ let(:doc) do
229
+ test do
230
+ threads do
231
+ If condition: '2>1' do
232
+ visit url: "/"
233
+ end
234
+ end
235
+ end.to_doc
236
+ end
237
+
238
+ let(:fragment) { doc.search("//IfController").first }
239
+
240
+ it 'should match on If' do
241
+ fragment.search(".//stringProp[@name='IfController.condition']").text.should == '2>1'
242
+ end
23
243
  end
24
244
 
25
- it "should output a test plan to stdout" do
26
- $stdout.should_receive(:puts).with(/jmeterTestPlan/i)
27
- test do
28
- end.out
245
+
246
+ describe 'exists' do
247
+ let(:doc) do
248
+ test do
249
+ threads do
250
+ exists 'apple' do
251
+ visit url: "/"
252
+ end
253
+ end
254
+ end.to_doc
255
+ end
256
+
257
+ let(:fragment) { doc.search("//IfController").first }
258
+
259
+ it 'should match on exists' do
260
+ fragment.search(".//stringProp[@name='IfController.condition']").text.should == "'${apple}'.length > 0"
261
+ end
29
262
  end
30
263
 
31
- it "should output a test plan to jmx file" do
32
- file = mock('file')
33
- File.should_receive(:open).with("jmeter.jmx", "w").and_yield(file)
34
- file.should_receive(:write).with(/jmeterTestPlan/i)
35
- test do
36
- end.jmx
264
+
265
+ describe 'While' do
266
+ let(:doc) do
267
+ test do
268
+ threads do
269
+ While condition: 'true' do
270
+ visit url: "/"
271
+ end
272
+ end
273
+ end.to_doc
274
+ end
275
+
276
+ let(:fragment) { doc.search("//WhileController").first }
277
+
278
+ it 'should match on While' do
279
+ fragment.search(".//stringProp[@name='WhileController.condition']").text.should == 'true'
280
+ end
37
281
  end
38
282
 
39
- describe 'Disabled reports' do
283
+
284
+ describe 'Loop' do
40
285
  let(:doc) do
41
286
  test do
42
- aggregate_report('Aggregate Report disabled', {enabled: false})
43
- aggregate_report('Aggregate Report enabled', {enabled: true})
44
- aggregate_report('Aggregate Report default', {enabled: true})
287
+ threads do
288
+ Loop count: 5 do
289
+ visit url: "/"
290
+ end
291
+ end
45
292
  end.to_doc
46
293
  end
47
294
 
48
- let(:aggregate_report_disabled) { doc.search("//ResultCollector[@testname='Aggregate Report disabled']").first }
49
- let(:aggregate_report_enabled) { doc.search("//ResultCollector[@testname='Aggregate Report enabled']").first }
50
- let(:aggregate_report_default) { doc.search("//ResultCollector[@testname='Aggregate Report default']").first }
295
+ let(:fragment) { doc.search("//LoopController").first }
51
296
 
52
- it 'should disable Aggregate Report disabled' do
53
- aggregate_report_disabled.attributes['enabled'].value.should == 'false'
297
+ it 'should match on Loops' do
298
+ fragment.search(".//stringProp[@name='LoopController.loops']").text.should == '5'
54
299
  end
300
+ end
301
+
55
302
 
56
- it 'should disable Aggregate Report enabled' do
57
- aggregate_report_enabled.attributes['enabled'].value.should == 'true'
303
+ describe 'Counter' do
304
+ let(:doc) do
305
+ test do
306
+ threads do
307
+ visit url: "/" do
308
+ counter start: 1, per_user: true
309
+ end
310
+ end
311
+ end.to_doc
58
312
  end
59
- it 'should disable Aggregate Report default' do
60
- aggregate_report_enabled.attributes['enabled'].value.should == 'true'
313
+
314
+ let(:fragment) { doc.search("//CounterConfig").first }
315
+
316
+ it 'should match on 5 Loops' do
317
+ fragment.search(".//boolProp[@name='CounterConfig.per_user']").text.should == 'true'
61
318
  end
62
319
  end
63
320
 
64
- describe do
65
321
 
322
+ describe 'Switch' do
66
323
  let(:doc) do
67
324
  test do
68
- view_results_full_visualizer('View Results Tree error_only', {error_only: true})
69
- view_results_full_visualizer('View Results Tree not error_only', {error_only: false})
70
- view_results_full_visualizer('View Results Tree default')
325
+ threads do
326
+ Switch value: 'cat' do
327
+ visit url: "/"
328
+ end
329
+ end
71
330
  end.to_doc
72
331
  end
73
332
 
74
- let(:report_errors_only) { doc.search("//ResultCollector[@testname='View Results Tree error_only']").first }
75
- let(:report_not_errors_only) { doc.search("//ResultCollector[@testname='View Results Tree not error_only']").first }
76
- let(:report_default) { doc.search("//ResultCollector[@testname='View Results Tree default']").first }
333
+ let(:fragment) { doc.search("//SwitchController").first }
77
334
 
78
- it 'should be true when errors only' do
79
- error_logging = report_errors_only.children.first
80
- error_logging.attributes['name'].value.should == 'ResultCollector.error_logging'
81
- error_logging.text.should == 'true'
335
+ it 'should match on Switch' do
336
+ fragment.search(".//stringProp[@name='SwitchController.value']").text.should == 'cat'
82
337
  end
338
+ end
83
339
 
84
- it 'should be false when not errors only' do
85
- error_logging = report_not_errors_only.children.first
86
- error_logging.attributes['name'].value.should == 'ResultCollector.error_logging'
87
- error_logging.text.should == 'false'
340
+ describe 'regex extract' do
341
+ let(:doc) do
342
+ test do
343
+ extract regex: 'pattern', name: 'my_regex'
344
+ end.to_doc
88
345
  end
89
- it 'should default to false when not given' do
90
- error_logging = report_default.children.first
91
- error_logging.attributes['name'].value.should == 'ResultCollector.error_logging'
92
- error_logging.text.should == 'false'
346
+
347
+ let(:fragment) { doc.search("//RegexExtractor").first }
348
+
349
+ it 'should match on refname' do
350
+ fragment.search(".//stringProp[@name='RegexExtractor.refname']").text.should == 'my_regex'
93
351
  end
94
352
  end
95
353
 
96
- describe 'extract use_headers_type' do
97
354
 
355
+ describe 'xpath extract' do
98
356
  let(:doc) do
99
357
  test do
100
- extract :regex, 'match on url', 'blah', {match_on: 'URL'}
101
- extract :regex, 'match on default', 'blah'
358
+ extract xpath: '//node', name: 'my_xpath'
102
359
  end.to_doc
103
360
  end
104
361
 
105
- let(:extract_url) { doc.search("//RegexExtractor[@testname='match on url']").first }
106
- let(:extract) { doc.search("//RegexExtractor[@testname='match on default']").first }
362
+ let(:fragment) { doc.search("//XPathExtractor").first }
107
363
 
108
- it 'should match on URL' do
109
- extract_url.search(".//stringProp[@name='RegexExtractor.useHeaders']").text.should == 'URL'
364
+ it 'should match on refname' do
365
+ fragment.search(".//stringProp[@name='XPathExtractor.refname']").text.should == 'my_xpath'
110
366
  end
367
+ end
368
+
369
+
370
+ describe 'assertions' do
371
+
372
+ describe 'scope all' do
373
+ let(:doc) do
374
+ test do
375
+ visit '/' do
376
+ assert contains: 'Welcome'
377
+ end
378
+ end.to_doc
379
+ end
380
+
381
+ let(:fragment) { doc.search("//ResponseAssertion").first }
111
382
 
112
- it 'should default to false' do
113
- extract.search(".//stringProp[@name='RegexExtractor.useHeaders']").text.should == 'false'
383
+ it 'should match on match' do
384
+ fragment.search(".//stringProp[@name='match']").text.should == 'Welcome'
385
+ end
386
+
387
+ it 'should match on scope' do
388
+ fragment.search(".//stringProp[@name='Assertion.scope']").text.should == 'all'
389
+ end
390
+
391
+ it 'should match on test_type' do
392
+ fragment.search(".//intProp[@name='Assertion.test_type']").text.should == '2'
393
+ end
114
394
  end
115
395
 
396
+ describe 'scope main' do
397
+ let(:doc) do
398
+ test do
399
+ visit '/' do
400
+ assert contains: 'Welcome', scope: 'main'
401
+ end
402
+ end.to_doc
403
+ end
404
+
405
+ let(:fragment) { doc.search("//ResponseAssertion").first }
406
+
407
+ it 'should match on scope' do
408
+ puts doc.to_xml indent: 2
409
+ fragment.search(".//stringProp[@name='Assertion.scope']").text.should == ""
410
+ end
411
+ end
116
412
  end
117
413
 
118
- describe 'Nested controllers' do
119
414
 
415
+ describe 'Nested controllers' do
120
416
  let(:doc) do
121
417
  test do
122
- simple 'blah1.1' do
123
- simple 'blah2.1'
124
- simple 'blah2.2' do
125
- simple 'blah3.1'
418
+ Simple name: 'node1.1' do
419
+ Simple name: 'node2.1'
420
+ Simple name: 'node2.2' do
421
+ Simple name: 'node3.1'
126
422
  end
127
- simple 'blah2.3'
423
+ Simple name: 'node2.3'
128
424
  end
129
- simple 'blah1.2'
425
+ Simple name: 'node1.2'
130
426
  end.to_doc
131
427
  end
132
428
 
133
- let(:blah1_1) { doc.search("//GenericController[@testname='blah1.1']").first }
134
- let(:blah1_2) { doc.search("//GenericController[@testname='blah1.2']").first }
429
+ let(:node1_1) { doc.search("//GenericController[@testname='node1.1']").first }
430
+ let(:node1_2) { doc.search("//GenericController[@testname='node1.2']").first }
135
431
 
136
- let(:blah2_1) { doc.search("//GenericController[@testname='blah2.1']").first }
137
- let(:blah2_2) { doc.search("//GenericController[@testname='blah2.2']").first }
138
- let(:blah2_3) { doc.search("//GenericController[@testname='blah2.3']").first }
432
+ let(:node2_1) { doc.search("//GenericController[@testname='node2.1']").first }
433
+ let(:node2_2) { doc.search("//GenericController[@testname='node2.2']").first }
434
+ let(:node2_3) { doc.search("//GenericController[@testname='node2.3']").first }
139
435
 
140
- let(:blah3_1) { doc.search("//GenericController[@testname='blah3.1']").first }
436
+ let(:node3_1) { doc.search("//GenericController[@testname='node3.1']").first }
141
437
 
142
438
  it 'nodes should have hashTree as its parent' do
143
- [blah1_1, blah1_2, blah2_1, blah2_2, blah2_3, blah3_1].each do |node|
439
+ [node1_1, node1_2, node2_1, node2_2, node2_3, node3_1].each do |node|
144
440
  node.parent.name.should == 'hashTree'
145
441
  end
146
442
  end
147
443
 
148
- describe 'blah3_1' do
149
- it 'parent parent should be blah2_2' do
150
- blah3_1.parent.should == blah2_2.next
444
+ describe 'node3_1' do
445
+ it 'parent parent should be node2_2' do
446
+ node3_1.parent.should == node2_2.next
151
447
  end
152
448
  end
153
449
 
154
- describe 'blah1_2' do
155
- it 'previous non hashTree sibling is blah1_1' do
156
- blah1_2.previous.previous.should == blah1_1
450
+ describe 'node1_2' do
451
+ it 'previous non hashTree sibling is node1_1' do
452
+ node1_2.previous.previous.should == node1_1
157
453
  end
158
454
  end
159
455
 
160
456
  end
161
-
162
457
  end