This is an automated email from the ASF dual-hosted git repository.

jhyde pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite-avatica.git

commit 796523376fe8df3bcaf508475406854150ff96fd
Author: Istvan Toth <st...@cloudera.com>
AuthorDate: Tue Apr 5 15:26:29 2022 -0400

    [CALCITE-4971] Update httpclient and httpcore to latest 5.1 release
    
    Update mockito to 4.4.0, to try to fix JDK14 tests.
    
    Give more time for the connection to time out from the cache during test.
    
    Closes #174
    
    Signed-off-by: Josh Elser <els...@apache.org>
---
 bom/build.gradle.kts                               |  5 +-
 core/build.gradle.kts                              |  5 +-
 .../remote/AvaticaCommonsHttpClientImpl.java       | 97 ++++++++++++----------
 .../remote/AvaticaHttpClientFactoryImpl.java       |  2 +-
 .../avatica/remote/CommonsHttpClientPoolCache.java | 24 +++---
 .../avatica/remote/HttpClientPoolConfigurable.java |  2 +-
 .../remote/AvaticaCommonsHttpClientImplTest.java   | 44 +++++-----
 gradle.properties                                  |  6 +-
 server/build.gradle.kts                            |  2 +-
 .../avatica/remote/ConnectionPropertiesTest.java   |  4 +-
 .../server/AvaticaSpnegoAuthenticatorTest.java     |  6 +-
 .../server/HttpServerSpnegoWithoutJaasTest.java    |  2 +-
 12 files changed, 101 insertions(+), 98 deletions(-)

