restassured_cli 0.1.1
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.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +139 -0
- data/Rakefile +3 -0
- data/bin/console +14 -0
- data/bin/restassured_cli +46 -0
- data/bin/setup +7 -0
- data/lib/restassured_cli.rb +77 -0
- data/lib/restassured_cli/createcontroller.rb +81 -0
- data/lib/restassured_cli/filenames.rb +69 -0
- data/lib/restassured_cli/source/maven/pom.xml +14 -0
- data/lib/restassured_cli/source/maven/testing/README.md +26 -0
- data/lib/restassured_cli/source/maven/testing/pom.xml +27 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-perf-tests/LoginTest.java +14 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-perf-tests/pom.xml +14 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-perf-tests/testng-perf-notests.xml +9 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-perf-tests/testng-perf.xml +9 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-production-tests/logback.xml +15 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-production-tests/pom.xml +21 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-production-tests/testng-production.xml +9 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/default/SampleTest.java +30 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/default/testng-ci.xml +13 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/default/testng-e2e.xml +13 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/default/testng-qa.xml +9 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/full/SampleComponentTest.java +312 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/full/SampleServiceIntegrationTest.java +129 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/full/testng-ci.xml +13 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/full/testng-e2e.xml +9 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/full/testng-qa.xml +9 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/logback.xml +15 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/pom.xml +22 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/resources/ci/sample.properties +0 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/resources/default/sample.properties +2 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/resources/e2e/sample.properties +1 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-service-tests/resources/qa/sample.properties +0 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/default/BaseConstant.java +48 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/default/InternalConfigManager.java +52 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/default/ServiceTestBase.java +103 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/default/sample/base/Constant.java +12 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/default/sample/base/SampleTestBase.java +15 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/full/Customer.java +83 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/full/Phone.java +31 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/full/SampleServiceHelper.java +8 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/full/sample/base/Constant.java +12 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/full/sample/base/SampleTestBase.java +63 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-library/pom.xml +14 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-parent-pom/pom.xml +225 -0
- data/lib/restassured_cli/source/maven/testing/sampleservice-test-runner/pom.xml +84 -0
- data/lib/restassured_cli/userinterface.rb +55 -0
- data/lib/restassured_cli/version.rb +3 -0
- data/spec/restassured_cli_spec.rb +84 -0
- data/spec/spec_helper.rb +14 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 802f2ba025cd683d386eb915a4441d585e20375b
|
4
|
+
data.tar.gz: 55e93899fa4eaa01fe6f3378458655b5b5ab2fc6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30dc207df48d412bd7046e15ac7b4de01c224c227a9f6b6c61f0fa91943fe7557f66135e0a68313f03ff433afb942699ea32f0ae656ea69987736785366c42e1
|
7
|
+
data.tar.gz: 52f698dc147b55aa2bcc2bf7eb7e4916e29b08212c3d6377c043e18b56faab7fbdb63c4f097cda171b236d3713ddf23f2333f2526b599e0c85d4dc838a3907cf
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Intuit Inc. All rights reserved.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
# restassured_cli release notes
|
2
|
+
|
3
|
+
## About
|
4
|
+
|
5
|
+
Command line utility (CLI) to generate test projects and sample tests using [RestAssured BDD framework](https://github.com/jayway/rest-assured), a Java DSL for easy testing of REST services.
|
6
|
+
|
7
|
+
## Release notes
|
8
|
+
|
9
|
+
* v1.0.0 - First release with examples as presented in [StarWest 2015](http://starwest.techwell.com/sessions/starwest-2015/automate-rest-services-testing-restassured)
|
10
|
+
|
11
|
+
## Getting started
|
12
|
+
|
13
|
+
### To install as gem
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'restassured_cli'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install restassured_cli
|
27
|
+
|
28
|
+
### To run as ruby executable
|
29
|
+
* Just run ./bin/restassured_cli
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```
|
34
|
+
$ ./restassured_cli
|
35
|
+
Usage: restassured_cli [-f] [-p projectVersion] [-j jdkVersion] <base package> <service name>
|
36
|
+
Options
|
37
|
+
-f,--full : full option, generates sample tests
|
38
|
+
-j,--jdk : project JDK version (default: 1.7)
|
39
|
+
-p,--projectVersion : project version (default: 1.0.0-SNAPSHOT)
|
40
|
+
-h,--help : display this screen
|
41
|
+
|
42
|
+
Examples
|
43
|
+
restassured_cli com.intuit.samples smallbusiness
|
44
|
+
restassured_cli -p 1.0.0 -f com.intuit.samples smallbusiness
|
45
|
+
|
46
|
+
$./restassured_cli -p 1.0.0 -f com.intuit.samples smallbusiness
|
47
|
+
Created project for smallbusiness service ...
|
48
|
+
|
49
|
+
smallbusiness
|
50
|
+
|── smallbusiness-service
|
51
|
+
| |── src/main/java/
|
52
|
+
| └── src/test/java/
|
53
|
+
└── testing
|
54
|
+
|── smallbusiness-perf-tests
|
55
|
+
| └── jmeter/regression/
|
56
|
+
| |── src/main/java/com/intuit/samples/smallbusiness/tests/perf/
|
57
|
+
| └── src/main/resources/
|
58
|
+
| └── testng-perf.xml
|
59
|
+
|── smallbusiness-production-tests
|
60
|
+
| |── src/main/java/com/intuit/samples/smallbusiness/tests/production/
|
61
|
+
| └── src/main/resources/
|
62
|
+
| └── testng-production.xml
|
63
|
+
|── smallbusiness-service-tests
|
64
|
+
| |── src/main/java/com/intuit/samples/smallbusiness/tests/service/
|
65
|
+
| |── src/main/java/com/intuit/samples/smallbusiness/tests/serviceintegration/
|
66
|
+
| └── src/main/resources/
|
67
|
+
| |── default/*.properties
|
68
|
+
| |── ci/*.properties
|
69
|
+
| |── qa/*.properties
|
70
|
+
| |── e2e/*.properties
|
71
|
+
| |── testng-ci.xml
|
72
|
+
| |── testng-qa.xml
|
73
|
+
| └── testng-e2e.xml
|
74
|
+
└── smallbusiness-test-library
|
75
|
+
└── src/main/java/com/intuit/samples/smallbusiness/tests/library/
|
76
|
+
```
|
77
|
+
|
78
|
+
## Maven
|
79
|
+
|
80
|
+
* pom files
|
81
|
+
- **Root level pom** or project top level pom, should be replaced with your own project pom.
|
82
|
+
- testing/project-parent-pom/pom.xml, should contain all your project dependencies
|
83
|
+
- testing/project-test-runner/pom.xml, runs tests without recompiling and is used in Jenkins
|
84
|
+
|
85
|
+
## How to run tests
|
86
|
+
|
87
|
+
* Running test artifacts
|
88
|
+
- Tests are run *without* recompiling. Artifacts are downloaded and testng files are extracted.
|
89
|
+
|
90
|
+
```
|
91
|
+
$ cd testing
|
92
|
+
$ mvn clean install
|
93
|
+
|
94
|
+
$ cd testing/<project>-test-runner
|
95
|
+
$ mvn clean install -U -P ci
|
96
|
+
$ mvn clean install -U -P qa
|
97
|
+
$ mvn clean install -U -P e2e
|
98
|
+
$ mvn clean install -U -P perf
|
99
|
+
```
|
100
|
+
- For profiles other than ci, qa, e2e, perf and production, create your own profiles in test-parent-pom.
|
101
|
+
|
102
|
+
## Eclipse
|
103
|
+
|
104
|
+
* To import testing project into Eclipse :
|
105
|
+
|
106
|
+
- cd testing; mvn eclipse:eclipse
|
107
|
+
|
108
|
+
- File > Import > Maven > Existing Maven Projects > Browse to testing root directory (all selections checked) and click Finish
|
109
|
+
|
110
|
+
* To run tests for environments other than qa, add **-Dtargetenv=ci** in Run Configuration’s VM arguments/options.
|
111
|
+
|
112
|
+
## Windows users
|
113
|
+
|
114
|
+
* Steps to run CLI
|
115
|
+
- Install Ruby from http://rubyinstaller.org/downloads/
|
116
|
+
- In the directory where you install restassured_cli, run
|
117
|
+
```
|
118
|
+
c:\Ruby22-x64\bin\ruby.exe restassured_cli -p 1.0.0 -j 1.7 -f com.intuit.samples smallbusiness
|
119
|
+
```
|
120
|
+
|
121
|
+
## Tips
|
122
|
+
|
123
|
+
* Updating project-test-library requires a "mvn install" before tests can pick up the change.
|
124
|
+
* Remove sample test code in service-tests and test-library when you're done
|
125
|
+
* TestNG xml files requires updating once you created tests.
|
126
|
+
|
127
|
+
## Contributing
|
128
|
+
|
129
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/eing/restassured_cli.
|
130
|
+
|
131
|
+
## Contributors (thank you!)
|
132
|
+
|
133
|
+
This release contains contributions from the following developers (in alphabetical order) across Intuit. Many others also contributed in different ways.
|
134
|
+
* Baechul Kim
|
135
|
+
* Todd Ekenstam
|
136
|
+
|
137
|
+
## License
|
138
|
+
|
139
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "restassured_cli"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/restassured_cli
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "restassured_cli"
|
5
|
+
require "restassured_cli/userinterface"
|
6
|
+
rescue LoadError
|
7
|
+
# if user does not have gem installed
|
8
|
+
puts "Detecting restassured_cli gem is not installed, fallback on local install"
|
9
|
+
$LOAD_PATH << __dir__ + '/../lib'
|
10
|
+
$LOAD_PATH << __dir__ + '/lib'
|
11
|
+
require "restassured_cli"
|
12
|
+
require "restassured_cli/userinterface"
|
13
|
+
puts "... Found and executing local install"
|
14
|
+
end
|
15
|
+
require "optparse"
|
16
|
+
|
17
|
+
options = {}
|
18
|
+
optparse = OptionParser.new do |opts|
|
19
|
+
options[:full] = false
|
20
|
+
opts.on('-f', '--full', 'full option to create sample tests') do
|
21
|
+
options[:full] = true
|
22
|
+
end
|
23
|
+
|
24
|
+
options[:projectVersion] = '1.0.0-SNAPSHOT'
|
25
|
+
opts.on('-p', '--projectVersion projectVersion', 'specify project version') do |version|
|
26
|
+
options[:projectVersion] = version
|
27
|
+
end
|
28
|
+
|
29
|
+
options[:jdkVersion] = '1.7'
|
30
|
+
opts.on('-j', '--jdk jdkVersion', 'jdk option to specify JDK version') do |jdkVersion|
|
31
|
+
options[:jdkVersion] = jdkVersion
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('-h', '--help', 'display help') do
|
35
|
+
Display.help
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
optparse.parse!
|
41
|
+
if ARGV.length < 2
|
42
|
+
Display.help
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
RestAssuredCLI::process(ARGV[0], ARGV[1], options)
|
data/bin/setup
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require "restassured_cli/filenames"
|
2
|
+
require "restassured_cli/userinterface"
|
3
|
+
require "restassured_cli/createcontroller"
|
4
|
+
|
5
|
+
module RestAssuredCLI
|
6
|
+
|
7
|
+
def self.process(firstArg, secondArg, options)
|
8
|
+
# checking required first argument for null
|
9
|
+
if firstArg.nil?
|
10
|
+
puts "Error: Base package name cannot be null\n\n"
|
11
|
+
Display.help
|
12
|
+
return
|
13
|
+
end
|
14
|
+
# checking required second argument for null
|
15
|
+
if secondArg.nil?
|
16
|
+
puts "Error: Service name cannot be null\n\n"
|
17
|
+
Display.help
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
# setting default values
|
22
|
+
if options.nil?
|
23
|
+
options[:jdkVersion] = "1.7"
|
24
|
+
options[:projectVersion] = "1.0.0"
|
25
|
+
options[:full] = false
|
26
|
+
end
|
27
|
+
if options[:jdkVersion].nil?
|
28
|
+
options[:jdkVersion] = "1.7"
|
29
|
+
end
|
30
|
+
if options[:projectVersion].nil?
|
31
|
+
options[:projectVersion] = "1.0.0"
|
32
|
+
end
|
33
|
+
if options[:full].nil?
|
34
|
+
options[:full] = false
|
35
|
+
end
|
36
|
+
|
37
|
+
$baseJavaPackage = firstArg
|
38
|
+
|
39
|
+
# servicename = test module name
|
40
|
+
$serviceName = secondArg
|
41
|
+
|
42
|
+
# projectName = project root and can contain dashes
|
43
|
+
$projectName = $serviceName
|
44
|
+
|
45
|
+
# groupId = java test package names cannot contain dashes
|
46
|
+
baseJavaPackageDashesRemoved = $baseJavaPackage.gsub(/-/, '')
|
47
|
+
serviceNameDashesRemoved = $serviceName.gsub(/-/, '')
|
48
|
+
$groupId = baseJavaPackageDashesRemoved + "." + serviceNameDashesRemoved
|
49
|
+
|
50
|
+
# packageName = test directory path replaces . with /
|
51
|
+
$packageName = baseJavaPackageDashesRemoved.gsub(/\./,'/') + '/' + serviceNameDashesRemoved
|
52
|
+
|
53
|
+
filegen = CreateController.new("#{$projectName}", "#{$groupId}", "#{$serviceName}", "#{$packageName}")
|
54
|
+
filegen.setJdkVersion(options[:jdkVersion])
|
55
|
+
filegen.setProjectVersion(options[:projectVersion])
|
56
|
+
files = FileNames.new("#{$serviceName}", "#{$packageName}")
|
57
|
+
baseCopyToDir = "#{$projectName}/testing"
|
58
|
+
|
59
|
+
# Create common directories
|
60
|
+
filegen.mkdir_common
|
61
|
+
filegen.mkdir_service_default
|
62
|
+
if options[:full]
|
63
|
+
filegen.mkdir_service_full
|
64
|
+
files.full.each do |filename|
|
65
|
+
filegen.copyFilesWithoutOverwriting "#{filename[0]}", "#{baseCopyToDir}/#{filename[1]}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
# Default option
|
69
|
+
files.default.each do |filename|
|
70
|
+
filegen.copyFilesWithoutOverwriting "#{filename[0]}", "#{baseCopyToDir}/#{filename[1]}"
|
71
|
+
end
|
72
|
+
files.testRunner.each do |filename|
|
73
|
+
filegen.copyFilesWithoutOverwriting "#{filename[0]}", "#{baseCopyToDir}/#{filename[1]}"
|
74
|
+
end
|
75
|
+
Display.results
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
# Class creates directories and copy files for restassured cli tool.
|
4
|
+
class CreateController
|
5
|
+
|
6
|
+
def initialize(projectName, groupId, serviceName, packageName)
|
7
|
+
# required parameters
|
8
|
+
@projectName = projectName
|
9
|
+
@groupId = groupId
|
10
|
+
@serviceName = serviceName
|
11
|
+
@packageName = packageName
|
12
|
+
# optional parameters
|
13
|
+
@version = '1.0.0-SNAPSHOT'
|
14
|
+
@jdkVersion = '1.7'
|
15
|
+
end
|
16
|
+
|
17
|
+
def mkdir_common
|
18
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-test-runner"
|
19
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-test-parent-pom"
|
20
|
+
end
|
21
|
+
|
22
|
+
# create directories for basic option
|
23
|
+
def mkdir_service_default
|
24
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-service-tests/src/main/java/"
|
25
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-service-tests/src/main/resources/"
|
26
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-service-tests/src/main/java/#{@packageName}/tests/service"
|
27
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-service-tests/src/main/java/#{@packageName}/tests/serviceintegration"
|
28
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-service-tests/src/main/resources/default"
|
29
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-service-tests/src/main/resources/qa"
|
30
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-service-tests/src/main/resources/ci"
|
31
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-service-tests/src/main/resources/e2e"
|
32
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-test-library/src/main/java/"
|
33
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library"
|
34
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/base"
|
35
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-perf-tests/src/main/java/"
|
36
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-perf-tests/src/main/resources/"
|
37
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-perf-tests/src/main/scripts/"
|
38
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-production-tests/src/main/java/"
|
39
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-production-tests/src/assembly/"
|
40
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-production-tests/src/main/resources/production"
|
41
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-production-tests/src/main/java/#{@packageName}/tests/production"
|
42
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-perf-tests/src/main/java/#{@packageName}/tests/perf"
|
43
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/sample/base"
|
44
|
+
end
|
45
|
+
|
46
|
+
# create tests directories for full option
|
47
|
+
def mkdir_service_full
|
48
|
+
FileUtils.mkdir_p "#{@projectName}/testing/#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/schema"
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def setJdkVersion(version)
|
53
|
+
@jdkVersion = version
|
54
|
+
end
|
55
|
+
|
56
|
+
def setProjectVersion(version)
|
57
|
+
@version = version
|
58
|
+
end
|
59
|
+
|
60
|
+
# copy poms, testng, tests files and replace with groupId, projectName and serviceName
|
61
|
+
def replaceStringsInFile(filename)
|
62
|
+
text = File.read(filename)
|
63
|
+
text = text.gsub(/GROUPID/, @groupId)
|
64
|
+
text = text.gsub(/PROJECTNAME/, @projectName)
|
65
|
+
text = text.gsub(/SERVICENAME/, @serviceName)
|
66
|
+
text = text.gsub(/PACKAGENAME/, @serviceName)
|
67
|
+
text = text.gsub(/PROJECTVERSION/, @version)
|
68
|
+
text = text.gsub(/JDKVERSION/, @jdkVersion)
|
69
|
+
File.open(filename, "w") { |file| file << text }
|
70
|
+
end
|
71
|
+
|
72
|
+
# copy a file only when it does not already exist
|
73
|
+
def copyFilesWithoutOverwriting(filenameFrom, filenameTo)
|
74
|
+
unless File.file?(filenameTo)
|
75
|
+
fullPath = __dir__ + '/source/maven/testing/' + filenameFrom
|
76
|
+
FileUtils.cp fullPath, filenameTo
|
77
|
+
replaceStringsInFile filenameTo
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Class to maintain filenames to copy
|
2
|
+
class FileNames
|
3
|
+
|
4
|
+
attr_reader :default
|
5
|
+
attr_reader :full
|
6
|
+
attr_reader :testRunner
|
7
|
+
|
8
|
+
def initialize(serviceName, packageName)
|
9
|
+
@serviceName = serviceName
|
10
|
+
@packageName = packageName
|
11
|
+
initializeDefault
|
12
|
+
initializeFull
|
13
|
+
initializeTestRunner
|
14
|
+
end
|
15
|
+
|
16
|
+
def initializeDefault
|
17
|
+
@default = [
|
18
|
+
["../pom.xml", "../pom.xml"],
|
19
|
+
["README.md", "README.md"],
|
20
|
+
["pom.xml", "pom.xml"],
|
21
|
+
["sampleservice-perf-tests/pom.xml", "#{@serviceName}-perf-tests/pom.xml"],
|
22
|
+
["sampleservice-perf-tests/testng-perf-notests.xml", "#{@serviceName}-perf-tests/src/main/resources/testng-perf.xml"],
|
23
|
+
["sampleservice-production-tests/pom.xml", "#{@serviceName}-production-tests/pom.xml"],
|
24
|
+
["sampleservice-production-tests/logback.xml", "#{@serviceName}-production-tests/src/main/resources/logback.xml"],
|
25
|
+
["sampleservice-production-tests/testng-production.xml", "#{@serviceName}-production-tests/src/main/resources/testng-production.xml"],
|
26
|
+
["sampleservice-test-library/pom.xml", "#{@serviceName}-test-library/pom.xml"],
|
27
|
+
["sampleservice-test-library/default/ServiceTestBase.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/base/ServiceTestBase.java"],
|
28
|
+
["sampleservice-test-library/default/BaseConstant.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/base/BaseConstant.java"],
|
29
|
+
["sampleservice-test-library/default/InternalConfigManager.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/base/InternalConfigManager.java"],
|
30
|
+
["sampleservice-test-library/default/sample/base/Constant.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/sample/base/Constant.java"],
|
31
|
+
["sampleservice-test-library/default/sample/base/SampleTestBase.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/sample/base/SampleTestBase.java"],
|
32
|
+
["sampleservice-service-tests/pom.xml", "#{@serviceName}-service-tests/pom.xml"],
|
33
|
+
["sampleservice-service-tests/logback.xml", "#{@serviceName}-service-tests/src/main/resources/logback.xml"],
|
34
|
+
["sampleservice-service-tests/resources/default/sample.properties", "#{@serviceName}-service-tests/src/main/resources/default/sample.properties"],
|
35
|
+
["sampleservice-service-tests/resources/ci/sample.properties", "#{@serviceName}-service-tests/src/main/resources/ci/sample.properties"],
|
36
|
+
["sampleservice-service-tests/resources/qa/sample.properties", "#{@serviceName}-service-tests/src/main/resources/qa/sample.properties"],
|
37
|
+
["sampleservice-service-tests/resources/e2e/sample.properties", "#{@serviceName}-service-tests/src/main/resources/e2e/sample.properties"],
|
38
|
+
["sampleservice-service-tests/default/SampleTest.java", "#{@serviceName}-service-tests/src/main/java/#{@packageName}/tests/service/SampleTest.java"],
|
39
|
+
["sampleservice-service-tests/default/testng-ci.xml", "#{@serviceName}-service-tests/src/main/resources/testng-ci.xml"],
|
40
|
+
["sampleservice-service-tests/default/testng-qa.xml", "#{@serviceName}-service-tests/src/main/resources/testng-qa.xml"],
|
41
|
+
["sampleservice-service-tests/default/testng-e2e.xml", "#{@serviceName}-service-tests/src/main/resources/testng-e2e.xml"]
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
def initializeFull
|
46
|
+
@full = [
|
47
|
+
["sampleservice-test-library/full/sample/base/Constant.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/sample/base/Constant.java"],
|
48
|
+
["sampleservice-test-library/full/sample/base/SampleTestBase.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/sample/base/SampleTestBase.java"],
|
49
|
+
["sampleservice-test-library/full/SampleServiceHelper.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/sample/SampleServiceHelper.java"],
|
50
|
+
["sampleservice-test-library/full/Customer.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/schema/Customer.java"],
|
51
|
+
["sampleservice-test-library/full/Phone.java", "#{@serviceName}-test-library/src/main/java/#{@packageName}/tests/library/schema/Phone.java"],
|
52
|
+
["sampleservice-service-tests/full/SampleComponentTest.java", "#{@serviceName}-service-tests/src/main/java/#{@packageName}/tests/service/SampleComponentTest.java"],
|
53
|
+
["sampleservice-service-tests/full/SampleServiceIntegrationTest.java", "#{@serviceName}-service-tests/src/main/java/#{@packageName}/tests/serviceintegration/SampleServiceIntegrationTest.java"],
|
54
|
+
["sampleservice-service-tests/full/testng-qa.xml", "#{@serviceName}-service-tests/src/main/resources/testng-qa.xml"],
|
55
|
+
["sampleservice-service-tests/full/testng-ci.xml", "#{@serviceName}-service-tests/src/main/resources/testng-ci.xml"],
|
56
|
+
["sampleservice-service-tests/full/testng-e2e.xml", "#{@serviceName}-service-tests/src/main/resources/testng-e2e.xml"],
|
57
|
+
["sampleservice-perf-tests/LoginTest.java", "#{@serviceName}-perf-tests/src/main/java/#{@packageName}/tests/perf/LoginTest.java"],
|
58
|
+
["sampleservice-perf-tests/testng-perf.xml", "#{@serviceName}-perf-tests/src/main/resources/testng-perf.xml"]
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
def initializeTestRunner
|
63
|
+
@testRunner = [
|
64
|
+
["sampleservice-test-runner/pom.xml", "#{@serviceName}-test-runner/pom.xml"],
|
65
|
+
["sampleservice-test-parent-pom/pom.xml", "#{@serviceName}-test-parent-pom/pom.xml"]
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|