Sipper 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (326) hide show
  1. data/sipper/README.rb +26 -0
  2. data/sipper/b2bua_controller.rb +163 -0
  3. data/sipper/b2bua_session_mixin.rb +24 -0
  4. data/sipper/base_controller.rb +425 -0
  5. data/sipper/bin/common.rb +42 -0
  6. data/sipper/bin/generate.rb +70 -0
  7. data/sipper/bin/project.rb +44 -0
  8. data/sipper/bin/run.rb +85 -0
  9. data/sipper/bin/run_smoke.rb +8 -0
  10. data/sipper/config/log4r.xml +71 -0
  11. data/sipper/controller_class_loader.rb +29 -0
  12. data/sipper/controller_selector.rb +119 -0
  13. data/sipper/controllers/invite_controller.rb +30 -0
  14. data/sipper/controllers/order.yaml +3 -0
  15. data/sipper/custom_message.rb +4 -0
  16. data/sipper/detached_session.rb +11 -0
  17. data/sipper/docs/manual.txt +1621 -0
  18. data/sipper/generators/README +12 -0
  19. data/sipper/generators/gen_controller.rb +228 -0
  20. data/sipper/generators/gen_project.rb +45 -0
  21. data/sipper/generators/gen_test.rb +72 -0
  22. data/sipper/generators/project_template_dir/Rakefile +56 -0
  23. data/sipper/generators/project_template_dir/config/sipper.cfg +31 -0
  24. data/sipper/generators/project_template_dir/controllers/README.txt +2 -0
  25. data/sipper/generators/project_template_dir/dot_sipper.proj +2 -0
  26. data/sipper/generators/project_template_dir/logs/README.txt +2 -0
  27. data/sipper/generators/project_template_dir/tests/README.txt +2 -0
  28. data/sipper/lib/smc/statemap.rb +194 -0
  29. data/sipper/logs/dialog_info_store +0 -0
  30. data/sipper/logs/r.cmd +6 -0
  31. data/sipper/logs/r.sh +6 -0
  32. data/sipper/media/sipper_media_client.rb +268 -0
  33. data/sipper/media/sipper_media_event.rb +43 -0
  34. data/sipper/media/sipper_media_manager.rb +145 -0
  35. data/sipper/media/sipper_media_proxy.rb +60 -0
  36. data/sipper/media/sipper_offer_answer.rb +285 -0
  37. data/sipper/message.rb +512 -0
  38. data/sipper/modified_pattern_formatter.rb +119 -0
  39. data/sipper/proxy_controller.rb +143 -0
  40. data/sipper/registration.rb +52 -0
  41. data/sipper/request.rb +109 -0
  42. data/sipper/response.rb +123 -0
  43. data/sipper/ruby_ext/module.rb +27 -0
  44. data/sipper/ruby_ext/mutable_class.rb +17 -0
  45. data/sipper/ruby_ext/object.rb +38 -0
  46. data/sipper/ruby_ext/pqueue.rb +190 -0
  47. data/sipper/ruby_ext/snapshot.rb +201 -0
  48. data/sipper/ruby_ext/string.rb +18 -0
  49. data/sipper/ruby_ext/time.rb +9 -0
  50. data/sipper/run/run_sipper1.rb +28 -0
  51. data/sipper/run/run_sipper2.rb +56 -0
  52. data/sipper/sdp/sdp.rb +257 -0
  53. data/sipper/sdp/sdp_generator.rb +131 -0
  54. data/sipper/sdp/sdp_parser.rb +136 -0
  55. data/sipper/session.rb +1952 -0
  56. data/sipper/session_manager.rb +170 -0
  57. data/sipper/session_recorder.rb +190 -0
  58. data/sipper/session_state/DialogState.sm +54 -0
  59. data/sipper/session_state/DialogState_sm.rb +337 -0
  60. data/sipper/session_state/dialog_routes.rb +141 -0
  61. data/sipper/sip_headers/header.rb +632 -0
  62. data/sipper/sip_headers/sipuri.rb +352 -0
  63. data/sipper/sip_logger.rb +65 -0
  64. data/sipper/sip_message_router.rb +231 -0
  65. data/sipper/sip_test_driver_controller.rb +10 -0
  66. data/sipper/sipper.rb +329 -0
  67. data/sipper/sipper_assertions.rb +21 -0
  68. data/sipper/sipper_configurator.rb +376 -0
  69. data/sipper/sipper_http/sipper_http_request_dispatcher.rb +71 -0
  70. data/sipper/sipper_http/sipper_http_response.rb +25 -0
  71. data/sipper/stray_message_manager.rb +40 -0
  72. data/sipper/test_completion_signaling_helper.rb +77 -0
  73. data/sipper/transaction/Ict.sm +59 -0
  74. data/sipper/transaction/Ict_sm.rb +430 -0
  75. data/sipper/transaction/Ist.sm +74 -0
  76. data/sipper/transaction/Ist_sm.rb +460 -0
  77. data/sipper/transaction/Nict.sm +51 -0
  78. data/sipper/transaction/Nict_sm.rb +325 -0
  79. data/sipper/transaction/Nist.sm +59 -0
  80. data/sipper/transaction/Nist_sm.rb +356 -0
  81. data/sipper/transaction/invite_client_transaction.rb +274 -0
  82. data/sipper/transaction/invite_server_transaction.rb +319 -0
  83. data/sipper/transaction/non_invite_client_transaction.rb +230 -0
  84. data/sipper/transaction/non_invite_server_transaction.rb +263 -0
  85. data/sipper/transaction/state_machine_wrapper.rb +58 -0
  86. data/sipper/transaction/transaction.rb +212 -0
  87. data/sipper/transport/base_transport.rb +84 -0
  88. data/sipper/transport/rel_unrel.rb +19 -0
  89. data/sipper/transport/transport_and_route_resolver.rb +67 -0
  90. data/sipper/transport/udp_transport.rb +156 -0
  91. data/sipper/transport_manager.rb +33 -0
  92. data/sipper/udp_session.rb +17 -0
  93. data/sipper/util/command_element.rb +62 -0
  94. data/sipper/util/compact_converter.rb +50 -0
  95. data/sipper/util/counter.rb +26 -0
  96. data/sipper/util/digest/digest_authorizer.rb +204 -0
  97. data/sipper/util/expectation_parser.rb +164 -0
  98. data/sipper/util/locator.rb +31 -0
  99. data/sipper/util/message_fill.rb +58 -0
  100. data/sipper/util/persistence/ps_sipper_map.rb +63 -0
  101. data/sipper/util/persistence/sipper_map.rb +41 -0
  102. data/sipper/util/sipper_util.rb +305 -0
  103. data/sipper/util/timer/sip_timer_helper.rb +26 -0
  104. data/sipper/util/timer/timer_manager.rb +80 -0
  105. data/sipper/util/timer/timer_task.rb +56 -0
  106. data/sipper/util/validations.rb +44 -0
  107. data/sipper/version.rb +10 -0
  108. data/sipper_test/_test_media_uas.rb +79 -0
  109. data/sipper_test/base_test_case.rb +31 -0
  110. data/sipper_test/c_134.txt +7 -0
  111. data/sipper_test/driven_sip_test_case.rb +96 -0
  112. data/sipper_test/gold.txt +10 -0
  113. data/sipper_test/gold_res.txt +8 -0
  114. data/sipper_test/gold_sub.txt +9 -0
  115. data/sipper_test/hello_sipper.au +0 -0
  116. data/sipper_test/in_sipper.au +0 -0
  117. data/sipper_test/nonrr_proxy.rb +17 -0
  118. data/sipper_test/order_tests.yaml +4 -0
  119. data/sipper_test/rake_res.txt +399 -0
  120. data/sipper_test/rr_proxy.rb +17 -0
  121. data/sipper_test/run_test.cmd +94 -0
  122. data/sipper_test/sip_test_case.rb +104 -0
  123. data/sipper_test/test2xx_retransmission.rb +80 -0
  124. data/sipper_test/test2xx_retransmission_with_limit.rb +81 -0
  125. data/sipper_test/test2xx_retransmission_with_nist.rb +91 -0
  126. data/sipper_test/test2xx_retransmission_with_txns.rb +94 -0
  127. data/sipper_test/test_address_header.rb +66 -0
  128. data/sipper_test/test_b2bua1.rb +130 -0
  129. data/sipper_test/test_b2bua2.rb +120 -0
  130. data/sipper_test/test_b2bua3.rb +160 -0
  131. data/sipper_test/test_b2bua4.rb +130 -0
  132. data/sipper_test/test_base_controller.rb +110 -0
  133. data/sipper_test/test_base_transport.rb +37 -0
  134. data/sipper_test/test_cancel.rb +21 -0
  135. data/sipper_test/test_cancel_after2xx.rb +81 -0
  136. data/sipper_test/test_cancel_retransmission.rb +105 -0
  137. data/sipper_test/test_cancel_with481.rb +83 -0
  138. data/sipper_test/test_cancel_with487.rb +70 -0
  139. data/sipper_test/test_cancel_with_ist_without_nist.rb +99 -0
  140. data/sipper_test/test_cancel_with_nist.rb +84 -0
  141. data/sipper_test/test_cancel_without487.rb +77 -0
  142. data/sipper_test/test_command_element.rb +38 -0
  143. data/sipper_test/test_compact_converter.rb +33 -0
  144. data/sipper_test/test_controller_class_loader.rb +37 -0
  145. data/sipper_test/test_controller_selector.rb +53 -0
  146. data/sipper_test/test_controller_using_compact_headers.rb +74 -0
  147. data/sipper_test/test_controller_using_header_order.rb +85 -0
  148. data/sipper_test/test_controller_using_ict.rb +64 -0
  149. data/sipper_test/test_controller_using_ict_with_non_success.rb +72 -0
  150. data/sipper_test/test_controller_using_ict_with_tcbh.rb +24 -0
  151. data/sipper_test/test_controller_using_ict_with_tcbh_no_action.rb +24 -0
  152. data/sipper_test/test_controller_using_ist.rb +70 -0
  153. data/sipper_test/test_controller_using_ist_with_tcbh.rb +24 -0
  154. data/sipper_test/test_controller_using_nict.rb +115 -0
  155. data/sipper_test/test_controller_using_nict_with_tcbh.rb +24 -0
  156. data/sipper_test/test_controller_using_nist.rb +63 -0
  157. data/sipper_test/test_controller_using_pre_existing_rs0.rb +73 -0
  158. data/sipper_test/test_controller_using_pre_existing_rs1.rb +75 -0
  159. data/sipper_test/test_controller_using_pre_existing_rs2.rb +71 -0
  160. data/sipper_test/test_controller_using_route_set.rb +86 -0
  161. data/sipper_test/test_controller_with_sdp.rb +80 -0
  162. data/sipper_test/test_controllers/cancel/order.yaml +2 -0
  163. data/sipper_test/test_controllers/cancel/uac_cancel_controller.rb +35 -0
  164. data/sipper_test/test_controllers/cancel/uas_cancel_controller.rb +25 -0
  165. data/sipper_test/test_controllers/class_loading/ordered/first_ordered_controller.rb +5 -0
  166. data/sipper_test/test_controllers/class_loading/ordered/order.yaml +3 -0
  167. data/sipper_test/test_controllers/class_loading/ordered/recond_ordered_controller.rb +6 -0
  168. data/sipper_test/test_controllers/class_loading/ordered/second_ordered_controller.rb +6 -0
  169. data/sipper_test/test_controllers/class_loading/unordered/first_unordered_controller.rb +7 -0
  170. data/sipper_test/test_controllers/class_loading/unordered/second_unordered_controller.rb +6 -0
  171. data/sipper_test/test_controllers/ctrl_trhandler/lib/transport_filters/my_transport_handler.rb +22 -0
  172. data/sipper_test/test_controllers/ctrl_trhandler/uac_tr_handler_controller.rb +27 -0
  173. data/sipper_test/test_controllers/ctrl_trhandler/uas_tr_handler_controller.rb +21 -0
  174. data/sipper_test/test_controllers/ete/order.yaml +1 -0
  175. data/sipper_test/test_controllers/ete/uac_controller.rb +39 -0
  176. data/sipper_test/test_controllers/ete/uas_controller.rb +34 -0
  177. data/sipper_test/test_controllers/extensions/extension_uac_controller.rb +24 -0
  178. data/sipper_test/test_controllers/extensions/extension_uas_controller.rb +35 -0
  179. data/sipper_test/test_controllers/extensions/lib/sipper_extensions/my_from_extension.rb +16 -0
  180. data/sipper_test/test_controllers/ict_tcbh/lib/transaction_handlers/app_ict_handler.rb +23 -0
  181. data/sipper_test/test_controllers/ict_tcbh/uac_ict_tcbh_controller.rb +27 -0
  182. data/sipper_test/test_controllers/ict_tcbh/uac_ict_tcbh_no_action_controller.rb +28 -0
  183. data/sipper_test/test_controllers/ict_tcbh/uas_ict_tcbh_controller.rb +29 -0
  184. data/sipper_test/test_controllers/ict_tcbh/uas_ict_tcbh_no_action_controller.rb +31 -0
  185. data/sipper_test/test_controllers/ist_tcbh/lib/app_ist_handler.rb +13 -0
  186. data/sipper_test/test_controllers/ist_tcbh/uac_ist_tcbh_controller.rb +22 -0
  187. data/sipper_test/test_controllers/ist_tcbh/uas_ist_tcbh_controller.rb +31 -0
  188. data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/in_order.yaml +2 -0
  189. data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/my_transport_handler1.rb +21 -0
  190. data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/my_transport_handler2.rb +21 -0
  191. data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/out_order.yaml +2 -0
  192. data/sipper_test/test_controllers/multi_trhandlers/uac_multi_tr_handler_controller.rb +27 -0
  193. data/sipper_test/test_controllers/multi_trhandlers/uas_multi_tr_handler_controller.rb +29 -0
  194. data/sipper_test/test_controllers/multiple/lib/blank_test.rb +2 -0
  195. data/sipper_test/test_controllers/multiple/uac_info_controller.rb +21 -0
  196. data/sipper_test/test_controllers/multiple/uac_msg_controller.rb +20 -0
  197. data/sipper_test/test_controllers/multiple/uas_info_controller.rb +15 -0
  198. data/sipper_test/test_controllers/multiple/uas_msg_controller.rb +14 -0
  199. data/sipper_test/test_controllers/nict_tcbh/lib/transaction_handlers/app_nict_handler.rb +13 -0
  200. data/sipper_test/test_controllers/nict_tcbh/uac_nict_tcbh_controller.rb +26 -0
  201. data/sipper_test/test_controllers/nict_tcbh/uas_nict_tcbh_controller.rb +20 -0
  202. data/sipper_test/test_controllers/state_machine_based/lib/CreditControl.sm +43 -0
  203. data/sipper_test/test_controllers/state_machine_based/lib/CreditControl_sm.rb +194 -0
  204. data/sipper_test/test_controllers/state_machine_based/order.yaml +1 -0
  205. data/sipper_test/test_controllers/state_machine_based/uac_message_controller.rb +34 -0
  206. data/sipper_test/test_controllers/state_machine_based/uas_message_controller.rb +44 -0
  207. data/sipper_test/test_controllers/stray_message/lib/sipper_extensions/my_stray_handler.rb +9 -0
  208. data/sipper_test/test_controllers/stray_message/stray_uac_controller.rb +24 -0
  209. data/sipper_test/test_controllers/stray_message/stray_uas_controller.rb +31 -0
  210. data/sipper_test/test_controllers/string/order.yaml +1 -0
  211. data/sipper_test/test_controllers/string/uac_controller.rb +29 -0
  212. data/sipper_test/test_controllers/string/uas_controller.rb +22 -0
  213. data/sipper_test/test_controllers/test_controller.rb +24 -0
  214. data/sipper_test/test_detached_session1.rb +78 -0
  215. data/sipper_test/test_dialog_routes.rb +139 -0
  216. data/sipper_test/test_digest_challenge1.rb +89 -0
  217. data/sipper_test/test_digest_challenge2.rb +90 -0
  218. data/sipper_test/test_dynamic_parse.rb +249 -0
  219. data/sipper_test/test_empty_sdp.rb +89 -0
  220. data/sipper_test/test_ete.rb +37 -0
  221. data/sipper_test/test_expectation_parser.rb +76 -0
  222. data/sipper_test/test_extensions.rb +28 -0
  223. data/sipper_test/test_freeze.rb +81 -0
  224. data/sipper_test/test_generated.rb +90 -0
  225. data/sipper_test/test_header_parameters.rb +75 -0
  226. data/sipper_test/test_header_parse.rb +141 -0
  227. data/sipper_test/test_http_client1.rb +84 -0
  228. data/sipper_test/test_http_client2.rb +90 -0
  229. data/sipper_test/test_ict_with_timeout.rb +62 -0
  230. data/sipper_test/test_in_dialog_request.rb +61 -0
  231. data/sipper_test/test_inline_controller.rb +67 -0
  232. data/sipper_test/test_invite_client_transaction.rb +272 -0
  233. data/sipper_test/test_invite_replace.rb +147 -0
  234. data/sipper_test/test_invite_retransmission.rb +90 -0
  235. data/sipper_test/test_invite_server_transaction.rb +208 -0
  236. data/sipper_test/test_lower_cseq.rb +79 -0
  237. data/sipper_test/test_media.rb +52 -0
  238. data/sipper_test/test_message.rb +392 -0
  239. data/sipper_test/test_method_specific_response_handling.rb +81 -0
  240. data/sipper_test/test_multi_homed1.rb +127 -0
  241. data/sipper_test/test_multi_homed2.rb +109 -0
  242. data/sipper_test/test_multi_homed_duplicate.rb +87 -0
  243. data/sipper_test/test_multi_homed_with_detached.rb +88 -0
  244. data/sipper_test/test_multiple.rb +49 -0
  245. data/sipper_test/test_multiple_contacts.rb +89 -0
  246. data/sipper_test/test_non2xx_retransmission_with_ist.rb +87 -0
  247. data/sipper_test/test_non_invite_client_transaction.rb +210 -0
  248. data/sipper_test/test_non_invite_retransmission.rb +91 -0
  249. data/sipper_test/test_non_invite_server_transaction.rb +202 -0
  250. data/sipper_test/test_offer_answer_prack.rb +103 -0
  251. data/sipper_test/test_pickup.rb +258 -0
  252. data/sipper_test/test_prack.rb +105 -0
  253. data/sipper_test/test_prack_store_and_dispatch.rb +101 -0
  254. data/sipper_test/test_prack_timer.rb +105 -0
  255. data/sipper_test/test_ps_sipper_map.rb +56 -0
  256. data/sipper_test/test_re_invite_uas_ongoing_ict.rb +81 -0
  257. data/sipper_test/test_re_invite_uas_ongoing_ist.rb +84 -0
  258. data/sipper_test/test_re_invite_with_ongoing_ict.rb +101 -0
  259. data/sipper_test/test_re_invite_with_ongoing_ist.rb +89 -0
  260. data/sipper_test/test_recorder_swap.rb +157 -0
  261. data/sipper_test/test_refer.rb +121 -0
  262. data/sipper_test/test_registeration_clearing.rb +97 -0
  263. data/sipper_test/test_registrar.rb +109 -0
  264. data/sipper_test/test_registration_controller.rb +73 -0
  265. data/sipper_test/test_registration_timeout.rb +90 -0
  266. data/sipper_test/test_remote_controller.rb +39 -0
  267. data/sipper_test/test_remote_target_update_on2xx.rb +140 -0
  268. data/sipper_test/test_request.rb +106 -0
  269. data/sipper_test/test_response.rb +40 -0
  270. data/sipper_test/test_response_without_to_tag.rb +92 -0
  271. data/sipper_test/test_rport.rb +88 -0
  272. data/sipper_test/test_sdp.rb +91 -0
  273. data/sipper_test/test_sdp_parser.rb +145 -0
  274. data/sipper_test/test_session.rb +276 -0
  275. data/sipper_test/test_session_callback_handler.rb +68 -0
  276. data/sipper_test/test_session_lifetime.rb +66 -0
  277. data/sipper_test/test_session_manager.rb +141 -0
  278. data/sipper_test/test_session_recorder.rb +145 -0
  279. data/sipper_test/test_session_state_user_defined.rb +84 -0
  280. data/sipper_test/test_session_states.rb +91 -0
  281. data/sipper_test/test_simple_dialog_state.rb +86 -0
  282. data/sipper_test/test_simple_re_invite.rb +86 -0
  283. data/sipper_test/test_sip_uri.rb +234 -0
  284. data/sipper_test/test_sipper_util.rb +45 -0
  285. data/sipper_test/test_smc_controller.rb +17 -0
  286. data/sipper_test/test_smoke.rb +80 -0
  287. data/sipper_test/test_stray.rb +28 -0
  288. data/sipper_test/test_stray_inline.rb +89 -0
  289. data/sipper_test/test_stray_res_acked.rb +103 -0
  290. data/sipper_test/test_stray_respond.rb +104 -0
  291. data/sipper_test/test_stray_retry.rb +92 -0
  292. data/sipper_test/test_stray_retry_failure.rb +93 -0
  293. data/sipper_test/test_stray_retry_initial.rb +100 -0
  294. data/sipper_test/test_strict_router_with_angled.rb +84 -0
  295. data/sipper_test/test_string_record.rb +31 -0
  296. data/sipper_test/test_subscribe_notify.rb +141 -0
  297. data/sipper_test/test_subscribe_notify_client_timeout.rb +158 -0
  298. data/sipper_test/test_subscribe_notify_dialog.rb +146 -0
  299. data/sipper_test/test_subscribe_notify_expires.rb +155 -0
  300. data/sipper_test/test_subscribe_notify_multiple_subscription.rb +157 -0
  301. data/sipper_test/test_subscribe_notify_server_timeout.rb +144 -0
  302. data/sipper_test/test_subsequent_unsent.rb +88 -0
  303. data/sipper_test/test_target_refresh_proxy_detached.rb +128 -0
  304. data/sipper_test/test_target_refresh_proxy_udp.rb +130 -0
  305. data/sipper_test/test_target_refresh_rr_proxy_udp.rb +133 -0
  306. data/sipper_test/test_target_refresh_with_new_port.rb +158 -0
  307. data/sipper_test/test_target_refresh_with_proxy1.rb +113 -0
  308. data/sipper_test/test_target_refresh_with_rr_update_proxy.rb +145 -0
  309. data/sipper_test/test_target_refresh_with_update_proxy.rb +144 -0
  310. data/sipper_test/test_target_refresh_with_update_proxy2.rb +139 -0
  311. data/sipper_test/test_timer_manager.rb +71 -0
  312. data/sipper_test/test_timer_task.rb +60 -0
  313. data/sipper_test/test_transport_handler.rb +19 -0
  314. data/sipper_test/test_transport_multi_handler.rb +18 -0
  315. data/sipper_test/test_udp_transport.rb +119 -0
  316. data/sipper_test/test_unparsed.rb +70 -0
  317. data/sipper_test/test_validations.rb +69 -0
  318. data/sipper_test/test_with_rr_proxy.rb +111 -0
  319. data/sipper_test/testmediacontroller.rb +71 -0
  320. data/sipper_test/tracing.rb +23 -0
  321. data/sipper_test/transaction_test_helper.rb +176 -0
  322. data/sipper_test/transport_filters.rb +26 -0
  323. data/sipper_test/ts_sipper.rb +91 -0
  324. data/sipper_test/ts_smoke.rb +3 -0
  325. data/sipper_test/tt.cmd +20 -0
  326. metadata +455 -0
