jdyer1 commented on code in PR #2374:
URL: https://github.com/apache/solr/pull/2374#discussion_r1548587323


##########
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:
   Let me clarify why I have been overriding these shared tests.  You are right 
it does work generally on IntelliJ, however, if you want to run only 1 test 
method and not the whole class, this doesn't seem to work.  Even if you run all 
the tests, then right click to re-run just the individual test method, I am 
getting an error.  This makes it very difficult to debug, which is why I have 
been using all those 1-line test override methods.



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to