testability-driver 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/config/sut_parameters.rb +21 -8
  2. data/config/tdriver_custom_error_recovery.rb +83 -0
  3. data/ext/extconf.rb +3 -2
  4. data/ext/native_extensions.c +60 -2
  5. data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +2 -105
  6. data/lib/tdriver/base/behaviour/factory.rb +154 -89
  7. data/lib/tdriver/base/behaviour/factory_new.rb +409 -0
  8. data/lib/tdriver/base/errors.rb +3 -3
  9. data/lib/tdriver/base/state_object.rb +85 -22
  10. data/lib/tdriver/base/sut/adapter.rb +26 -0
  11. data/lib/tdriver/base/sut/controller.rb +1 -1
  12. data/lib/tdriver/base/sut/generic/behaviours/application.rb +89 -118
  13. data/lib/tdriver/base/sut/generic/behaviours/find.rb +67 -62
  14. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +296 -187
  15. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +7 -7
  16. data/lib/tdriver/base/sut/generic/commands/application.rb +366 -295
  17. data/lib/tdriver/base/sut/sut.rb +19 -3
  18. data/lib/tdriver/base/test_object/abstract.rb +41 -21
  19. data/lib/tdriver/base/test_object/adapter.rb +62 -9
  20. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +10 -6
  21. data/lib/tdriver/base/test_object/behaviours/test_object.rb +84 -47
  22. data/lib/tdriver/base/test_object/factory.rb +124 -68
  23. data/lib/tdriver/base/test_object/loader.rb +3 -4
  24. data/lib/tdriver/base/test_object/verification.rb +3 -3
  25. data/lib/tdriver/base/test_object/xml/adapter.rb +734 -0
  26. data/lib/tdriver/loader.rb +12 -0
  27. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +3 -2
  28. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +14 -14
  29. data/lib/tdriver/report/report.rb +4 -8
  30. data/lib/tdriver/report/report_api.rb +9 -0
  31. data/lib/tdriver/report/report_crash_file_capture.rb +4 -4
  32. data/lib/tdriver/report/report_creator.rb +57 -35
  33. data/lib/tdriver/report/report_cucumber.rb +1 -1
  34. data/lib/tdriver/report/report_cucumber_listener.rb +5 -158
  35. data/lib/tdriver/report/report_cucumber_reporter.rb +7 -161
  36. data/lib/tdriver/report/report_execution_statistics.rb +4 -4
  37. data/lib/tdriver/report/report_file_capture.rb +5 -5
  38. data/lib/tdriver/report/report_grouping.rb +24 -22
  39. data/lib/tdriver/report/report_junit_xml.rb +5 -5
  40. data/lib/tdriver/report/report_test_case_run.rb +31 -22
  41. data/lib/tdriver/report/report_test_run.rb +107 -104
  42. data/lib/tdriver/report/report_writer.rb +150 -83
  43. data/lib/tdriver/tdriver.rb +147 -103
  44. data/lib/tdriver/util/common/boolean.rb +51 -0
  45. data/lib/tdriver/util/common/crc16.rb +110 -68
  46. data/lib/tdriver/util/common/hash.rb +63 -7
  47. data/lib/tdriver/util/common/kernel.rb +46 -1
  48. data/lib/tdriver/util/common/loader.rb +1 -0
  49. data/lib/tdriver/util/common/object.rb +20 -8
  50. data/lib/tdriver/util/common/string.rb +21 -2
  51. data/lib/tdriver/util/logger/logger.rb +4 -4
  52. data/lib/tdriver/util/parameter/loader.rb +2 -19
  53. data/lib/tdriver/util/parameter/parameter.rb +874 -177
  54. data/lib/tdriver/util/plugin/service.rb +1 -1
  55. data/lib/tdriver/util/recorder/recorder.rb +7 -1
  56. data/lib/tdriver/util/xml/abstraction.rb +13 -1
  57. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +63 -10
  58. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +8 -2
  59. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +16 -3
  60. data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +36 -32
  61. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +19 -22
  62. data/lib/tdriver/util/xml/xml.rb +147 -32
  63. data/lib/tdriver/verify/verify.rb +1112 -289
  64. data/lib/tdriver/version.rb +1 -1
  65. data/xml/templates/generic.xml +14 -2
  66. metadata +51 -24
  67. data/lib/tdriver/util/parameter/parameter_hash.rb +0 -104
  68. data/lib/tdriver/util/parameter/parameter_new.rb +0 -869
  69. data/lib/tdriver/util/parameter/parameter_template.rb +0 -120
  70. data/lib/tdriver/util/parameter/parameter_user_api.rb +0 -116
  71. data/lib/tdriver/util/parameter/parameter_xml.rb +0 -261
