cutedriver-driver 2.0.0.20210120164037

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +16 -0
  3. data/bin/start_app_perf +200 -0
  4. data/bin/tdriver-devtools +3 -0
  5. data/config/sut_parameters.rb +52 -0
  6. data/config/sut_setup.rb +32 -0
  7. data/config/sut_teardown.rb +32 -0
  8. data/config/tdriver_custom_error_recovery.rb +83 -0
  9. data/ext/extconf.rb +70 -0
  10. data/ext/native_extensions.c +315 -0
  11. data/lib/matti.rb +25 -0
  12. data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +120 -0
  13. data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
  14. data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
  15. data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
  16. data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
  17. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
  18. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
  19. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
  20. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
  21. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
  22. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
  23. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
  24. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
  25. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
  26. data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
  27. data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
  28. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1945 -0
  29. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
  30. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
  31. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
  32. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
  33. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
  34. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
  35. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
  36. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
  37. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
  38. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
  39. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
  40. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
  41. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
  42. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
  43. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
  44. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
  45. data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
  46. data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
  47. data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
  48. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
  49. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
  50. data/lib/tdriver-devtools/doc/generate.rb +917 -0
  51. data/lib/tdriver-devtools/doc/update +1 -0
  52. data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
  53. data/lib/tdriver-devtools/doc/xslt/template.xsl +2170 -0
  54. data/lib/tdriver-devtools/doc/xslt/update +3 -0
  55. data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
  56. data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
  57. data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
  58. data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
  59. data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
  60. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
  61. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
  62. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
  63. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
  64. data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
  65. data/lib/tdriver.rb +23 -0
  66. data/lib/tdriver/base/behaviour/abstract.rb +29 -0
  67. data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
  68. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +99 -0
  69. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +278 -0
  70. data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +119 -0
  71. data/lib/tdriver/base/behaviour/factory.rb +495 -0
  72. data/lib/tdriver/base/behaviour/loader.rb +46 -0
  73. data/lib/tdriver/base/command_data/command_data.rb +51 -0
  74. data/lib/tdriver/base/command_data/loader.rb +29 -0
  75. data/lib/tdriver/base/controller/abstraction.rb +56 -0
  76. data/lib/tdriver/base/controller/loader.rb +21 -0
  77. data/lib/tdriver/base/errors.rb +134 -0
  78. data/lib/tdriver/base/loader.rb +47 -0
  79. data/lib/tdriver/base/state_object.rb +373 -0
  80. data/lib/tdriver/base/sut/adapter.rb +54 -0
  81. data/lib/tdriver/base/sut/controller.rb +151 -0
  82. data/lib/tdriver/base/sut/factory.rb +339 -0
  83. data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
  84. data/lib/tdriver/base/sut/generic/behaviours/application.rb +427 -0
  85. data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
  86. data/lib/tdriver/base/sut/generic/behaviours/find.rb +107 -0
  87. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +337 -0
  88. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1888 -0
  89. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +210 -0
  90. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +222 -0
  91. data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
  92. data/lib/tdriver/base/sut/generic/commands/application.rb +274 -0
  93. data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
  94. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +94 -0
  95. data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +64 -0
  96. data/lib/tdriver/base/sut/generic/plugin.rb +97 -0
  97. data/lib/tdriver/base/sut/loader.rb +35 -0
  98. data/lib/tdriver/base/sut/sut.rb +98 -0
  99. data/lib/tdriver/base/test_object/abstract.rb +208 -0
  100. data/lib/tdriver/base/test_object/adapter.rb +740 -0
  101. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +144 -0
  102. data/lib/tdriver/base/test_object/behaviours/test_object.rb +1047 -0
  103. data/lib/tdriver/base/test_object/cache.rb +134 -0
  104. data/lib/tdriver/base/test_object/factory.rb +684 -0
  105. data/lib/tdriver/base/test_object/loader.rb +51 -0
  106. data/lib/tdriver/base/test_object/verification.rb +178 -0
  107. data/lib/tdriver/base/test_object/xml/abstraction.rb +63 -0
  108. data/lib/tdriver/base/test_object/xml/adapter.rb +773 -0
  109. data/lib/tdriver/env.rb +21 -0
  110. data/lib/tdriver/loader.rb +57 -0
  111. data/lib/tdriver/matti.rb +35 -0
  112. data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
  113. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +168 -0
  114. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +106 -0
  115. data/lib/tdriver/report/report.rb +61 -0
  116. data/lib/tdriver/report/report_api.rb +348 -0
  117. data/lib/tdriver/report/report_combine.rb +86 -0
  118. data/lib/tdriver/report/report_crash_file_capture.rb +178 -0
  119. data/lib/tdriver/report/report_creator.rb +665 -0
  120. data/lib/tdriver/report/report_cucumber.rb +158 -0
  121. data/lib/tdriver/report/report_cucumber_listener.rb +184 -0
  122. data/lib/tdriver/report/report_cucumber_reporter.rb +181 -0
  123. data/lib/tdriver/report/report_data_presentation.rb +156 -0
  124. data/lib/tdriver/report/report_data_table.rb +64 -0
  125. data/lib/tdriver/report/report_execution_statistics.rb +400 -0
  126. data/lib/tdriver/report/report_file_capture.rb +159 -0
  127. data/lib/tdriver/report/report_graph_generator.rb +59 -0
  128. data/lib/tdriver/report/report_grouping.rb +541 -0
  129. data/lib/tdriver/report/report_javascript.rb +199 -0
  130. data/lib/tdriver/report/report_junit_xml.rb +147 -0
  131. data/lib/tdriver/report/report_rspec.rb +108 -0
  132. data/lib/tdriver/report/report_test_case_run.rb +725 -0
  133. data/lib/tdriver/report/report_test_run.rb +1476 -0
  134. data/lib/tdriver/report/report_test_unit.rb +223 -0
  135. data/lib/tdriver/report/report_writer.rb +1621 -0
  136. data/lib/tdriver/tdriver.rb +209 -0
  137. data/lib/tdriver/util/agent/loader.rb +22 -0
  138. data/lib/tdriver/util/agent/service.rb +107 -0
  139. data/lib/tdriver/util/common/array.rb +39 -0
  140. data/lib/tdriver/util/common/boolean.rb +48 -0
  141. data/lib/tdriver/util/common/crc16.rb +149 -0
  142. data/lib/tdriver/util/common/environment.rb +154 -0
  143. data/lib/tdriver/util/common/error.rb +40 -0
  144. data/lib/tdriver/util/common/exception.rb +53 -0
  145. data/lib/tdriver/util/common/exceptions.rb +12 -0
  146. data/lib/tdriver/util/common/file.rb +328 -0
  147. data/lib/tdriver/util/common/gem.rb +109 -0
  148. data/lib/tdriver/util/common/hash.rb +288 -0
  149. data/lib/tdriver/util/common/kernel.rb +253 -0
  150. data/lib/tdriver/util/common/loader.rb +47 -0
  151. data/lib/tdriver/util/common/numeric.rb +159 -0
  152. data/lib/tdriver/util/common/object.rb +159 -0
  153. data/lib/tdriver/util/common/retryable.rb +179 -0
  154. data/lib/tdriver/util/common/stackable.rb +185 -0
  155. data/lib/tdriver/util/common/string.rb +174 -0
  156. data/lib/tdriver/util/database/access.rb +240 -0
  157. data/lib/tdriver/util/database/connection.rb +44 -0
  158. data/lib/tdriver/util/database/error.rb +34 -0
  159. data/lib/tdriver/util/database/loader.rb +28 -0
  160. data/lib/tdriver/util/filters/attribute_filter.rb +121 -0
  161. data/lib/tdriver/util/filters/loader.rb +29 -0
  162. data/lib/tdriver/util/fixture/loader.rb +22 -0
  163. data/lib/tdriver/util/fixture/service.rb +211 -0
  164. data/lib/tdriver/util/hooking/hooking.rb +477 -0
  165. data/lib/tdriver/util/keymap/keymap.rb +81 -0
  166. data/lib/tdriver/util/loader.rb +80 -0
  167. data/lib/tdriver/util/localisation/error.rb +31 -0
  168. data/lib/tdriver/util/localisation/loader.rb +25 -0
  169. data/lib/tdriver/util/localisation/localisation.rb +762 -0
  170. data/lib/tdriver/util/logger/loader.rb +22 -0
  171. data/lib/tdriver/util/logger/logger.rb +591 -0
  172. data/lib/tdriver/util/operator_data/error.rb +29 -0
  173. data/lib/tdriver/util/operator_data/loader.rb +27 -0
  174. data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
  175. data/lib/tdriver/util/other/config.rb +221 -0
  176. data/lib/tdriver/util/parameter/error.rb +48 -0
  177. data/lib/tdriver/util/parameter/loader.rb +25 -0
  178. data/lib/tdriver/util/parameter/parameter.rb +1161 -0
  179. data/lib/tdriver/util/plugin/abstract.rb +61 -0
  180. data/lib/tdriver/util/plugin/error.rb +0 -0
  181. data/lib/tdriver/util/plugin/loader.rb +28 -0
  182. data/lib/tdriver/util/plugin/service.rb +319 -0
  183. data/lib/tdriver/util/recorder/loader.rb +25 -0
  184. data/lib/tdriver/util/recorder/recorder.rb +72 -0
  185. data/lib/tdriver/util/recorder/scripter.rb +294 -0
  186. data/lib/tdriver/util/statistics/statistics.rb +89 -0
  187. data/lib/tdriver/util/user_data/error.rb +28 -0
  188. data/lib/tdriver/util/user_data/loader.rb +25 -0
  189. data/lib/tdriver/util/user_data/user_data.rb +104 -0
  190. data/lib/tdriver/util/video/camera.rb +67 -0
  191. data/lib/tdriver/util/video/camera_linux.rb +153 -0
  192. data/lib/tdriver/util/video/camera_windows.rb +174 -0
  193. data/lib/tdriver/util/video/loader.rb +31 -0
  194. data/lib/tdriver/util/video/video_utils.rb +139 -0
  195. data/lib/tdriver/util/xml/abstraction.rb +117 -0
  196. data/lib/tdriver/util/xml/attribute.rb +32 -0
  197. data/lib/tdriver/util/xml/builder.rb +53 -0
  198. data/lib/tdriver/util/xml/comment.rb +32 -0
  199. data/lib/tdriver/util/xml/document.rb +32 -0
  200. data/lib/tdriver/util/xml/element.rb +32 -0
  201. data/lib/tdriver/util/xml/error.rb +46 -0
  202. data/lib/tdriver/util/xml/loader.rb +62 -0
  203. data/lib/tdriver/util/xml/nil_node.rb +95 -0
  204. data/lib/tdriver/util/xml/nodeset.rb +32 -0
  205. data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
  206. data/lib/tdriver/util/xml/parsers/loader.rb +21 -0
  207. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +167 -0
  208. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +66 -0
  209. data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +64 -0
  210. data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
  211. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +66 -0
  212. data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +39 -0
  213. data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +58 -0
  214. data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +212 -0
  215. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +237 -0
  216. data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +39 -0
  217. data/lib/tdriver/util/xml/text.rb +32 -0
  218. data/lib/tdriver/util/xml/xml.rb +332 -0
  219. data/lib/tdriver/verify/verify.rb +2398 -0
  220. data/lib/tdriver/version.rb +21 -0
  221. data/xml/behaviours/generic.xml +530 -0
  222. data/xml/defaults/generic.xml +11 -0
  223. data/xml/defaults/sut_generic.xml +8 -0
  224. data/xml/parameters/tdriver_parameters.xml +23 -0
  225. data/xml/templates/generic.xml +292 -0
  226. metadata +324 -0