@@ -0,0 +1,71 @@
1
+ require 'net/http'
2
+ require 'thread'
3
+ require 'uri'
4
+ require 'sipper_http/sipper_http_response'
5
+ require 'sip_logger'
6
+
7
+ class HttpUrlContext
8
+ attr_accessor :url, :session, :params, :req_method
9
+ def initialize(url, req_method, session, params)
10
+ @url = url
11
+ @session = session
12
+ @params = params
13
+ @req_method = req_method
14
+ end
15
+ end
16
+
17
+
18
+ class SipperHttpRequestDispatcher
19
+ include SipLogger
20
+ # sipper_message_queue is the main event queue in sipper
21
+ # this is where all the sip/timer/media and now http responses
22
+ # are queued.
23
+ def initialize(sipper_msg_queue, num_threads = 5)
24
+ @num_threads = num_threads
25
+ @request_queue = Queue.new
26
+ @run = false
27
+ @smq = sipper_msg_queue
28
+ end
29
+
30
+ def start
31
+ @run = true
32
+ 1.upto(@num_threads) do |i|
33
+ Thread.new do
34
+ Thread.current[:name] = "HttpClientThread-"+i.to_s
35
+ while @run
36
+ url_context = @request_queue.pop
37
+ url = URI.parse(url_context.url)
38
+ res = nil
39
+ if url_context.req_method == 'get'
40
+ req = Net::HTTP::Get.new(url.path)
41
+ res = Net::HTTP.start(url.host, url.port) {|http|
42
+ http.request(req)
43
+ }
44
+ elsif url_context.req_method == 'post'
45
+ req = Net::HTTP::Post.new(url.path)
46
+ req.set_form_data( url_context.params, '&')
47
+ res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
48
+ end
49
+ sipper_res = SipperHttp::SipperHttpResponse.new(res, url_context.session)
50
+ @smq << sipper_res
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ def stop
57
+ @run = false
58
+ end
59
+
60
+ # params are a hash of POST parameters
61
+ def request_post(url, session, params)
62
+ logd('POST request called on dispatcher, now enquing request')
63
+ @request_queue << HttpUrlContext.new(url, 'post', session, params)
64
+ end
65
+
66
+ def request_get(url, session)
67
+ logd('GET request called on dispatcher, now enquing request')
68
+ @request_queue << HttpUrlContext.new(url, 'get', session, nil)
69
+ end
70
+
71
+ end
@@ -0,0 +1,25 @@
1
+ require 'delegate'
2
+
3
+ # Wraps the HTTPResponse, with Sipper context data.
4
+
5
+ module SipperHttp
6
+ class SipperHttpResponse < SimpleDelegator
7
+
8
+ attr_reader :session, :wrapped_http_res
9
+
10
+ def initialize(http_res, session)
11
+ super(http_res)
12
+ @session = session
13
+ @wrapped_http_res = http_res
14
+ end
15
+
16
+ def dispatch
17
+ @session.on_http_response(self)
18
+ end
19
+
20
+ def short_to_s
21
+ self.inspect
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,40 @@
1
+
2
+ module SIP
3
+
4
+ class StrayMessageHandler
5
+
6
+ SMH_DROP = 8000
7
+ SMH_HANDLED = 8001
8
+ SMH_RETRY = 8002
9
+ SMH_TREAT_INITIAL = 8003
10
+
11
+ # Filter on anonymous Module because if the stray handler is defined inline then
12
+ # we load the string twice, once in an anonymous module and once in top
13
+ # level object. We do not want to register the stray handler twice.
14
+ def self.inherited(child)
15
+ @stray_message_handler = child.new unless child.to_s =~ /^#<Module/
16
+ end
17
+
18
+ # default handler
19
+ def handle(msg)
20
+ [SIP::StrayMessageHandler::SMH_DROP, nil]
21
+ end
22
+
23
+ class << self; attr_accessor :stray_message_handler end
24
+ end
25
+
26
+
27
+ class StrayMessageManager
28
+
29
+ def self.stray_message_handler
30
+ return StrayMessageHandler.stray_message_handler
31
+ end
32
+
33
+ def self.clear_handler
34
+ StrayMessageHandler.stray_message_handler = nil
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
@@ -0,0 +1,77 @@
1
+ require 'monitor'
2
+ require 'ostruct'
3
+ require 'util/locator'
4
+
5
+ module SIP
6
+
7
+ class TcshProxy
8
+ def signal_waiting_test(test_name)
9
+ SipLogger['siplog::sip_testcompletionsignalinghelper'].debug("Fetching the signal data for remote server")
10
+ TestCompletionSignalingHelper.signal_waiting_test(test_name, true)
11
+ end
12
+ end
13
+
14
+ class TestCompletionSignalingHelper
15
+ include SipLogger
16
+
17
+ @@ro = nil
18
+
19
+ # The breakdown into two following methods: one to be called before starting any SIP
20
+ # signaling and other to be called after having started the controllers, is to set the monitor
21
+ # infra in place, such that in the unlikely event of SIP signaling completing before the driver
22
+ # even waits for the signal.
23
+
24
+ def self.prepare_monitor_for(test_class_name)
25
+ test_running = []
26
+ test_running.extend(MonitorMixin)
27
+ compl_cond = test_running.new_cond
28
+ signal_data = OpenStruct.new
29
+ signal_data.lock = test_running
30
+ signal_data.cond = compl_cond
31
+ (SIP::Locator[:Tlocks] ||= {})[test_class_name.to_s] = signal_data
32
+ end
33
+
34
+ # todo make use of count_waiters and signal added to the test_running[]
35
+ def self.wait_for_completion_on(signal_data)
36
+ signal_data.lock.synchronize do
37
+ if signal_data.lock.nitems > 0
38
+ SipLogger['siplog::sip_testcompletionsignalinghelper'].debug "Found queued signal, clearing"
39
+ signal_data.lock.clear
40
+ else
41
+ SipLogger['siplog::sip_testcompletionsignalinghelper'].debug "Now waiting for the signal"
42
+ k = 0
43
+ while k < SipperConfigurator[:WaitSecondsForTestCompletion]
44
+ signal_data.cond.wait(3)
45
+ break if signal_data.lock.nitems > 0
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+
52
+ def self.signal_waiting_test(test_name, proxy_call=false)
53
+ signal_data = SIP::Locator[:Tlocks][test_name] if SIP::Locator[:Tlocks]
54
+ unless signal_data
55
+ unless proxy_call
56
+ SipLogger['siplog::sip_testcompletionsignalinghelper'].debug "Signaling the remote object"
57
+ @@ro = DRbObject.new(nil, "druby://#{SipperConfigurator[:TestManagerName]}:#{SipperConfigurator[:TestManagerPort]}") unless @@ro
58
+ signal_data = @@ro.signal_waiting_test(test_name)
59
+ return true
60
+ else
61
+ SipLogger['siplog::sip_testcompletionsignalinghelper'].debug "No SD anywhere"
62
+ return false
63
+ end
64
+ end
65
+ signal_data.lock.synchronize do
66
+ signal_data.lock << "signal"
67
+ if signal_data.cond.count_waiters > 0
68
+ SipLogger['siplog::sip_testcompletionsignalinghelper'].debug("Signaling the waiting test driver")
69
+ signal_data.cond.signal
70
+ else
71
+ SipLogger['siplog::sip_testcompletionsignalinghelper'].debug "Queueing the signal"
72
+ end
73
+ end
74
+ end
75
+
76
+ end
77
+ end
@@ -0,0 +1,59 @@
1
+ // Invite Client Transaction. Section 17.1.1
2
+
3
+ %class Ict
4
+
5
+ %start IctMap::Initial
6
+
7
+ %map IctMap
8
+
9
+ %%
10
+
11
+ Initial
12
+ {
13
+ invite Calling { __send_invite(); __start_A(); __start_B(); }
14
+ transport_err Terminated { __transport_err(); } // even though not mentioned in RFC
15
+ }
16
+
17
+
18
+ Calling
19
+ Exit { __cancel_A(); __cancel_B(); }
20
+ {
21
+ timer_A(t: ltime) nil { __send_invite(); __reset_A(t); }
22
+ provisional Proceeding { __consume_msg(true); }
23
+ non_success_final Completed { __create_ack(); __send_ack(); __cancel_Y(); __consume_msg(true); }
24
+ success_final Terminated { __cancel_Y(); __consume_msg(true); }
25
+ timer_B Terminated { __timeout(); }
26
+ transport_err Terminated { __transport_err(); }
27
+ cancel_sent nil { __start_Y(); }
28
+ timer_Y Terminated { __timeout(); }
29
+ }
30
+
31
+
32
+ Proceeding
33
+ Exit { __cancel_Y(); }
34
+ {
35
+ provisional nil { __consume_msg(true); }
36
+ non_success_final Completed { __create_ack(); __send_ack(); __consume_msg(true); }
37
+ success_final Terminated { __consume_msg(true); }
38
+ transport_err Terminated { __transport_err(); } // even though not mentioned in RFC
39
+ cancel_sent nil { __start_Y(); }
40
+ timer_Y Terminated { __timeout(); }
41
+ }
42
+
43
+ Completed
44
+ Entry { __start_D(); }
45
+ {
46
+ non_success_final nil { __send_ack(); __consume_msg(false); }
47
+ timer_D Terminated { }
48
+ transport_err Terminated { __transport_err(); }
49
+ cancel_sent nil { } // no effect
50
+ }
51
+
52
+
53
+ Terminated
54
+ Entry { __cleanup(); }
55
+ {
56
+ cancel_sent nil { } // no effect
57
+ }
58
+
59
+ %%
@@ -0,0 +1,430 @@
1
+ # DO NOT EDIT.
2
+ # generated by smc (http://smc.sourceforge.net/)
3
+ # from file : Ict.sm
4
+
5
+ require 'statemap'
6
+
7
+ class IctState < Statemap::State
8
+
9
+ def Entry(fsm) end
10
+
11
+ def Exit(fsm) end
12
+
13
+ def cancel_sent(fsm)
14
+ Default(fsm)
15
+ end
16
+
17
+ def invite(fsm)
18
+ Default(fsm)
19
+ end
20
+
21
+ def non_success_final(fsm)
22
+ Default(fsm)
23
+ end
24
+
25
+ def provisional(fsm)
26
+ Default(fsm)
27
+ end
28
+
29
+ def success_final(fsm)
30
+ Default(fsm)
31
+ end
32
+
33
+ def timer_A(fsm, t)
34
+ Default(fsm)
35
+ end
36
+
37
+ def timer_B(fsm)
38
+ Default(fsm)
39
+ end
40
+
41
+ def timer_D(fsm)
42
+ Default(fsm)
43
+ end
44
+
45
+ def timer_Y(fsm)
46
+ Default(fsm)
47
+ end
48
+
49
+ def transport_err(fsm)
50
+ Default(fsm)
51
+ end
52
+
53
+ def Default(fsm)
54
+ msg = "\nState: " + fsm.getState.getName +
55
+ "\nTransition: " + fsm.getTransition + "\n"
56
+ raise Statemap::TransitionUndefinedException, msg
57
+ end
58
+
59
+ end
60
+
61
+ class IctMap_Default < IctState
62
+
63
+ end
64
+
65
+ class IctMap_Initial < IctMap_Default
66
+
67
+ def invite(fsm)
68
+ ctxt = fsm.getOwner
69
+ fsm.getState.Exit(fsm)
70
+ fsm.clearState
71
+ begin
72
+ ctxt.__send_invite()
73
+ ctxt.__start_A()
74
+ ctxt.__start_B()
75
+ ensure
76
+ fsm.setState(IctMap::Calling)
77
+ fsm.getState.Entry(fsm)
78
+ end
79
+ end
80
+
81
+ def transport_err(fsm)
82
+ ctxt = fsm.getOwner
83
+ fsm.getState.Exit(fsm)
84
+ fsm.clearState
85
+ begin
86
+ ctxt.__transport_err()
87
+ ensure
88
+ fsm.setState(IctMap::Terminated)
89
+ fsm.getState.Entry(fsm)
90
+ end
91
+ end
92
+
93
+ end
94
+
95
+ class IctMap_Calling < IctMap_Default
96
+
97
+ def Exit(fsm)
98
+ ctxt = fsm.getOwner
99
+ ctxt.__cancel_A()
100
+ ctxt.__cancel_B()
101
+ end
102
+
103
+ def cancel_sent(fsm)
104
+ ctxt = fsm.getOwner
105
+ endState = fsm.getState
106
+ fsm.clearState
107
+ begin
108
+ ctxt.__start_Y()
109
+ ensure
110
+ fsm.setState(endState)
111
+ end
112
+ end
113
+
114
+ def non_success_final(fsm)
115
+ ctxt = fsm.getOwner
116
+ fsm.getState.Exit(fsm)
117
+ fsm.clearState
118
+ begin
119
+ ctxt.__create_ack()
120
+ ctxt.__send_ack()
121
+ ctxt.__cancel_Y()
122
+ ctxt.__consume_msg(true)
123
+ ensure
124
+ fsm.setState(IctMap::Completed)
125
+ fsm.getState.Entry(fsm)
126
+ end
127
+ end
128
+
129
+ def provisional(fsm)
130
+ ctxt = fsm.getOwner
131
+ fsm.getState.Exit(fsm)
132
+ fsm.clearState
133
+ begin
134
+ ctxt.__consume_msg(true)
135
+ ensure
136
+ fsm.setState(IctMap::Proceeding)
137
+ fsm.getState.Entry(fsm)
138
+ end
139
+ end
140
+
141
+ def success_final(fsm)
142
+ ctxt = fsm.getOwner
143
+ fsm.getState.Exit(fsm)
144
+ fsm.clearState
145
+ begin
146
+ ctxt.__cancel_Y()
147
+ ctxt.__consume_msg(true)
148
+ ensure
149
+ fsm.setState(IctMap::Terminated)
150
+ fsm.getState.Entry(fsm)
151
+ end
152
+ end
153
+
154
+ def timer_A(fsm, t)
155
+ ctxt = fsm.getOwner
156
+ endState = fsm.getState
157
+ fsm.clearState
158
+ begin
159
+ ctxt.__send_invite()
160
+ ctxt.__reset_A(t)
161
+ ensure
162
+ fsm.setState(endState)
163
+ end
164
+ end
165
+
166
+ def timer_B(fsm)
167
+ ctxt = fsm.getOwner
168
+ fsm.getState.Exit(fsm)
169
+ fsm.clearState
170
+ begin
171
+ ctxt.__timeout()
172
+ ensure
173
+ fsm.setState(IctMap::Terminated)
174
+ fsm.getState.Entry(fsm)
175
+ end
176
+ end
177
+
178
+ def timer_Y(fsm)
179
+ ctxt = fsm.getOwner
180
+ fsm.getState.Exit(fsm)
181
+ fsm.clearState
182
+ begin
183
+ ctxt.__timeout()
184
+ ensure
185
+ fsm.setState(IctMap::Terminated)
186
+ fsm.getState.Entry(fsm)
187
+ end
188
+ end
189
+
190
+ def transport_err(fsm)
191
+ ctxt = fsm.getOwner
192
+ fsm.getState.Exit(fsm)
193
+ fsm.clearState
194
+ begin
195
+ ctxt.__transport_err()
196
+ ensure
197
+ fsm.setState(IctMap::Terminated)
198
+ fsm.getState.Entry(fsm)
199
+ end
200
+ end
201
+
202
+ end
203
+
204
+ class IctMap_Proceeding < IctMap_Default
205
+
206
+ def Exit(fsm)
207
+ ctxt = fsm.getOwner
208
+ ctxt.__cancel_Y()
209
+ end
210
+
211
+ def cancel_sent(fsm)
212
+ ctxt = fsm.getOwner
213
+ endState = fsm.getState
214
+ fsm.clearState
215
+ begin
216
+ ctxt.__start_Y()
217
+ ensure
218
+ fsm.setState(endState)
219
+ end
220
+ end
221
+
222
+ def non_success_final(fsm)
223
+ ctxt = fsm.getOwner
224
+ fsm.getState.Exit(fsm)
225
+ fsm.clearState
226
+ begin
227
+ ctxt.__create_ack()
228
+ ctxt.__send_ack()
229
+ ctxt.__consume_msg(true)
230
+ ensure
231
+ fsm.setState(IctMap::Completed)
232
+ fsm.getState.Entry(fsm)
233
+ end
234
+ end
235
+
236
+ def provisional(fsm)
237
+ ctxt = fsm.getOwner
238
+ endState = fsm.getState
239
+ fsm.clearState
240
+ begin
241
+ ctxt.__consume_msg(true)
242
+ ensure
243
+ fsm.setState(endState)
244
+ end
245
+ end
246
+
247
+ def success_final(fsm)
248
+ ctxt = fsm.getOwner
249
+ fsm.getState.Exit(fsm)
250
+ fsm.clearState
251
+ begin
252
+ ctxt.__consume_msg(true)
253
+ ensure
254
+ fsm.setState(IctMap::Terminated)
255
+ fsm.getState.Entry(fsm)
256
+ end
257
+ end
258
+
259
+ def timer_Y(fsm)
260
+ ctxt = fsm.getOwner
261
+ fsm.getState.Exit(fsm)
262
+ fsm.clearState
263
+ begin
264
+ ctxt.__timeout()
265
+ ensure
266
+ fsm.setState(IctMap::Terminated)
267
+ fsm.getState.Entry(fsm)
268
+ end
269
+ end
270
+
271
+ def transport_err(fsm)
272
+ ctxt = fsm.getOwner
273
+ fsm.getState.Exit(fsm)
274
+ fsm.clearState
275
+ begin
276
+ ctxt.__transport_err()
277
+ ensure
278
+ fsm.setState(IctMap::Terminated)
279
+ fsm.getState.Entry(fsm)
280
+ end
281
+ end
282
+
283
+ end
284
+
285
+ class IctMap_Completed < IctMap_Default
286
+
287
+ def Entry(fsm)
288
+ ctxt = fsm.getOwner
289
+ ctxt.__start_D()
290
+ end
291
+
292
+ def cancel_sent(fsm)
293
+ end
294
+
295
+ def non_success_final(fsm)
296
+ ctxt = fsm.getOwner
297
+ endState = fsm.getState
298
+ fsm.clearState
299
+ begin
300
+ ctxt.__send_ack()
301
+ ctxt.__consume_msg(false)
302
+ ensure
303
+ fsm.setState(endState)
304
+ end
305
+ end
306
+
307
+ def timer_D(fsm)
308
+ fsm.getState.Exit(fsm)
309
+ fsm.setState(IctMap::Terminated)
310
+ fsm.getState.Entry(fsm)
311
+ end
312
+
313
+ def transport_err(fsm)
314
+ ctxt = fsm.getOwner
315
+ fsm.getState.Exit(fsm)
316
+ fsm.clearState
317
+ begin
318
+ ctxt.__transport_err()
319
+ ensure
320
+ fsm.setState(IctMap::Terminated)
321
+ fsm.getState.Entry(fsm)
322
+ end
323
+ end
324
+
325
+ end
326
+
327
+ class IctMap_Terminated < IctMap_Default
328
+
329
+ def Entry(fsm)
330
+ ctxt = fsm.getOwner
331
+ ctxt.__cleanup()
332
+ end
333
+
334
+ def cancel_sent(fsm)
335
+ end
336
+
337
+ end
338
+
339
+ module IctMap
340
+
341
+ Initial = IctMap_Initial::new('IctMap.Initial', 0).freeze
342
+ Calling = IctMap_Calling::new('IctMap.Calling', 1).freeze
343
+ Proceeding = IctMap_Proceeding::new('IctMap.Proceeding', 2).freeze
344
+ Completed = IctMap_Completed::new('IctMap.Completed', 3).freeze
345
+ Terminated = IctMap_Terminated::new('IctMap.Terminated', 4).freeze
346
+ Default = IctMap_Default::new('IctMap.Default', -1).freeze
347
+
348
+ end
349
+
350
+ class Ict_sm < Statemap::FSMContext
351
+
352
+ def initialize(owner)
353
+ super()
354
+ @_owner = owner
355
+ setState(IctMap::Initial)
356
+ IctMap::Initial.Entry(self)
357
+ end
358
+
359
+ def cancel_sent()
360
+ @_transition = 'cancel_sent'
361
+ getState.cancel_sent(self)
362
+ @_transition = nil
363
+ end
364
+
365
+ def invite()
366
+ @_transition = 'invite'
367
+ getState.invite(self)
368
+ @_transition = nil
369
+ end
370
+
371
+ def non_success_final()
372
+ @_transition = 'non_success_final'
373
+ getState.non_success_final(self)
374
+ @_transition = nil
375
+ end
376
+
377
+ def provisional()
378
+ @_transition = 'provisional'
379
+ getState.provisional(self)
380
+ @_transition = nil
381
+ end
382
+
383
+ def success_final()
384
+ @_transition = 'success_final'
385
+ getState.success_final(self)
386
+ @_transition = nil
387
+ end
388
+
389
+ def timer_A(*arglist)
390
+ @_transition = 'timer_A'
391
+ getState.timer_A(self, *arglist)
392
+ @_transition = nil
393
+ end
394
+
395
+ def timer_B()
396
+ @_transition = 'timer_B'
397
+ getState.timer_B(self)
398
+ @_transition = nil
399
+ end
400
+
401
+ def timer_D()
402
+ @_transition = 'timer_D'
403
+ getState.timer_D(self)
404
+ @_transition = nil
405
+ end
406
+
407
+ def timer_Y()
408
+ @_transition = 'timer_Y'
409
+ getState.timer_Y(self)
410
+ @_transition = nil
411
+ end
412
+
413
+ def transport_err()
414
+ @_transition = 'transport_err'
415
+ getState.transport_err(self)
416
+ @_transition = nil
417
+ end
418
+
419
+ def getState()
420
+ if @_state.nil? then
421
+ raise Statemap::StateUndefinedException
422
+ end
423
+ return @_state
424
+ end
425
+
426
+ def getOwner()
427
+ return @_owner
428
+ end
429
+
430
+ end