diff --git a/bom/build.gradle.kts b/bom/build.gradle.kts
index c83801ce3..294af9560 100644
--- a/bom/build.gradle.kts
+++ b/bom/build.gradle.kts
@@ -56,8 +56,8 @@ dependencies {
         apiv("javax.servlet:javax.servlet-api", "servlet")
         apiv("junit:junit")
         apiv("net.hydromatic:scott-data-hsqldb")
-        apiv("org.apache.httpcomponents:httpclient")
-        apiv("org.apache.httpcomponents:httpcore")
+        apiv("org.apache.httpcomponents.client5:httpclient5")
+        apiv("org.apache.httpcomponents.core5:httpcore5")
         apiv("org.apache.kerby:kerb-client", "kerby")
         apiv("org.apache.kerby:kerb-core", "kerby")
         apiv("org.apache.kerby:kerb-simplekdc", "kerby")
@@ -70,6 +70,7 @@ dependencies {
         apiv("org.hamcrest:hamcrest-core", "hamcrest")
         apiv("org.hsqldb:hsqldb")
         apiv("org.mockito:mockito-core", "mockito")
+        apiv("org.mockito:mockito-inline", "mockito")
         apiv("org.ow2.asm:asm")
         apiv("org.ow2.asm:asm-all", "asm")
         apiv("org.ow2.asm:asm-analysis", "asm")
diff --git a/core/build.gradle.kts b/core/build.gradle.kts
index 607dfe99d..e1ea37d40 100644
--- a/core/build.gradle.kts
+++ b/core/build.gradle.kts
@@ -35,11 +35,12 @@ dependencies {
     api("com.fasterxml.jackson.core:jackson-databind")
     api("com.google.protobuf:protobuf-java")
     implementation("com.fasterxml.jackson.core:jackson-core")
-    implementation("org.apache.httpcomponents:httpclient")
-    implementation("org.apache.httpcomponents:httpcore")
+    implementation("org.apache.httpcomponents.client5:httpclient5")
+    implementation("org.apache.httpcomponents.core5:httpcore5")
     implementation("org.slf4j:slf4j-api")
     testImplementation("junit:junit")
     testImplementation("org.mockito:mockito-core")
+    testImplementation("org.mockito:mockito-inline")
     testImplementation("org.hamcrest:hamcrest-core")
     testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
 }
diff --git 
a/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java
 
b/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java
index d44682e8b..66b7ca8fc 100644
--- 
a/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java
+++ 
b/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImpl.java
@@ -16,34 +16,35 @@
  */
 package org.apache.calcite.avatica.remote;
 
-import org.apache.http.HttpHost;
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.KerberosCredentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.impl.auth.BasicSchemeFactory;
-import org.apache.http.impl.auth.DigestSchemeFactory;
-import org.apache.http.impl.auth.SPNegoSchemeFactory;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.client5.http.ClientProtocolException;
+import org.apache.hc.client5.http.SystemDefaultDnsResolver;
+import org.apache.hc.client5.http.auth.AuthSchemeFactory;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.CredentialsProvider;
+import org.apache.hc.client5.http.auth.KerberosConfig;
+import org.apache.hc.client5.http.auth.KerberosCredentials;
+import org.apache.hc.client5.http.auth.StandardAuthScheme;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
+import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
+import org.apache.hc.client5.http.impl.auth.BasicSchemeFactory;
+import org.apache.hc.client5.http.impl.auth.DigestSchemeFactory;
+import org.apache.hc.client5.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.NoHttpResponseException;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
 
 import org.ietf.jgss.GSSCredential;
 import org.slf4j.Logger;
@@ -69,8 +70,12 @@ public class AvaticaCommonsHttpClientImpl implements 
AvaticaHttpClient, HttpClie
   private static final boolean USE_CANONICAL_HOSTNAME = Boolean
       
.parseBoolean(System.getProperty("avatica.http.spnego.use_canonical_hostname", 
"true"));
   private static final boolean STRIP_PORT_ON_SERVER_LOOKUP = true;
+  private static final KerberosConfig KERBEROS_CONFIG =
+          KerberosConfig.custom().setStripPort(STRIP_PORT_ON_SERVER_LOOKUP)
+          .setUseCanonicalHostname(USE_CANONICAL_HOSTNAME)
+          .build();
+  private static AuthScope anyAuthScope = new AuthScope(null, -1);
 
-  protected final HttpHost host;
   protected final URI uri;
   protected BasicAuthCache authCache;
   protected CloseableHttpClient client;
@@ -79,11 +84,10 @@ public class AvaticaCommonsHttpClientImpl implements 
AvaticaHttpClient, HttpClie
 
   protected UsernamePasswordCredentials credentials = null;
   protected CredentialsProvider credentialsProvider = null;
-  protected Lookup<AuthSchemeProvider> authRegistry = null;
+  protected Lookup<AuthSchemeFactory> authRegistry = null;
   protected Object userToken;
 
   public AvaticaCommonsHttpClientImpl(URL url) {
-    this.host = new HttpHost(url.getHost(), url.getPort(), url.getProtocol());
     this.uri = toURI(Objects.requireNonNull(url));
   }
 
@@ -98,8 +102,6 @@ public class AvaticaCommonsHttpClientImpl implements 
AvaticaHttpClient, HttpClie
     while (true) {
       HttpClientContext context = HttpClientContext.create();
 
-      context.setTargetHost(host);
-
       // Set the credentials if they were provided.
       if (null != this.credentialsProvider) {
         context.setCredentialsProvider(credentialsProvider);
@@ -118,7 +120,7 @@ public class AvaticaCommonsHttpClientImpl implements 
AvaticaHttpClient, HttpClie
       post.setEntity(entity);
 
       try (CloseableHttpResponse response = execute(post, context)) {
-        final int statusCode = response.getStatusLine().getStatusCode();
+        final int statusCode = response.getCode();
         if (HttpURLConnection.HTTP_OK == statusCode
             || HttpURLConnection.HTTP_INTERNAL_ERROR == statusCode) {
           userToken = context.getUserToken();
@@ -152,18 +154,18 @@ public class AvaticaCommonsHttpClientImpl implements 
AvaticaHttpClient, HttpClie
   @Override public void setUsernamePassword(AuthenticationType authType, 
String username,
       String password) {
     this.credentials = new 
UsernamePasswordCredentials(Objects.requireNonNull(username),
-        Objects.requireNonNull(password));
+        Objects.requireNonNull(password).toCharArray());
 
     this.credentialsProvider = new BasicCredentialsProvider();
-    credentialsProvider.setCredentials(AuthScope.ANY, credentials);
+    ((BasicCredentialsProvider) 
credentialsProvider).setCredentials(anyAuthScope, credentials);
 
-    RegistryBuilder<AuthSchemeProvider> authRegistryBuilder = 
RegistryBuilder.create();
+    RegistryBuilder<AuthSchemeFactory> authRegistryBuilder = 
RegistryBuilder.create();
     switch (authType) {
     case BASIC:
-      authRegistryBuilder.register(AuthSchemes.BASIC, new 
BasicSchemeFactory());
+      authRegistryBuilder.register(StandardAuthScheme.BASIC, new 
BasicSchemeFactory());
       break;
     case DIGEST:
-      authRegistryBuilder.register(AuthSchemes.DIGEST, new 
DigestSchemeFactory());
+      authRegistryBuilder.register(StandardAuthScheme.DIGEST, new 
DigestSchemeFactory());
       break;
     default:
       throw new IllegalArgumentException("Unsupported authentiation type: " + 
authType);
@@ -171,21 +173,24 @@ public class AvaticaCommonsHttpClientImpl implements 
AvaticaHttpClient, HttpClie
     this.authRegistry = authRegistryBuilder.build();
   }
 
-  public void setGSSCredential(GSSCredential credential) {
-    this.authRegistry = RegistryBuilder.<AuthSchemeProvider>create()
-        .register(AuthSchemes.SPNEGO,
-            new SPNegoSchemeFactory(STRIP_PORT_ON_SERVER_LOOKUP, 
USE_CANONICAL_HOSTNAME))
+  @Override public void setGSSCredential(GSSCredential credential) {
+
+    this.authRegistry = RegistryBuilder.<AuthSchemeFactory>create()
+        .register(StandardAuthScheme.SPNEGO,
+                new SPNegoSchemeFactory(KERBEROS_CONFIG, 
SystemDefaultDnsResolver.INSTANCE))
         .build();
 
     this.credentialsProvider = new BasicCredentialsProvider();
     if (null != credential) {
       // Non-null credential should be used directly with KerberosCredentials.
       // This is never set by the JDBC driver, nor the tests
-      this.credentialsProvider.setCredentials(AuthScope.ANY, new 
KerberosCredentials(credential));
+      ((BasicCredentialsProvider) this.credentialsProvider)
+              .setCredentials(anyAuthScope, new 
KerberosCredentials(credential));
     } else {
       // A null credential implies that the user is logged in via JAAS using 
the
       // java.security.auth.login.config system property
-      this.credentialsProvider.setCredentials(AuthScope.ANY, 
EmptyCredentials.INSTANCE);
+      ((BasicCredentialsProvider) this.credentialsProvider)
+              .setCredentials(anyAuthScope, EmptyCredentials.INSTANCE);
     }
   }
 
@@ -195,7 +200,7 @@ public class AvaticaCommonsHttpClientImpl implements 
AvaticaHttpClient, HttpClie
   private static class EmptyCredentials implements Credentials {
     public static final EmptyCredentials INSTANCE = new EmptyCredentials();
 
-    @Override public String getPassword() {
+    @Override public char[] getPassword() {
       return null;
     }
 
diff --git 
a/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClientFactoryImpl.java
 
b/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClientFactoryImpl.java
index d3cf8494f..420da0e63 100644
--- 
a/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClientFactoryImpl.java
+++ 
b/core/src/main/java/org/apache/calcite/avatica/remote/AvaticaHttpClientFactoryImpl.java
@@ -18,7 +18,7 @@ package org.apache.calcite.avatica.remote;
 
 import org.apache.calcite.avatica.ConnectionConfig;
 
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
diff --git 
a/core/src/main/java/org/apache/calcite/avatica/remote/CommonsHttpClientPoolCache.java
 
b/core/src/main/java/org/apache/calcite/avatica/remote/CommonsHttpClientPoolCache.java
index 504bebbf7..22139296e 100644
--- 
a/core/src/main/java/org/apache/calcite/avatica/remote/CommonsHttpClientPoolCache.java
+++ 
b/core/src/main/java/org/apache/calcite/avatica/remote/CommonsHttpClientPoolCache.java
@@ -19,15 +19,16 @@ package org.apache.calcite.avatica.remote;
 import org.apache.calcite.avatica.ConnectionConfig;
 import 
org.apache.calcite.avatica.remote.HostnameVerificationConfigurable.HostnameVerification;
 
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.ssl.SSLContextBuilder;
-import org.apache.http.ssl.SSLContexts;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.client5.http.ssl.HttpsSupport;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
+import org.apache.hc.core5.ssl.SSLContexts;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -145,14 +146,13 @@ public class CommonsHttpClientPoolCache {
    */
   private static HostnameVerifier getHostnameVerifier(HostnameVerification 
verification) {
     // Normally, the configuration logic would give us a default of STRICT if 
it was
-    // not
-    // provided by the user. It's easy for us to do a double-check.
+    // not provided by the user. It's easy for us to do a double-check.
     if (verification == null) {
       verification = HostnameVerification.STRICT;
     }
     switch (verification) {
     case STRICT:
-      return SSLConnectionSocketFactory.getDefaultHostnameVerifier();
+      return HttpsSupport.getDefaultHostnameVerifier();
     case NONE:
       return NoopHostnameVerifier.INSTANCE;
     default:
diff --git 
a/core/src/main/java/org/apache/calcite/avatica/remote/HttpClientPoolConfigurable.java
 
b/core/src/main/java/org/apache/calcite/avatica/remote/HttpClientPoolConfigurable.java
index 2d074be13..7bdf24ea7 100644
--- 
a/core/src/main/java/org/apache/calcite/avatica/remote/HttpClientPoolConfigurable.java
+++ 
b/core/src/main/java/org/apache/calcite/avatica/remote/HttpClientPoolConfigurable.java
@@ -16,7 +16,7 @@
  */
 package org.apache.calcite.avatica.remote;
 
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
 
 /**
  * Allows a http connection pool to be provided to enable TLS authentication.
diff --git 
a/core/src/test/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImplTest.java
 
b/core/src/test/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImplTest.java
index e95c74137..8b2a34b36 100644
--- 
a/core/src/test/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImplTest.java
+++ 
b/core/src/test/java/org/apache/calcite/avatica/remote/AvaticaCommonsHttpClientImplTest.java
@@ -16,22 +16,24 @@
  */
 package org.apache.calcite.avatica.remote;
 
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.StatusLine;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.entity.StringEntity;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.core5.http.NoHttpResponseException;
+import org.apache.hc.core5.http.io.entity.StringEntity;
 
 import org.junit.Test;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
 import java.net.HttpURLConnection;
+import java.net.URL;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
@@ -45,8 +47,6 @@ public class AvaticaCommonsHttpClientImplTest {
     final byte[] requestBytes = "fake_request".getBytes(UTF_8);
     final CloseableHttpResponse badResponse = 
mock(CloseableHttpResponse.class);
     final CloseableHttpResponse goodResponse = 
mock(CloseableHttpResponse.class);
-    final StatusLine badStatusLine = mock(StatusLine.class);
-    final StatusLine goodStatusLine = mock(StatusLine.class);
     final StringEntity responseEntity = new StringEntity("success");
     final Answer<CloseableHttpResponse> failThenSucceed = new 
Answer<CloseableHttpResponse>() {
       private int iteration = 0;
@@ -60,16 +60,15 @@ public class AvaticaCommonsHttpClientImplTest {
       }
     };
 
-    final AvaticaCommonsHttpClientImpl client = 
mock(AvaticaCommonsHttpClientImpl.class);
+    final AvaticaCommonsHttpClientImpl client =
+            spy(new AvaticaCommonsHttpClientImpl(new URL("http://127.0.0.1";)));
 
-    when(client.send(any(byte[].class))).thenCallRealMethod();
-    when(client.execute(any(HttpPost.class), 
any(HttpClientContext.class))).then(failThenSucceed);
+    doAnswer(failThenSucceed).when(client)
+            .execute(any(HttpPost.class), any(HttpClientContext.class));
 
-    when(badResponse.getStatusLine()).thenReturn(badStatusLine);
-    
when(badStatusLine.getStatusCode()).thenReturn(HttpURLConnection.HTTP_UNAVAILABLE);
+    when(badResponse.getCode()).thenReturn(HttpURLConnection.HTTP_UNAVAILABLE);
 
-    when(goodResponse.getStatusLine()).thenReturn(goodStatusLine);
-    when(goodStatusLine.getStatusCode()).thenReturn(HttpURLConnection.HTTP_OK);
+    when(goodResponse.getCode()).thenReturn(HttpURLConnection.HTTP_OK);
     when(goodResponse.getEntity()).thenReturn(responseEntity);
 
     byte[] responseBytes = client.send(requestBytes);
@@ -80,8 +79,6 @@ public class AvaticaCommonsHttpClientImplTest {
     final byte[] requestBytes = "fake_request".getBytes(UTF_8);
     final CloseableHttpResponse badResponse = 
mock(CloseableHttpResponse.class);
     final CloseableHttpResponse goodResponse = 
mock(CloseableHttpResponse.class);
-    final StatusLine badStatusLine = mock(StatusLine.class);
-    final StatusLine goodStatusLine = mock(StatusLine.class);
     final StringEntity responseEntity = new StringEntity("success");
     final Answer<CloseableHttpResponse> failThenSucceed = new 
Answer<CloseableHttpResponse>() {
       private int iteration = 0;
@@ -95,16 +92,15 @@ public class AvaticaCommonsHttpClientImplTest {
       }
     };
 
-    final AvaticaCommonsHttpClientImpl client = 
mock(AvaticaCommonsHttpClientImpl.class);
+    final AvaticaCommonsHttpClientImpl client =
+            spy(new AvaticaCommonsHttpClientImpl(new URL("http://127.0.0.1";)));
 
-    when(client.send(any(byte[].class))).thenCallRealMethod();
-    when(client.execute(any(HttpPost.class), 
any(HttpClientContext.class))).then(failThenSucceed);
+    doAnswer(failThenSucceed).when(client)
+            .execute(any(HttpPost.class), any(HttpClientContext.class));
 
-    when(badResponse.getStatusLine()).thenReturn(badStatusLine);
-    
when(badStatusLine.getStatusCode()).thenReturn(HttpURLConnection.HTTP_UNAVAILABLE);
+    when(badResponse.getCode()).thenReturn(HttpURLConnection.HTTP_UNAVAILABLE);
 
-    when(goodResponse.getStatusLine()).thenReturn(goodStatusLine);
-    when(goodStatusLine.getStatusCode()).thenReturn(HttpURLConnection.HTTP_OK);
+    when(goodResponse.getCode()).thenReturn(HttpURLConnection.HTTP_OK);
     when(goodResponse.getEntity()).thenReturn(responseEntity);
 
     byte[] responseBytes = client.send(requestBytes);
diff --git a/gradle.properties b/gradle.properties
index 81c319986..a1dbc1b42 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -64,8 +64,8 @@ guava.version=31.0.1-jre
 hamcrest.version=1.3
 hsqldb.version=2.4.1
 h2.version=1.4.197
-httpclient.version=4.5.9
-httpcore.version=4.4.11
+httpclient5.version=5.1.3
+httpcore5.version=5.1.3
 jackson.version=2.10.0
 jcip-annotations.version=1.0-1
 jcommander.version=1.72
@@ -73,7 +73,7 @@ jetty.version=9.4.44.v20210927
 junit.version=4.12
 kerby.version=1.1.1
 log4j2.version=2.17.1
-mockito.version=2.23.4
+mockito.version=4.4.0
 protobuf.version=3.17.1
 scott-data-hsqldb.version=0.1
 servlet.version=4.0.1
diff --git a/server/build.gradle.kts b/server/build.gradle.kts
index cc628fe71..180678252 100644
--- a/server/build.gradle.kts
+++ b/server/build.gradle.kts
@@ -45,7 +45,7 @@ dependencies {
     testImplementation("org.bouncycastle:bcprov-jdk15on")
     testImplementation("org.hamcrest:hamcrest-core")
     testImplementation("org.mockito:mockito-core")
-    testImplementation("org.apache.httpcomponents:httpclient")
+    testImplementation("org.apache.httpcomponents.client5:httpclient5")
     testRuntimeOnly("org.hsqldb:hsqldb")
     testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
 }
diff --git 
a/server/src/test/java/org/apache/calcite/avatica/remote/ConnectionPropertiesTest.java
 
b/server/src/test/java/org/apache/calcite/avatica/remote/ConnectionPropertiesTest.java
index 515c8b970..f517d0cb3 100644
--- 
a/server/src/test/java/org/apache/calcite/avatica/remote/ConnectionPropertiesTest.java
+++ 
b/server/src/test/java/org/apache/calcite/avatica/remote/ConnectionPropertiesTest.java
@@ -91,7 +91,7 @@ public class ConnectionPropertiesTest {
               Connection.TRANSACTION_REPEATABLE_READ);
 
       // after 1s, remote connection expired and reopen
-      Thread.sleep(1000);
+      Thread.sleep(10000);
 
       conn.createStatement();
       Connection remoteConn1 = getConnection(
@@ -123,7 +123,7 @@ public class ConnectionPropertiesTest {
               Connection.TRANSACTION_REPEATABLE_READ);
 
       // after 1s, remote connection expired and reopen
-      Thread.sleep(1000);
+      Thread.sleep(10000);
 
       try {
         conn.createStatement();
diff --git 
a/server/src/test/java/org/apache/calcite/avatica/server/AvaticaSpnegoAuthenticatorTest.java
 
b/server/src/test/java/org/apache/calcite/avatica/server/AvaticaSpnegoAuthenticatorTest.java
index 3005c68ae..e7fac8c04 100644
--- 
a/server/src/test/java/org/apache/calcite/avatica/server/AvaticaSpnegoAuthenticatorTest.java
+++ 
b/server/src/test/java/org/apache/calcite/avatica/server/AvaticaSpnegoAuthenticatorTest.java
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.anyInt;
 import static org.mockito.Mockito.anyLong;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 /**
@@ -61,8 +61,8 @@ public class AvaticaSpnegoAuthenticatorTest {
         Authentication.SEND_FAILURE, Authentication.SEND_SUCCESS);
     for (Authentication auth : authsNotRequiringUpdate) {
       assertEquals(auth, authenticator.sendChallengeIfNecessary(auth, request, 
response));
-      verifyZeroInteractions(request);
-      verifyZeroInteractions(response);
+      verifyNoMoreInteractions(request);
+      verifyNoMoreInteractions(response);
     }
   }
 
diff --git 
a/server/src/test/java/org/apache/calcite/avatica/server/HttpServerSpnegoWithoutJaasTest.java
 
b/server/src/test/java/org/apache/calcite/avatica/server/HttpServerSpnegoWithoutJaasTest.java
index 2f01f6bbb..025e2046f 100644
--- 
a/server/src/test/java/org/apache/calcite/avatica/server/HttpServerSpnegoWithoutJaasTest.java
+++ 
b/server/src/test/java/org/apache/calcite/avatica/server/HttpServerSpnegoWithoutJaasTest.java
@@ -22,7 +22,7 @@ import org.apache.calcite.avatica.SpnegoTestUtil;
 import org.apache.calcite.avatica.remote.AvaticaCommonsHttpClientImpl;
 import org.apache.calcite.avatica.remote.CommonsHttpClientPoolCache;
 
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.client.KrbConfig;
 import org.apache.kerby.kerberos.kerb.client.KrbConfigKey;

Reply via email to