use of org.apache.solr.client.solrj.ResponseParser in project lucene-solr by apache.
the class LBHttpSolrClientBuilderTest method testDefaultsToBinaryResponseParserWhenNoneProvided.
@Test
public void testDefaultsToBinaryResponseParserWhenNoneProvided() {
try (LBHttpSolrClient createdClient = new Builder().withBaseSolrUrl(ANY_BASE_SOLR_URL).build()) {
final ResponseParser usedParser = createdClient.getParser();
assertTrue(usedParser instanceof BinaryResponseParser);
}
}
use of org.apache.solr.client.solrj.ResponseParser in project lucene-solr by apache.
the class LBHttpSolrClientTest method testLBHttpSolrClientHttpClientResponseParserStringArray.
/**
* Test method for {@link LBHttpSolrClient#LBHttpSolrClient(org.apache.http.client.HttpClient, org.apache.solr.client.solrj.ResponseParser, java.lang.String[])}.
*
* Validate that the parser passed in is used in the <code>HttpSolrClient</code> instances created.
*/
@Test
public void testLBHttpSolrClientHttpClientResponseParserStringArray() throws IOException {
CloseableHttpClient httpClient = HttpClientUtil.createClient(new ModifiableSolrParams());
try (LBHttpSolrClient testClient = new LBHttpSolrClient(httpClient, (ResponseParser) null);
HttpSolrClient httpSolrClient = testClient.makeSolrClient("http://127.0.0.1:8080")) {
assertNull("Generated server should have null parser.", httpSolrClient.getParser());
} finally {
HttpClientUtil.close(httpClient);
}
ResponseParser parser = new BinaryResponseParser();
httpClient = HttpClientUtil.createClient(new ModifiableSolrParams());
try {
try (LBHttpSolrClient testClient = new LBHttpSolrClient(httpClient, parser);
HttpSolrClient httpSolrClient = testClient.makeSolrClient("http://127.0.0.1:8080")) {
assertEquals("Invalid parser passed to generated server.", parser, httpSolrClient.getParser());
}
} finally {
HttpClientUtil.close(httpClient);
}
}
use of org.apache.solr.client.solrj.ResponseParser in project lucene-solr by apache.
the class NoOpResponseParserTest method assertResponse.
private void assertResponse(String responseString) throws IOException {
ResponseParser xmlResponseParser = new XMLResponseParser();
NamedList expectedResponse = xmlResponseParser.processResponse(IOUtils.toInputStream(responseString, "UTF-8"), "UTF-8");
List<SolrDocument> documentList = (List<SolrDocument>) expectedResponse.getAll("response").get(0);
assertEquals(1, documentList.size());
SolrDocument solrDocument = documentList.get(0);
assertEquals("1234", String.valueOf(solrDocument.getFieldValue("id")));
}
Aggregations