dsmiley commented on code in PR #2374:
URL: https://github.com/apache/solr/pull/2374#discussion_r1545278812
##########
solr/solrj/src/test/org/apache/solr/client/solrj/impl/DebugServlet.java:
##########
@@ -136,6 +137,16 @@ private void recordRequest(HttpServletRequest req,
HttpServletResponse resp) {
resp.addHeader(h[0], h[1]);
}
}
+ String qs = req.getQueryString();
Review Comment:
could use a one-liner comment to explain
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java:
##########
@@ -469,6 +531,23 @@ protected String
allProcessorSupportedContentTypesCommaDelimited(
.collect(Collectors.joining(", "));
}
+ protected static class HttpSolrClientCancellable implements Cancellable {
Review Comment:
Seeing this class, to me, really underscores a mismatch between Solr's
needless Async API helper classes (Cancellable is one), and using a
CompletableFuture directly. See the parent JIRA issue where I direct you to a
previous stalled effort that could be resumed.
##########
solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java:
##########
@@ -532,4 +538,67 @@ protected void
testUseOptionalCredentialsWithNull(HttpSolrClientBase client) {
assertNull(
"No authorization headers expected. Headers: " + DebugServlet.headers,
authorizationHeader);
}
+
+ protected void testQueryAsync(SolrRequest.METHOD method) throws Exception {
+ ResponseParser rp = new XMLResponseParser();
+ DebugServlet.clear();
+ DebugServlet.addResponseHeader("Content-Type", "application/xml;
charset=UTF-8");
+ String url = getBaseUrl() + DEBUG_SERVLET_PATH;
+ HttpSolrClientBuilderBase<?, ?> b =
+ builder(url, DEFAULT_CONNECTION_TIMEOUT,
DEFAULT_CONNECTION_TIMEOUT).withResponseParser(rp);
+ int limit = 10;
+ CountDownLatch cdl = new CountDownLatch(limit);
+ DebugAsyncListener[] listeners = new DebugAsyncListener[limit];
+ Cancellable[] cancellables = new Cancellable[limit];
+ try (HttpSolrClientBase client = b.build()) {
+ for (int i = 0; i < limit; i++) {
+ DebugServlet.responseBodyByQueryFragment.put(
+ ("id=KEY-" + i),
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response><result
name=\"response\" numFound=\"2\" start=\"1\" numFoundExact=\"true\"><doc><str
name=\"id\">KEY-"
+ + i
+ + "</str></doc></result></response>");
+ QueryRequest query =
+ new QueryRequest(new MapSolrParams(Collections.singletonMap("id",
"KEY-" + i)));
+ query.setMethod(method);
+ listeners[i] = new DebugAsyncListener(cdl);
+ client.asyncRequest(query, null, listeners[i]);
+ }
+ cdl.await(1, TimeUnit.MINUTES);
+ }
+
+ for (int i = 0; i < limit; i++) {
+ NamedList<Object> result = listeners[i].onSuccessResult;
+ SolrDocumentList sdl = (SolrDocumentList) result.get("response");
+ assertEquals(2, sdl.getNumFound());
+ assertEquals(1, sdl.getStart());
+ assertTrue(sdl.getNumFoundExact());
+ assertEquals(1, sdl.size());
+ assertEquals(1, sdl.iterator().next().size());
+ assertEquals("KEY-" + i, sdl.iterator().next().get("id"));
+
+ assertNull(listeners[i].onFailureResult);
+ assertTrue(listeners[i].onStartCalled);
+ }
+ }
+
+ protected DebugAsyncListener testAsyncExceptionBase() throws Exception {
Review Comment:
Not sure if tests can return non-void. If so, you could just make it public
and add `@Test` and remove the "Base" suffix in the name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]