use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class ShowFileRequestHandlerTest method test404ViaHttp.
public void test404ViaHttp() throws SolrServerException, IOException {
SolrClient client = getSolrClient();
QueryRequest request = new QueryRequest(params("file", "does-not-exist-404.txt"));
request.setPath("/admin/file");
try {
QueryResponse resp = request.process(client);
fail("didn't get 404 exception");
} catch (SolrException e) {
assertEquals(404, e.code());
}
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class SchemaTest method testDeleteFieldTypeAccuracy.
@Test
public void testDeleteFieldTypeAccuracy() throws Exception {
Map<String, Object> fieldTypeAttributes = new LinkedHashMap<>();
String fieldTypeName = "delInt";
fieldTypeAttributes.put("name", fieldTypeName);
fieldTypeAttributes.put("class", "solr.TrieIntField");
fieldTypeAttributes.put("precisionStep", 0);
fieldTypeAttributes.put("omitNorms", true);
fieldTypeAttributes.put("positionIncrementGap", 0);
FieldTypeDefinition fieldTypeDefinition = new FieldTypeDefinition();
fieldTypeDefinition.setAttributes(fieldTypeAttributes);
SchemaRequest.AddFieldType addFieldTypeRequest = new SchemaRequest.AddFieldType(fieldTypeDefinition);
SolrClient c = getSolrClient();
SchemaResponse.UpdateResponse addFieldTypeResponse = addFieldTypeRequest.process(c);
assertValidSchemaResponse(addFieldTypeResponse);
SchemaRequest.FieldType fieldTypeRequest = new SchemaRequest.FieldType(fieldTypeName);
SchemaResponse.FieldTypeResponse initialFieldTypeResponse = fieldTypeRequest.process(getSolrClient());
assertValidSchemaResponse(initialFieldTypeResponse);
FieldTypeRepresentation responseFieldTypeRepresentation = initialFieldTypeResponse.getFieldType();
assertThat(fieldTypeName, is(equalTo(responseFieldTypeRepresentation.getAttributes().get("name"))));
SchemaRequest.DeleteFieldType deleteFieldTypeRequest = new SchemaRequest.DeleteFieldType(fieldTypeName);
SchemaResponse.UpdateResponse deleteFieldTypeResponse = deleteFieldTypeRequest.process(getSolrClient());
assertValidSchemaResponse(deleteFieldTypeResponse);
try {
fieldTypeRequest.process(getSolrClient());
fail(String.format(Locale.ROOT, "after removal, the field type %s shouldn't be anymore available over Schema API", fieldTypeName));
} catch (SolrException e) {
//success
}
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class SchemaTest method addDynamicFieldShouldntBeCalledTwiceWithTheSameName.
@Test
public void addDynamicFieldShouldntBeCalledTwiceWithTheSameName() throws Exception {
Map<String, Object> fieldAttributes = new LinkedHashMap<>();
fieldAttributes.put("name", "*_failure");
fieldAttributes.put("type", "string");
SchemaRequest.AddDynamicField addDFieldUpdateSchemaRequest = new SchemaRequest.AddDynamicField(fieldAttributes);
SolrClient client = getSolrClient();
SchemaResponse.UpdateResponse addDFieldFirstResponse = addDFieldUpdateSchemaRequest.process(client);
assertValidSchemaResponse(addDFieldFirstResponse);
SchemaResponse.UpdateResponse addDFieldSecondResponse = addDFieldUpdateSchemaRequest.process(getSolrClient());
assertEquals(0, addDFieldSecondResponse.getStatus());
assertNotNull(addDFieldSecondResponse.getResponse().get("errors"));
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestSolrConfigHandlerCloud method setupHarnesses.
private void setupHarnesses() {
for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(((HttpSolrClient) client)::getBaseURL);
restTestHarnesses.add(harness);
}
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestSolrConfigHandlerConcurrent method setupHarnesses.
private void setupHarnesses() {
for (final SolrClient client : clients) {
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
restTestHarnesses.add(harness);
}
}
Aggregations