gerlowskija commented on code in PR #3262:
URL: https://github.com/apache/solr/pull/3262#discussion_r2006286200
##########
solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java:
##########
@@ -139,6 +144,52 @@ public void testWTParam() throws Exception {
assertEquals(respString, 0, Utils.getObjectByPath(resp, true,
"/responseHeader/status"));
}
+ @Test
+ public void testObeysWtParameterWhenProvided() throws Exception {
+ final var httpClient = getRawClient();
+ final var listCollRequest = getListCollectionsRequest();
+ listCollRequest.setURI(
+ new URIBuilder(listCollRequest.getURI()).addParameter("wt",
"xml").build());
+
+ final var response = httpClient.execute(listCollRequest);
+
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals("application/xml",
response.getFirstHeader("Content-type").getValue());
+ }
+
+ @Test
+ public void testObeysAcceptHeaderWhenWtParamNotProvided() throws Exception {
+ final var httpClient = getRawClient();
+ final var listCollRequest = getListCollectionsRequest();
+ listCollRequest.addHeader("Accept", "application/xml");
+
+ final var response = httpClient.execute(listCollRequest);
+
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals("application/xml",
response.getFirstHeader("Content-type").getValue());
+ }
+
+ @Test
+ public void testRespondsWithJsonWhenWtAndAcceptAreMissing() throws Exception
{
+ final var httpClient = getRawClient();
+ final var listCollRequest = getListCollectionsRequest();
+
+ final var response = httpClient.execute(listCollRequest);
+
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals("application/json",
response.getFirstHeader("Content-type").getValue());
+ }
+
+ private HttpClient getRawClient() {
+ return ((CloudLegacySolrClient) cluster.getSolrClient()).getHttpClient();
+ }
Review Comment:
What's the best way to do that? Is there one?
Per [the Slack discussion
here](https://the-asf.slack.com/archives/CEKUCUNE9/p1741870697981609), there's
not yet a general utility for creating a Jetty client. And adding a
well-thought-out version of that is conceptually unrelated and beyond the scope
of this PR.
--
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]