You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/11/24 19:56:50 UTC

[GitHub] [solr] madrob commented on a diff in pull request #1158: SOLR-16368: experiment with builder to simplify client creation

madrob commented on code in PR #1158:
URL: https://github.com/apache/solr/pull/1158#discussion_r1031797318


##########
solr/core/src/test/org/apache/solr/schema/TestCloudManagedSchema.java:
##########
@@ -53,21 +54,22 @@ public void test() throws Exception {
     QueryRequest request = new QueryRequest(params);
     request.setPath("/admin/cores");
     int which = r.nextInt(clients.size());
-    HttpSolrClient client = (HttpSolrClient) clients.get(which);
-    String previousBaseURL = client.getBaseURL();
-    // Strip /collection1 step from baseURL - requests fail otherwise
-    client.setBaseURL(previousBaseURL.substring(0, previousBaseURL.lastIndexOf("/")));
-    NamedList<?> namedListResponse = client.request(request);
-    client.setBaseURL(previousBaseURL); // Restore baseURL
-    NamedList<?> status = (NamedList<?>) namedListResponse.get("status");
-    NamedList<?> collectionStatus = (NamedList<?>) status.getVal(0);
-    String collectionSchema = (String) collectionStatus.get(CoreAdminParams.SCHEMA);
-    // Make sure the upgrade to managed schema happened
-    assertEquals(
-        "Schema resource name differs from expected name", "managed-schema.xml", collectionSchema);
 
-    SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), 30000);
-    try {
+    // create a client that does not have the /collection1 as part of the URL.
+    try (SolrClient rootClient =
+        new HttpSolrClient.Builder(buildUrl(jettys.get(which).getLocalPort())).build()) {
+      NamedList<?> namedListResponse = rootClient.request(request);
+      NamedList<?> status = (NamedList<?>) namedListResponse.get("status");

Review Comment:
   There's a multi argument get or something on named list that lets you drill in. Don't remember what it's called exactly, I'm on my phone now. 



-- 
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-unsubscribe@solr.apache.org

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


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