WAAT 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,19 @@
1
- #**
2
- # * Created by: Anand Bagmar
3
- # * Email: abagmar@gmail.com
4
- # * Date: Dec 29, 2010
5
- # * Time: 9:34:02 AM
6
- # *
7
- # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
- # *
9
- # * http://essenceoftesting.blogspot.com/search/label/waat
10
- # * http://github.com/anandbagmar/WAAT-Ruby
11
- # * http://github.com/anandbagmar/WAAT
12
- # *
13
- #**
14
-
15
- Feature: Check if tags are reported when my blog page is opened
16
-
17
- @waat
18
- Scenario: Tags reported on loading blog page
1
+ #**
2
+ # * Created by: Anand Bagmar
3
+ # * Email: abagmar@gmail.com
4
+ # * Date: Dec 29, 2010
5
+ # * Time: 9:34:02 AM
6
+ # *
7
+ # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
+ # *
9
+ # * http://essenceoftesting.blogspot.com/search/label/waat
10
+ # * http://github.com/anandbagmar/WAAT-Ruby
11
+ # * http://github.com/anandbagmar/WAAT
12
+ # *
13
+ #**
14
+
15
+ Feature: Check if tags are reported when my blog page is opened
16
+
17
+ @waat
18
+ Scenario: Tags reported on loading blog page
19
19
  Given I navigate to Anand Bagmar's blog
@@ -1,41 +1,41 @@
1
- #**
2
- # * Created by: Anand Bagmar
3
- # * Email: abagmar@gmail.com
4
- # * Date: Dec 29, 2010
5
- # * Time: 9:34:02 AM
6
- # *
7
- # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
- # *
9
- # * http://essenceoftesting.blogspot.com/search/label/waat
10
- # * http://github.com/anandbagmar/WAAT-Ruby
11
- # * http://github.com/anandbagmar/WAAT
12
- # *
13
- #**
14
-
15
- require 'selenium-webdriver'
16
-
17
- Given /^I navigate to Anand Bagmar's blog$/ do
18
- url_patterns = ["GET /ps/ifr?container=friendconnect&mid=0"]
19
- action_name = "OpenWAATArticleOnBlog_HttpSniffer"
20
- test_data_file_name = File.join(File.dirname(__FILE__), "..", "..", "sampleData", "TestData.xml")
21
-
22
- # initialize_waat()
23
- #
24
- # enable_web_analytics_testing
25
-
26
- url = "http://essenceoftesting.blogspot.com"
27
- @driver = Selenium::WebDriver.for :firefox
28
- @driver.get url
29
-
30
- params = [:test_data_file_name=> test_data_file_name, :action_name => action_name, :url_patterns => url_patterns, :minimum_number_of_packets => 1]
31
- result = verify_web_analytics_data(params)
32
-
33
- puts "->#{result.status}"
34
- assert (result.status=="FAIL"), "Incorrect Verification Status. Expected: 'FAIL', Actual: #{result.status}"
35
- assert (result.list_of_errors.size==14), "Incorrect number of errors. Expected: '14', Actual: #{result.list_of_errors.size}"
36
- result.list_of_errors.each do |err|
37
- puts "->\t#{err}"
38
- end
39
-
40
- # disable_web_analytics_testing
1
+ #**
2
+ # * Created by: Anand Bagmar
3
+ # * Email: abagmar@gmail.com
4
+ # * Date: Dec 29, 2010
5
+ # * Time: 9:34:02 AM
6
+ # *
7
+ # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
+ # *
9
+ # * http://essenceoftesting.blogspot.com/search/label/waat
10
+ # * http://github.com/anandbagmar/WAAT-Ruby
11
+ # * http://github.com/anandbagmar/WAAT
12
+ # *
13
+ #**
14
+
15
+ require 'selenium-webdriver'
16
+
17
+ Given /^I navigate to Anand Bagmar's blog$/ do
18
+ url_patterns = ["GET /ps/ifr?container=friendconnect&mid=0"]
19
+ action_name = "OpenWAATArticleOnBlog_HttpSniffer"
20
+ test_data_file_name = File.join(File.dirname(__FILE__), "..", "..", "sampleData", "TestData.xml")
21
+
22
+ # initialize_waat()
23
+ #
24
+ # enable_web_analytics_testing
25
+
26
+ url = "http://essenceoftesting.blogspot.com"
27
+ @driver = Selenium::WebDriver.for :firefox
28
+ @driver.get url
29
+
30
+ params = [:test_data_file_name=> test_data_file_name, :action_name => action_name, :url_patterns => url_patterns, :minimum_number_of_packets => 1]
31
+ result = verify_web_analytics_data(params)
32
+
33
+ puts "->#{result.status}"
34
+ assert (result.status=="FAIL"), "Incorrect Verification Status. Expected: 'FAIL', Actual: #{result.status}"
35
+ assert (result.list_of_errors.size==14), "Incorrect number of errors. Expected: '14', Actual: #{result.list_of_errors.size}"
36
+ result.list_of_errors.each do |err|
37
+ puts "->\t#{err}"
38
+ end
39
+
40
+ # disable_web_analytics_testing
41
41
  end
