org.apache.solr.util

## Class BaseTestHarness

- java.lang.Object
- - org.apache.solr.util.BaseTestHarness

- Direct Known Subclasses:
    RestTestHarness, TestHarness

      public abstract class BaseTestHarness
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BaseTestHarness()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `checkUpdateStatus(String xml, String code)` Validates that an "update" (add, commit or optimize) results in success.
    `static String` | `commit(String... args)` Helper that returns an <commit> String with optional key/val pairs.
    `static String` | `deleteById(String id, String... args)` Generates a delete by id xml string
    `static String` | `deleteByQuery(String q, String... args)` Generates a delete by query xml string
    `static Object` | `evaluateXPath(String xml, String xpath, QName returnType)`
    `static DocumentBuilder` | `getXmlDocumentBuilder()`
    `static XPath` | `getXpath()`
    `static String` | `makeSimpleDoc(String... fieldsAndValues)` A helper that creates an xml <doc> containing all of the fields and values specified
    `static String` | `optimize(String... args)` Helper that returns an <optimize> String with optional key/val pairs.
    `abstract void` | `reload()` Reloads the core
    `static String` | `simpleTag(String tag, String... args)`
    `abstract String` | `update(String xml)` Processes an "update" (add, commit or optimize) and returns the response as a String.
    `String` | `validateErrorUpdate(String xml)` Validates that an "update" (add, commit or optimize) results in success.
    `String` | `validateUpdate(String xml)` Validates that an "update" (add, commit or optimize) results in success.
    `static String` | `validateXPath(String xml, String... tests)` A helper method which validates a String against an array of XPath test strings.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BaseTestHarness

          public BaseTestHarness()

  - ### Method Detail

    - #### getXmlDocumentBuilder

          public static DocumentBuilder getXmlDocumentBuilder()

    - #### getXpath

          public static XPath getXpath()

    - #### validateXPath

          public static String validateXPath(String xml,
                                             String... tests)
                                      throws XPathExpressionException,
                                             SAXException

      A helper method which validates a String against an array of XPath test strings.
      Parameters:
        `xml` - The xml String to validate
        `tests` - Array of XPath strings to test (in boolean mode) on the xml
      Returns:
        null if all good, otherwise the first test that fails.
      Throws:
        `XPathExpressionException`
        `SAXException`

    - #### evaluateXPath

          public static Object evaluateXPath(String xml,
                                             String xpath,
                                             QName returnType)
                                      throws XPathExpressionException,
                                             SAXException

      Throws:
        `XPathExpressionException`
        `SAXException`

    - #### makeSimpleDoc

          public static String makeSimpleDoc(String... fieldsAndValues)

      A helper that creates an xml <doc> containing all of the fields and values specified
      Parameters:
        `fieldsAndValues` - 0 and Even numbered args are fields names odds are field values.

    - #### deleteByQuery

          public static String deleteByQuery(String q,
                                             String... args)

      Generates a delete by query xml string
      Parameters:
        `q` - Query that has not already been xml escaped
        `args` - The attributes of the delete tag

    - #### deleteById

          public static String deleteById(String id,
                                          String... args)

      Generates a delete by id xml string
      Parameters:
        `id` - ID that has not already been xml escaped
        `args` - The attributes of the delete tag

    - #### optimize

          public static String optimize(String... args)

      Helper that returns an <optimize> String with optional key/val pairs.
      Parameters:
        `args` - 0 and Even numbered args are params, Odd numbered args are values.

    - #### simpleTag

          public static String simpleTag(String tag,
                                         String... args)

    - #### commit

          public static String commit(String... args)

      Helper that returns an <commit> String with optional key/val pairs.
      Parameters:
        `args` - 0 and Even numbered args are params, Odd numbered args are values.

    - #### reload

          public abstract void reload()
                               throws Exception

      Reloads the core
      Throws:
        `Exception`

    - #### update

          public abstract String update(String xml)

      Processes an "update" (add, commit or optimize) and returns the response as a String. This method does NOT commit after the request.
      Parameters:
        `xml` - The XML of the update
      Returns:
        The XML response to the update

    - #### validateUpdate

          public String validateUpdate(String xml)
                                throws SAXException

      Validates that an "update" (add, commit or optimize) results in success. :TODO: currently only deals with one add/doc at a time, this will need changed if/when SOLR-2 is resolved
      Parameters:
        `xml` - The XML of the update
      Returns:
        null if successful, otherwise the XML response to the update
      Throws:
        `SAXException`

    - #### validateErrorUpdate

          public String validateErrorUpdate(String xml)
                                     throws SAXException

      Validates that an "update" (add, commit or optimize) results in success. :TODO: currently only deals with one add/doc at a time, this will need changed if/when SOLR-2 is resolved
      Parameters:
        `xml` - The XML of the update
      Returns:
        null if successful, otherwise the XML response to the update
      Throws:
        `SAXException`

    - #### checkUpdateStatus

          public String checkUpdateStatus(String xml,
                                          String code)
                                   throws SAXException

      Validates that an "update" (add, commit or optimize) results in success. :TODO: currently only deals with one add/doc at a time, this will need changed if/when SOLR-2 is resolved
      Parameters:
        `xml` - The XML of the update
      Returns:
        null if successful, otherwise the XML response to the update
      Throws:
        `SAXException`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.