Skip to content

Commit 902cd4e

Browse files
authored
Merge pull request #1818 from marklogic/feature/java17
MLE-23032 Bumping to Java 17 and OkHttp 5
2 parents 0eb5f56 + 7c377fd commit 902cd4e

File tree

8 files changed

+40
-32
lines changed

8 files changed

+40
-32
lines changed

Jenkinsfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
@Library('shared-libraries') _
22

33
def getJava(){
4-
if(env.JAVA_VERSION=="JAVA17"){
5-
return "/home/builder/java/jdk-17.0.2"
6-
}else if(env.JAVA_VERSION=="JAVA11"){
7-
return "/home/builder/java/jdk-11.0.2"
8-
}else if(env.JAVA_VERSION=="JAVA21"){
4+
if (env.JAVA_VERSION == "JAVA21") {
95
return "/home/builder/java/jdk-21.0.1"
10-
}else{
11-
return "/home/builder/java/openjdk-1.8.0-262"
6+
} else {
7+
return "/home/builder/java/jdk-17.0.2"
128
}
139
}
1410

@@ -26,6 +22,7 @@ def setupDockerMarkLogic(String image){
2622
MARKLOGIC_IMAGE='''+image+''' MARKLOGIC_LOGS_VOLUME=marklogicLogs docker compose up -d --build
2723
echo "Waiting for MarkLogic server to initialize."
2824
sleep 60s
25+
export JAVA_HOME=$JAVA_HOME_DIR
2926
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
3027
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
3128
./gradlew mlTestConnections

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ subprojects {
2323
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
2424
}
2525

26-
// To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8.
2726
java {
28-
sourceCompatibility = 1.8
29-
targetCompatibility = 1.8
27+
toolchain {
28+
languageVersion = JavaLanguageVersion.of(17)
29+
}
3030
}
3131

3232
configurations {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=com.marklogic
2-
version=7.3-SNAPSHOT
2+
version=8.0-SNAPSHOT
33
describedName=MarkLogic Java Client API
44
publishUrl=file:../marklogic-java/releases
55

marklogic-client-api-functionaltests/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies {
1919
testImplementation 'org.skyscreamer:jsonassert:1.5.3'
2020
testImplementation 'org.slf4j:slf4j-api:2.0.17'
2121
testImplementation 'commons-io:commons-io:2.17.0'
22-
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
22+
testImplementation 'com.squareup.okhttp3:okhttp:5.1.0'
2323
testImplementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
2424
testImplementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
2525
testImplementation "org.jdom:jdom2:2.0.6.1"
@@ -32,7 +32,7 @@ dependencies {
3232
exclude module: "commons-lang3"
3333
}
3434

35-
testImplementation 'ch.qos.logback:logback-classic:1.3.15'
35+
testImplementation 'ch.qos.logback:logback-classic:1.5.18'
3636
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
3737
testImplementation 'org.xmlunit:xmlunit-legacy:2.10.0'
3838

marklogic-client-api/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ dependencies {
1818
api "jakarta.xml.bind:jakarta.xml.bind-api:3.0.1"
1919
implementation "org.glassfish.jaxb:jaxb-runtime:3.0.2"
2020

21-
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
22-
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
23-
implementation 'io.github.rburgst:okhttp-digest:2.7'
21+
implementation 'com.squareup.okhttp3:okhttp:5.1.0'
22+
implementation 'com.squareup.okhttp3:logging-interceptor:5.1.0'
23+
implementation 'io.github.rburgst:okhttp-digest:3.1.1'
2424

2525
// We tried upgrading to the org.eclipse.angus:angus-mail dependency, but we ran into significant performance issues
2626
// with using the Java Client eval call in our Spark connector. Example - an eval() call for getting 50k URIs would
@@ -57,10 +57,10 @@ dependencies {
5757
// Starting with mockito 5.x, Java 11 is required, so sticking with 4.x as we have to support Java 8.
5858
testImplementation "org.mockito:mockito-core:4.11.0"
5959
testImplementation "org.mockito:mockito-inline:4.11.0"
60-
testImplementation "com.squareup.okhttp3:mockwebserver:4.12.0"
60+
testImplementation "com.squareup.okhttp3:mockwebserver3:5.1.0"
6161

6262
testImplementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jacksonVersion}"
63-
testImplementation 'ch.qos.logback:logback-classic:1.3.15'
63+
testImplementation 'ch.qos.logback:logback-classic:1.5.18'
6464

6565
// Using this to avoid a schema validation issue with the regular xercesImpl
6666
testImplementation 'org.opengis.cite.xerces:xercesImpl-xsd11:2.12-beta-r1667115'

marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/OAuthAuthenticationConfigurerTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@
44
package com.marklogic.client.impl.okhttp;
55

66
import com.marklogic.client.DatabaseClientFactory;
7+
import mockwebserver3.MockWebServer;
78
import okhttp3.Request;
8-
import okhttp3.mockwebserver.MockWebServer;
99
import org.junit.jupiter.api.Test;
1010

1111
import static org.junit.jupiter.api.Assertions.assertEquals;
1212

13-
public class OAuthAuthenticationConfigurerTest {
13+
class OAuthAuthenticationConfigurerTest {
1414

1515
@Test
16-
void test() {
17-
DatabaseClientFactory.OAuthContext authContext = new DatabaseClientFactory.OAuthContext("abc123");
18-
Request request = new Request.Builder().url(new MockWebServer().url("/url-doesnt-matter")).build();
16+
void test() throws Exception {
17+
try (MockWebServer server = new MockWebServer()) {
18+
server.start();
19+
Request request = new Request.Builder().url(server.url("/url-doesnt-matter")).build();
1920

20-
Request authenticatedRequest = new OAuthAuthenticationConfigurer().makeAuthenticatedRequest(request, authContext);
21-
assertEquals("Bearer abc123", authenticatedRequest.header("Authorization"));
21+
DatabaseClientFactory.OAuthContext authContext = new DatabaseClientFactory.OAuthContext("abc123");
22+
Request authenticatedRequest = new OAuthAuthenticationConfigurer().makeAuthenticatedRequest(request, authContext);
23+
assertEquals("Bearer abc123", authenticatedRequest.header("Authorization"));
24+
}
2225
}
2326
}

marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/TokenAuthenticationInterceptorTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
package com.marklogic.client.impl.okhttp;
55

66
import com.marklogic.client.ext.helper.LoggingObject;
7+
import mockwebserver3.MockResponse;
8+
import mockwebserver3.MockWebServer;
79
import okhttp3.OkHttpClient;
810
import okhttp3.Request;
9-
import okhttp3.mockwebserver.MockResponse;
10-
import okhttp3.mockwebserver.MockWebServer;
11+
import org.junit.jupiter.api.AfterEach;
1112
import org.junit.jupiter.api.BeforeEach;
1213
import org.junit.jupiter.api.Test;
1314

@@ -23,15 +24,17 @@
2324
* Uses OkHttp's MockWebServer to completely mock a MarkLogic instance so that we can control what response codes are
2425
* returned and processed by TokenAuthenticationInterceptor.
2526
*/
26-
public class TokenAuthenticationInterceptorTest extends LoggingObject {
27+
class TokenAuthenticationInterceptorTest extends LoggingObject {
2728

2829
private MockWebServer mockWebServer;
2930
private FakeTokenGenerator fakeTokenGenerator;
3031
private OkHttpClient okHttpClient;
3132

3233
@BeforeEach
33-
void beforeEach() {
34+
void beforeEach() throws IOException {
3435
mockWebServer = new MockWebServer();
36+
mockWebServer.start();
37+
3538
fakeTokenGenerator = new FakeTokenGenerator();
3639

3740
ProgressDataCloudAuthenticationConfigurer.TokenAuthenticationInterceptor interceptor =
@@ -43,6 +46,11 @@ void beforeEach() {
4346
okHttpClient = new OkHttpClient.Builder().addInterceptor(interceptor).build();
4447
}
4548

49+
@AfterEach
50+
void tearDown() {
51+
mockWebServer.close();
52+
}
53+
4654
@Test
4755
void receive401() {
4856
enqueueResponseCodes(200, 200, 401, 200);
@@ -110,7 +118,7 @@ void multipleThreads() throws Exception {
110118
*/
111119
private void enqueueResponseCodes(int... codes) {
112120
for (int code : codes) {
113-
mockWebServer.enqueue(new MockResponse().setResponseCode(code));
121+
mockWebServer.enqueue(new MockResponse.Builder().code(code).build());
114122
}
115123
}
116124

ml-development-tools/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ publishing {
7171
}
7272

7373
compileKotlin {
74-
kotlinOptions.jvmTarget = '1.8'
74+
kotlinOptions.jvmTarget = '17'
7575
}
7676
compileTestKotlin {
77-
kotlinOptions.jvmTarget = '1.8'
77+
kotlinOptions.jvmTarget = '17'
7878
}
7979

8080
tasks.register("generateTests", JavaExec) {

0 commit comments

Comments
 (0)