testability-driver 0.9.2
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.
- data/README +1 -0
- data/bin/start_app_perf +199 -0
- data/bin/tdriver-devtools +3 -0
- data/config/sut_parameters.rb +39 -0
- data/ext/extconf.rb +67 -0
- data/ext/native_extensions.c +70 -0
- data/lib/matti.rb +30 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +223 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
- data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
- data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
- data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
- data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1924 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +245 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +964 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +68 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +1865 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +7 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/xml_generator/update +3 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/generate.rb +892 -0
- data/lib/tdriver-devtools/doc/update +1 -0
- data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
- data/lib/tdriver-devtools/doc/xslt/template.xsl +1861 -0
- data/lib/tdriver-devtools/doc/xslt/update +3 -0
- data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
- data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +233 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +194 -0
- data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
- data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
- data/lib/tdriver.rb +26 -0
- data/lib/tdriver/base/behaviour/behaviour.rb +32 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +94 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +262 -0
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +111 -0
- data/lib/tdriver/base/behaviour/factory.rb +380 -0
- data/lib/tdriver/base/behaviour/loader.rb +28 -0
- data/lib/tdriver/base/command_data/command_data.rb +51 -0
- data/lib/tdriver/base/command_data/loader.rb +25 -0
- data/lib/tdriver/base/errors.rb +131 -0
- data/lib/tdriver/base/loader.rb +38 -0
- data/lib/tdriver/base/state_object.rb +270 -0
- data/lib/tdriver/base/sut/adapter.rb +28 -0
- data/lib/tdriver/base/sut/controller.rb +119 -0
- data/lib/tdriver/base/sut/factory.rb +287 -0
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +243 -0
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +96 -0
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +346 -0
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1268 -0
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +182 -0
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +119 -0
- data/lib/tdriver/base/sut/generic/commands/application.rb +219 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +82 -0
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +58 -0
- data/lib/tdriver/base/sut/generic/plugin.rb +96 -0
- data/lib/tdriver/base/sut/loader.rb +35 -0
- data/lib/tdriver/base/sut/sut.rb +67 -0
- data/lib/tdriver/base/test_object/abstract.rb +179 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +94 -0
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +787 -0
- data/lib/tdriver/base/test_object/factory.rb +618 -0
- data/lib/tdriver/base/test_object/identificator.rb +511 -0
- data/lib/tdriver/base/test_object/loader.rb +37 -0
- data/lib/tdriver/env.rb +21 -0
- data/lib/tdriver/loader.rb +36 -0
- data/lib/tdriver/matti.rb +35 -0
- data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +158 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +98 -0
- data/lib/tdriver/report/report.rb +47 -0
- data/lib/tdriver/report/report_api.rb +207 -0
- data/lib/tdriver/report/report_combine.rb +86 -0
- data/lib/tdriver/report/report_crash_file_capture.rb +167 -0
- data/lib/tdriver/report/report_creator.rb +571 -0
- data/lib/tdriver/report/report_cucumber.rb +158 -0
- data/lib/tdriver/report/report_cucumber_listener.rb +337 -0
- data/lib/tdriver/report/report_cucumber_reporter.rb +335 -0
- data/lib/tdriver/report/report_data_presentation.rb +152 -0
- data/lib/tdriver/report/report_data_table.rb +64 -0
- data/lib/tdriver/report/report_execution_statistics.rb +284 -0
- data/lib/tdriver/report/report_file_capture.rb +159 -0
- data/lib/tdriver/report/report_grouping.rb +539 -0
- data/lib/tdriver/report/report_junit_xml.rb +147 -0
- data/lib/tdriver/report/report_rspec.rb +108 -0
- data/lib/tdriver/report/report_test_case_run.rb +621 -0
- data/lib/tdriver/report/report_test_run.rb +1286 -0
- data/lib/tdriver/report/report_test_unit.rb +175 -0
- data/lib/tdriver/report/report_writer.rb +1405 -0
- data/lib/tdriver/tdriver.rb +158 -0
- data/lib/tdriver/util/common.rb +24 -0
- data/lib/tdriver/util/common/array.rb +39 -0
- data/lib/tdriver/util/common/crc16.rb +100 -0
- data/lib/tdriver/util/common/environment.rb +153 -0
- data/lib/tdriver/util/common/error.rb +39 -0
- data/lib/tdriver/util/common/file.rb +315 -0
- data/lib/tdriver/util/common/gem.rb +108 -0
- data/lib/tdriver/util/common/kernel.rb +189 -0
- data/lib/tdriver/util/common/loader.rb +39 -0
- data/lib/tdriver/util/common/retryable.rb +98 -0
- data/lib/tdriver/util/common/string.rb +77 -0
- data/lib/tdriver/util/dbaccess/dbaccess.rb +188 -0
- data/lib/tdriver/util/dbaccess/dbconnection.rb +41 -0
- data/lib/tdriver/util/dbaccess/error.rb +35 -0
- data/lib/tdriver/util/dbaccess/loader.rb +29 -0
- data/lib/tdriver/util/dynamic_attribute_filter.rb +182 -0
- data/lib/tdriver/util/hooking.rb +434 -0
- data/lib/tdriver/util/loader.rb +65 -0
- data/lib/tdriver/util/localisation.rb +24 -0
- data/lib/tdriver/util/localisation/error.rb +32 -0
- data/lib/tdriver/util/localisation/loader.rb +28 -0
- data/lib/tdriver/util/localisation/localisation.rb +479 -0
- data/lib/tdriver/util/logger.rb +377 -0
- data/lib/tdriver/util/operator_data/error.rb +29 -0
- data/lib/tdriver/util/operator_data/loader.rb +26 -0
- data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
- data/lib/tdriver/util/other/config.rb +221 -0
- data/lib/tdriver/util/parameter.rb +24 -0
- data/lib/tdriver/util/parameter/error.rb +45 -0
- data/lib/tdriver/util/parameter/loader.rb +37 -0
- data/lib/tdriver/util/parameter/parameter.rb +285 -0
- data/lib/tdriver/util/parameter/parameter_hash.rb +101 -0
- data/lib/tdriver/util/parameter/parameter_template.rb +120 -0
- data/lib/tdriver/util/parameter/parameter_user_api.rb +84 -0
- data/lib/tdriver/util/parameter/parameter_xml.rb +247 -0
- data/lib/tdriver/util/plugin/abstract.rb +60 -0
- data/lib/tdriver/util/plugin/error.rb +25 -0
- data/lib/tdriver/util/plugin/loader.rb +28 -0
- data/lib/tdriver/util/plugin/service.rb +200 -0
- data/lib/tdriver/util/recorder.rb +292 -0
- data/lib/tdriver/util/stats.rb +90 -0
- data/lib/tdriver/util/user_data/error.rb +29 -0
- data/lib/tdriver/util/user_data/loader.rb +26 -0
- data/lib/tdriver/util/user_data/user_data.rb +103 -0
- data/lib/tdriver/util/video_rec.rb +264 -0
- data/lib/tdriver/util/xml/abstraction.rb +47 -0
- data/lib/tdriver/util/xml/builder.rb +54 -0
- data/lib/tdriver/util/xml/document.rb +32 -0
- data/lib/tdriver/util/xml/element.rb +32 -0
- data/lib/tdriver/util/xml/error.rb +46 -0
- data/lib/tdriver/util/xml/loader.rb +46 -0
- data/lib/tdriver/util/xml/nil_element.rb +89 -0
- data/lib/tdriver/util/xml/nodeset.rb +32 -0
- data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
- data/lib/tdriver/util/xml/parsers/loader.rb +22 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +111 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +54 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +147 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +42 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +187 -0
- data/lib/tdriver/util/xml/xml.rb +170 -0
- data/lib/tdriver/verify/verify.rb +687 -0
- data/lib/tdriver/verify/verify.rb_org +630 -0
- data/lib/tdriver/version.rb +21 -0
- data/xml/behaviours/generic.xml +495 -0
- data/xml/defaults/generic.xml +97 -0
- data/xml/defaults/sut_generic.xml +36 -0
- data/xml/parameters/tdriver_parameters.xml +23 -0
- data/xml/templates/generic.xml +227 -0
- metadata +327 -0
|
@@ -0,0 +1,377 @@
|
|
|
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
|
+
require 'log4r'
|
|
21
|
+
require 'log4r/configurator'
|
|
22
|
+
|
|
23
|
+
module MobyUtil
|
|
24
|
+
|
|
25
|
+
class Logger
|
|
26
|
+
|
|
27
|
+
include Singleton
|
|
28
|
+
|
|
29
|
+
attr_reader :include_behaviour_info
|
|
30
|
+
|
|
31
|
+
def initialize()
|
|
32
|
+
|
|
33
|
+
# Allow all levels to be reported - do not change this!
|
|
34
|
+
@custom_levels = ['debug', 'behaviour', 'info', 'warning', 'error', 'fatal']
|
|
35
|
+
|
|
36
|
+
Log4r::Configurator.custom_levels( *@custom_levels.collect{ | level | level.upcase } )
|
|
37
|
+
|
|
38
|
+
Log4r::Logger.root.level = Log4r::DEBUG
|
|
39
|
+
|
|
40
|
+
@enabled_stack = [ false ]
|
|
41
|
+
|
|
42
|
+
@logger_instance = nil
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def include_behaviour_info=( value )
|
|
47
|
+
|
|
48
|
+
raise ArgumentError.new( "Unexpected variable type (%s) for 'include_behaviour_info' boolean, expected TrueClass or FalseClass" ) unless [ TrueClass, FalseClass ].include?( value.class )
|
|
49
|
+
|
|
50
|
+
@include_behaviour_info = value
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# allow reporting by passing level as method name, raise exception if method_id not found in @custom_levels array
|
|
55
|
+
def method_missing( method_id, *method_arguments )
|
|
56
|
+
|
|
57
|
+
super unless @custom_levels.include?( method_id.to_s )
|
|
58
|
+
|
|
59
|
+
self.log( method_id.to_s, *method_arguments )
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# TODO: add documentation
|
|
64
|
+
def enabled
|
|
65
|
+
|
|
66
|
+
@enabled_stack[ -1 ]
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# TODO: add documentation
|
|
71
|
+
def enabled=( value )
|
|
72
|
+
|
|
73
|
+
@enabled_stack[ -1 ] = value
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# TODO: add documentation
|
|
78
|
+
def push_enabled( value )
|
|
79
|
+
|
|
80
|
+
# push current value to stack if given argument is other than boolean
|
|
81
|
+
value = @enabled_stack[ -1 ] unless [ TrueClass, FalseClass ].include?( value.class )
|
|
82
|
+
|
|
83
|
+
@enabled_stack << value
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# TODO: add documentation
|
|
88
|
+
def pop_enabled
|
|
89
|
+
|
|
90
|
+
@enabled_stack.pop if @enabled_stack.count > 1
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# TODO: add documentation
|
|
95
|
+
def set_report_level( report_level )
|
|
96
|
+
|
|
97
|
+
Log4r::Logger.root.level = report_level
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# TODO: add documentation
|
|
102
|
+
def new_logger( logger_name )
|
|
103
|
+
|
|
104
|
+
Log4r::Logger.new( logger_name )
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# TODO: add documentation
|
|
109
|
+
def get_logger( logger_name )
|
|
110
|
+
|
|
111
|
+
begin
|
|
112
|
+
|
|
113
|
+
Log4r::Logger.get( logger_name )
|
|
114
|
+
|
|
115
|
+
rescue
|
|
116
|
+
|
|
117
|
+
Kernel::raise ArgumentError.new( "Logger '%s' not found" % logger_name )
|
|
118
|
+
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# TODO: add documentation
|
|
124
|
+
def create_outputter( outputter_class, *args )
|
|
125
|
+
|
|
126
|
+
outputter_class.new( *args )
|
|
127
|
+
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# TODO: add documentation
|
|
131
|
+
def add_outputter( logger_instance, outputter_instance )
|
|
132
|
+
|
|
133
|
+
logger_instance.add( outputter_instance )
|
|
134
|
+
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# TODO: add documentation
|
|
138
|
+
def remove_outputter( logger_instance, outputter_instance )
|
|
139
|
+
|
|
140
|
+
logger_instance.remove( outputter_instance )
|
|
141
|
+
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# TODO: add documentation
|
|
145
|
+
def set_outputter_pattern( outputter_instance, pattern )
|
|
146
|
+
|
|
147
|
+
# Allow only FileOutputter instances
|
|
148
|
+
Kernel::raise ArgumentError.new("Outputter instance not valid") if ![ Log4r::FileOutputter ].include?( outputter_instance.class )
|
|
149
|
+
|
|
150
|
+
# Allow only FileOutputter instances
|
|
151
|
+
Kernel::raise ArgumentError.new("Outputter pattern not valid, %M required by minimum") if !/\%M/.match( pattern )
|
|
152
|
+
|
|
153
|
+
# create pattern for outputter
|
|
154
|
+
outputter_instance.formatter = Log4r::PatternFormatter.new( :pattern => pattern )
|
|
155
|
+
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# TODO: add documentation
|
|
159
|
+
# return logger instance
|
|
160
|
+
def self.[]( key )
|
|
161
|
+
|
|
162
|
+
self.instance.get_logger( key )
|
|
163
|
+
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# TODO: add documentation
|
|
167
|
+
def root
|
|
168
|
+
|
|
169
|
+
Log4r::Logger.global
|
|
170
|
+
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# TODO: add documentation
|
|
174
|
+
def log( level, *text_array )
|
|
175
|
+
|
|
176
|
+
if self.enabled && @logger_instance
|
|
177
|
+
|
|
178
|
+
# convert to lowercase string
|
|
179
|
+
level = level.to_s.downcase
|
|
180
|
+
|
|
181
|
+
include_behaviour_info = @include_behaviour_info
|
|
182
|
+
|
|
183
|
+
# debug log entries and logging by using TDriver.logging.info or MobyUtil::Logging.instance.info etc
|
|
184
|
+
if caller.first =~ /method_missing/
|
|
185
|
+
|
|
186
|
+
# get correct caller method
|
|
187
|
+
log_caller = caller.at( 1 )
|
|
188
|
+
|
|
189
|
+
# debug level
|
|
190
|
+
if log_caller =~ /hooking\.rb/
|
|
191
|
+
|
|
192
|
+
log_caller = caller.at( 3 ).first
|
|
193
|
+
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
elsif caller.first =~ /logger\.rb/
|
|
197
|
+
|
|
198
|
+
# do not add caller info if called from self
|
|
199
|
+
include_behaviour_info = false
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
else
|
|
203
|
+
|
|
204
|
+
# normal logging, e.g. behaviour logging from method etc
|
|
205
|
+
log_caller = caller.at( 0 )
|
|
206
|
+
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# log text to given level if logging enabled
|
|
210
|
+
text_array.each{ | text |
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@logger_instance.send( level, ( include_behaviour_info && !text.empty? ) ? ( "%s in %s" % [ text, log_caller ] ) : ( "%s" % text ) )
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def enable_raise_hooking
|
|
223
|
+
|
|
224
|
+
def Kernel::raise( exception )
|
|
225
|
+
|
|
226
|
+
begin
|
|
227
|
+
|
|
228
|
+
super( exception )
|
|
229
|
+
|
|
230
|
+
rescue => ex
|
|
231
|
+
|
|
232
|
+
ex.backtrace.slice!( 0 )
|
|
233
|
+
|
|
234
|
+
warn_array = [ '', "(%s) %s" % [ ex.class, ex.message.split("\n") ], '', ex.backtrace, '' ].flatten
|
|
235
|
+
|
|
236
|
+
MobyUtil::Logger.instance.log( 'warning', *warn_array )
|
|
237
|
+
|
|
238
|
+
super( ex )
|
|
239
|
+
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# TODO: add documentation
|
|
247
|
+
def enable_logging
|
|
248
|
+
|
|
249
|
+
logging_level = Parameter[ :logging_level, nil ]
|
|
250
|
+
|
|
251
|
+
return nil if logging_level.nil?
|
|
252
|
+
|
|
253
|
+
Kernel::raise RuntimeError.new( "Wrong logging level format '%s' (Expected: %s)" % [ logging_level, "Numeric string"] ) unless MobyUtil::StringHelper.numeric?( logging_level )
|
|
254
|
+
|
|
255
|
+
logging_level = logging_level.to_i
|
|
256
|
+
|
|
257
|
+
Kernel::raise RuntimeError.new( "Invalid logging level '%s' (Expected: %s)" % [ logging_level, "0..5"] ) unless (0..5).include?( logging_level.to_i )
|
|
258
|
+
|
|
259
|
+
@include_behaviour_info = ( MobyUtil::Parameter[ :logging_include_behaviour_info, 'false' ].downcase == 'true' )
|
|
260
|
+
|
|
261
|
+
# create error dump folder if not exist, used e.g. when xml parse error
|
|
262
|
+
MobyUtil::FileHelper.mkdir_path( MobyUtil::FileHelper.expand_path( MobyUtil::Parameter[ :logging_xml_parse_error_dump_path ] ) )
|
|
263
|
+
|
|
264
|
+
unless logging_level.zero?
|
|
265
|
+
|
|
266
|
+
# create new logger instance
|
|
267
|
+
MobyUtil::Logger.instance.new_logger( 'TDriver' )
|
|
268
|
+
|
|
269
|
+
# get logger object reference
|
|
270
|
+
@logger_instance = get_logger( 'TDriver' )
|
|
271
|
+
|
|
272
|
+
# create unique name for logfile or use default (TDriver.log)
|
|
273
|
+
filename = ( MobyUtil::StringHelper.to_boolean( Parameter[ :logging_outputter_unique_filename ] ) ? "TDriver_%i.log" % Time.now : "TDriver.log" )
|
|
274
|
+
|
|
275
|
+
# logger output path
|
|
276
|
+
outputter_path = MobyUtil::FileHelper.expand_path( MobyUtil::Parameter[ :logging_outputter_path ] )
|
|
277
|
+
|
|
278
|
+
# create outputter folder if not exist
|
|
279
|
+
MobyUtil::FileHelper.mkdir_path( outputter_path )
|
|
280
|
+
|
|
281
|
+
# check if outputter is enabled
|
|
282
|
+
if MobyUtil::StringHelper.to_boolean( Parameter[ :logging_outputter_enabled ] )
|
|
283
|
+
|
|
284
|
+
# create new outputter instance type of FileOutputter
|
|
285
|
+
outputter = create_outputter(
|
|
286
|
+
|
|
287
|
+
# outputter type
|
|
288
|
+
Log4r::FileOutputter,
|
|
289
|
+
|
|
290
|
+
# outputter name
|
|
291
|
+
"TDriver_LOG",
|
|
292
|
+
|
|
293
|
+
# outputter filename
|
|
294
|
+
:filename => File.join( outputter_path, filename ),
|
|
295
|
+
|
|
296
|
+
# append to or truncate file
|
|
297
|
+
:trunc => MobyUtil::StringHelper.to_boolean( Parameter[ :logging_outputter_append ] ) == false,
|
|
298
|
+
|
|
299
|
+
# logging level
|
|
300
|
+
:level => logging_level
|
|
301
|
+
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
# set outputter log event write pattern
|
|
305
|
+
set_outputter_pattern( outputter, Parameter[ :logging_outputter_pattern ] )
|
|
306
|
+
|
|
307
|
+
# add outputter to logger instance
|
|
308
|
+
add_outputter( @logger_instance, outputter )
|
|
309
|
+
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# debug logging
|
|
313
|
+
if ( logging_level == 1 )
|
|
314
|
+
|
|
315
|
+
# enable exception capturing on debug level
|
|
316
|
+
enable_raise_hooking
|
|
317
|
+
|
|
318
|
+
# pass logger instance to hooking module
|
|
319
|
+
MobyUtil::Hooking.instance.set_logger_instance( MobyUtil::Logger.instance )
|
|
320
|
+
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# enable logging
|
|
324
|
+
@enabled_stack = [ true ]
|
|
325
|
+
|
|
326
|
+
# log event: start logging
|
|
327
|
+
log( 'info' , "", "Logging engine started", "" )
|
|
328
|
+
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
report_status_at_exit
|
|
332
|
+
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def report_status_at_exit
|
|
336
|
+
|
|
337
|
+
at_exit{
|
|
338
|
+
|
|
339
|
+
begin
|
|
340
|
+
exit_status = nil
|
|
341
|
+
|
|
342
|
+
case $!
|
|
343
|
+
|
|
344
|
+
when NilClass
|
|
345
|
+
|
|
346
|
+
exit_status = ['info', '', 'Execution finished succesfully', '']
|
|
347
|
+
|
|
348
|
+
when SystemExit
|
|
349
|
+
|
|
350
|
+
exit_status = ['info', '', 'Execution terminated by system exit', '' ]
|
|
351
|
+
|
|
352
|
+
else
|
|
353
|
+
|
|
354
|
+
exit_status = ['error', '', "Execution terminated with exception: %s: %s" % [ caller.first, $!.message.split("\n") ], '' ]
|
|
355
|
+
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
log( *exit_status )
|
|
359
|
+
|
|
360
|
+
rescue
|
|
361
|
+
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
}
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def hook_methods( _base )
|
|
368
|
+
|
|
369
|
+
#STDOUT.puts "Use MobyUtil::Hooking instead of MobyUtil::Logging when calling hook_methods (#{ caller(1).first })"
|
|
370
|
+
|
|
371
|
+
MobyUtil::Hooking.instance.hook_methods( _base ) #if @enabled
|
|
372
|
+
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
end # Logger
|
|
376
|
+
|
|
377
|
+
end # MobyUtil
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
|
|
21
|
+
module MobyUtil
|
|
22
|
+
|
|
23
|
+
# This error should be raised when information about operator data is not found
|
|
24
|
+
class OperatorDataNotFoundError < StandardError; def initialize ( msg = nil ); super( msg ); end; end # class
|
|
25
|
+
|
|
26
|
+
# This error should be raised when the search column is not found
|
|
27
|
+
class OperatorDataColumnNotFoundError < StandardError; def initialize ( msg = nil ); super( msg ); end; end # class
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
21
|
+
# user data inputs related errors
|
|
22
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'error.rb' ) )
|
|
23
|
+
|
|
24
|
+
# user data inputs module implementation
|
|
25
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'operator_data.rb' ) )
|
|
26
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
# Utility for handling operator data inputs database
|
|
21
|
+
|
|
22
|
+
module MobyUtil
|
|
23
|
+
|
|
24
|
+
class OperatorData
|
|
25
|
+
|
|
26
|
+
# == description
|
|
27
|
+
# Function to fetch a translation for a given logical name from the localisation DB
|
|
28
|
+
#
|
|
29
|
+
# == arguments
|
|
30
|
+
# operator_data_lname
|
|
31
|
+
# String
|
|
32
|
+
# description: operator data identifier
|
|
33
|
+
# example: "op_welcome_message""
|
|
34
|
+
#
|
|
35
|
+
# operator
|
|
36
|
+
# String
|
|
37
|
+
# description: Operator column name to be used when fetching operator data
|
|
38
|
+
# example: "Orange"
|
|
39
|
+
#
|
|
40
|
+
# table_name
|
|
41
|
+
# String
|
|
42
|
+
# description: Name of the operator data table to use from the operator table DB
|
|
43
|
+
# example: "operator_data_week201042"
|
|
44
|
+
#
|
|
45
|
+
# == returns
|
|
46
|
+
# String
|
|
47
|
+
# description: Operator data string
|
|
48
|
+
#
|
|
49
|
+
# == throws
|
|
50
|
+
# OperatorDataColumnNotFoundError
|
|
51
|
+
# description: If the desired operator data is not found
|
|
52
|
+
#
|
|
53
|
+
# OperatorDataColumnNotFoundError
|
|
54
|
+
# description: If the desired data column name to be used for the output is not found
|
|
55
|
+
#
|
|
56
|
+
# SqlError
|
|
57
|
+
# description: if there is and sql error while executing the query
|
|
58
|
+
#
|
|
59
|
+
def self.retrieve( operator_data_lname, operator, table_name )
|
|
60
|
+
|
|
61
|
+
Kernel::raise OperatorDataNotFoundError.new( "Search string parameter cannot be nil" ) if operator_data_lname == nil
|
|
62
|
+
|
|
63
|
+
# Get Localization parameters for DB Connection
|
|
64
|
+
db_type = MobyUtil::Parameter[ :operator_data_db_type, nil ].to_s.downcase
|
|
65
|
+
host = MobyUtil::Parameter[ :operator_data_server_ip ]
|
|
66
|
+
username = MobyUtil::Parameter[ :operator_data_server_username ]
|
|
67
|
+
password = MobyUtil::Parameter[ :operator_data_server_password ]
|
|
68
|
+
database_name = MobyUtil::Parameter[ :operator_data_server_database_name ]
|
|
69
|
+
|
|
70
|
+
db_connection = DBConnection.new( db_type, host, database_name, username, password )
|
|
71
|
+
|
|
72
|
+
search_string = "#{ operator_data_lname }' AND `Operator` = '#{ operator }"
|
|
73
|
+
query_string = "select `Value` from `#{ table_name }` where `LogicalName` = '#{ search_string }' and `LogicalName` <> '#MISSING'"
|
|
74
|
+
|
|
75
|
+
begin
|
|
76
|
+
result = MobyUtil::DBAccess.query( db_connection, query_string )
|
|
77
|
+
rescue
|
|
78
|
+
# if data column to be searched is not found then Kernel::raise error for search column not found
|
|
79
|
+
Kernel::raise OperatorDataColumnNotFoundError.new( "Search column 'Value' not found in database" ) unless $!.message.index( "Unknown column" ) == nil
|
|
80
|
+
Kernel::raise SqlError.new( $!.message )
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Return always the first column of the row
|
|
84
|
+
Kernel::raise OperatorDataNotFoundError.new("No matches found for search string '#{ operator_data_lname }' in search column 'LogicalName' for opreator #{ operator }" ) if ( result.empty?)
|
|
85
|
+
# Result is an Array of rows (Array<String>)! We want the first column of the first row.
|
|
86
|
+
return result[0][0]
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end # class
|
|
91
|
+
|
|
92
|
+
end # module
|
|
93
|
+
|