Class RestTestBase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase

public abstract class RestTestBase extends SolrJettyTestBase
  • Field Details

  • Constructor Details

    • RestTestBase

      public RestTestBase()
  • Method Details

    • cleanUpHarness

      public static void cleanUpHarness() throws IOException
      Throws:
      IOException
    • createJettyAndHarness

      public static void createJettyAndHarness(Path solrHome, String configFile, String schemaFile, String context, boolean stopAtShutdown, SortedMap<org.eclipse.jetty.ee10.servlet.ServletHolder,String> extraServlets) throws Exception
      Throws:
      Exception
    • assertU

      public static void assertU(String update)
      Validates an update XML String is successful
    • assertU

      public static void assertU(String message, String update)
      Validates an update XML String is successful
    • assertFailedU

      public static void assertFailedU(String update)
      Validates an update XML String failed
    • assertFailedU

      public static void assertFailedU(String message, String update)
      Validates an update XML String failed
    • checkUpdateU

      public static void checkUpdateU(String update, String... tests)
    • assertQ

      public static void assertQ(String request, String... tests)
      Validates a query matches some XPath test expressions
      Parameters:
      request - a URL path with optional query params, e.g. "/schema/fields?fl=id,_version_"
    • assertHead

      public static void assertHead(String request, int expectedStatusCode) throws IOException
      Throws:
      IOException
    • JQ

      public static String JQ(String request) throws IOException
      Makes a query request and returns the JSON string response
      Parameters:
      request - a URL path with optional query params, e.g. "/schema/fields?fl=id,_version_"
      Throws:
      IOException
    • assertJQ

      public static void assertJQ(String request, String... tests) throws Exception
      Validates a query matches some JSON test expressions using the default double delta tolerance.
      Throws:
      Exception
      See Also:
    • assertJQ

      public static void assertJQ(String request, double delta, String... tests) throws IOException
      Validates a query matches some JSON test expressions and closes the query. The text expression is of the form path:JSON. To facilitate easy embedding in Java strings, the JSON can have double quotes replaced with single quotes.

      Please use this with care: this makes it easy to match complete structures, but doing so can result in fragile tests if you are matching more than what you want to test.

      Parameters:
      request - a URL path with optional query params, e.g. "/schema/fields?fl=id,_version_"
      delta - tolerance allowed in comparing float/double values
      tests - JSON path expression + '==' + expected value
      Throws:
      IOException
    • assertJPut

      public static void assertJPut(String request, String content, String... tests) throws IOException
      Validates the response from a PUT request matches some JSON test expressions
      Throws:
      IOException
      See Also:
    • assertJPut

      public static void assertJPut(String request, String content, double delta, String... tests) throws IOException
      Validates the response from a PUT request matches some JSON test expressions and closes the query. The text expression is of the form path==JSON. To facilitate easy embedding in Java strings, the JSON can have double quotes replaced with single quotes.

      Please use this with care: this makes it easy to match complete structures, but doing so can result in fragile tests if you are matching more than what you want to test.

      Parameters:
      request - a URL path with optional query params, e.g. "/schema/fields?fl=id,_version_"
      content - The content to include with the PUT request
      delta - tolerance allowed in comparing float/double values
      tests - JSON path expression + '==' + expected value
      Throws:
      IOException
    • assertJPost

      public static void assertJPost(String request, String content, String... tests) throws Exception
      Validates the response from a POST request matches some JSON test expressions
      Throws:
      Exception
      See Also:
    • assertJPost

      public static void assertJPost(String request, String content, double delta, String... tests) throws Exception
      Validates the response from a PUT request matches some JSON test expressions and closes the query. The text expression is of the form path==JSON. To facilitate easy embedding in Java strings, the JSON can have double quotes replaced with single quotes.

      Please use this with care: this makes it easy to match complete structures, but doing so can result in fragile tests if you are matching more than what you want to test.

      Parameters:
      request - a URL path with optional query params, e.g. "/schema/fields?fl=id,_version_"
      content - The content to include with the PUT request
      delta - tolerance allowed in comparing float/double values
      tests - JSON path expression + '==' + expected value
      Throws:
      Exception
    • assertJDelete

      public static void assertJDelete(String request, String... tests) throws Exception
      Deletes a resource and then matches some JSON test expressions against the response using the default double delta tolerance.
      Throws:
      Exception
      See Also:
    • assertJDelete

      public static void assertJDelete(String request, double delta, String... tests) throws Exception
      Deletes a resource and then matches some JSON test expressions against the response using the specified double delta tolerance.
      Throws:
      Exception