@@ -0,0 +1,39 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ module MobyUtil
21
+
22
+ module XML
23
+
24
+ module Nokogiri
25
+
26
+ module Text # behaviour
27
+
28
+ include Node
29
+
30
+ # enable hooking for performance measurement & debug logging
31
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
32
+
33
+ end # Element
34
+
35
+ end # Nokogiri
36
+
37
+ end # XML
38
+
39
+ end # MobyUtil
@@ -0,0 +1,32 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ module MobyUtil
21
+
22
+ module XML
23
+
24
+ class Text
25
+
26
+ include Abstraction
27
+
28
+ end # Text
29
+
30
+ end # XML
31
+
32
+ end # MobyUtil
@@ -0,0 +1,332 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ module MobyUtil
21
+
22
+ module XML
23
+
24
+ class << self
25
+
26
+ private
27
+
28
+ def initialize_class
29
+
30
+ @parser = nil
31
+
32
+ # empty xml cache hash
33
+ @document_cache = { :cache => [], :objects => {} }
34
+
35
+ # default xml cache buffer size
36
+ @document_cache_buffer_size = 10
37
+
38
+ # configure parser module to be used
39
+ __send__(:current_parser=, MobyUtil::XML::Nokogiri)
40
+
41
+ end
42
+
43
+ end
44
+
45
+ # Get current XML parser
46
+ # == params
47
+ # == return
48
+ # Module::
49
+ # == raises
50
+ def self.current_parser
51
+
52
+ @parser
53
+
54
+ end
55
+
56
+ # Set XML document cache buffering size, set 0 to disable
57
+ # == params
58
+ # == return
59
+ # Integer::
60
+ # == raises
61
+ # TypeError::
62
+ def self.buffer_size=( value )
63
+
64
+ value.check_type Integer, 'wrong argument type $1 for XML cache buffer size (expected $2)'
65
+
66
+ @document_cache_buffer_size = value
67
+
68
+ end
69
+
70
+ # Get current XML document cache buffering size
71
+ # == params
72
+ # == return
73
+ # Integer::
74
+ # == raises
75
+ def self.buffer_size
76
+
77
+ @document_cache_buffer_size
78
+
79
+ end
80
+
81
+ # Set XML parser to be used
82
+ # == params
83
+ # Module::
84
+ # == return
85
+ # nil
86
+ # Document:: XML document object
87
+ # == raises
88
+ def self.current_parser=( parser )
89
+
90
+ # set current parser
91
+ @parser = parser
92
+
93
+ # apply parser implementation to abstraction modules
94
+ [
95
+ :Document,
96
+ :Element,
97
+ :Nodeset,
98
+ :Attribute,
99
+ :Text,
100
+ :Builder,
101
+ :Comment
102
+
103
+ ].each do | _module |
104
+
105
+ const_get( _module ).module_exec{
106
+
107
+ begin
108
+
109
+ # include parser behaviour
110
+ include parser.const_get( _module )
111
+
112
+ rescue NameError
113
+
114
+ # raise proper exception if behaviour module not found
115
+ raise NotImplementedError, "Required behaviour module #{ parser.name }::#{ _module } not found"
116
+
117
+ end
118
+
119
+ }
120
+
121
+ end
122
+
123
+ # return current parser as result
124
+ parser
125
+
126
+ end
127
+
128
+ # Create XML Document object by parsing XML from string
129
+ #
130
+ # Usage: MobyUtil::XML.parse_string('<root>value</root>')
131
+ # ==> Returns XML document object; default xml parser will be used.
132
+ #
133
+ # == params
134
+ # xml_string:: String containing XML
135
+ # crc:: Optional CRC16 checksum - used for cache/buffering if given
136
+ # == return
137
+ # Document:: XML document object
138
+ # Array:: Array containing XML document object and status was it already found from cache
139
+ # == raises
140
+ def self.parse_string( xml_string, crc = nil )
141
+
142
+ begin
143
+
144
+ =begin
145
+ unless crc.nil?
146
+
147
+ [ Document.new( xml_string ), false ]
148
+
149
+ else
150
+
151
+ Document.new( xml_string )
152
+
153
+ end
154
+ =end
155
+
156
+ # JKo: disable xml caching for now, need more investigation why tests starts to fail
157
+ #=begin
158
+ unless crc.nil?
159
+
160
+ if @document_cache[ :cache ].include?( crc )
161
+
162
+ # return cached object and status that object was found from cache
163
+ [ @document_cache[ :objects ][ crc ], true ]
164
+
165
+ else
166
+
167
+ cache_enabled = ( @document_cache_buffer_size > 0 )
168
+
169
+ # create new document object with given xml string
170
+ document = Document.new( xml_string, { :cache_enabled => cache_enabled } )
171
+
172
+ # verify that xml caching is enabled
173
+ if cache_enabled
174
+
175
+ # drop olders cached xml object
176
+ if @document_cache[ :cache ].count == @document_cache_buffer_size
177
+
178
+ # remove data object from cache
179
+ @document_cache[ :objects ].delete(
180
+
181
+ # take (oldest) first from cache buffer
182
+ @document_cache[ :cache ].shift
183
+
184
+ )
185
+
186
+ end
187
+
188
+ # add new xml data object to cache
189
+ @document_cache[ :cache ] << crc
190
+
191
+ # add new xml data object to cache
192
+ @document_cache[ :objects ][ crc ] = document
193
+
194
+ end
195
+
196
+ # return document object and status that object was not found from cache
197
+ [ document, false ]
198
+
199
+ end
200
+
201
+ else
202
+
203
+ # create new document object with given xml string - no caching used
204
+ Document.new( xml_string )
205
+
206
+ end
207
+ #=end
208
+ rescue
209
+
210
+ if $TDRIVER_INITIALIZED == true
211
+
212
+ # string for exception message
213
+ dump_location = ""
214
+
215
+ # check if xml parse error logging is enabled
216
+ if $parameters[ :logging_xml_parse_error_dump, 'true' ].to_s.to_boolean
217
+
218
+ # construct filename for xml dump
219
+ filename = 'xml_error_dump'
220
+
221
+ # add timestamp to filename if not overwriting the existing dump file
222
+ unless $parameters[ :logging_xml_parse_error_dump_overwrite, 'false' ].to_s.to_boolean
223
+
224
+ filename << "_#{ Time.now.to_i }"
225
+
226
+ end
227
+
228
+ # add file extension
229
+ filename << '.xml'
230
+
231
+ # ... join filename with xml dump output path
232
+ path = File.join( MobyUtil::FileHelper.expand_path( $parameters[ :logging_xml_parse_error_dump_path ] ), filename )
233
+
234
+ begin
235
+
236
+ # write xml string to file
237
+ File.open( path, "w" ){ | file | file << xml_string }
238
+
239
+ dump_location = "Saved to #{ path }"
240
+
241
+ rescue
242
+
243
+ dump_location = "Error while saving to file #{ path }"
244
+
245
+ end
246
+
247
+ end
248
+
249
+ # raise exception
250
+ raise MobyUtil::XML::ParseError, "#{ $!.message.gsub("\n", '') } (#{ $!.class }). #{ dump_location }"
251
+
252
+ else
253
+
254
+ # raise exception
255
+ raise MobyUtil::XML::ParseError, "#{ $!.message.gsub("\n", '') } (#{ $!.class })"
256
+
257
+ end
258
+
259
+ end
260
+
261
+ end
262
+
263
+ # Create XML Document object by parsing XML from file
264
+ #
265
+ # Usage: MobyUtil::XML.parse_file('xml_dump.xml')
266
+ # ==> Returns XML document object; default xml parser will be used.
267
+ #
268
+ # == params
269
+ # filename:: String containing path and filename of XML file.
270
+ # == return
271
+ # Document:: XML document object
272
+ # == raises
273
+ # IOError:: File <name> not found
274
+ def self.parse_file( filename )
275
+
276
+ # raise exception if file not found
277
+ raise IOError, "File #{ filename.inspect } not found" unless File.exist?( filename )
278
+
279
+ # parse file content
280
+ parse_string(
281
+
282
+ IO.read( filename )
283
+
284
+ )
285
+
286
+ end
287
+
288
+ # Create XML builder object dynamically
289
+ #
290
+ # Usage:
291
+ #
292
+ # MobyUtil::XML.build{
293
+ # root{
294
+ # element(:name => "element_name", :id => "0") {
295
+ # child(:name => "1st_child_of_element_0", :value => "123" )
296
+ # child(:name => "2nd_child_of_element_0", :value => "456" )
297
+ # }
298
+ # }
299
+ # }.to_xml
300
+ #
301
+ # == params
302
+ # &block::
303
+ # == return
304
+ # MobyUtil::XML::Builder
305
+ # == raises
306
+ def self.build( &block )
307
+
308
+ begin
309
+
310
+ Builder.new.tap{ | builder |
311
+
312
+ builder.build( &block )
313
+
314
+ }
315
+
316
+ rescue
317
+
318
+ raise MobyUtil::XML::BuilderError, "#{ $!.message } (#{ $!.class })"
319
+
320
+ end
321
+
322
+ end
323
+
324
+ # enable hooking for performance measurement & debug logging
325
+ TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
326
+
327
+ # initialize class
328
+ initialize_class
329
+
330
+ end # XML
331
+
332
+ end # MobyUtil
@@ -0,0 +1,2398 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ module TDriverVerify
21
+
22
+ TIMEOUT_CYCLE_SECONDS = 0.1 if !defined?( TIMEOUT_CYCLE_SECONDS )
23
+
24
+ @@on_error_verify_block = nil
25
+
26
+ def on_error_verify_block( &block )
27
+
28
+ raise ArgumentError.new( "No verify block given" ) unless block_given?
29
+
30
+ @@on_error_verify_block = block
31
+
32
+ end
33
+
34
+ def reset_on_error_verify_block
35
+
36
+ @@on_error_verify_block = nil
37
+
38
+ end
39
+
40
+ def execute_on_error_verify_block
41
+
42
+ unless @@on_error_verify_block.nil?
43
+
44
+ begin
45
+
46
+ @@on_error_verify_block.call
47
+
48
+ rescue Exception
49
+
50
+ raise $!.class, "Exception was raised while executing on_error_verify_block. Reason: #{ $!.message.to_s }"
51
+
52
+ end
53
+
54
+ else
55
+
56
+ raise ArgumentError, 'No verify block defined with on_error_verify_block method'
57
+
58
+ end
59
+
60
+ end
61
+
62
+ # Verifies that the block given to this method evaluates without throwing any exceptions. Verification is synchronized with all connected suts.
63
+ # If this method is called for a sut, synchronization is only done with that sut.
64
+ #
65
+ # === params
66
+ # timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
67
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
68
+ # === returns
69
+ # nil
70
+ # === raises
71
+ # ArgumentError:: message was not a String or timeout an integer, or no block was given.
72
+ # VerificationError:: The verification failed.
73
+ def verify( timeout = nil, message = nil, &block )
74
+
75
+ begin
76
+
77
+ # determine name of caller method
78
+ verify_caller = caller( 1 ).first.to_s
79
+
80
+ # store orignal logging state
81
+ logging_enabled = $logger.enabled
82
+
83
+ # disable behaviour logging
84
+ $logger.enabled = false
85
+
86
+ # ensure that timeout is either nil or type of integer
87
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
88
+
89
+ # ensure that message is either nil or type of string
90
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
91
+
92
+ # verify that block was given
93
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
94
+
95
+ # convert timeout to integer, nil will be zero
96
+ timeout = get_timeout( timeout )
97
+
98
+ # verify that timeout is valid
99
+ timeout.not_negative 'timeout value cannot be negative'
100
+
101
+ # calculate the time when timeout exceeds
102
+ timeout_end_time = Time.now + timeout
103
+
104
+ # convert message to string, nil will be empty string
105
+ message = message.to_s
106
+
107
+ # add double quotation and trailing whitespace if not empty string
108
+ message = "#{ message.inspect } " if message.length > 0
109
+
110
+ # store original timeout value
111
+ original_timeout_value = TDriver::TestObjectFactory.timeout
112
+
113
+ # set the testobject timeout to 0 for the duration of the verify call
114
+ TDriver::TestObjectFactory.timeout = 0
115
+
116
+ loop do
117
+
118
+ begin
119
+
120
+ counter = ref_counter
121
+
122
+ # execute code block
123
+ yield
124
+
125
+ # break loop if no exceptions thrown
126
+ break
127
+
128
+ rescue
129
+
130
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
131
+
132
+ # refresh and retry unless timeout exceeded
133
+ raise $! if Time.now > timeout_end_time
134
+
135
+ # retry interval
136
+ sleep TIMEOUT_CYCLE_SECONDS
137
+
138
+ # refresh suts
139
+ refresh_suts if counter == ref_counter
140
+
141
+ end # begin
142
+
143
+ end # do loop
144
+
145
+ rescue
146
+
147
+ # restore logger state
148
+ $logger.enabled = logging_enabled
149
+
150
+ # execute on verification error code block
151
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
152
+
153
+ # process the exception
154
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
155
+
156
+ raise
157
+
158
+ else
159
+
160
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
161
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
162
+
163
+ end
164
+
165
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify;"
166
+
167
+ # raise the exception
168
+ raise MobyBase::VerificationError, error_message
169
+
170
+ ensure
171
+
172
+ # restore original test object factory timeout value
173
+ TDriver::TestObjectFactory.timeout = original_timeout_value
174
+
175
+ # restore logger state
176
+ $logger.enabled = logging_enabled
177
+
178
+ end
179
+
180
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify;"
181
+
182
+ nil
183
+
184
+ end
185
+
186
+ def minitest_verify( timeout = nil, message = nil, &block )
187
+ require 'minitest/assertions'
188
+ begin
189
+
190
+ # determine name of caller method
191
+ verify_caller = caller( 1 ).first.to_s
192
+
193
+ # store orignal logging state
194
+ logging_enabled = $logger.enabled
195
+
196
+ # disable behaviour logging
197
+ $logger.enabled = false
198
+
199
+ # ensure that timeout is either nil or type of integer
200
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
201
+
202
+ # ensure that message is either nil or type of string
203
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
204
+
205
+ # verify that block was given
206
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
207
+
208
+ # convert timeout to integer, nil will be zero
209
+ timeout = get_timeout( timeout )
210
+
211
+ # verify that timeout is valid
212
+ timeout.not_negative 'timeout value cannot be negative'
213
+
214
+ # calculate the time when timeout exceeds
215
+ timeout_end_time = Time.now + timeout
216
+
217
+ # convert message to string, nil will be empty string
218
+ message = message.to_s
219
+
220
+ # add double quotation and trailing whitespace if not empty string
221
+ message = "#{ message.inspect } " if message.length > 0
222
+
223
+ # store original timeout value
224
+ original_timeout_value = TDriver::TestObjectFactory.timeout
225
+
226
+ # set the testobject timeout to 0 for the duration of the verify call
227
+ TDriver::TestObjectFactory.timeout = 0
228
+
229
+ loop do
230
+
231
+ begin
232
+
233
+ counter = ref_counter
234
+
235
+ # execute code block
236
+ yield
237
+
238
+ # break loop if no exceptions thrown
239
+ break
240
+
241
+ rescue
242
+
243
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
244
+
245
+ # refresh and retry unless timeout exceeded
246
+ raise $! if Time.now > timeout_end_time
247
+
248
+ # retry interval
249
+ sleep TIMEOUT_CYCLE_SECONDS
250
+
251
+ # refresh suts
252
+ refresh_suts if counter == ref_counter
253
+
254
+ end # begin
255
+
256
+ end # do loop
257
+
258
+ rescue
259
+
260
+ # restore logger state
261
+ $logger.enabled = logging_enabled
262
+
263
+ # execute on verification error code block
264
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
265
+
266
+ # process the exception
267
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
268
+
269
+ raise
270
+
271
+ else
272
+
273
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
274
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
275
+
276
+ end
277
+
278
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify;"
279
+
280
+ # raise the exception
281
+ raise Minitest::Assertion, error_message
282
+
283
+ ensure
284
+
285
+ # restore original test object factory timeout value
286
+ TDriver::TestObjectFactory.timeout = original_timeout_value
287
+
288
+ # restore logger state
289
+ $logger.enabled = logging_enabled
290
+
291
+ end
292
+
293
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify;"
294
+
295
+ nil
296
+
297
+ end
298
+
299
+ # Verifies that the block given to this method throws an exception while being evaluated. Verification is synchronized with all connected suts.
300
+ # If this method is called for a sut, synchronization is only done with that sut.
301
+ #
302
+ # === params
303
+ # timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
304
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
305
+ # === returns
306
+ # nil
307
+ # === raises
308
+ # ArgumentError:: message was not a String or timeout an integer, or no block was given.
309
+ # VerificationError:: The verification failed.
310
+ def verify_not( timeout = nil, message = nil, &block )
311
+
312
+ begin
313
+
314
+ # determine name of caller method
315
+ verify_caller = caller( 1 ).first.to_s
316
+
317
+ # store orignal logging state
318
+ logging_enabled = $logger.enabled
319
+
320
+ # disable behaviour logging
321
+ $logger.enabled = false
322
+
323
+ # ensure that timeout is either nil or type of integer
324
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
325
+
326
+ # ensure that message is either nil or type of string
327
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
328
+
329
+ # verify that block was given
330
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
331
+
332
+ # convert timeout to integer, nil will be zero
333
+ timeout = get_timeout( timeout )
334
+
335
+ # verify that timeout is valid
336
+ timeout.not_negative 'timeout value cannot be negative'
337
+
338
+ # calculate the time when timeout exceeds
339
+ timeout_end_time = Time.now + timeout
340
+
341
+ # convert message to string, nil will be empty string
342
+ message = message.to_s
343
+
344
+ # add double quotation and trailing whitespace if not empty string
345
+ message = "#{ message.inspect } " if message.length > 0
346
+
347
+ # store original timeout value
348
+ original_timeout_value = TDriver::TestObjectFactory.timeout
349
+
350
+ # set the testobject timeout to 0 for the duration of the verify call
351
+ TDriver::TestObjectFactory.timeout = 0
352
+
353
+ # result container
354
+ result = nil
355
+
356
+ loop do
357
+
358
+ counter = ref_counter
359
+
360
+ begin
361
+
362
+ # execute code block
363
+ result = yield
364
+
365
+ rescue
366
+
367
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
368
+
369
+ # break loop if exceptions thrown
370
+ break
371
+
372
+ end
373
+
374
+ # refresh and retry unless timeout exceeded
375
+ raise $! if Time.now > timeout_end_time
376
+
377
+ # retry interval
378
+ sleep TIMEOUT_CYCLE_SECONDS
379
+
380
+ # refresh suts
381
+ refresh_suts if counter == ref_counter
382
+
383
+ end # do loop
384
+
385
+ rescue
386
+
387
+ # restore logger state
388
+ $logger.enabled = logging_enabled
389
+
390
+ # execute on verification error code block
391
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
392
+
393
+ # process the exception
394
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
395
+
396
+ raise
397
+
398
+ elsif $!.kind_of?( MobyBase::VerificationError )
399
+
400
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
401
+ error_message << "The block did not raise exception. It returned: #{ result.inspect }"
402
+
403
+ else
404
+
405
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
406
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
407
+
408
+ end
409
+
410
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_not;"
411
+
412
+ # raise the exception
413
+ raise MobyBase::VerificationError, error_message
414
+
415
+ ensure
416
+
417
+ # restore original test object factory timeout value
418
+ TDriver::TestObjectFactory.timeout = original_timeout_value
419
+
420
+ # restore logger state
421
+ $logger.enabled = logging_enabled
422
+
423
+ end
424
+
425
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_not;"
426
+
427
+ nil
428
+
429
+ end
430
+
431
+ def minitest_verify_not( timeout = nil, message = nil, &block )
432
+ require 'minitest/assertions'
433
+ begin
434
+
435
+ # determine name of caller method
436
+ verify_caller = caller( 1 ).first.to_s
437
+
438
+ # store orignal logging state
439
+ logging_enabled = $logger.enabled
440
+
441
+ # disable behaviour logging
442
+ $logger.enabled = false
443
+
444
+ # ensure that timeout is either nil or type of integer
445
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
446
+
447
+ # ensure that message is either nil or type of string
448
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
449
+
450
+ # verify that block was given
451
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
452
+
453
+ # convert timeout to integer, nil will be zero
454
+ timeout = get_timeout( timeout )
455
+
456
+ # verify that timeout is valid
457
+ timeout.not_negative 'timeout value cannot be negative'
458
+
459
+ # calculate the time when timeout exceeds
460
+ timeout_end_time = Time.now + timeout
461
+
462
+ # convert message to string, nil will be empty string
463
+ message = message.to_s
464
+
465
+ # add double quotation and trailing whitespace if not empty string
466
+ message = "#{ message.inspect } " if message.length > 0
467
+
468
+ # store original timeout value
469
+ original_timeout_value = TDriver::TestObjectFactory.timeout
470
+
471
+ # set the testobject timeout to 0 for the duration of the verify call
472
+ TDriver::TestObjectFactory.timeout = 0
473
+
474
+ # result container
475
+ result = nil
476
+
477
+ loop do
478
+
479
+ counter = ref_counter
480
+
481
+ begin
482
+
483
+ # execute code block
484
+ result = yield
485
+
486
+ rescue
487
+
488
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
489
+
490
+ # break loop if exceptions thrown
491
+ break
492
+
493
+ end
494
+
495
+ # refresh and retry unless timeout exceeded
496
+ raise $! if Time.now > timeout_end_time
497
+
498
+ # retry interval
499
+ sleep TIMEOUT_CYCLE_SECONDS
500
+
501
+ # refresh suts
502
+ refresh_suts if counter == ref_counter
503
+
504
+ end # do loop
505
+
506
+ rescue
507
+
508
+ # restore logger state
509
+ $logger.enabled = logging_enabled
510
+
511
+ # execute on verification error code block
512
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
513
+
514
+ # process the exception
515
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
516
+
517
+ raise
518
+
519
+ elsif $!.kind_of?( MobyBase::VerificationError )
520
+
521
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
522
+ error_message << "The block did not raise exception. It returned: #{ result.inspect }"
523
+
524
+ else
525
+
526
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
527
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
528
+
529
+ end
530
+
531
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_not;"
532
+
533
+ # raise the exception
534
+ raise Minitest::Assertion, error_message
535
+
536
+ ensure
537
+
538
+ # restore original test object factory timeout value
539
+ TDriver::TestObjectFactory.timeout = original_timeout_value
540
+
541
+ # restore logger state
542
+ $logger.enabled = logging_enabled
543
+
544
+ end
545
+
546
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_not;"
547
+
548
+ nil
549
+
550
+ end
551
+
552
+
553
+
554
+
555
+ # Verifies that the block given to this method evaluates to true. Verification is synchronized with all connected suts.
556
+ # If this method is called for a sut, synchronization is only done with that sut.
557
+ #
558
+ # === params
559
+ # timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
560
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
561
+ # === returns
562
+ # nil
563
+ # === raises
564
+ # ArgumentError:: message was not a String or timeout an integer, or no block was given.
565
+ # VerificationError:: The verification failed.
566
+ # RuntimeError:: An unexpected error was encountered during verification.
567
+ def verify_true( timeout = nil, message = nil, &block )
568
+
569
+ begin
570
+
571
+ # expected result
572
+ expected_value = true
573
+
574
+ # determine name of caller method
575
+ verify_caller = caller( 1 ).first.to_s
576
+
577
+ # store orignal logging state
578
+ logging_enabled = $logger.enabled
579
+
580
+ # disable behaviour logging
581
+ $logger.enabled = false
582
+
583
+ # ensure that timeout is either nil or type of integer
584
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
585
+
586
+ # ensure that message is either nil or type of string
587
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
588
+
589
+ # verify that block was given
590
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
591
+
592
+ # convert timeout to integer, nil will be zero
593
+ timeout = get_timeout( timeout )
594
+
595
+ # verify that timeout is valid
596
+ timeout.not_negative 'timeout value cannot be negative'
597
+
598
+ # calculate the time when timeout exceeds
599
+ timeout_end_time = Time.now + timeout
600
+
601
+ # convert message to string, nil will be empty string
602
+ message = message.to_s
603
+
604
+ # add double quotation and trailing whitespace if not empty string
605
+ message = "#{ message.inspect } " if message.length > 0
606
+
607
+ # store original timeout value
608
+ original_timeout_value = TDriver::TestObjectFactory.timeout
609
+
610
+ # set the testobject timeout to 0 for the duration of the verify call
611
+ TDriver::TestObjectFactory.timeout = 0
612
+
613
+ # result container
614
+ result = nil
615
+
616
+ loop do
617
+
618
+ begin
619
+
620
+ counter = ref_counter
621
+
622
+ # execute code block
623
+ result = yield
624
+
625
+ # raise exception if result of yield does not equal with expected value
626
+ raise MobyBase::VerificationError unless result == expected_value
627
+
628
+ # break loop if no exceptions thrown
629
+ break
630
+
631
+ rescue
632
+
633
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
634
+
635
+ # refresh and retry unless timeout exceeded
636
+ raise $! if Time.now > timeout_end_time
637
+
638
+ # retry interval
639
+ sleep TIMEOUT_CYCLE_SECONDS
640
+
641
+ # refresh suts
642
+ refresh_suts if counter == ref_counter
643
+
644
+ end # begin
645
+
646
+ end # do loop
647
+
648
+ rescue
649
+
650
+ # restore logger state
651
+ $logger.enabled = logging_enabled
652
+
653
+ # execute on verification error code block
654
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
655
+
656
+ # process the exception
657
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
658
+
659
+ raise
660
+
661
+ elsif $!.kind_of?( MobyBase::VerificationError )
662
+
663
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
664
+ error_message << "The block did not return #{ expected_value }. It returned: #{ result.inspect }"
665
+
666
+ else
667
+
668
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
669
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
670
+
671
+ end
672
+
673
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_true;"
674
+
675
+ # raise the exception
676
+ raise MobyBase::VerificationError, error_message
677
+
678
+ ensure
679
+
680
+ # restore original test object factory timeout value
681
+ TDriver::TestObjectFactory.timeout = original_timeout_value
682
+
683
+ # restore logger state
684
+ $logger.enabled = logging_enabled
685
+
686
+ end
687
+
688
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_true;"
689
+
690
+ nil
691
+
692
+ end
693
+
694
+
695
+ def minitest_verify_true( timeout = nil, message = nil, &block )
696
+ require 'minitest/assertions'
697
+
698
+ begin
699
+
700
+ # expected result
701
+ expected_value = true
702
+
703
+ # determine name of caller method
704
+ verify_caller = caller( 1 ).first.to_s
705
+
706
+ # store orignal logging state
707
+ logging_enabled = $logger.enabled
708
+
709
+ # disable behaviour logging
710
+ $logger.enabled = false
711
+
712
+ # ensure that timeout is either nil or type of integer
713
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
714
+
715
+ # ensure that message is either nil or type of string
716
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
717
+
718
+ # verify that block was given
719
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
720
+
721
+ # convert timeout to integer, nil will be zero
722
+ timeout = get_timeout( timeout )
723
+
724
+ # verify that timeout is valid
725
+ timeout.not_negative 'timeout value cannot be negative'
726
+
727
+ # calculate the time when timeout exceeds
728
+ timeout_end_time = Time.now + timeout
729
+
730
+ # convert message to string, nil will be empty string
731
+ message = message.to_s
732
+
733
+ # add double quotation and trailing whitespace if not empty string
734
+ message = "#{ message.inspect } " if message.length > 0
735
+
736
+ # store original timeout value
737
+ original_timeout_value = TDriver::TestObjectFactory.timeout
738
+
739
+ # set the testobject timeout to 0 for the duration of the verify call
740
+ TDriver::TestObjectFactory.timeout = 0
741
+
742
+ # result container
743
+ result = nil
744
+
745
+ loop do
746
+
747
+ begin
748
+
749
+ counter = ref_counter
750
+
751
+ # execute code block
752
+ result = yield
753
+
754
+ # raise exception if result of yield does not equal with expected value
755
+ raise MobyBase::VerificationError unless result == expected_value
756
+
757
+ # break loop if no exceptions thrown
758
+ break
759
+
760
+ rescue
761
+
762
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
763
+
764
+ # refresh and retry unless timeout exceeded
765
+ raise $! if Time.now > timeout_end_time
766
+
767
+ # retry interval
768
+ sleep TIMEOUT_CYCLE_SECONDS
769
+
770
+ # refresh suts
771
+ refresh_suts if counter == ref_counter
772
+
773
+ end # begin
774
+
775
+ end # do loop
776
+
777
+ rescue
778
+
779
+ # restore logger state
780
+ $logger.enabled = logging_enabled
781
+
782
+ # execute on verification error code block
783
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
784
+
785
+ # process the exception
786
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
787
+
788
+ raise
789
+
790
+ elsif $!.kind_of?( MobyBase::VerificationError )
791
+
792
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
793
+ error_message << "The block did not return #{ expected_value }. It returned: #{ result.inspect }"
794
+
795
+ else
796
+
797
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
798
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
799
+
800
+ end
801
+
802
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_true;"
803
+
804
+ # raise the exception
805
+ raise Minitest::Assertion, error_message
806
+
807
+ ensure
808
+
809
+ # restore original test object factory timeout value
810
+ TDriver::TestObjectFactory.timeout = original_timeout_value
811
+
812
+ # restore logger state
813
+ $logger.enabled = logging_enabled
814
+
815
+ end
816
+
817
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_true;"
818
+
819
+ nil
820
+
821
+ end
822
+
823
+
824
+
825
+
826
+
827
+
828
+
829
+ # Verifies that the block given to this method evaluates to false. Verification is synchronized with all connected suts.
830
+ # If this method is called for a sut, synchronization is only done with that sut.
831
+ #
832
+ # === params
833
+ # timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
834
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
835
+ # === returns
836
+ # nil
837
+ # === raises
838
+ # ArgumentError:: message was not a String or timeout an integer, or no block was given.
839
+ # VerificationError:: The verification failed.
840
+ # RuntimeError:: An unexpected error was encountered during verification.
841
+ def verify_false( timeout = nil, message = nil, &block )
842
+
843
+ begin
844
+
845
+ # expected result
846
+ expected_value = false
847
+
848
+ # determine name of caller method
849
+ verify_caller = caller( 1 ).first.to_s
850
+
851
+ # store orignal logging state
852
+ logging_enabled = $logger.enabled
853
+
854
+ # disable behaviour logging
855
+ $logger.enabled = false
856
+
857
+ # ensure that timeout is either nil or type of integer
858
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
859
+
860
+ # ensure that message is either nil or type of string
861
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
862
+
863
+ # verify that block was given
864
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
865
+
866
+ # convert timeout to integer, nil will be zero
867
+ timeout = get_timeout( timeout )
868
+
869
+ # verify that timeout is valid
870
+ timeout.not_negative 'timeout value cannot be negative'
871
+
872
+ # calculate the time when timeout exceeds
873
+ timeout_end_time = Time.now + timeout
874
+
875
+ # convert message to string, nil will be empty string
876
+ message = message.to_s
877
+
878
+ # add double quotation and trailing whitespace if not empty string
879
+ message = "#{ message.inspect } " if message.length > 0
880
+
881
+ # store original timeout value
882
+ original_timeout_value = TDriver::TestObjectFactory.timeout
883
+
884
+ # set the testobject timeout to 0 for the duration of the verify call
885
+ TDriver::TestObjectFactory.timeout = 0
886
+
887
+ # result container
888
+ result = nil
889
+
890
+ loop do
891
+
892
+ begin
893
+
894
+ counter = ref_counter
895
+
896
+ # execute code block
897
+ result = yield
898
+
899
+ # raise exception if result of yield does not equal with expected value
900
+ raise MobyBase::VerificationError unless result == expected_value
901
+
902
+ # break loop if no exceptions thrown
903
+ break
904
+
905
+ rescue
906
+
907
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
908
+
909
+ # refresh and retry unless timeout exceeded
910
+ raise $! if Time.now > timeout_end_time
911
+
912
+ # retry interval
913
+ sleep TIMEOUT_CYCLE_SECONDS
914
+
915
+ # refresh suts
916
+ refresh_suts if counter == ref_counter
917
+
918
+ end # begin
919
+
920
+ end # do loop
921
+
922
+ rescue
923
+
924
+ # restore logger state
925
+ $logger.enabled = logging_enabled
926
+
927
+ # execute on verification error code block
928
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
929
+
930
+ # process the exception
931
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
932
+
933
+ raise
934
+
935
+ elsif $!.kind_of?( MobyBase::VerificationError )
936
+
937
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
938
+ error_message << "The block did not return #{ expected_value }. It returned: #{ result.inspect }"
939
+
940
+ else
941
+
942
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
943
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
944
+
945
+ end
946
+
947
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_false;"
948
+
949
+ # raise the exception
950
+ raise MobyBase::VerificationError, error_message
951
+
952
+ ensure
953
+
954
+ # restore original test object factory timeout value
955
+ TDriver::TestObjectFactory.timeout = original_timeout_value
956
+
957
+ # restore logger state
958
+ $logger.enabled = logging_enabled
959
+
960
+ end
961
+
962
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_false;"
963
+
964
+ nil
965
+
966
+ end
967
+
968
+ def minitest_verify_false( timeout = nil, message = nil, &block )
969
+ require 'minitest/assertions'
970
+
971
+ begin
972
+
973
+ # expected result
974
+ expected_value = false
975
+
976
+ # determine name of caller method
977
+ verify_caller = caller( 1 ).first.to_s
978
+
979
+ # store orignal logging state
980
+ logging_enabled = $logger.enabled
981
+
982
+ # disable behaviour logging
983
+ $logger.enabled = false
984
+
985
+ # ensure that timeout is either nil or type of integer
986
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
987
+
988
+ # ensure that message is either nil or type of string
989
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
990
+
991
+ # verify that block was given
992
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
993
+
994
+ # convert timeout to integer, nil will be zero
995
+ timeout = get_timeout( timeout )
996
+
997
+ # verify that timeout is valid
998
+ timeout.not_negative 'timeout value cannot be negative'
999
+
1000
+ # calculate the time when timeout exceeds
1001
+ timeout_end_time = Time.now + timeout
1002
+
1003
+ # convert message to string, nil will be empty string
1004
+ message = message.to_s
1005
+
1006
+ # add double quotation and trailing whitespace if not empty string
1007
+ message = "#{ message.inspect } " if message.length > 0
1008
+
1009
+ # store original timeout value
1010
+ original_timeout_value = TDriver::TestObjectFactory.timeout
1011
+
1012
+ # set the testobject timeout to 0 for the duration of the verify call
1013
+ TDriver::TestObjectFactory.timeout = 0
1014
+
1015
+ # result container
1016
+ result = nil
1017
+
1018
+ loop do
1019
+
1020
+ begin
1021
+
1022
+ counter = ref_counter
1023
+
1024
+ # execute code block
1025
+ result = yield
1026
+
1027
+ # raise exception if result of yield does not equal with expected value
1028
+ raise MobyBase::VerificationError unless result == expected_value
1029
+
1030
+ # break loop if no exceptions thrown
1031
+ break
1032
+
1033
+ rescue
1034
+
1035
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
1036
+
1037
+ # refresh and retry unless timeout exceeded
1038
+ raise $! if Time.now > timeout_end_time
1039
+
1040
+ # retry interval
1041
+ sleep TIMEOUT_CYCLE_SECONDS
1042
+
1043
+ # refresh suts
1044
+ refresh_suts if counter == ref_counter
1045
+
1046
+ end # begin
1047
+
1048
+ end # do loop
1049
+
1050
+ rescue
1051
+
1052
+ # restore logger state
1053
+ $logger.enabled = logging_enabled
1054
+
1055
+ # execute on verification error code block
1056
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
1057
+
1058
+ # process the exception
1059
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
1060
+
1061
+ raise
1062
+
1063
+ elsif $!.kind_of?( MobyBase::VerificationError )
1064
+
1065
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
1066
+ error_message << "The block did not return #{ expected_value }. It returned: #{ result.inspect }"
1067
+
1068
+ else
1069
+
1070
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
1071
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
1072
+
1073
+ end
1074
+
1075
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_false;"
1076
+
1077
+ # raise the exception
1078
+ raise Minitest::Assertion, error_message
1079
+
1080
+ ensure
1081
+
1082
+ # restore original test object factory timeout value
1083
+ TDriver::TestObjectFactory.timeout = original_timeout_value
1084
+
1085
+ # restore logger state
1086
+ $logger.enabled = logging_enabled
1087
+
1088
+ end
1089
+
1090
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_false;"
1091
+
1092
+ nil
1093
+
1094
+ end
1095
+
1096
+
1097
+
1098
+
1099
+
1100
+ # Verifies that result of given block equals to expected value. Verification is synchronized with all connected suts.
1101
+ # If this method is called for a sut, synchronization is only done with that sut.
1102
+ #
1103
+ # === params
1104
+ # expected:: Expected result value of the block
1105
+ # timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
1106
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
1107
+ # === returns
1108
+ # nil
1109
+ # === raises
1110
+ # ArgumentError:: message was not a String or timeout an integer, or no block was given.
1111
+ # VerificationError:: The verification failed.
1112
+ # RuntimeError:: An unexpected error was encountered during verification.
1113
+ def verify_equal( expected_value, timeout = nil, message = nil, &block )
1114
+
1115
+ begin
1116
+
1117
+ # determine name of caller method
1118
+ verify_caller = caller( 1 ).first.to_s
1119
+
1120
+ # store orignal logging state
1121
+ logging_enabled = $logger.enabled
1122
+
1123
+ # disable behaviour logging
1124
+ $logger.enabled = false
1125
+
1126
+ # ensure that timeout is either nil or type of integer
1127
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
1128
+
1129
+ # ensure that message is either nil or type of string
1130
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
1131
+
1132
+ # verify that block was given
1133
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
1134
+
1135
+ # convert timeout to integer, nil will be zero
1136
+ timeout = get_timeout( timeout )
1137
+
1138
+ # verify that timeout is valid
1139
+ timeout.not_negative 'timeout value cannot be negative'
1140
+
1141
+ # calculate the time when timeout exceeds
1142
+ timeout_end_time = Time.now + timeout
1143
+
1144
+ # convert message to string, nil will be empty string
1145
+ message = message.to_s
1146
+
1147
+ # add double quotation and trailing whitespace if not empty string
1148
+ message = "#{ message.inspect } " if message.length > 0
1149
+
1150
+ # store original timeout value
1151
+ original_timeout_value = TDriver::TestObjectFactory.timeout
1152
+
1153
+ # set the testobject timeout to 0 for the duration of the verify call
1154
+ TDriver::TestObjectFactory.timeout = 0
1155
+
1156
+ # result container
1157
+ result = nil
1158
+
1159
+ loop do
1160
+
1161
+ begin
1162
+
1163
+ counter = ref_counter
1164
+
1165
+ # execute code block
1166
+ result = yield
1167
+
1168
+ # raise exception if result of yield does not equal with expected value
1169
+ raise MobyBase::VerificationError unless result == expected_value
1170
+
1171
+ # break loop if no exceptions thrown
1172
+ break
1173
+
1174
+ rescue
1175
+
1176
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
1177
+
1178
+ # refresh and retry unless timeout exceeded
1179
+ raise $! if Time.now > timeout_end_time
1180
+
1181
+ # retry interval
1182
+ sleep TIMEOUT_CYCLE_SECONDS
1183
+
1184
+ # refresh suts
1185
+ refresh_suts if counter == ref_counter
1186
+
1187
+ end # begin
1188
+
1189
+ end # do loop
1190
+
1191
+ rescue
1192
+
1193
+ # restore logger state
1194
+ $logger.enabled = logging_enabled
1195
+
1196
+ # execute on verification error code block
1197
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
1198
+
1199
+ # process the exception
1200
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
1201
+
1202
+ raise
1203
+
1204
+ elsif $!.kind_of?( MobyBase::VerificationError )
1205
+
1206
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
1207
+ error_message << "The value was not equal to #{ expected_value }. It returned: #{ result.inspect }"
1208
+
1209
+ else
1210
+
1211
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
1212
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
1213
+
1214
+ end
1215
+
1216
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_equal;"
1217
+
1218
+ # raise the exception
1219
+ raise MobyBase::VerificationError, error_message
1220
+
1221
+ ensure
1222
+
1223
+ # restore original test object factory timeout value
1224
+ TDriver::TestObjectFactory.timeout = original_timeout_value
1225
+
1226
+ # restore logger state
1227
+ $logger.enabled = logging_enabled
1228
+
1229
+ end
1230
+
1231
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_equal;"
1232
+
1233
+ nil
1234
+
1235
+ end
1236
+
1237
+
1238
+ def minitest_verify_equal( expected_value, timeout = nil, message = nil, &block )
1239
+ require 'minitest/assertions'
1240
+ begin
1241
+
1242
+ # determine name of caller method
1243
+ verify_caller = caller( 1 ).first.to_s
1244
+
1245
+ # store orignal logging state
1246
+ logging_enabled = $logger.enabled
1247
+
1248
+ # disable behaviour logging
1249
+ $logger.enabled = false
1250
+
1251
+ # ensure that timeout is either nil or type of integer
1252
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
1253
+
1254
+ # ensure that message is either nil or type of string
1255
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
1256
+
1257
+ # verify that block was given
1258
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
1259
+
1260
+ # convert timeout to integer, nil will be zero
1261
+ timeout = get_timeout( timeout )
1262
+
1263
+ # verify that timeout is valid
1264
+ timeout.not_negative 'timeout value cannot be negative'
1265
+
1266
+ # calculate the time when timeout exceeds
1267
+ timeout_end_time = Time.now + timeout
1268
+
1269
+ # convert message to string, nil will be empty string
1270
+ message = message.to_s
1271
+
1272
+ # add double quotation and trailing whitespace if not empty string
1273
+ message = "#{ message.inspect } " if message.length > 0
1274
+
1275
+ # store original timeout value
1276
+ original_timeout_value = TDriver::TestObjectFactory.timeout
1277
+
1278
+ # set the testobject timeout to 0 for the duration of the verify call
1279
+ TDriver::TestObjectFactory.timeout = 0
1280
+
1281
+ # result container
1282
+ result = nil
1283
+
1284
+ loop do
1285
+
1286
+ begin
1287
+
1288
+ counter = ref_counter
1289
+
1290
+ # execute code block
1291
+ result = yield
1292
+
1293
+ # raise exception if result of yield does not equal with expected value
1294
+ raise MobyBase::VerificationError unless result == expected_value
1295
+
1296
+ # break loop if no exceptions thrown
1297
+ break
1298
+
1299
+ rescue
1300
+
1301
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
1302
+
1303
+ # refresh and retry unless timeout exceeded
1304
+ raise $! if Time.now > timeout_end_time
1305
+
1306
+ # retry interval
1307
+ sleep TIMEOUT_CYCLE_SECONDS
1308
+
1309
+ # refresh suts
1310
+ refresh_suts if counter == ref_counter
1311
+
1312
+ end # begin
1313
+
1314
+ end # do loop
1315
+
1316
+ rescue
1317
+
1318
+ # restore logger state
1319
+ $logger.enabled = logging_enabled
1320
+
1321
+ # execute on verification error code block
1322
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
1323
+
1324
+ # process the exception
1325
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
1326
+
1327
+ raise
1328
+
1329
+ elsif $!.kind_of?( MobyBase::VerificationError )
1330
+
1331
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
1332
+ error_message << "The value was not equal to #{ expected_value }. It returned: #{ result.inspect }"
1333
+
1334
+ else
1335
+
1336
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
1337
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
1338
+
1339
+ end
1340
+
1341
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_equal;"
1342
+
1343
+ # raise the exception
1344
+ raise Minitest::Assertion, error_message
1345
+
1346
+ ensure
1347
+
1348
+ # restore original test object factory timeout value
1349
+ TDriver::TestObjectFactory.timeout = original_timeout_value
1350
+
1351
+ # restore logger state
1352
+ $logger.enabled = logging_enabled
1353
+
1354
+ end
1355
+
1356
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_equal;"
1357
+
1358
+ nil
1359
+
1360
+ end
1361
+
1362
+
1363
+ # Verifies that result of the given block is less than expected value. Verification is synchronized with all connected suts.
1364
+ # If this method is called for a sut, synchronization is only done with that sut.
1365
+ #
1366
+ # === params
1367
+ # expected:: Expected result value of the block
1368
+ # timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
1369
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
1370
+ # === returns
1371
+ # nil
1372
+ # === raises
1373
+ # ArgumentError:: message was not a String or timeout an integer, or no block was given.
1374
+ # VerificationError:: The verification failed.
1375
+ # RuntimeError:: An unexpected error was encountered during verification.
1376
+ def verify_less( expected_value, timeout = nil, message = nil, &block )
1377
+
1378
+ begin
1379
+
1380
+ # determine name of caller method
1381
+ verify_caller = caller( 1 ).first.to_s
1382
+
1383
+ # store orignal logging state
1384
+ logging_enabled = $logger.enabled
1385
+
1386
+ # disable behaviour logging
1387
+ $logger.enabled = false
1388
+
1389
+ # ensure that timeout is either nil or type of integer
1390
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
1391
+
1392
+ # ensure that message is either nil or type of string
1393
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
1394
+
1395
+ # verify that block was given
1396
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
1397
+
1398
+ # convert timeout to integer, nil will be zero
1399
+ timeout = get_timeout( timeout )
1400
+
1401
+ # verify that timeout is valid
1402
+ timeout.not_negative 'timeout value cannot be negative'
1403
+
1404
+ # calculate the time when timeout exceeds
1405
+ timeout_end_time = Time.now + timeout
1406
+
1407
+ # convert message to string, nil will be empty string
1408
+ message = message.to_s
1409
+
1410
+ # add double quotation and trailing whitespace if not empty string
1411
+ message = "#{ message.inspect } " if message.length > 0
1412
+
1413
+ # store original timeout value
1414
+ original_timeout_value = TDriver::TestObjectFactory.timeout
1415
+
1416
+ # set the testobject timeout to 0 for the duration of the verify call
1417
+ TDriver::TestObjectFactory.timeout = 0
1418
+
1419
+ # result container
1420
+ result = nil
1421
+
1422
+ loop do
1423
+
1424
+ begin
1425
+
1426
+ counter = ref_counter
1427
+
1428
+ # execute code block
1429
+ result = yield
1430
+
1431
+ # raise exception if result of yield is less than expected value
1432
+ raise MobyBase::VerificationError unless result < expected_value
1433
+
1434
+ # break loop if no exceptions thrown
1435
+ break
1436
+
1437
+ rescue
1438
+
1439
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
1440
+
1441
+ # refresh and retry unless timeout exceeded
1442
+ raise $! if Time.now > timeout_end_time
1443
+
1444
+ # retry interval
1445
+ sleep TIMEOUT_CYCLE_SECONDS
1446
+
1447
+ # refresh suts
1448
+ refresh_suts if counter == ref_counter
1449
+
1450
+ end # begin
1451
+
1452
+ end # do loop
1453
+
1454
+ rescue
1455
+
1456
+ # restore logger state
1457
+ $logger.enabled = logging_enabled
1458
+
1459
+ # execute on verification error code block
1460
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
1461
+
1462
+ # process the exception
1463
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
1464
+
1465
+ raise
1466
+
1467
+ elsif $!.kind_of?( MobyBase::VerificationError )
1468
+
1469
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
1470
+ error_message << "The value was not less than #{ expected_value }. It returned: #{ result.inspect }"
1471
+
1472
+ else
1473
+
1474
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
1475
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
1476
+
1477
+ end
1478
+
1479
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_less;"
1480
+
1481
+ # raise the exception
1482
+ raise MobyBase::VerificationError, error_message
1483
+
1484
+ ensure
1485
+
1486
+ # restore original test object factory timeout value
1487
+ TDriver::TestObjectFactory.timeout = original_timeout_value
1488
+
1489
+ # restore logger state
1490
+ $logger.enabled = logging_enabled
1491
+
1492
+ end
1493
+
1494
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_less;"
1495
+
1496
+ nil
1497
+
1498
+ end
1499
+
1500
+ def minitest_verify_less( expected_value, timeout = nil, message = nil, &block )
1501
+ require 'minitest/assertions'
1502
+ begin
1503
+
1504
+ # determine name of caller method
1505
+ verify_caller = caller( 1 ).first.to_s
1506
+
1507
+ # store orignal logging state
1508
+ logging_enabled = $logger.enabled
1509
+
1510
+ # disable behaviour logging
1511
+ $logger.enabled = false
1512
+
1513
+ # ensure that timeout is either nil or type of integer
1514
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
1515
+
1516
+ # ensure that message is either nil or type of string
1517
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
1518
+
1519
+ # verify that block was given
1520
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
1521
+
1522
+ # convert timeout to integer, nil will be zero
1523
+ timeout = get_timeout( timeout )
1524
+
1525
+ # verify that timeout is valid
1526
+ timeout.not_negative 'timeout value cannot be negative'
1527
+
1528
+ # calculate the time when timeout exceeds
1529
+ timeout_end_time = Time.now + timeout
1530
+
1531
+ # convert message to string, nil will be empty string
1532
+ message = message.to_s
1533
+
1534
+ # add double quotation and trailing whitespace if not empty string
1535
+ message = "#{ message.inspect } " if message.length > 0
1536
+
1537
+ # store original timeout value
1538
+ original_timeout_value = TDriver::TestObjectFactory.timeout
1539
+
1540
+ # set the testobject timeout to 0 for the duration of the verify call
1541
+ TDriver::TestObjectFactory.timeout = 0
1542
+
1543
+ # result container
1544
+ result = nil
1545
+
1546
+ loop do
1547
+
1548
+ begin
1549
+
1550
+ counter = ref_counter
1551
+
1552
+ # execute code block
1553
+ result = yield
1554
+
1555
+ # raise exception if result of yield is less than expected value
1556
+ raise MobyBase::VerificationError unless result < expected_value
1557
+
1558
+ # break loop if no exceptions thrown
1559
+ break
1560
+
1561
+ rescue
1562
+
1563
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
1564
+
1565
+ # refresh and retry unless timeout exceeded
1566
+ raise $! if Time.now > timeout_end_time
1567
+
1568
+ # retry interval
1569
+ sleep TIMEOUT_CYCLE_SECONDS
1570
+
1571
+ # refresh suts
1572
+ refresh_suts if counter == ref_counter
1573
+
1574
+ end # begin
1575
+
1576
+ end # do loop
1577
+
1578
+ rescue
1579
+
1580
+ # restore logger state
1581
+ $logger.enabled = logging_enabled
1582
+
1583
+ # execute on verification error code block
1584
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
1585
+
1586
+ # process the exception
1587
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
1588
+
1589
+ raise
1590
+
1591
+ elsif $!.kind_of?( MobyBase::VerificationError )
1592
+
1593
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
1594
+ error_message << "The value was not less than #{ expected_value }. It returned: #{ result.inspect }"
1595
+
1596
+ else
1597
+
1598
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
1599
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
1600
+
1601
+ end
1602
+
1603
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_less;"
1604
+
1605
+ # raise the exception
1606
+ raise Minitest::Assertion, error_message
1607
+
1608
+ ensure
1609
+
1610
+ # restore original test object factory timeout value
1611
+ TDriver::TestObjectFactory.timeout = original_timeout_value
1612
+
1613
+ # restore logger state
1614
+ $logger.enabled = logging_enabled
1615
+
1616
+ end
1617
+
1618
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_less;"
1619
+
1620
+ nil
1621
+
1622
+ end
1623
+
1624
+
1625
+
1626
+ # Verifies that result of the given block is greater than expected value. Verification is synchronized with all connected suts.
1627
+ # If this method is called for a sut, synchronization is only done with that sut.
1628
+ #
1629
+ # === params
1630
+ # expected:: Expected result value of the block
1631
+ # timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
1632
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
1633
+ # === returns
1634
+ # nil
1635
+ # === raises
1636
+ # ArgumentError:: message was not a String or timeout an integer, or no block was given.
1637
+ # VerificationError:: The verification failed.
1638
+ # RuntimeError:: An unexpected error was encountered during verification.
1639
+ def verify_greater( expected_value, timeout = nil, message = nil, &block )
1640
+
1641
+ begin
1642
+
1643
+ # determine name of caller method
1644
+ verify_caller = caller( 1 ).first.to_s
1645
+
1646
+ # store orignal logging state
1647
+ logging_enabled = $logger.enabled
1648
+
1649
+ # disable behaviour logging
1650
+ $logger.enabled = false
1651
+
1652
+ # ensure that timeout is either nil or type of integer
1653
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
1654
+
1655
+ # ensure that message is either nil or type of string
1656
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
1657
+
1658
+ # verify that block was given
1659
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
1660
+
1661
+ # convert timeout to integer, nil will be zero
1662
+ timeout = get_timeout( timeout )
1663
+
1664
+ # verify that timeout is valid
1665
+ timeout.not_negative 'timeout value cannot be negative'
1666
+
1667
+ # calculate the time when timeout exceeds
1668
+ timeout_end_time = Time.now + timeout
1669
+
1670
+ # convert message to string, nil will be empty string
1671
+ message = message.to_s
1672
+
1673
+ # add double quotation and trailing whitespace if not empty string
1674
+ message = "#{ message.inspect } " if message.length > 0
1675
+
1676
+ # store original timeout value
1677
+ original_timeout_value = TDriver::TestObjectFactory.timeout
1678
+
1679
+ # set the testobject timeout to 0 for the duration of the verify call
1680
+ TDriver::TestObjectFactory.timeout = 0
1681
+
1682
+ # result container
1683
+ result = nil
1684
+
1685
+ loop do
1686
+
1687
+ begin
1688
+
1689
+ counter = ref_counter
1690
+
1691
+ # execute code block
1692
+ result = yield
1693
+
1694
+ # raise exception if result of yield is greater than expected value
1695
+ raise MobyBase::VerificationError unless result > expected_value
1696
+
1697
+ # break loop if no exceptions thrown
1698
+ break
1699
+
1700
+ rescue
1701
+
1702
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
1703
+
1704
+ # refresh and retry unless timeout exceeded
1705
+ raise $! if Time.now > timeout_end_time
1706
+
1707
+ # retry interval
1708
+ sleep TIMEOUT_CYCLE_SECONDS
1709
+
1710
+ # refresh suts
1711
+ refresh_suts if counter == ref_counter
1712
+
1713
+ end # begin
1714
+
1715
+ end # do loop
1716
+
1717
+ rescue
1718
+
1719
+ # restore logger state
1720
+ $logger.enabled = logging_enabled
1721
+
1722
+ # execute on verification error code block
1723
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
1724
+
1725
+ # process the exception
1726
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
1727
+
1728
+ raise
1729
+
1730
+ elsif $!.kind_of?( MobyBase::VerificationError )
1731
+
1732
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
1733
+ error_message << "The value vas not greater than #{ expected_value }. It returned: #{ result.inspect }"
1734
+
1735
+ else
1736
+
1737
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
1738
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
1739
+
1740
+ end
1741
+
1742
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_greater;"
1743
+
1744
+ # raise the exception
1745
+ raise MobyBase::VerificationError, error_message
1746
+
1747
+ ensure
1748
+
1749
+ # restore original test object factory timeout value
1750
+ TDriver::TestObjectFactory.timeout = original_timeout_value
1751
+
1752
+ # restore logger state
1753
+ $logger.enabled = logging_enabled
1754
+
1755
+ end
1756
+
1757
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_greater;"
1758
+
1759
+ nil
1760
+
1761
+ end
1762
+
1763
+ def minitest_verify_greater( expected_value, timeout = nil, message = nil, &block )
1764
+ require 'minitest/assertions'
1765
+ begin
1766
+
1767
+ # determine name of caller method
1768
+ verify_caller = caller( 1 ).first.to_s
1769
+
1770
+ # store orignal logging state
1771
+ logging_enabled = $logger.enabled
1772
+
1773
+ # disable behaviour logging
1774
+ $logger.enabled = false
1775
+
1776
+ # ensure that timeout is either nil or type of integer
1777
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
1778
+
1779
+ # ensure that message is either nil or type of string
1780
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
1781
+
1782
+ # verify that block was given
1783
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
1784
+
1785
+ # convert timeout to integer, nil will be zero
1786
+ timeout = get_timeout( timeout )
1787
+
1788
+ # verify that timeout is valid
1789
+ timeout.not_negative 'timeout value cannot be negative'
1790
+
1791
+ # calculate the time when timeout exceeds
1792
+ timeout_end_time = Time.now + timeout
1793
+
1794
+ # convert message to string, nil will be empty string
1795
+ message = message.to_s
1796
+
1797
+ # add double quotation and trailing whitespace if not empty string
1798
+ message = "#{ message.inspect } " if message.length > 0
1799
+
1800
+ # store original timeout value
1801
+ original_timeout_value = TDriver::TestObjectFactory.timeout
1802
+
1803
+ # set the testobject timeout to 0 for the duration of the verify call
1804
+ TDriver::TestObjectFactory.timeout = 0
1805
+
1806
+ # result container
1807
+ result = nil
1808
+
1809
+ loop do
1810
+
1811
+ begin
1812
+
1813
+ counter = ref_counter
1814
+
1815
+ # execute code block
1816
+ result = yield
1817
+
1818
+ # raise exception if result of yield is greater than expected value
1819
+ raise MobyBase::VerificationError unless result > expected_value
1820
+
1821
+ # break loop if no exceptions thrown
1822
+ break
1823
+
1824
+ rescue
1825
+
1826
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
1827
+
1828
+ # refresh and retry unless timeout exceeded
1829
+ raise $! if Time.now > timeout_end_time
1830
+
1831
+ # retry interval
1832
+ sleep TIMEOUT_CYCLE_SECONDS
1833
+
1834
+ # refresh suts
1835
+ refresh_suts if counter == ref_counter
1836
+
1837
+ end # begin
1838
+
1839
+ end # do loop
1840
+
1841
+ rescue
1842
+
1843
+ # restore logger state
1844
+ $logger.enabled = logging_enabled
1845
+
1846
+ # execute on verification error code block
1847
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
1848
+
1849
+ # process the exception
1850
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
1851
+
1852
+ raise
1853
+
1854
+ elsif $!.kind_of?( MobyBase::VerificationError )
1855
+
1856
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
1857
+ error_message << "The value vas not greater than #{ expected_value }. It returned: #{ result.inspect }"
1858
+
1859
+ else
1860
+
1861
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
1862
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
1863
+
1864
+ end
1865
+
1866
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_greater;"
1867
+
1868
+ # raise the exception
1869
+ raise Minitest::Assertion, error_message
1870
+
1871
+ ensure
1872
+
1873
+ # restore original test object factory timeout value
1874
+ TDriver::TestObjectFactory.timeout = original_timeout_value
1875
+
1876
+ # restore logger state
1877
+ $logger.enabled = logging_enabled
1878
+
1879
+ end
1880
+
1881
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_greater;"
1882
+
1883
+ nil
1884
+
1885
+ end
1886
+
1887
+
1888
+ # Verifies that the block given to return value matches with expected regular expression pattern. Verification is synchronized with all connected suts.
1889
+ # If this method is called for a sut, synchronization is only done with that sut.
1890
+ #
1891
+ # === params
1892
+ # expected:: Regular expression
1893
+ # timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
1894
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
1895
+ # === returns
1896
+ # nil
1897
+ # === raises
1898
+ # ArgumentError:: message was not a String or timeout an integer, or no block was given.
1899
+ # TypeError:: if block result not type of String.
1900
+ # VerificationError:: The verification failed.
1901
+ # RuntimeError:: An unexpected error was encountered during verification.
1902
+ def verify_regexp( expected_value, timeout = nil, message = nil, &block )
1903
+
1904
+ begin
1905
+
1906
+ # store original timeout value
1907
+ original_timeout_value = TDriver::TestObjectFactory.timeout
1908
+
1909
+ # determine name of caller method
1910
+ verify_caller = caller( 1 ).first.to_s
1911
+
1912
+ # store orignal logging state
1913
+ logging_enabled = $logger.enabled
1914
+
1915
+ # disable behaviour logging
1916
+ $logger.enabled = false
1917
+
1918
+ # verify that arguments was given in correct format
1919
+ expected_value.check_type Regexp, "wrong argument type $1 for expected result (expected $2)"
1920
+
1921
+ # ensure that timeout is either nil or type of integer
1922
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
1923
+
1924
+ # ensure that message is either nil or type of string
1925
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
1926
+
1927
+ # verify that block was given
1928
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
1929
+
1930
+ # convert timeout to integer, nil will be zero
1931
+ timeout = get_timeout( timeout )
1932
+
1933
+ # verify that timeout is valid
1934
+ timeout.not_negative 'timeout value cannot be negative'
1935
+
1936
+ # calculate the time when timeout exceeds
1937
+ timeout_end_time = Time.now + timeout
1938
+
1939
+ # convert message to string, nil will be empty string
1940
+ message = message.to_s
1941
+
1942
+ # add double quotation and trailing whitespace if not empty string
1943
+ message = "#{ message.inspect } " if message.length > 0
1944
+
1945
+ # set the testobject timeout to 0 for the duration of the verify call
1946
+ TDriver::TestObjectFactory.timeout = 0
1947
+
1948
+ # result container
1949
+ result = nil
1950
+
1951
+ loop do
1952
+
1953
+ begin
1954
+
1955
+ counter = ref_counter
1956
+
1957
+ # execute code block
1958
+ result = yield
1959
+
1960
+ # raise exception if result of yield does not match with expected value regexp
1961
+ raise MobyBase::VerificationError unless result =~ expected_value
1962
+
1963
+ # break loop if no exceptions thrown
1964
+ break
1965
+
1966
+ rescue
1967
+
1968
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
1969
+
1970
+ # refresh and retry unless timeout exceeded
1971
+ raise $! if Time.now > timeout_end_time
1972
+
1973
+ # retry interval
1974
+ sleep TIMEOUT_CYCLE_SECONDS
1975
+
1976
+ # refresh suts
1977
+ refresh_suts if counter == ref_counter
1978
+
1979
+ end # begin
1980
+
1981
+ end # do loop
1982
+
1983
+ rescue
1984
+
1985
+ # restore logger state
1986
+ $logger.enabled = logging_enabled
1987
+
1988
+ # execute on verification error code block
1989
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
1990
+
1991
+ # process the exception
1992
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
1993
+
1994
+ raise
1995
+
1996
+ elsif $!.kind_of?( MobyBase::VerificationError )
1997
+
1998
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
1999
+ error_message << "The return value of block did not match with #{ expected_value.inspect } pattern. Block returned: #{ result.inspect }"
2000
+
2001
+ else
2002
+
2003
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
2004
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
2005
+
2006
+ end
2007
+
2008
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_regexp;"
2009
+
2010
+ # raise the exception
2011
+ raise MobyBase::VerificationError, error_message
2012
+
2013
+ ensure
2014
+
2015
+ # restore original test object factory timeout value
2016
+ TDriver::TestObjectFactory.timeout = original_timeout_value
2017
+
2018
+ # restore logger state
2019
+ $logger.enabled = logging_enabled
2020
+
2021
+ end
2022
+
2023
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_regexp;"
2024
+
2025
+ nil
2026
+
2027
+ end
2028
+
2029
+ def minitest_verify_regexp( expected_value, timeout = nil, message = nil, &block )
2030
+ require 'minitest/assertions'
2031
+ begin
2032
+
2033
+ # store original timeout value
2034
+ original_timeout_value = TDriver::TestObjectFactory.timeout
2035
+
2036
+ # determine name of caller method
2037
+ verify_caller = caller( 1 ).first.to_s
2038
+
2039
+ # store orignal logging state
2040
+ logging_enabled = $logger.enabled
2041
+
2042
+ # disable behaviour logging
2043
+ $logger.enabled = false
2044
+
2045
+ # verify that arguments was given in correct format
2046
+ expected_value.check_type Regexp, "wrong argument type $1 for expected result (expected $2)"
2047
+
2048
+ # ensure that timeout is either nil or type of integer
2049
+ timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
2050
+
2051
+ # ensure that message is either nil or type of string
2052
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
2053
+
2054
+ # verify that block was given
2055
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
2056
+
2057
+ # convert timeout to integer, nil will be zero
2058
+ timeout = get_timeout( timeout )
2059
+
2060
+ # verify that timeout is valid
2061
+ timeout.not_negative 'timeout value cannot be negative'
2062
+
2063
+ # calculate the time when timeout exceeds
2064
+ timeout_end_time = Time.now + timeout
2065
+
2066
+ # convert message to string, nil will be empty string
2067
+ message = message.to_s
2068
+
2069
+ # add double quotation and trailing whitespace if not empty string
2070
+ message = "#{ message.inspect } " if message.length > 0
2071
+
2072
+ # set the testobject timeout to 0 for the duration of the verify call
2073
+ TDriver::TestObjectFactory.timeout = 0
2074
+
2075
+ # result container
2076
+ result = nil
2077
+
2078
+ loop do
2079
+
2080
+ begin
2081
+
2082
+ counter = ref_counter
2083
+
2084
+ # execute code block
2085
+ result = yield
2086
+
2087
+ # raise exception if result of yield does not match with expected value regexp
2088
+ raise MobyBase::VerificationError unless result =~ expected_value
2089
+
2090
+ # break loop if no exceptions thrown
2091
+ break
2092
+
2093
+ rescue
2094
+
2095
+ raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
2096
+
2097
+ # refresh and retry unless timeout exceeded
2098
+ raise $! if Time.now > timeout_end_time
2099
+
2100
+ # retry interval
2101
+ sleep TIMEOUT_CYCLE_SECONDS
2102
+
2103
+ # refresh suts
2104
+ refresh_suts if counter == ref_counter
2105
+
2106
+ end # begin
2107
+
2108
+ end # do loop
2109
+
2110
+ rescue
2111
+
2112
+ # restore logger state
2113
+ $logger.enabled = logging_enabled
2114
+
2115
+ # execute on verification error code block
2116
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
2117
+
2118
+ # process the exception
2119
+ if $!.kind_of?( MobyBase::ContinuousVerificationError )
2120
+
2121
+ raise
2122
+
2123
+ elsif $!.kind_of?( MobyBase::VerificationError )
2124
+
2125
+ error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
2126
+ error_message << "The return value of block did not match with #{ expected_value.inspect } pattern. Block returned: #{ result.inspect }"
2127
+
2128
+ else
2129
+
2130
+ error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
2131
+ error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
2132
+
2133
+ end
2134
+
2135
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_regexp;"
2136
+
2137
+ # raise the exception
2138
+ raise Minitest::Assertion, error_message
2139
+
2140
+ ensure
2141
+
2142
+ # restore original test object factory timeout value
2143
+ TDriver::TestObjectFactory.timeout = original_timeout_value
2144
+
2145
+ # restore logger state
2146
+ $logger.enabled = logging_enabled
2147
+
2148
+ end
2149
+
2150
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_regexp;"
2151
+
2152
+ nil
2153
+
2154
+ end
2155
+
2156
+
2157
+ # Verifies that the given signal is emitted.
2158
+ #
2159
+ # === params
2160
+ # timeout:: Integer, defining the amount of seconds during which the verification must pass.
2161
+ # signal_name:: String, name of the signal
2162
+ # message:: (optional) A String that is displayed as additional information if the verification fails.
2163
+ # block:: code to execute while listening signals
2164
+ # === returns
2165
+ # nil
2166
+ # === raises
2167
+ # ArgumentError:: message or signal_name was not a String or timeout a non negative Integer
2168
+ # VerificationError:: The verification failed.
2169
+ def verify_signal( timeout, signal_name, message = nil, &block )
2170
+
2171
+ begin
2172
+
2173
+ logging_enabled = $logger.enabled
2174
+
2175
+ $logger.enabled = false
2176
+
2177
+ # ensure that timeout is either nil or type of integer
2178
+ timeout.check_type Integer, 'wrong argument type $1 for timeout (expected $2)'
2179
+
2180
+ # ensure that message is either nil or type of string
2181
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
2182
+
2183
+ # verify that block was given
2184
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
2185
+
2186
+ # verify that timeout is valid
2187
+ timeout.not_negative 'timeout value cannot be negative'
2188
+
2189
+ # convert message to string, nil will be empty string
2190
+ message = message.to_s
2191
+
2192
+ # add double quotation and trailing whitespace if not empty string
2193
+ message = "#{ message.inspect } " if message.length > 0
2194
+
2195
+ verify_caller = caller(1).first.to_s
2196
+
2197
+ # wait for the signal
2198
+ begin
2199
+
2200
+ wait_for_signal( timeout, signal_name, &block )
2201
+
2202
+ rescue
2203
+
2204
+ error_msg = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source(verify_caller) }"
2205
+ error_msg << "The signal #{ signal_name } was not emitted in #{ timeout } seconds.\nNested exception:\n#{ $!.inspect }"
2206
+
2207
+ raise MobyBase::VerificationError, error_msg
2208
+
2209
+ end
2210
+
2211
+ rescue
2212
+
2213
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
2214
+
2215
+ $logger.enabled = logging_enabled
2216
+
2217
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s } using timeout '#{ timeout }.;#{ kind_of?(MobyBase::SUT) ? id.to_s + ';sut' : ';' };{};verify_signal;#{ signal_name }"
2218
+
2219
+ raise
2220
+
2221
+ ensure
2222
+
2223
+ $logger.enabled = logging_enabled
2224
+
2225
+ end
2226
+
2227
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_signal;#{ signal_name }"
2228
+
2229
+ nil
2230
+
2231
+ end
2232
+
2233
+ def minitest_verify_signal( timeout, signal_name, message = nil, &block )
2234
+ require 'minitest/assertions'
2235
+ begin
2236
+
2237
+ logging_enabled = $logger.enabled
2238
+
2239
+ $logger.enabled = false
2240
+
2241
+ # ensure that timeout is either nil or type of integer
2242
+ timeout.check_type Integer, 'wrong argument type $1 for timeout (expected $2)'
2243
+
2244
+ # ensure that message is either nil or type of string
2245
+ message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
2246
+
2247
+ # verify that block was given
2248
+ raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
2249
+
2250
+ # verify that timeout is valid
2251
+ timeout.not_negative 'timeout value cannot be negative'
2252
+
2253
+ # convert message to string, nil will be empty string
2254
+ message = message.to_s
2255
+
2256
+ # add double quotation and trailing whitespace if not empty string
2257
+ message = "#{ message.inspect } " if message.length > 0
2258
+
2259
+ verify_caller = caller(1).first.to_s
2260
+
2261
+ # wait for the signal
2262
+ begin
2263
+
2264
+ wait_for_signal( timeout, signal_name, &block )
2265
+
2266
+ rescue
2267
+
2268
+ error_msg = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source(verify_caller) }"
2269
+ error_msg << "The signal #{ signal_name } was not emitted in #{ timeout } seconds.\nNested exception:\n#{ $!.inspect }"
2270
+
2271
+ raise Minitest::Assertion, error_msg
2272
+
2273
+ end
2274
+
2275
+ rescue
2276
+
2277
+ execute_on_error_verify_block unless @@on_error_verify_block.nil?
2278
+
2279
+ $logger.enabled = logging_enabled
2280
+
2281
+ $logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s } using timeout '#{ timeout }.;#{ kind_of?(MobyBase::SUT) ? id.to_s + ';sut' : ';' };{};verify_signal;#{ signal_name }"
2282
+
2283
+ raise
2284
+
2285
+ ensure
2286
+
2287
+ $logger.enabled = logging_enabled
2288
+
2289
+ end
2290
+
2291
+ $logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ kind_of?( MobyBase::SUT ) ? id.to_s + ';sut' : ';' };{};verify_signal;#{ signal_name }"
2292
+
2293
+ nil
2294
+
2295
+ end
2296
+
2297
+
2298
+
2299
+ private
2300
+
2301
+ # TODO: remove me?
2302
+ def get_end_time( timeout )
2303
+
2304
+ if kind_of?( MobyBase::SUT )
2305
+
2306
+ Time.now + ( timeout.nil? ? $parameters[ sut ][ :synchronization_timeout, '10' ].to_i : timeout.to_i )
2307
+
2308
+ else
2309
+
2310
+ Time.now + ( timeout.nil? ? $parameters[ :synchronization_timeout, '10' ].to_i : timeout.to_i )
2311
+
2312
+ end
2313
+
2314
+ end
2315
+
2316
+ def get_timeout( timeout )
2317
+
2318
+ if kind_of?( MobyBase::SUT )
2319
+
2320
+ timeout = $parameters[ sut ][ :synchronization_timeout, '10' ] if timeout.nil?
2321
+
2322
+ else
2323
+
2324
+ timeout = $parameters[ :synchronization_timeout, '10' ] if timeout.nil?
2325
+
2326
+ end
2327
+
2328
+ timeout.to_i
2329
+
2330
+ end
2331
+
2332
+ # Current count of combined sut refresh calls to all suts
2333
+ def ref_counter
2334
+ counter = 0
2335
+ if kind_of?( MobyBase::SUT )
2336
+ counter = dump_count
2337
+ else
2338
+ TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes|
2339
+ counter += sut_attributes[:sut].dump_count
2340
+ end
2341
+ end
2342
+ counter
2343
+ end
2344
+
2345
+ def verify_refresh(b_use_id=true)
2346
+ if kind_of?( MobyBase::SUT )
2347
+ begin
2348
+ appid = get_application_id
2349
+ rescue
2350
+ appid='-1'
2351
+ end
2352
+ if appid != "-1" && b_use_id
2353
+ refresh({:id => appid})
2354
+ else
2355
+ refresh
2356
+ end
2357
+ else
2358
+ #refresh all connected suts
2359
+ TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes|
2360
+ begin
2361
+ appid = sut_attributes[:sut].get_application_id
2362
+ rescue
2363
+ appid='-1'
2364
+ end
2365
+ if appid != "-1" && b_use_id
2366
+ sut_attributes[:sut].refresh({:id => appid}) if sut_attributes[:is_connected]
2367
+ else
2368
+ sut_attributes[:sut].refresh if sut_attributes[:is_connected]
2369
+ end
2370
+ end
2371
+ end
2372
+ end
2373
+
2374
+ # Refresh ui state inside verify
2375
+ def refresh_suts
2376
+ begin
2377
+ verify_refresh
2378
+ # Ignore all availability errors
2379
+ rescue RuntimeError, MobyBase::ApplicationNotAvailableError => e
2380
+ begin
2381
+ verify_refresh(false)
2382
+ rescue RuntimeError, MobyBase::ApplicationNotAvailableError => e
2383
+ # This occurs when no applications are registered to sut
2384
+ if !(e.message =~ /no longer available/)
2385
+ puts 'Raising exception'
2386
+ # all other errors are passed up
2387
+ raise e
2388
+ end
2389
+ end
2390
+ end
2391
+ end
2392
+
2393
+ end
2394
+
2395
+ module MattiVerify
2396
+ include TDriverVerify
2397
+
2398
+ end