epugh commented on code in PR #4131:
URL: https://github.com/apache/solr/pull/4131#discussion_r2804020408
##########
solr/test-framework/src/java/org/apache/solr/util/TestHarness.java:
##########
@@ -417,23 +417,39 @@ public LocalRequestFactory() {}
*/
@SuppressWarnings({"unchecked"})
public SolrQueryRequestBase makeRequest(String... q) {
- args.computeIfAbsent("wt", k -> "xml");
+ // Validate input length - must be 1 (single query string) or even
(key-value pairs)
+ if (q.length != 1 && q.length % 2 != 0) {
+ throw new RuntimeException(
+ "The length of the string array (query arguments) needs to be 1 or
even");
+ }
+
+ ModifiableSolrParams params;
+
if (q.length == 1) {
- Map<String, String[]> map = new HashMap<>();
+ // Single argument case: use args as base, add query string and
defaults
+ args.computeIfAbsent("wt", k -> "xml");
+ params = new ModifiableSolrParams();
for (Map.Entry<String, String> e : args.entrySet()) {
- map.put(e.getKey(), new String[] {e.getValue()});
+ params.set(e.getKey(), e.getValue());
+ }
+ if (q[0] != null) {
+ params.set(CommonParams.Q, q[0]);
+ }
+ if (qtype != null) {
+ params.set(CommonParams.QT, qtype);
+ }
+ params.set(CommonParams.START, Integer.toString(start));
+ params.set(CommonParams.ROWS, Integer.toString(limit));
+ } else {
+ // Multiple arguments case: use only the key-value pairs from q array
+ params = SolrTestCaseJ4.params(q);
+ // Ensure wt defaults to xml if not explicitly set, for backwards
compatibility
+ if (params.get(CommonParams.WT) == null) {
+ params.set(CommonParams.WT, "xml");
}
Review Comment:
nice! will do that.
--
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]