WAAT 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +19 -0
- data/LICENSE.txt +13 -0
- data/README +1 -0
- data/README.rdoc +41 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/WAAT.gemspec +95 -0
- data/features/WAAT-ruby.feature +19 -0
- data/features/step_definitions/WAAT-ruby_steps.rb +41 -0
- data/features/support/env.rb +42 -0
- data/features/support/hook.rb +34 -0
- data/lib/WAAT.rb +188 -0
- data/lib/WAAT/LICENSE.txt +13 -0
- data/lib/WAAT/docs/Jpcap_Install.html +131 -0
- data/lib/WAAT/docs/README +32 -0
- data/lib/WAAT/docs/README.rdoc +38 -0
- data/lib/WAAT/docs/WAAT Readme.doc +0 -0
- data/lib/WAAT/docs/WAAT Readme.docx +0 -0
- data/lib/WAAT/docs/WAAT Readme.html +2150 -0
- data/lib/WAAT/docs/WAAT Readme.pdf +0 -0
- data/lib/WAAT/lib/WAAT_v1.4.jar +0 -0
- data/lib/WAAT/lib/commons-lang-2.3.jar +0 -0
- data/lib/WAAT/lib/httpSniffer/Linux/jpcap-0.7-1.i386.rpm +0 -0
- data/lib/WAAT/lib/httpSniffer/Linux/jpcap-0.7.deb +0 -0
- data/lib/WAAT/lib/httpSniffer/Linux/libpcap-1.1.1.tar.gz +0 -0
- data/lib/WAAT/lib/httpSniffer/Windows/JpcapSetup-0.7.exe +0 -0
- data/lib/WAAT/lib/httpSniffer/Windows/System32/Jpcap.dll +0 -0
- data/lib/WAAT/lib/httpSniffer/Windows/System32/Packet.dll +0 -0
- data/lib/WAAT/lib/httpSniffer/Windows/System32/drivers/npf.sys +0 -0
- data/lib/WAAT/lib/httpSniffer/Windows/System32/pthreadVC.dll +0 -0
- data/lib/WAAT/lib/httpSniffer/Windows/System32/wpcap.dll +0 -0
- data/lib/WAAT/lib/httpSniffer/Windows/WinPcap_4_1_2.exe +0 -0
- data/lib/WAAT/lib/httpSniffer/jpcap.jar +0 -0
- data/lib/WAAT/lib/jpcap.jar +0 -0
- data/lib/WAAT/lib/log4j-1.2.16.jar +0 -0
- data/lib/WAAT/lib/xstream-1.3.1.jar +0 -0
- data/lib/WAAT/resources/log4j.properties +20 -0
- data/lib/WAAT/sampledata/TestData.xml +86 -0
- data/lib/WAAT/samplescripts/com/thoughtworks/webanalyticsautomation/scriptrunner/SeleniumScriptRunner.java +49 -0
- data/lib/WAAT/samplescripts/com/thoughtworks/webanalyticsautomation/scriptrunner/WebDriverScriptRunner.java +67 -0
- data/sampledata/TestData.xml +66 -0
- metadata +187 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +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
|
+
|
10
|
+
source "http://rubygems.org"
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem "selenium-webdriver", ">= 2.0.0"
|
14
|
+
gem "cucumber", ">= 0"
|
15
|
+
gem "jeweler", "~> 1.6.4"
|
16
|
+
gem 'ffi', "1.0.7"
|
17
|
+
end
|
18
|
+
|
19
|
+
gem "bundler", "~> 1.0.0"
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2010 Anand Bagmar (abagmar@gmail.com).
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
WAAT-ruby
|
data/README.rdoc
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
= WAAT-ruby
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Created by: Anand Bagmar
|
5
|
+
* Email: abagmar@gmail.com
|
6
|
+
*
|
7
|
+
* Copyright 2010 Anand Bagmar. Distributed under the Apache 2.0 License
|
8
|
+
*
|
9
|
+
* See LICENSE.txt for further details.
|
10
|
+
**/
|
11
|
+
|
12
|
+
|
13
|
+
== What is Web Analytics
|
14
|
+
|
15
|
+
Web Analytics is the measurement, collection, analysis and reporting of internet data for purposes of understanding and optimizing web usage. Web Analytics is not just a tool for measuring website traffic, but can also be used as a tool for business research and market research.
|
16
|
+
Web Analytics applications can also help companies measure the results of traditional print advertising campaigns. It helps one to estimate how the traffic to the web site changed after the launch of a new advertising campaign.
|
17
|
+
|
18
|
+
Web Analytics provides data on the number of visitors, page views, etc. to gauge the traffic popularity trends which helps doing the market research.
|
19
|
+
Official definition of Web Analytics from Wikipedia[http://en.wikipedia.org/wiki/Web_analytics)]
|
20
|
+
|
21
|
+
|
22
|
+
== What is WAAT?
|
23
|
+
|
24
|
+
<b>{WAAT = Web Analytics Automation Testing.}[http://essenceoftesting.blogspot.com/search/label/waat]</b>
|
25
|
+
|
26
|
+
See the {WAAT-Ruby wiki}[http://github.com/anandbagmar/WAAT-Ruby/wiki] for answers to questions like what, why, how, and more.
|
27
|
+
|
28
|
+
For any other questions, comments, help, email Anand Bagmar @ abagmar@gmail.com
|
29
|
+
|
30
|
+
|
31
|
+
== Latest version
|
32
|
+
|
33
|
+
* <b>WAAT-Ruby v1.4 gem is available from the {WAAT-Ruby pkg}[http://github.com/anandbagmar/WAAT-ruby/tree/master/pkg] folder.</b>
|
34
|
+
* <b>WAAT-Java v1.4 is available from the {WAAT-Java dist}[http://github.com/anandbagmar/WAAT/tree/master/dist] folder.</b>
|
35
|
+
|
36
|
+
|
37
|
+
== Platforms supported
|
38
|
+
|
39
|
+
* {WAAT}[http://github.com/anandbagmar/WAAT] for Java.
|
40
|
+
* {WAAT}[http://github.com/anandbagmar/WAAT-Ruby] for Ruby. The Ruby gem uses RJB (Ruby-Java-Bridge) to invoke APIs defined by WAAT-Java to enable Web Analytics Testing.
|
41
|
+
* <b>See {my blog}[http://essenceoftesting.blogspot.com/search/label/waat] for all activity around WAAT.</b>
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
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
|
+
|
10
|
+
# encoding: utf-8
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'bundler'
|
14
|
+
begin
|
15
|
+
Bundler.setup(:default, :development)
|
16
|
+
rescue Bundler::BundlerError => e
|
17
|
+
$stderr.puts e.message
|
18
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
19
|
+
exit e.status_code
|
20
|
+
end
|
21
|
+
require 'rake'
|
22
|
+
|
23
|
+
require 'jeweler'
|
24
|
+
Jeweler::Tasks.new do |gem|
|
25
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
26
|
+
gem.name = "WAAT"
|
27
|
+
gem.homepage = "http://github.com/anandbagmar/WAAT-ruby"
|
28
|
+
gem.license = "Apache 2.0"
|
29
|
+
gem.summary = %Q{Web Analytics Automation Testing Framework}
|
30
|
+
gem.description = %Q{An automated way of testing the Web Analytic tags reported to 'n' number of Web Analytic tools by your product. See here for more details: http://essenceoftesting.blogspot.com/search/label/waat}
|
31
|
+
gem.email = "abagmar@gmail.com"
|
32
|
+
gem.authors = ["Anand Bagmar"]
|
33
|
+
|
34
|
+
# dependencies defined in Gemfile
|
35
|
+
# gem.add_dependency('rjb', ">= 1.3.2")
|
36
|
+
end
|
37
|
+
Jeweler::RubygemsDotOrgTasks.new
|
38
|
+
|
39
|
+
require 'cucumber/rake/task'
|
40
|
+
Cucumber::Rake::Task.new(:features)
|
41
|
+
|
42
|
+
task :default => :features
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "WAAT-ruby #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.4.0
|
data/WAAT.gemspec
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{WAAT}
|
8
|
+
s.version = "1.4.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Anand Bagmar"]
|
12
|
+
s.date = %q{2011-07-28}
|
13
|
+
s.description = %q{An automated way of testing the Web Analytic tags reported to 'n' number of Web Analytic tools by your product. See here for more details: http://essenceoftesting.blogspot.com/search/label/waat}
|
14
|
+
s.email = %q{abagmar@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"WAAT.gemspec",
|
29
|
+
"features/WAAT-ruby.feature",
|
30
|
+
"features/step_definitions/WAAT-ruby_steps.rb",
|
31
|
+
"features/support/env.rb",
|
32
|
+
"features/support/hook.rb",
|
33
|
+
"lib/WAAT.rb",
|
34
|
+
"lib/WAAT/LICENSE.txt",
|
35
|
+
"lib/WAAT/docs/Jpcap_Install.html",
|
36
|
+
"lib/WAAT/docs/README",
|
37
|
+
"lib/WAAT/docs/README.rdoc",
|
38
|
+
"lib/WAAT/docs/WAAT Readme.doc",
|
39
|
+
"lib/WAAT/docs/WAAT Readme.docx",
|
40
|
+
"lib/WAAT/docs/WAAT Readme.html",
|
41
|
+
"lib/WAAT/docs/WAAT Readme.pdf",
|
42
|
+
"lib/WAAT/lib/WAAT_v1.4.jar",
|
43
|
+
"lib/WAAT/lib/commons-lang-2.3.jar",
|
44
|
+
"lib/WAAT/lib/httpSniffer/Linux/jpcap-0.7-1.i386.rpm",
|
45
|
+
"lib/WAAT/lib/httpSniffer/Linux/jpcap-0.7.deb",
|
46
|
+
"lib/WAAT/lib/httpSniffer/Linux/libpcap-1.1.1.tar.gz",
|
47
|
+
"lib/WAAT/lib/httpSniffer/Windows/JpcapSetup-0.7.exe",
|
48
|
+
"lib/WAAT/lib/httpSniffer/Windows/System32/Jpcap.dll",
|
49
|
+
"lib/WAAT/lib/httpSniffer/Windows/System32/Packet.dll",
|
50
|
+
"lib/WAAT/lib/httpSniffer/Windows/System32/drivers/npf.sys",
|
51
|
+
"lib/WAAT/lib/httpSniffer/Windows/System32/pthreadVC.dll",
|
52
|
+
"lib/WAAT/lib/httpSniffer/Windows/System32/wpcap.dll",
|
53
|
+
"lib/WAAT/lib/httpSniffer/Windows/WinPcap_4_1_2.exe",
|
54
|
+
"lib/WAAT/lib/httpSniffer/jpcap.jar",
|
55
|
+
"lib/WAAT/lib/jpcap.jar",
|
56
|
+
"lib/WAAT/lib/log4j-1.2.16.jar",
|
57
|
+
"lib/WAAT/lib/xstream-1.3.1.jar",
|
58
|
+
"lib/WAAT/resources/log4j.properties",
|
59
|
+
"lib/WAAT/sampledata/TestData.xml",
|
60
|
+
"lib/WAAT/samplescripts/com/thoughtworks/webanalyticsautomation/scriptrunner/SeleniumScriptRunner.java",
|
61
|
+
"lib/WAAT/samplescripts/com/thoughtworks/webanalyticsautomation/scriptrunner/WebDriverScriptRunner.java",
|
62
|
+
"sampledata/TestData.xml"
|
63
|
+
]
|
64
|
+
s.homepage = %q{http://github.com/anandbagmar/WAAT-ruby}
|
65
|
+
s.licenses = ["Apache 2.0"]
|
66
|
+
s.require_paths = ["lib"]
|
67
|
+
s.rubygems_version = %q{1.3.7}
|
68
|
+
s.summary = %q{Web Analytics Automation Testing Framework}
|
69
|
+
|
70
|
+
if s.respond_to? :specification_version then
|
71
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
72
|
+
s.specification_version = 3
|
73
|
+
|
74
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
75
|
+
s.add_runtime_dependency(%q<bundler>, ["~> 1.0.0"])
|
76
|
+
s.add_development_dependency(%q<selenium-webdriver>, [">= 2.0.0"])
|
77
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
78
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
79
|
+
s.add_development_dependency(%q<ffi>, ["= 1.0.7"])
|
80
|
+
else
|
81
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
82
|
+
s.add_dependency(%q<selenium-webdriver>, [">= 2.0.0"])
|
83
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
84
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
85
|
+
s.add_dependency(%q<ffi>, ["= 1.0.7"])
|
86
|
+
end
|
87
|
+
else
|
88
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
89
|
+
s.add_dependency(%q<selenium-webdriver>, [">= 2.0.0"])
|
90
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
91
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
92
|
+
s.add_dependency(%q<ffi>, ["= 1.0.7"])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +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
|
19
|
+
Given I navigate to Anand Bagmar's blog
|
@@ -0,0 +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
|
41
|
+
end
|
@@ -0,0 +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)
|
@@ -0,0 +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
|
+
|
data/lib/WAAT.rb
ADDED
@@ -0,0 +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
|
188
|
+
World(WAAT)
|