Skip to content

Commit eb61568

Browse files
committed
MLE-24505 Configuring custom Test tasks correctly
This avoids Gradle warnings and also gets the reverse proxy server tests working properly again.
1 parent 8ba60db commit eb61568

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
subprojects {
66
apply plugin: 'java-library'
77

8-
tasks.withType(JavaCompile) {
9-
options.encoding = 'UTF-8'
10-
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
11-
}
12-
138
java {
149
toolchain {
1510
languageVersion = JavaLanguageVersion.of(17)
@@ -32,12 +27,19 @@ subprojects {
3227
mavenCentral()
3328
}
3429

35-
test {
30+
tasks.withType(JavaCompile) {
31+
options.encoding = 'UTF-8'
32+
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
33+
}
34+
35+
tasks.withType(Test).configureEach {
3636
useJUnitPlatform()
3737
testLogging {
3838
events = ['started', 'passed', 'skipped', 'failed']
3939
exceptionFormat = 'full'
4040
}
41+
42+
// Will remove this in a future PR to determine if they're needed or not.
4143
systemProperty "file.encoding", "UTF-8"
4244
systemProperty "javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl"
4345
}

marklogic-client-api-functionaltests/build.gradle

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
* Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
33
*/
44

5-
test {
6-
// For use in testing TestDatabaseClientKerberosFromFile
7-
systemProperty "keytabFile", System.getProperty("keytabFile")
8-
systemProperty "principal", System.getProperty("principal")
9-
10-
systemProperty "TEST_USE_REVERSE_PROXY_SERVER", testUseReverseProxyServer
11-
}
12-
135
dependencies {
146
testImplementation project(':marklogic-client-api')
157
testImplementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.4"
@@ -37,20 +29,30 @@ dependencies {
3729
testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.13.4"
3830
}
3931

32+
tasks.withType(Test).configureEach {
33+
// For use in testing TestDatabaseClientKerberosFromFile
34+
systemProperty "keytabFile", System.getProperty("keytabFile")
35+
systemProperty "principal", System.getProperty("principal")
36+
37+
systemProperty "TEST_USE_REVERSE_PROXY_SERVER", testUseReverseProxyServer
38+
}
39+
4040
tasks.register("runFragileTests", Test) {
41-
useJUnitPlatform()
4241
description = "These are called 'fragile' because they'll pass when run by themselves, but when run as part of the " +
4342
"full suite, there seem to be one or more other fast functional tests that run before them and cause some of " +
4443
"their test methods to break. The Jenkinsfile thus calls these first before running the other functional " +
4544
"tests."
45+
testClassesDirs = sourceSets.test.output.classesDirs
46+
classpath = sourceSets.test.runtimeClasspath
4647
include "com/marklogic/client/fastfunctest/TestQueryOptionBuilder.class"
4748
include "com/marklogic/client/fastfunctest/TestRawCombinedQuery.class"
4849
include "com/marklogic/client/fastfunctest/TestRawStructuredQuery.class"
4950
}
5051

5152
tasks.register("runFastFunctionalTests", Test) {
52-
useJUnitPlatform()
5353
description = "Run all fast functional tests that don't setup/teardown custom app servers / databases"
54+
testClassesDirs = sourceSets.test.output.classesDirs
55+
classpath = sourceSets.test.runtimeClasspath
5456
include "com/marklogic/client/fastfunctest/**"
5557
// Exclude the "fragile" ones
5658
exclude "com/marklogic/client/fastfunctest/TestQueryOptionBuilder.class"
@@ -59,8 +61,9 @@ tasks.register("runFastFunctionalTests", Test) {
5961
}
6062

6163
tasks.register("runSlowFunctionalTests", Test) {
62-
useJUnitPlatform()
6364
description = "Run slow functional tests; i.e. those that setup/teardown custom app servers / databases"
65+
testClassesDirs = sourceSets.test.output.classesDirs
66+
classpath = sourceSets.test.runtimeClasspath
6467
include "com/marklogic/client/datamovement/functionaltests/**"
6568
include "com/marklogic/client/functionaltest/**"
6669
}

marklogic-client-api/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ dependencies {
7777
}
7878

7979
// Ensure that mlHost and mlPassword can override the defaults of localhost/admin if they've been modified
80-
test {
81-
useJUnitPlatform()
80+
tasks.withType(Test).configureEach {
8281
systemProperty "TEST_HOST", mlHost
8382
systemProperty "TEST_ADMIN_PASSWORD", mlPassword
8483
// Needed by the tests for the example programs
@@ -88,8 +87,9 @@ test {
8887
}
8988

9089
tasks.register("testRows", Test) {
91-
useJUnitPlatform()
9290
description = "Run all 'rows' tests; i.e. those exercising Optic and Optic Update functionality"
91+
testClassesDirs = sourceSets.test.output.classesDirs
92+
classpath = sourceSets.test.runtimeClasspath
9393
include "com/marklogic/client/test/rows/**"
9494
}
9595

@@ -101,8 +101,9 @@ tasks.register("debugCloudAuth", JavaExec) {
101101
}
102102

103103
tasks.register("runXmlSmokeTests", Test) {
104-
useJUnitPlatform()
105104
description = "Run a bunch of XML-related tests for smoke-testing on a particular JVM"
105+
testClassesDirs = sourceSets.test.output.classesDirs
106+
classpath = sourceSets.test.runtimeClasspath
106107
include "com/marklogic/client/test/BufferableHandleTest.class"
107108
include "com/marklogic/client/test/EvalTest.class"
108109
include "com/marklogic/client/test/HandleAsTest.class"

0 commit comments

Comments
 (0)