Skip to content

Commit a9462d9

Browse files
committed
Fixing integTests and adding new test
1 parent e03a871 commit a9462d9

File tree

8 files changed

+80
-27
lines changed

8 files changed

+80
-27
lines changed

buildSrc/src/test/java/org/elasticsearch/gradle/precommit/DependencyLicensesTasksIT.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,49 @@
2424
public class DependencyLicensesTasksIT extends GradleIntegrationTestCase {
2525

2626
public void testNoDependenciesWithNoFolder() {
27-
GradleRunner runner = getRunner("no_dependencies_and_no_folder");
27+
String project = "no_dependencies_and_no_folder";
28+
GradleRunner runner = getRunner(project);
2829

29-
assertTaskSuccessful(runner.build(), ":no_dependencies_and_no_folder:dependencyLicenses");
30+
assertTaskSuccessful(runner.build(), ":" + project + ":dependencyLicenses");
3031
}
3132

3233
public void testDependenciesOk() {
33-
GradleRunner runner = getRunner("dependencies_ok");
34+
String project = "dependencies_ok";
35+
GradleRunner runner = getRunner(project);
3436

35-
assertTaskSuccessful(runner.build(), ":dependencies_ok:dependencyLicenses");
37+
assertTaskSuccessful(runner.build(), ":" + project + ":dependencyLicenses");
3638
}
3739

3840
public void testNoDependenciesWithFolder() {
39-
GradleRunner runner = getRunner("no_dependencies_with_folder");
41+
String project = "no_dependencies_with_folder";
42+
GradleRunner runner = getRunner(project);
4043

41-
assertTaskFailed(runner.buildAndFail(), ":no_dependencies_and_no_folder:dependencyLicenses");
44+
String expectedOutcome = "Licenses dir " + getProjectName(runner, project) + "licenses exists, but there are no dependencies";
45+
assertOutputContains(runner.buildAndFail().getOutput(), expectedOutcome);
4246
}
4347

44-
public void testDependenciesMissing() {
45-
GradleRunner runner = getRunner("dependencies_missing");
48+
public void testShaMissing() {
49+
String project = "sha_missing";
50+
GradleRunner runner = getRunner(project);
4651

47-
assertTaskFailed(runner.buildAndFail(), ":dependencies_missing:dependencyLicenses");
52+
String expectedOutcome = "Missing SHA for icu4j-62.1.jar. Run \"gradle updateSHAs\" to create them";
53+
assertOutputContains(runner.buildAndFail().getOutput(), expectedOutcome);
54+
}
55+
56+
public void testLicensesMissing() {
57+
String project = "license_missing";
58+
GradleRunner runner = getRunner(project);
59+
60+
String expectedOutcome = "Missing LICENSE for icu4j-62.1.jar, expected in icu4j-LICENSE.txt";
61+
assertOutputContains(runner.buildAndFail().getOutput(), expectedOutcome);
4862
}
4963

5064
public void testTooManyDependencies() {
51-
GradleRunner runner = getRunner("no_dependencies_with_folder");
65+
String project = "dependencies_too_much";
66+
GradleRunner runner = getRunner(project);
5267

53-
assertTaskFailed(runner.buildAndFail(), ":dependencies_too_much:dependencyLicenses");
68+
String expectedOutcome = "Unused license super-csv-LICENSE.txt";
69+
assertOutputContains(runner.buildAndFail().getOutput(), expectedOutcome);
5470
}
5571

5672
private GradleRunner getRunner(String subProject) {
@@ -61,4 +77,7 @@ private GradleRunner getRunner(String subProject) {
6177
.withPluginClasspath();
6278
}
6379

80+
private String getProjectName(GradleRunner runner, String subProject) {
81+
return runner.getProjectDir().toString() + "/" + subProject + "/";
82+
}
6483
}
Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1+
plugins {
2+
id 'java'
3+
id 'elasticsearch.build'
4+
}
5+
6+
ext.licenseFile = file("$buildDir/dummy/license")
7+
ext.noticeFile = file("$buildDir/dummy/notice")
8+
19
subprojects {
210
apply plugin: 'java'
311
apply plugin: 'elasticsearch.build'
412

5-
repositories {
6-
jcenter()
7-
repositories {
8-
maven {
9-
url System.getProperty("local.repo.path")
10-
}
11-
}
12-
}
13-
14-
unitTest.enabled = false
15-
dependenciesInfo.enabled = false
16-
forbiddenApisMain.enabled = false
17-
forbiddenApisTest.enabled = false
18-
thirdPartyAudit.enabled = false
13+
ext.licenseFile = file("$buildDir/dummy/license")
14+
ext.noticeFile = file("$buildDir/dummy/notice")
1915
}

buildSrc/src/testKit/licenses/dependencies_missing/licenses/.gitignore

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7a4d00d5ec5febd252a6182e8b6e87a0a9821f81
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include 'no_dependencies_and_no_folder'
22
include 'no_dependencies_with_folder'
33
include 'dependencies_ok'
4-
include 'dependencies_missing'
5-
include 'dependencies_too_much'
4+
include 'dependencies_too_much'
5+
include 'sha_missing'
6+
include 'license_missing'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies {
2+
compile "com.ibm.icu:icu4j:62.1"
3+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
ICU License - ICU 1.8.1 and later
2+
3+
COPYRIGHT AND PERMISSION NOTICE
4+
5+
Copyright (c) 1995-2012 International Business Machines Corporation and others
6+
7+
All rights reserved.
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, and/or sell copies of the
13+
Software, and to permit persons to whom the Software is furnished to do so,
14+
provided that the above copyright notice(s) and this permission notice appear
15+
in all copies of the Software and that both the above copyright notice(s) and
16+
this permission notice appear in supporting documentation.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
21+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE
22+
LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR
23+
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
24+
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
25+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26+
27+
Except as contained in this notice, the name of a copyright holder shall not
28+
be used in advertising or otherwise to promote the sale, use or other
29+
dealings in this Software without prior written authorization of the
30+
copyright holder.
31+
32+
All trademarks and registered trademarks mentioned herein are the property of
33+
their respective owners.

0 commit comments

Comments
 (0)