@@ -1,42 +1,42 @@
1
- #**
2
- # * Created by: Anand Bagmar
3
- # * Email: abagmar@gmail.com
4
- # * Date: Dec 29, 2010
5
- # * Time: 9:34:02 AM
6
- # *
7
- # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
- # *
9
- # * http://essenceoftesting.blogspot.com/search/label/waat
10
- # * http://github.com/anandbagmar/WAAT-Ruby
11
- # * http://github.com/anandbagmar/WAAT
12
- # *
13
- #**
14
-
15
- require 'bundler'
16
- require 'selenium-webdriver'
17
-
18
- begin
19
- Bundler.setup(:default, :development)
20
- rescue Bundler::BundlerError => e
21
- $stderr.puts e.message
22
- $stderr.puts "Run `bundle install` to install missing gems"
23
- exit e.status_code
24
- end
25
-
26
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", "lib"))
27
-
28
- require 'test/unit/assertions'
29
-
30
- #
31
- #
32
- # WAAT configuration
33
- #
34
- #
35
-
36
- @waat_src = File.join(File.dirname(__FILE__), "..", "..", "lib", "WAAT")
37
- puts "@WAAT_root_location: #{@waat_src}"
38
- require @waat_src
39
-
40
- # end WAAT configuration
41
-
42
- World(Test::Unit::Assertions)
1
+ #**
2
+ # * Created by: Anand Bagmar
3
+ # * Email: abagmar@gmail.com
4
+ # * Date: Dec 29, 2010
5
+ # * Time: 9:34:02 AM
6
+ # *
7
+ # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
+ # *
9
+ # * http://essenceoftesting.blogspot.com/search/label/waat
10
+ # * http://github.com/anandbagmar/WAAT-Ruby
11
+ # * http://github.com/anandbagmar/WAAT
12
+ # *
13
+ #**
14
+
15
+ require 'bundler'
16
+ require 'selenium-webdriver'
17
+
18
+ begin
19
+ Bundler.setup(:default, :development)
20
+ rescue Bundler::BundlerError => e
21
+ $stderr.puts e.message
22
+ $stderr.puts "Run `bundle install` to install missing gems"
23
+ exit e.status_code
24
+ end
25
+
26
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", "lib"))
27
+
28
+ require 'test/unit/assertions'
29
+
30
+ #
31
+ #
32
+ # WAAT configuration
33
+ #
34
+ #
35
+
36
+ @waat_src = File.join(File.dirname(__FILE__), "..", "..", "lib", "WAAT")
37
+ puts "@WAAT_root_location: #{@waat_src}"
38
+ require @waat_src
39
+
40
+ # end WAAT configuration
41
+
42
+ World(Test::Unit::Assertions)
@@ -1,34 +1,34 @@
1
- #**
2
- # * Created by: Anand Bagmar
3
- # * Email: abagmar@gmail.com
4
- # * Date: Dec 29, 2010
5
- # * Time: 9:34:02 AM
6
- # *
7
- # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
- # *
9
- # * http://essenceoftesting.blogspot.com/search/label/waat
10
- # * http://github.com/anandbagmar/WAAT-Ruby
11
- # * http://github.com/anandbagmar/WAAT
12
- # *
13
- #**
14
-
15
- Before do
16
- puts "Generic before hook"
17
- end
18
-
19
- Before ('@waat') do
20
- puts "*** Before hook for WAAT ***"
21
- initialize_waat()
22
- enable_web_analytics_testing
23
- end
24
-
25
- After do
26
- puts "Generic after hook"
27
- @driver.quit
28
- end
29
-
30
- After ('@waat') do
31
- puts "*** After hook for WAAT ***"
32
- disable_web_analytics_testing
33
- end
34
-
1
+ #**
2
+ # * Created by: Anand Bagmar
3
+ # * Email: abagmar@gmail.com
4
+ # * Date: Dec 29, 2010
5
+ # * Time: 9:34:02 AM
6
+ # *
7
+ # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
+ # *
9
+ # * http://essenceoftesting.blogspot.com/search/label/waat
10
+ # * http://github.com/anandbagmar/WAAT-Ruby
11
+ # * http://github.com/anandbagmar/WAAT
12
+ # *
13
+ #**
14
+
15
+ Before do
16
+ puts "Generic before hook"
17
+ end
18
+
19
+ Before ('@waat') do
20
+ puts "*** Before hook for WAAT ***"
21
+ initialize_waat()
22
+ enable_web_analytics_testing
23
+ end
24
+
25
+ After do
26
+ puts "Generic after hook"
27
+ @driver.quit
28
+ end
29
+
30
+ After ('@waat') do
31
+ puts "*** After hook for WAAT ***"
32
+ disable_web_analytics_testing
33
+ end
34
+
data/lib/WAAT.rb CHANGED
@@ -1,188 +1,188 @@
1
- #**
2
- # * Created by: Anand Bagmar
3
- # * Email: abagmar@gmail.com
4
- # * Date: July 20, 2011
5
- # * Time: 9:34:00 AM
6
- # *
7
- # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
- # *
9
- # * http://essenceoftesting.blogspot.com/search/label/waat
10
- # * http://github.com/anandbagmar/WAAT-Ruby
11
- # * http://github.com/anandbagmar/WAAT
12
- # *
13
- #**
14
-
15
- module WAAT
16
-
17
- #
18
- # Result class converts the Result object returned by WAAT-Java to a Ruby class
19
- #
20
- # This class has 2 methods
21
- # * status => PASS | FAIL | SKIP
22
- # * list_of_errors => An array of strings containing all the Web Analytic validation errors as returned by the verify_web_analytics_data method
23
- #
24
-
25
- class Result
26
- attr_reader :status, :list_of_errors
27
-
28
- def initialize(java_result)
29
- @status = java_result.getVerificationStatus.name
30
- @list_of_errors = []
31
- java_result.getListOfErrors.toArray.each do |each_error|
32
- @list_of_errors << each_error.toString
33
- end
34
- end
35
- end
36
-
37
- #
38
- # === Synopsis
39
- # This method initializes 'WAAT-Ruby'
40
- #
41
- # === Args
42
- # *keep_loaded_file_in_memory*: Default: true
43
- # This means the loaded test data file will be kept in memory till the tests are running.
44
- #
45
- # === Examples:
46
- #
47
- # * initialize_waat => This will use the default value for keep_loaded_file_in_memory
48
- # * initialize_waat(true) => Same as initialize_waat
49
- # * initialize_waat(false) => This will unload the test data file after the Web Analytic tags verification is done
50
- #
51
- # === Corresponding WAAT-Java API
52
- # getInstance(WebAnalyticTool, InputFileType, keepLoadedFileInMemory, log4jPropertiesFilePath)::
53
- # This method initializes WAAT-Java.
54
- # Unlike WAAT-Java, WAAT-Ruby supports only the http_sniffer mechanism for doing Web Analytics testing.
55
- # Also, WAAT-Ruby supports specification of the input test data in XML format only.
56
- #
57
- #
58
- def initialize_waat(keep_loaded_file_in_memory = true)
59
- logger = Logger.new(STDOUT)
60
- logger.level = Logger::INFO
61
- logger.info("Initializing WAAT")
62
- load_java_classes
63
- engine_instance(keep_loaded_file_in_memory)
64
- end
65
-
66
- #
67
- # === Synopsis
68
- # This method enables Web Analytic testing for all subsequent tests till it is explicitly disabled
69
- #
70
- # === Corresponding WAAT-Java API
71
- # enableWebAnalyticsTesting::
72
- # This method enables Web Analytic testing in WAAT-Java
73
- # When this method is called, the packet capturing is started on all the network interfaces on the machine where the tests are running.
74
- #
75
- def enable_web_analytics_testing
76
- logger.info("Enable Web Analytics Testing")
77
- engine_instance.enableWebAnalyticsTesting
78
- end
79
-
80
- #
81
- # === Synopsis
82
- # This method disables Web Analytic testing for all subsequent tests till it is explicitly enabled again
83
- #
84
- # === Corresponding WAAT-Java API
85
- # disableWebAnalyticsTesting::
86
- # This method disables Web Analytic testing in WAAT-Java
87
- # When this method is called, the packet capturing is stopped for all the network interfaces on the machine where the tests are running.
88
- #
89
- def disable_web_analytics_testing
90
- logger.info("Disable Web Analytics Testing")
91
- engine_instance.disableWebAnalyticsTesting
92
- end
93
-
94
- #
95
- # === Synopsis
96
- # This method verifies the Web Analytic tags using the http_sniffer mechanism
97
- #
98
- # === Args
99
- # params Hash with the following entries
100
- #
101
- # *:test_data_file_name*:
102
- # Absolute path to the input Test Data (xml) file name.
103
- #
104
- # *:action_name*:
105
- # A (String) name representing the action done in the UI, for which we want to do Web Analytics Testing.
106
- # This action_name matches the corresponding name in the test_data_file_name
107
- #
108
- # *:url_patterns*:
109
- # An array of Strings containing URL snippets that will be used to filter the packets captured by HttpSniffer
110
- #
111
- # *:minimum_number_of_packets*:
112
- # The minimum number of "filtered" packets to capture based on the url_patterns provided
113
- #
114
- # === Examples:
115
- #
116
- # * verify_web_analytics_data({:test_data_file_name, :action_name, :url_patterns, :minimum_number_of_packets}) => This will enable Web Analytic Testing
117
- # where:
118
- # :test_data_file_name => File.join(File.dirname(__FILE__), "..", "..", "sampleData", "TestData.xml")
119
- # :action_name => "OpenWAATArticleOnBlog_HttpSniffer"
120
- # :url_patterns => ["GET /ps/ifr?container=friendconnect&mid=0"]
121
- # :minimum_number_of_packets => 1
122
- #
123
- # === Corresponding WAAT-Java API
124
- # verifyWebAnalyticsData(test_data_file_name, action_name, url_patterns, minimum_number_of_packets)::
125
- # This method enables Web Analytic testing in WAAT-Java
126
- # When this method is called, the packet capturing is started on all the network interfaces on the machine where the tests are running.
127
- #
128
- def verify_web_analytics_data(params)
129
- logger.info("Verify Web Analytics Data")
130
- logger.info("\tTest Data File Name: #{params[:test_data_file_name]}")
131
- logger.info("\tAction Name: #{params[:action_name]}")
132
- java_result = @engine_instance.verifyWebAnalyticsData(params[:test_data_file_name], params[:action_name], params[:url_patterns], params[:minimum_number_of_packets])
133
- Result.new(java_result)
134
- end
135
-
136
- private
137
- def logger
138
- @logger ||= Logger.new(STDOUT)
139
- @logger.level = Logger::INFO
140
- @logger
141
- end
142
-
143
- def engine_instance(keep_loaded_file_in_memory = true)
144
- log4j_properties_absolute_file_path = File.join(File.dirname(__FILE__), "WAAT", "resources", "log4j.properties")
145
- @engine_instance ||= controller.getInstance(web_analytic_tool("http_sniffer"), input_file_type("xml"), keep_loaded_file_in_memory, log4j_properties_absolute_file_path)
146
- end
147
-
148
- def controller
149
- @controller ||= Rjb::import('com.thoughtworks.webanalyticsautomation.Controller')
150
- end
151
-
152
- def input_file_type_reference
153
- @input_file_type_reference ||= Rjb::import('com.thoughtworks.webanalyticsautomation.inputdata.InputFileType')
154
- end
155
-
156
- def web_analytic_tool_reference
157
- @web_analytic_tool_reference ||= Rjb::import('com.thoughtworks.webanalyticsautomation.plugins.WebAnalyticTool')
158
- end
159
-
160
- def load_java_classes
161
- separator = (Config::CONFIG['target_os'] =~ /[win|mingw]/) == 0 ? ';' : ':'
162
-
163
- waat_lib_directory = File.join(File.dirname(__FILE__), "WAAT", "lib")
164
- logger.info("WAAT LIB directory: #{waat_lib_directory}")
165
-
166
- waat_file_list = Dir.glob("#{waat_lib_directory}/*.jar").join(separator)
167
- logger.info("Loading following JARs: #{waat_file_list}")
168
-
169
- require 'rjb'
170
- Rjb::load(classpath = waat_file_list,[])
171
- end
172
-
173
- def proxy_from_java_enum(java_enum, web_analytic_tool)
174
- java_enum.values.each do |each_value|
175
- return each_value if each_value.name==web_analytic_tool.upcase
176
- end
177
- end
178
-
179
- def web_analytic_tool(web_analytic_tool)
180
- proxy_from_java_enum(web_analytic_tool_reference, web_analytic_tool)
181
- end
182
-
183
- def input_file_type(input_file_type)
184
- proxy_from_java_enum(input_file_type_reference, input_file_type)
185
- end
186
-
187
- end
1
+ #**
2
+ # * Created by: Anand Bagmar
3
+ # * Email: abagmar@gmail.com
4
+ # * Date: July 20, 2011
5
+ # * Time: 9:34:00 AM
6
+ # *
7
+ # * Copyright 2010 Anand Bagmar (abagmar@gmail.com). Distributed under the Apache 2.0 License
8
+ # *
9
+ # * http://essenceoftesting.blogspot.com/search/label/waat
10
+ # * http://github.com/anandbagmar/WAAT-Ruby
11
+ # * http://github.com/anandbagmar/WAAT
12
+ # *
13
+ #**
14
+
15
+ module WAAT
16
+
17
+ #
18
+ # Result class converts the Result object returned by WAAT-Java to a Ruby class
19
+ #
20
+ # This class has 2 methods
21
+ # * status => PASS | FAIL | SKIP
22
+ # * list_of_errors => An array of strings containing all the Web Analytic validation errors as returned by the verify_web_analytics_data method
23
+ #
24
+
25
+ class Result
26
+ attr_reader :status, :list_of_errors
27
+
28
+ def initialize(java_result)
29
+ @status = java_result.getVerificationStatus.name
30
+ @list_of_errors = []
31
+ java_result.getListOfErrors.toArray.each do |each_error|
32
+ @list_of_errors << each_error.toString
33
+ end
34
+ end
35
+ end
36
+
37
+ #
38
+ # === Synopsis
39
+ # This method initializes 'WAAT-Ruby'
40
+ #
41
+ # === Args
42
+ # *keep_loaded_file_in_memory*: Default: true
43
+ # This means the loaded test data file will be kept in memory till the tests are running.
44
+ #
45
+ # === Examples:
46
+ #
47
+ # * initialize_waat => This will use the default value for keep_loaded_file_in_memory
48
+ # * initialize_waat(true) => Same as initialize_waat
49
+ # * initialize_waat(false) => This will unload the test data file after the Web Analytic tags verification is done
50
+ #
51
+ # === Corresponding WAAT-Java API
52
+ # getInstance(WebAnalyticTool, InputFileType, keepLoadedFileInMemory, log4jPropertiesFilePath)::
53
+ # This method initializes WAAT-Java.
54
+ # Unlike WAAT-Java, WAAT-Ruby supports only the http_sniffer mechanism for doing Web Analytics testing.
55
+ # Also, WAAT-Ruby supports specification of the input test data in XML format only.
56
+ #
57
+ #
58
+ def initialize_waat(keep_loaded_file_in_memory = true)
59
+ logger = Logger.new(STDOUT)
60
+ logger.level = Logger::INFO
61
+ logger.info("Initializing WAAT")
62
+ load_java_classes
63
+ engine_instance(keep_loaded_file_in_memory)
64
+ end
65
+
66
+ #
67
+ # === Synopsis
68
+ # This method enables Web Analytic testing for all subsequent tests till it is explicitly disabled
69
+ #
70
+ # === Corresponding WAAT-Java API
71
+ # enableWebAnalyticsTesting::
72
+ # This method enables Web Analytic testing in WAAT-Java
73
+ # When this method is called, the packet capturing is started on all the network interfaces on the machine where the tests are running.
74
+ #
75
+ def enable_web_analytics_testing
76
+ logger.info("Enable Web Analytics Testing")
77
+ engine_instance.enableWebAnalyticsTesting
78
+ end
79
+
80
+ #
81
+ # === Synopsis
82
+ # This method disables Web Analytic testing for all subsequent tests till it is explicitly enabled again
83
+ #
84
+ # === Corresponding WAAT-Java API
85
+ # disableWebAnalyticsTesting::
86
+ # This method disables Web Analytic testing in WAAT-Java
87
+ # When this method is called, the packet capturing is stopped for all the network interfaces on the machine where the tests are running.
88
+ #
89
+ def disable_web_analytics_testing
90
+ logger.info("Disable Web Analytics Testing")
91
+ engine_instance.disableWebAnalyticsTesting
92
+ end
93
+
94
+ #
95
+ # === Synopsis
96
+ # This method verifies the Web Analytic tags using the http_sniffer mechanism
97
+ #
98
+ # === Args
99
+ # params Hash with the following entries
100
+ #
101
+ # *:test_data_file_name*:
102
+ # Absolute path to the input Test Data (xml) file name.
103
+ #
104
+ # *:action_name*:
105
+ # A (String) name representing the action done in the UI, for which we want to do Web Analytics Testing.
106
+ # This action_name matches the corresponding name in the test_data_file_name
107
+ #
108
+ # *:url_patterns*:
109
+ # An array of Strings containing URL snippets that will be used to filter the packets captured by HttpSniffer
110
+ #
111
+ # *:minimum_number_of_packets*:
112
+ # The minimum number of "filtered" packets to capture based on the url_patterns provided
113
+ #
114
+ # === Examples:
115
+ #
116
+ # * verify_web_analytics_data({:test_data_file_name, :action_name, :url_patterns, :minimum_number_of_packets}) => This will enable Web Analytic Testing
117
+ # where:
118
+ # :test_data_file_name => File.join(File.dirname(__FILE__), "..", "..", "sampleData", "TestData.xml")
119
+ # :action_name => "OpenWAATArticleOnBlog_HttpSniffer"
120
+ # :url_patterns => ["GET /ps/ifr?container=friendconnect&mid=0"]
121
+ # :minimum_number_of_packets => 1
122
+ #
123
+ # === Corresponding WAAT-Java API
124
+ # verifyWebAnalyticsData(test_data_file_name, action_name, url_patterns, minimum_number_of_packets)::
125
+ # This method enables Web Analytic testing in WAAT-Java
126
+ # When this method is called, the packet capturing is started on all the network interfaces on the machine where the tests are running.
127
+ #
128
+ def verify_web_analytics_data(params)
129
+ logger.info("Verify Web Analytics Data")
130
+ logger.info("\tTest Data File Name: #{params[:test_data_file_name]}")
131
+ logger.info("\tAction Name: #{params[:action_name]}")
132
+ java_result = @engine_instance.verifyWebAnalyticsData(params[:test_data_file_name], params[:action_name], params[:url_patterns], params[:minimum_number_of_packets])
133
+ Result.new(java_result)
134
+ end
135
+
136
+ private
137
+ def logger
138
+ @logger ||= Logger.new(STDOUT)
139
+ @logger.level = Logger::INFO
140
+ @logger
141
+ end
142
+
143
+ def engine_instance(keep_loaded_file_in_memory = true)
144
+ log4j_properties_absolute_file_path = File.join(File.dirname(__FILE__), "WAAT", "resources", "log4j.properties")
145
+ @engine_instance ||= controller.getInstance(web_analytic_tool("http_sniffer"), input_file_type("xml"), keep_loaded_file_in_memory, log4j_properties_absolute_file_path)
146
+ end
147
+
148
+ def controller
149
+ @controller ||= Rjb::import('com.thoughtworks.webanalyticsautomation.Controller')
150
+ end
151
+
152
+ def input_file_type_reference
153
+ @input_file_type_reference ||= Rjb::import('com.thoughtworks.webanalyticsautomation.inputdata.InputFileType')
154
+ end
155
+
156
+ def web_analytic_tool_reference
157
+ @web_analytic_tool_reference ||= Rjb::import('com.thoughtworks.webanalyticsautomation.plugins.WebAnalyticTool')
158
+ end
159
+
160
+ def load_java_classes
161
+ separator = (Config::CONFIG['target_os'] =~ /[win|mingw]/) == 0 ? ';' : ':'
162
+
163
+ waat_lib_directory = File.join(File.dirname(__FILE__), "WAAT", "lib")
164
+ logger.info("WAAT LIB directory: #{waat_lib_directory}")
165
+
166
+ waat_file_list = Dir.glob("#{waat_lib_directory}/*.jar").join(separator)
167
+ logger.info("Loading following JARs: #{waat_file_list}")
168
+
169
+ require 'rjb'
170
+ Rjb::load(classpath = waat_file_list,[])
171
+ end
172
+
173
+ def proxy_from_java_enum(java_enum, web_analytic_tool)
174
+ java_enum.values.each do |each_value|
175
+ return each_value if each_value.name==web_analytic_tool.upcase
176
+ end
177
+ end
178
+
179
+ def web_analytic_tool(web_analytic_tool)
180
+ proxy_from_java_enum(web_analytic_tool_reference, web_analytic_tool)
181
+ end
182
+
183
+ def input_file_type(input_file_type)
184
+ proxy_from_java_enum(input_file_type_reference, input_file_type)
185
+ end
186
+
187
+ end
188
188
  World(WAAT)