Java Code Examples for org.apache.solr.SolrTestCaseJ4#json()

The following examples show how to use org.apache.solr.SolrTestCaseJ4#json() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSolrConfigHandler.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public static void runConfigCommandExpectFailure(RestTestHarness harness, String uri, String payload, String expectedErrorMessage) throws Exception {
  String json = SolrTestCaseJ4.json(payload);
  log.info("going to send config command. path {} , payload: {}", uri, payload);
  String response = harness.post(uri, json);
  @SuppressWarnings({"rawtypes"})
  Map map = (Map)Utils.fromJSONString(response);
  assertNotNull(response, map.get("errorMessages"));
  assertNotNull(response, map.get("error"));
  assertTrue("Expected status != 0: " + response, 0L != (Long)((Map)map.get("responseHeader")).get("status"));
  @SuppressWarnings({"rawtypes"})
  List errorDetails = (List)((Map)map.get("error")).get("details");
  @SuppressWarnings({"rawtypes"})
  List errorMessages = (List)((Map)errorDetails.get(0)).get("errorMessages");
  assertTrue("Expected '" + expectedErrorMessage + "': " + response, 
      errorMessages.get(0).toString().contains(expectedErrorMessage));
}
 
Example 2
Source File: TestSolrConfigHandler.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"rawtypes"})
public static Map runConfigCommand(RestTestHarness harness, String uri, String payload) throws IOException {
  String json = SolrTestCaseJ4.json(payload);
  log.info("going to send config command. path {} , payload: {}", uri, payload);
  String response = harness.post(uri, json);
  Map map = (Map) Utils.fromJSONString(response);
  assertNull(response, map.get("errorMessages"));
  assertNull(response, map.get("errors")); // Will this ever be returned?
  return map;
}