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. I can throw together a client-creation snippet just for this test, but that feels a little hacky and the sort of thing that'd be likely to run afoul of our test randomization and cause flaky failures down the line whenever SSL or whatever variable is randomly toggled. I'm totally on board with moving towards the Jetty client - that's why I asked about the right way to do this in Slack. But IMO we should get the infrastructure and utilities in place first, and then look to start expanding the usage. -- 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