@@ -1,120 +0,0 @@
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
- class ParameterTemplates
23
-
24
- include Singleton
25
-
26
- def initialize
27
-
28
- @@templates = nil
29
-
30
- end
31
-
32
- def load_templates()
33
-
34
- content = MobyUtil::ParameterXml.merge_files( 'templates/', 'templates', '/templates/*' )
35
-
36
- @@templates = MobyUtil::XML::parse_string( content )
37
-
38
- end
39
-
40
- # Helper method for 'get_template_from_xml' to retrieve all requested inherited parameters.
41
- # === params
42
- # list_of_inherited_templates:: String representation of template names, separated with ";"
43
- # === returns
44
- # Hash:: Hash containing parameters
45
- # === raises
46
- # === example
47
- # result_hash = get_inherited_parameters( "template1;template2;template3" )
48
- def get_inherited_parameters( list_of_inherited_templates )
49
-
50
- result = ParameterHash.new
51
-
52
- if list_of_inherited_templates.kind_of?( String )
53
-
54
- list_of_inherited_templates.split( ";" ).each{ | inherits_from |
55
-
56
- result.merge_with_hash!(
57
-
58
- get_template_from_xml( inherits_from )
59
-
60
- )
61
-
62
- }
63
-
64
- end
65
-
66
- result
67
-
68
- end
69
-
70
- def get_template_from_xml( template_name )
71
-
72
- result = ParameterHash.new
73
-
74
- # return empty template hash if no templates loaded
75
- return result unless @@templates
76
-
77
- begin
78
-
79
- template_nodeset = @@templates.xpath( "/templates/template[@name='%s']" % [ template_name ] )
80
-
81
- if template_nodeset.size > 0
82
-
83
- template_nodeset.each{ | template_node |
84
-
85
- # merge and overwrite inherited template parameters
86
- result.merge!(
87
-
88
- get_inherited_parameters(
89
-
90
- template_node.attribute( 'inherits' ).to_s
91
-
92
- )
93
-
94
- ).merge!(
95
-
96
- # merge template to hash
97
- MobyUtil::ParameterXml.parse( template_node.to_s )
98
-
99
- )
100
- }
101
-
102
- end
103
-
104
- rescue Exception => exception
105
-
106
- Kernel::raise RuntimeError.new(
107
- "Error retrieving template %s from xml. Reason: %s (%s)" % [ template_name, exception.message, exception.class ]
108
- )
109
-
110
- end
111
-
112
- result
113
-
114
- end
115
-
116
- TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
117
-
118
- end # ParameterTemplates
119
-
120
- end # MobyUtil
@@ -1,116 +0,0 @@
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
- class ParameterUserAPI
23
-
24
- #include Singleton
25
-
26
- # TODO: document me
27
- def self.instance
28
-
29
- warn("warning: #{ self.name } is static class, use MobyUtil::ParameterUserAPI#method instead of using instance method")
30
-
31
- MobyUtil::ParameterUserAPI
32
-
33
- end
34
-
35
- # TODO: document me
36
- def self.[]=( key, value )
37
-
38
- $parameters[ key ] = value
39
-
40
- end
41
-
42
- # TODO: document me
43
- def self.[]( *args )
44
-
45
- $parameters[ *args ]
46
-
47
- end
48
-
49
- # TODO: document me
50
- def self.fetch( *args, &block )
51
-
52
- $parameters.fetch( *args, &block )
53
-
54
- end
55
-
56
- # TODO: document me
57
- def self.files
58
-
59
- $parameters.files
60
-
61
- end
62
-
63
- # TODO: document me
64
- def self.clear
65
-
66
- $parameters.clear
67
-
68
- end
69
-
70
- # TODO: document me
71
- def self.load_xml( filename )
72
-
73
- $parameters.parse_file( filename )
74
-
75
- end
76
-
77
- # TODO: document me
78
- def self.reset( *keys )
79
-
80
- $parameters.reset
81
-
82
- end
83
-
84
- # TODO: document me
85
- def self.inspect
86
-
87
- $parameters.inspect
88
-
89
- end
90
-
91
- # TODO: document me
92
- def self.to_s
93
-
94
- $parameters.to_s
95
-
96
- end
97
-
98
- # TODO: document me
99
- def self.keys
100
-
101
- $parameters.keys
102
-
103
- end
104
-
105
- # TODO: document me
106
- def self.values
107
-
108
- $parameters.values
109
-
110
- end
111
-
112
- TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
113
-
114
- end # ParameterUserAPI
115
-
116
- end # MobyUtil
@@ -1,261 +0,0 @@
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
- class ParameterXml
23
-
24
- # default values
25
- @@sut_list = []
26
-
27
- def self.reset
28
-
29
- @@sut_list = []
30
-
31
- end
32
-
33
- # return list of configured suts
34
- def self.sut_list
35
-
36
- @@sut_list
37
-
38
- end
39
-
40
- # Recursive function to process xml. Requires input to be either a valid xml fragment (as string) or a xml fragment as object.
41
- # Note: validity of the xml-fragment is not checked: please use appropriate methods for that
42
- # === params
43
- # root_element:: document or string containing xml
44
- # === returns
45
- # Hash:: Hash containing any attributes, parameters and id:s
46
- # === raises
47
- # SyntaxError:: if parameter-element does not have a name
48
- # ParameterError:: if loading subfile fails, see get_xmldocument_from_file function
49
- def self.parse( xml )
50
-
51
- # default results
52
- results = MobyUtil::ParameterHash.new
53
-
54
- # retrieve platform name
55
- platform = MobyUtil::EnvironmentHelper.platform
56
-
57
- # detect is posix platform
58
- is_posix = MobyUtil::EnvironmentHelper.posix?
59
-
60
- begin
61
-
62
- # create new xml document
63
- document = XML::parse_string( xml )
64
-
65
- rescue Exception => exception
66
-
67
- raise ParameterXmlParseError, "Error occured while parsing XML. Reason: \"#{ exception.message }\" (#{ exception.class })"
68
-
69
- end
70
-
71
- # go through each element in xml
72
- #document.xpath( "/#{ document.root.name }/*" ).each{ | element |
73
-
74
- # go through each element in xml
75
- document.root.xpath( "*" ).each{ | element |
76
-
77
- attribute = element.attributes.to_hash
78
-
79
- name = attribute[ "name" ].to_s
80
-
81
- # default value
82
- value = attribute[ "value" ].to_s
83
-
84
- # generic posix value - overwrites attribute["value"] if found
85
- value = attribute[ "posix" ].to_s unless attribute[ "posix" ].nil? if is_posix
86
-
87
- # platform specific value - overwrites existing value
88
- value = attribute[ platform.to_s ].to_s unless attribute[ platform.to_s ].nil?
89
-
90
- case element.name
91
-
92
- when 'fixture'
93
-
94
- plugin = attribute[ "plugin" ].to_s
95
-
96
- env = attribute[ "env" ].to_s unless attribute[ "env" ].nil?
97
-
98
- raise SyntaxError, "No name defined for fixture with value #{ name }" if name.empty?
99
-
100
- raise SyntaxError, "No plugin defined for fixture with name #{ name }" if plugin.empty?
101
-
102
- value = { :plugin => plugin, :env => env }
103
-
104
- when 'parameter'
105
-
106
- raise SyntaxError, "No name defined for parameter with value #{ attribute[ 'value' ] }" unless attribute[ "name" ]
107
-
108
- else
109
-
110
- if element.name == 'sut'
111
-
112
- id = attribute[ 'id' ].to_s
113
-
114
- # store sut id to array if element is type of sut
115
- @@sut_list << id unless @@sut_list.include?( id )
116
-
117
- end
118
-
119
- # get template name(s) if given
120
- templates = attribute[ "template" ].to_s
121
-
122
- if templates.empty?
123
-
124
- # empty value by default - content will be retrieved above
125
- value = ParameterHash.new()
126
-
127
- else
128
-
129
- # use template if defined
130
- value = MobyUtil::ParameterTemplates.instance.get_template_from_xml( templates ) unless templates.empty?
131
-
132
- end
133
-
134
- # read xml file from given location if defined - otherwise pass content as is
135
- if element.attribute( "xml_file" )
136
-
137
- content = parse( MobyUtil::FileHelper.get_file( element.attribute( "xml_file" ).to_s ) )
138
-
139
- else
140
-
141
- content = parse( "<xml>#{ element.inner_xml }</xml>" )
142
-
143
- end
144
-
145
- # merge hash values (value type of hash)
146
- value.merge_with_hash!( content )
147
-
148
- name = ( element.attribute( "id" ) || element.name ).to_s
149
-
150
- end
151
-
152
- # store values to parameters
153
- results[ name.to_sym ] = value
154
-
155
- }
156
-
157
- # return results hash
158
- results
159
-
160
- end
161
-
162
- # TODO: document me
163
- def self.load_file( filename )
164
-
165
- filename = MobyUtil::FileHelper.expand_path( filename )
166
-
167
- begin
168
-
169
- file_content = MobyUtil::FileHelper.get_file( filename )
170
-
171
- rescue EmptyFilenameError
172
-
173
- Kernel::raise EmptyFilenameError.new( "Unable to load parameters xml file due to filename is empty or nil" )
174
-
175
- rescue FileNotFoundError => exception
176
-
177
- Kernel::raise exception
178
-
179
- rescue IOError => exception
180
-
181
- Kernel::raise IOError.new( "Error occured while loading xml file. Reason: %s (%s)" % [ exception.message, exception.class ] )
182
-
183
- rescue => exception
184
-
185
- Kernel::raise ParameterFileParseError.new("Error occured while parsing parameters xml file %s\nDescription: %s" % [ filename, exception.message ] )
186
-
187
- end
188
-
189
- end
190
-
191
- # TODO: document me
192
- def self.parse_file( filename )
193
-
194
- begin
195
-
196
- parse(
197
-
198
- load_file( filename )
199
-
200
- )
201
-
202
- rescue Exception => exception
203
-
204
- Kernel::raise ParameterFileParseError.new(
205
-
206
- "Error occured while parsing parameters xml file %s. Reason: %s (%s)" % [ filename, exception.message, exception.class ]
207
-
208
- )
209
-
210
- end
211
-
212
- end
213
-
214
- # TODO: document me
215
- def self.merge_files( path, root_element_name, xpath_to_element = '/*', &block )
216
-
217
- @filename = ""
218
-
219
- xml = ""
220
-
221
- begin
222
-
223
- # merge all xml files
224
- Dir.glob( File.join( MobyUtil::FileHelper.expand_path( path ), '/*.xml' ) ).each { | filename |
225
-
226
- @file_name = filename
227
-
228
- content = MobyUtil::FileHelper.get_file( filename )
229
-
230
- xml << MobyUtil::XML::parse_string( content ).root.xpath( xpath_to_element ).to_s
231
-
232
- # pass the filename to block if one given
233
- yield( filename ) if block_given?
234
-
235
- }
236
-
237
- xml = "<%s>%s</%s>" % [ root_element_name, xml.to_s, root_element_name ]
238
-
239
- rescue MobyUtil::EmptyFilenameError
240
-
241
- Kernel::raise EmptyFilenameError.new( "Unable to load xml file due to filename is empty or nil" )
242
-
243
- rescue MobyUtil::FileNotFoundError => exception
244
-
245
- Kernel::raise exception
246
-
247
- rescue Exception => exception
248
-
249
- Kernel::raise RuntimeError.new( "Error occured while parsing xml file %s. Reason: %s (%s)" % [ @filename, exception.message, exception.class ] )
250
-
251
- end
252
-
253
- xml
254
-
255
- end
256
-
257
- TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
258
-
259
- end # ParameterXml
260
-
261
- end # MobyUtil