Apache Solr open-source search software
SOLR-14763: Remove "testAsyncAndCancel"
jdyer10a96a032843b
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.javaindex c1c2580e7a5..a8831fd4842 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java@@ -18,7 +18,6 @@package org.apache.solr.client.solrj.impl;import java.io.IOException;-import java.io.InputStream;import java.nio.charset.StandardCharsets;import java.util.Base64;import java.util.HashMap;@@ -32,7 +31,6 @@ import org.apache.solr.client.solrj.request.QueryRequest;import org.apache.solr.client.solrj.request.RequestWriter;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.MapSolrParams;-import org.apache.solr.common.util.NamedList;import org.eclipse.jetty.client.WWWAuthenticationProtocolHandler;import org.eclipse.jetty.http.HttpStatus;import org.eclipse.jetty.util.ssl.SslContextFactory;@@ -280,54 +278,6 @@ public class Http2SolrClientTest extends HttpSolrClientTestBase {super.testAsyncExceptionBase();}- @Test- public void testAsyncAndCancel() throws Exception {- String url = getBaseUrl() + DEBUG_SERVLET_PATH;- Http2SolrClient.Builder b =- new Http2SolrClient.Builder(url)- .withConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)- .withResponseParser(new XMLResponseParser());- try (PausableHttp2SolrClient client = new PausableHttp2SolrClient(url, b)) {- super.testAsyncAndCancel(client);- }- }-- public static class PausableHttp2SolrClient extends Http2SolrClient- implements PauseableHttpSolrClient {-- protected PausableHttp2SolrClient(String serverBaseUrl, Builder builder) {- super(serverBaseUrl, builder);- }-- @Override- protected NamedList<Object> processErrorsAndResponse(- int httpStatus,- String responseReason,- String responseMethod,- ResponseParser processor,- InputStream is,- String mimeType,- String encoding,- boolean isV2Api,- String urlExceptionMessage)- throws SolrServerException {- pause();- var nl =- super.processErrorsAndResponse(- httpStatus,- responseReason,- responseMethod,- processor,- is,- mimeType,- encoding,- isV2Api,- urlExceptionMessage);- unPause();- return nl;- }- }-@Testpublic void testFollowRedirect() throws Exception {final String clientUrl = getBaseUrl() + REDIRECT_SERVLET_PATH;diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.javaindex e5af5bd5f52..789ff090dd1 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java@@ -18,7 +18,6 @@package org.apache.solr.client.solrj.impl;import java.io.IOException;-import java.io.InputStream;import java.net.CookieHandler;import java.net.CookieManager;import java.net.Socket;@@ -48,7 +47,6 @@ import org.apache.solr.client.solrj.response.SolrPingResponse;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.common.util.ExecutorUtil;-import org.apache.solr.common.util.NamedList;import org.apache.solr.util.SSLTestConfig;import org.junit.After;import org.junit.BeforeClass;@@ -209,52 +207,6 @@ public class HttpJdkSolrClientTest extends HttpSolrClientTestBase {super.testAsyncExceptionBase();}- @Test- public void testAsyncAndCancel() throws Exception {- String url = getBaseUrl() + DEBUG_SERVLET_PATH;- HttpJdkSolrClient.Builder b =- new HttpJdkSolrClient.Builder(url).withResponseParser(new XMLResponseParser());- try (PausableHttpJdkSolrClient client = new PausableHttpJdkSolrClient(url, b)) {- super.testAsyncAndCancel(client);- }- }-- public static class PausableHttpJdkSolrClient extends HttpJdkSolrClient- implements PauseableHttpSolrClient {-- protected PausableHttpJdkSolrClient(String serverBaseUrl, Builder builder) {- super(serverBaseUrl, builder);- }-- @Override- protected NamedList<Object> processErrorsAndResponse(- int httpStatus,- String responseReason,- String responseMethod,- ResponseParser processor,- InputStream is,- String mimeType,- String encoding,- boolean isV2Api,- String urlExceptionMessage)- throws SolrServerException {- pause();- var nl =- super.processErrorsAndResponse(- httpStatus,- responseReason,- responseMethod,- processor,- is,- mimeType,- encoding,- isV2Api,- urlExceptionMessage);- unPause();- return nl;- }- }-@Testpublic void testTimeout() throws Exception {SolrQuery q = new SolrQuery("*:*");diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.javaindex 977275f5ea8..2c8caec0fdf 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java@@ -648,28 +648,4 @@ public abstract class HttpSolrClientTestBase extends SolrJettyTestBase {assertTrue(ee.getMessage(), ee.getMessage().contains("mime type"));}}-- protected void testAsyncAndCancel(PauseableHttpSolrClient client) throws Exception {- DebugServlet.clear();- DebugServlet.addResponseHeader("Content-Type", "application/xml; charset=UTF-8");- DebugServlet.responseBodyByQueryFragment.put(- "", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response />");-- QueryRequest query = new QueryRequest(new MapSolrParams(Collections.singletonMap("id", "1")));-- // We are using a version of the class under test that will wait for us before processing the- // response.- // This way we can ensure our test will always cancel the request before it finishes.- client.pause();-- // Make the request then immediately cancel it!- CompletableFuture<NamedList<Object>> future = client.requestAsync(query, "collection1");- future.cancel(true);-- // We are safe to unpause our client, having guaranteed that our cancel was before everything- // completed.- client.unPause();-- assertTrue(future.isCancelled());- }}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/PauseableHttpSolrClient.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/PauseableHttpSolrClient.javadeleted file mode 100644index 09a479427e0..00000000000--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/PauseableHttpSolrClient.java+++ /dev/null@@ -1,43 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.solr.client.solrj.impl;--import java.util.concurrent.CompletableFuture;-import java.util.concurrent.Semaphore;-import org.apache.solr.client.solrj.SolrRequest;-import org.apache.solr.common.util.NamedList;--public interface PauseableHttpSolrClient {-- Semaphore wait = new Semaphore(1);-- public default void pause() {- try {- wait.acquire();- } catch (InterruptedException ie) {- Thread.currentThread().interrupt();- }- }-- public default void unPause() {- wait.release();- }-- public CompletableFuture<NamedList<Object>> requestAsync(- final SolrRequest<?> solrRequest, String collection);-}