org.apache.solr

## Class SolrTestCaseJ4

- java.lang.Object
- - org.junit.Assert
  - - org.apache.lucene.util.LuceneTestCase
    - - org.apache.solr.SolrTestCaseJ4

- Direct Known Subclasses:
    AbstractBadConfigTestBase, AbstractSolrTestCase, AbstractZkTestCase, BaseDistributedSearchTestCase, SolrCloudTestCase, SolrJettyTestBase, SolrTestCaseHS

      @LuceneTestCase.SuppressSysoutChecks(bugUrl="Solr dumps tons of logs to console.")
       @LuceneTestCase.SuppressFileSystems(value="ExtrasFS")
       @RandomizeSSL
      public abstract class SolrTestCaseJ4
      extends org.apache.lucene.util.LuceneTestCase

  A junit4 Solr test harness that extends LuceneTestCaseJ4. To change which core is used when loading the schema and solrconfig.xml, simply invoke the `initCore(String, String, String, String)` method. Unlike `AbstractSolrTestCase`, a new core is not created for each test method.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SolrTestCaseJ4.CloudSolrClientBuilder`
    `static class` | `SolrTestCaseJ4.Doc`
    `static class` | `SolrTestCaseJ4.Fld`
    `protected class` | `SolrTestCaseJ4.FldType`
    `static class` | `SolrTestCaseJ4.FVal`
    `static class` | `SolrTestCaseJ4.IRange`
    `static class` | `SolrTestCaseJ4.IVals`
    `static class` | `SolrTestCaseJ4.IValsPercent`
    `static interface` | `SolrTestCaseJ4.SuppressObjectReleaseTracker` Annotation for test classes that want to disable ObjectReleaseTracker
    `static interface` | `SolrTestCaseJ4.SuppressSSL` Annotation for test classes that want to disable SSL
    `static class` | `SolrTestCaseJ4.SVal`
    `static class` | `SolrTestCaseJ4.Vals`
    `static class` | `SolrTestCaseJ4.XmlDoc` Necessary to make method signatures un-ambiguous

    - ### Nested classes/interfaces inherited from class org.apache.lucene.util.LuceneTestCase

      `org.apache.lucene.util.LuceneTestCase.AwaitsFix, org.apache.lucene.util.LuceneTestCase.BadApple, org.apache.lucene.util.LuceneTestCase.Monster, org.apache.lucene.util.LuceneTestCase.Nightly, org.apache.lucene.util.LuceneTestCase.Slow, org.apache.lucene.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.util.LuceneTestCase.SuppressFileSystems, org.apache.lucene.util.LuceneTestCase.SuppressFsync, org.apache.lucene.util.LuceneTestCase.SuppressReproduceLine, org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks, org.apache.lucene.util.LuceneTestCase.SuppressTempFileChecks, org.apache.lucene.util.LuceneTestCase.ThrowingRunnable, org.apache.lucene.util.LuceneTestCase.Weekly`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `configString`
    `protected static String` | `CORE_PROPERTIES_FILENAME`
    `static int` | `DEFAULT_CONNECTION_TIMEOUT`
    `static String` | `DEFAULT_TEST_COLLECTION_NAME`
    `static String` | `DEFAULT_TEST_CORENAME`
    `protected static TestHarness` | `h` Harness initialized by initTestHarness.
    `protected static String` | `hdfsDataDir`
    `protected static File` | `initCoreDataDir` The directory used to story the index managed by the TestHarness
    `protected static TestHarness.LocalRequestFactory` | `lrf` LocalRequestFactory initialized by initTestHarness using sensible defaults.
    `static SolrTestCaseJ4.IRange` | `ONE_ONE`
    `protected static String` | `schemaString`
    `static org.junit.rules.TestRule` | `solrClassRules`
    `protected static org.apache.solr.core.SolrConfig` | `solrConfig`
    `org.junit.rules.TestRule` | `solrTestRules`
    `protected static SSLTestConfig` | `sslConfig`
    `static String` | `SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICY` Deprecated.
    `static String` | `SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICYFACTORY`
    `static String` | `SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICY` Deprecated.
    `static String` | `SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICYFACTORY` Deprecated.
    `protected static Path` | `testSolrHome`
    `static SolrTestCaseJ4.IRange` | `ZERO_ONE`
    `static SolrTestCaseJ4.IRange` | `ZERO_TWO`

    - ### Fields inherited from class org.apache.lucene.util.LuceneTestCase

      `assertsAreEnabled, classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, LEAVE_TEMPORARY, MAYBE_CACHE_POLICY, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_BADAPPLES, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_WEEKLY, VERBOSE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SolrTestCaseJ4()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `add(SolrTestCaseJ4.XmlDoc doc, String... args)` Generates an <add><doc>...
    `static Long` | `addAndGetVersion(org.apache.solr.common.SolrInputDocument sdoc, org.apache.solr.common.params.SolrParams params)`
    `static String` | `adoc(org.apache.solr.common.SolrInputDocument sdoc)` Generates a simple <add><doc>...
    `static String` | `adoc(String... fieldsAndValues)` Generates a simple <add><doc>...
    `static void` | `assertFailedU(String update)` Validates an update XML String failed
    `static void` | `assertFailedU(String message, String update)` Validates an update XML String failed
    `static void` | `assertFieldValues(org.apache.solr.common.SolrDocumentList documents, String fieldName, Object... expectedValues)` Fails if the number of documents in the given SolrDocumentList differs from the given number of expected values, or if any of the values in the given field don't match the expected values in the same order.
    `static String` | `assertJQ(org.apache.solr.request.SolrQueryRequest req, double delta, String... tests)` Validates a query matches some JSON test expressions and closes the query.
    `static String` | `assertJQ(org.apache.solr.request.SolrQueryRequest req, String... tests)` Validates a query matches some JSON test expressions using the default double delta tolerance.
    `static void` | `assertQ(org.apache.solr.request.SolrQueryRequest req, String... tests)` Validates a query matches some XPath test expressions and closes the query
    `static void` | `assertQ(String message, org.apache.solr.request.SolrQueryRequest req, String... tests)` Validates a query matches some XPath test expressions and closes the query
    `static void` | `assertQEx(String message, org.apache.solr.request.SolrQueryRequest req, int code)` Makes sure a query throws a SolrException with the listed response code
    `static void` | `assertQEx(String message, org.apache.solr.request.SolrQueryRequest req, org.apache.solr.common.SolrException.ErrorCode code)`
    `static void` | `assertQEx(String failMessage, String exceptionMessage, org.apache.solr.request.SolrQueryRequest req, org.apache.solr.common.SolrException.ErrorCode code)` Makes sure a query throws a SolrException with the listed response code and expected message
    `boolean` | `assertSolrInputFieldEquals(Object expected, Object actual)`
    `static void` | `assertU(String update)` Validates an update XML String is successful
    `static void` | `assertU(String message, String update)` Validates an update XML String is successful
    `static void` | `assertXmlFile(File file, String... xpath)`
    `protected static org.apache.solr.client.solrj.embedded.JettyConfig` | `buildJettyConfig(String context)`
    `protected static String` | `buildUrl(int port, String context)`
    `static void` | `chooseMPForMP()`
    `void` | `clearIndex()`
    `static String` | `commit(String... args)`
    `boolean` | `compareSolrDocument(Object expected, Object actual)`
    `boolean` | `compareSolrDocumentList(Object expected, Object actual)`
    `boolean` | `compareSolrInputDocument(Object expected, Object actual)`
    `static Path` | `configset(String name)`
    `static void` | `copyMinConf(File dstRoot)`
    `static void` | `copyMinConf(File dstRoot, String propertiesContent)`
    `static void` | `copyMinFullSetup(File dstRoot)`
    `static void` | `copySolrHomeToTemp(File dstRoot, String collection)`
    `static Comparator<SolrTestCaseJ4.Doc>` | `createComparator(List<Comparator<SolrTestCaseJ4.Doc>> comparators)`
    `static Comparator<SolrTestCaseJ4.Doc>` | `createComparator(String field, boolean asc, boolean sortMissingLast, boolean sortMissingFirst, boolean sortMissingAsZero)`
    `static void` | `createCore()`
    `static org.apache.solr.core.CoreContainer` | `createCoreContainer(org.apache.solr.core.NodeConfig config, org.apache.solr.core.CoresLocator locator)`
    `static org.apache.solr.core.CoreContainer` | `createCoreContainer(Path solrHome, String solrXML)`
    `static org.apache.solr.core.CoreContainer` | `createCoreContainer(String coreName, String dataDir, String solrConfig, String schema)`
    `static org.apache.solr.core.CoreContainer` | `createDefaultCoreContainer(Path solrHome)`
    `static SolrTestCaseJ4.Doc` | `createDoc(List<SolrTestCaseJ4.FldType> descriptor)`
    `static Comparator<SolrTestCaseJ4.Doc>` | `createSort(org.apache.solr.schema.IndexSchema schema, List<SolrTestCaseJ4.FldType> fieldTypes, String[] out)`
    `static Long` | `deleteAndGetVersion(String id, org.apache.solr.common.params.SolrParams params)`
    `static Long` | `deleteByQueryAndGetVersion(String q, org.apache.solr.common.params.SolrParams params)`
    `static void` | `deleteCore()` Shuts down the test harness, and makes the best attempt possible to delete dataDir, unless the system property "solr.test.leavedatadir" is set.
    `static String` | `delI(String id)` Generates a <delete>...
    `static String` | `delQ(String q)` Generates a <delete>...
    `static SolrTestCaseJ4.XmlDoc` | `doc(String... fieldsAndValues)` Generates a simple <doc>...
    `static void` | `endTrackingSearchers(int waitSeconds, boolean failTest)`
    `protected static String` | `getClassName()`
    `static org.apache.solr.client.solrj.impl.CloudSolrClient` | `getCloudSolrClient(String zkHost)`
    `static org.apache.solr.client.solrj.impl.CloudSolrClient` | `getCloudSolrClient(String zkHost, boolean shardLeadersOnly)`
    `static org.apache.solr.client.solrj.impl.CloudSolrClient` | `getCloudSolrClient(String zkHost, boolean shardLeadersOnly, org.apache.http.client.HttpClient httpClient)`
    `static org.apache.solr.client.solrj.impl.CloudSolrClient` | `getCloudSolrClient(String zkHost, org.apache.http.client.HttpClient httpClient)`
    `static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient` | `getConcurrentUpdateSolrClient(String baseSolrUrl, org.apache.http.client.HttpClient httpClient, int queueSize, int threadCount)`
    `static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient` | `getConcurrentUpdateSolrClient(String baseSolrUrl, int queueSize, int threadCount)`
    `static File` | `getFile(String name)` Gets a resource from the context classloader as `File`.
    `static org.apache.solr.client.solrj.impl.HttpSolrClient` | `getHttpSolrClient(String url)`
    `static org.apache.solr.client.solrj.impl.HttpSolrClient` | `getHttpSolrClient(String url, org.apache.http.client.HttpClient httpClient)`
    `static org.apache.solr.client.solrj.impl.HttpSolrClient` | `getHttpSolrClient(String url, org.apache.http.client.HttpClient httpClient, org.apache.solr.client.solrj.ResponseParser responseParser)`
    `static org.apache.solr.client.solrj.impl.HttpSolrClient` | `getHttpSolrClient(String url, org.apache.http.client.HttpClient httpClient, org.apache.solr.client.solrj.ResponseParser responseParser, boolean compression)`
    `static org.apache.solr.client.solrj.impl.LBHttpSolrClient` | `getLBHttpSolrClient(org.apache.http.client.HttpClient client, String... solrUrls)`
    `static org.apache.solr.client.solrj.impl.LBHttpSolrClient` | `getLBHttpSolrClient(String... solrUrls)`
    `static Throwable` | `getRootCause(Throwable t)`
    `static String` | `getSchemaFile()` Subclasses must define this method to return the name of the schema.xml they wish to use.
    `protected static String` | `getSimpleClassName()`
    `static String` | `getSolrConfigFile()` Subclasses must define this method to return the name of the solrconfig.xml they wish to use.
    `static Throwable` | `getWrappedException(Throwable e)`
    `static boolean` | `hasInitException(Class<? extends Exception> exceptionType)`
    `static boolean` | `hasInitException(String message)`
    `static void` | `ignoreException(String pattern)` Causes an exception matching the regex pattern to not be logged.
    `Map<Comparable,SolrTestCaseJ4.Doc>` | `indexDocs(List<SolrTestCaseJ4.FldType> descriptor, Map<Comparable,SolrTestCaseJ4.Doc> model, int nDocs)`
    `static void` | `initClassLogLevels()`
    `static void` | `initCore()`
    `static void` | `initCore(String config, String schema)` Call initCore in @BeforeClass to instantiate a solr core in your test class.
    `static void` | `initCore(String config, String schema, String solrHome)` Call initCore in @BeforeClass to instantiate a solr core in your test class.
    `static void` | `initCore(String config, String schema, String solrHome, String pCoreName)` Call initCore in @BeforeClass to instantiate a solr core in your test class.
    `void` | `initMethodLogLevels()`
    `Map<Comparable,List<Comparable>>` | `invertField(Map<Comparable,SolrTestCaseJ4.Doc> model, String field)` Return a Map from field value to a list of document ids
    `protected static boolean` | `isSSLMode()`
    `static String` | `JQ(org.apache.solr.request.SolrQueryRequest req)` Makes a query request and returns the JSON string response
    `static String` | `json(org.apache.solr.common.SolrInputDocument doc)` Creates JSON from a SolrInputDocument.
    `static void` | `json(org.apache.solr.common.SolrInputDocument doc, org.noggit.CharArr out)` Appends to the `out` array with JSON from the `doc`.
    `static String` | `json(String testJSON)` Converts "test JSON" strings into JSON parseable by our JSON parser.
    `static String` | `jsonAdd(org.apache.solr.common.SolrInputDocument... docs)` Creates a JSON add command from a SolrInputDocument list.
    `static String` | `jsonDelId(Object... ids)` Creates a JSON delete command from an id list
    `static String` | `jsonDelQ(String... queries)` Creates a JSON deleteByQuery command
    `static Map` | `map(Object... params)`
    `static void` | `newRandomConfig()` sets system properties based on `LuceneTestCase.newIndexWriterConfig(org.apache.lucene.analysis.Analyzer)` configs can use these system properties to vary the indexwriter settings
    `static String` | `optimize(String... args)`
    `static org.apache.solr.common.params.ModifiableSolrParams` | `params(String... params)`
    `void` | `postSetUp()` Subclasses that override setUp can optionally call this method to log the fact that their setUp process has ended.
    `void` | `preTearDown()` Subclasses that override tearDown can optionally call this method to log the fact that the tearDown process has started.
    `static String` | `randomDate()` Returns a randomly generated Date in the appropriate Solr external (input) format
    `static String` | `randomSkewedDate()` Returns a Date such that all results from this method always have the same values for year+month+day+hour+minute but the seconds are randomized.
    `static String` | `randomXmlUsableUnicodeString()` We want "realistic" unicode strings beyond simple ascii, but because our updates use XML we need to ensure we don't get "special" code block.
    `static org.apache.solr.request.SolrQueryRequest` | `req(org.apache.solr.common.params.SolrParams params, String... moreParams)` Generates a SolrQueryRequest
    `static org.apache.solr.request.SolrQueryRequest` | `req(String... q)` Generates a SolrQueryRequest using the LocalRequestFactory
    `static org.apache.solr.request.SolrQueryRequest` | `req(String[] params, String... moreParams)` Generates a SolrQueryRequest using the LocalRequestFactory
    `static void` | `resetExceptionIgnores()`
    `static void` | `resetFactory()`
    `void` | `restoreMethodLogLevels()`
    `static org.apache.solr.common.SolrInputDocument` | `sdoc(Object... fieldsAndValues)`
    `static List<org.apache.solr.common.SolrInputDocument>` | `sdocs(org.apache.solr.common.SolrInputDocument... docs)`
    `void` | `setUp()`
    `static void` | `setupNoCoreTest(Path solrHome, String xmlStr)` Call this from @BeforeClass to set up the test harness and update handler with no cores.
    `static void` | `setupTestCases()`
    `static Object` | `skewed(Object likely, Object unlikely)` Returns `likely` most (1/10) of the time, otherwise `unlikely`
    `static void` | `startTrackingSearchers()`
    `protected static void` | `systemClearPropertySolrTestsMergePolicy()` Deprecated.
    `protected static void` | `systemClearPropertySolrTestsMergePolicyFactory()`
    `protected static void` | `systemSetPropertySolrTestsMergePolicy(String value)` Deprecated.
    `protected static void` | `systemSetPropertySolrTestsMergePolicyFactory(String value)`
    `void` | `tearDown()`
    `static void` | `teardownTestCases()`
    `static String` | `TEST_HOME()`
    `static Path` | `TEST_PATH()`
    `static String` | `toJSON(SolrTestCaseJ4.Doc doc)`
    `static void` | `unchooseMPForMP()`
    `static void` | `unIgnoreException(String pattern)`
    `static String` | `updateJ(String json, org.apache.solr.common.params.SolrParams args)` Send JSON update commands
    `static void` | `useFactory(String factory)` Use a different directory factory.
    `protected void` | `waitForWarming()`
    `protected static org.apache.lucene.analysis.MockTokenizer` | `whitespaceMockTokenizer(Reader input)`
    `protected static org.apache.lucene.analysis.MockTokenizer` | `whitespaceMockTokenizer(String input)`
    `static void` | `writeCoreProperties(Path coreDirectory, Properties properties, String testname)`
    `protected void` | `writeCoreProperties(Path coreDirectory, String corename)`

    - ### Methods inherited from class org.apache.lucene.util.LuceneTestCase

      `addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, assertFieldsEquals, assertFieldStatisticsEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, expectThrows, getBaseTempDirForTestClass, getDataInputStream, getDataPath, getOnlyLeafReader, getTestClass, getTestName, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMaybeVirusCheckingDirectory, newMaybeVirusCheckingFSDirectory, newMergePolicy, newMergePolicy, newMockDirectory, newMockDirectory, newMockDirectory, newMockFSDirectory, newMockFSDirectory, newSearcher, newSearcher, newSearcher, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, restoreSpins, runWithRestrictedPermissions, setIndexWriterMaxDocs, setupCPUCoreCount, setupSpins, slowFileExists, usually, usually, wrapReader`

    - ### Methods inherited from class org.junit.Assert

      `assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail`

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

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

- - ### Field Detail

    - #### DEFAULT_TEST_COLLECTION_NAME

          public static final String DEFAULT_TEST_COLLECTION_NAME

      See Also:
        Constant Field Values

    - #### DEFAULT_TEST_CORENAME

          public static final String DEFAULT_TEST_CORENAME

      See Also:
        Constant Field Values

    - #### CORE_PROPERTIES_FILENAME

          protected static final String CORE_PROPERTIES_FILENAME

      See Also:
        Constant Field Values

    - #### SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICYFACTORY

          public static final String SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICYFACTORY

      See Also:
        Constant Field Values

    - #### SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICY

          @Deprecated
          public static final String SYSTEM_PROPERTY_SOLR_TESTS_MERGEPOLICY

      Deprecated.
      See Also:
        Constant Field Values

    - #### SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICYFACTORY

          @Deprecated
          public static final String SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICYFACTORY

      Deprecated.
      See Also:
        Constant Field Values

    - #### SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICY

          @Deprecated
          public static final String SYSTEM_PROPERTY_SOLR_TESTS_USEMERGEPOLICY

      Deprecated.
      See Also:
        Constant Field Values

    - #### DEFAULT_CONNECTION_TIMEOUT

          public static int DEFAULT_CONNECTION_TIMEOUT

    - #### sslConfig

          protected static volatile SSLTestConfig sslConfig

    - #### solrClassRules

          public static org.junit.rules.TestRule solrClassRules

    - #### solrTestRules

          public org.junit.rules.TestRule solrTestRules

    - #### configString

          protected static String configString

    - #### schemaString

          protected static String schemaString

    - #### testSolrHome

          protected static Path testSolrHome

    - #### solrConfig

          protected static org.apache.solr.core.SolrConfig solrConfig

    - #### h

          protected static TestHarness h

      Harness initialized by initTestHarness.

      For use in test methods as needed.

    - #### lrf

          protected static TestHarness.LocalRequestFactory lrf

      LocalRequestFactory initialized by initTestHarness using sensible defaults.

      For use in test methods as needed.

    - #### initCoreDataDir

          protected static volatile File initCoreDataDir

      The directory used to story the index managed by the TestHarness

    - #### hdfsDataDir

          protected static String hdfsDataDir

    - #### ZERO_ONE

          public static final SolrTestCaseJ4.IRange ZERO_ONE

    - #### ZERO_TWO

          public static final SolrTestCaseJ4.IRange ZERO_TWO

    - #### ONE_ONE

          public static final SolrTestCaseJ4.IRange ONE_ONE

  - ### Constructor Detail

    - #### SolrTestCaseJ4

          public SolrTestCaseJ4()

  - ### Method Detail

    - #### writeCoreProperties

          protected void writeCoreProperties(Path coreDirectory,
                                             String corename)
                                      throws IOException

      Throws:
        `IOException`

    - #### writeCoreProperties

          public static void writeCoreProperties(Path coreDirectory,
                                                 Properties properties,
                                                 String testname)
                                          throws IOException

      Throws:
        `IOException`

    - #### setupTestCases

          public static void setupTestCases()

    - #### teardownTestCases

          public static void teardownTestCases()
                                        throws Exception

      Throws:
        `Exception`

    - #### initClassLogLevels

          public static void initClassLogLevels()

    - #### initMethodLogLevels

          public void initMethodLogLevels()

    - #### restoreMethodLogLevels

          public void restoreMethodLogLevels()

    - #### isSSLMode

          protected static boolean isSSLMode()

    - #### useFactory

          public static void useFactory(String factory)
                                 throws Exception

      Use a different directory factory. Passing "null" sets to an FS-based factory
      Throws:
        `Exception`

    - #### resetFactory

          public static void resetFactory()
                                   throws Exception

      Throws:
        `Exception`

    - #### buildJettyConfig

          protected static org.apache.solr.client.solrj.embedded.JettyConfig buildJettyConfig(String context)

    - #### buildUrl

          protected static String buildUrl(int port,
                                           String context)

    - #### whitespaceMockTokenizer

          protected static org.apache.lucene.analysis.MockTokenizer whitespaceMockTokenizer(Reader input)
                                                                                     throws IOException

      Throws:
        `IOException`

    - #### whitespaceMockTokenizer

          protected static org.apache.lucene.analysis.MockTokenizer whitespaceMockTokenizer(String input)
                                                                                     throws IOException

      Throws:
        `IOException`

    - #### setupNoCoreTest

          public static void setupNoCoreTest(Path solrHome,
                                             String xmlStr)
                                      throws Exception

      Call this from @BeforeClass to set up the test harness and update handler with no cores.
      Parameters:
        `solrHome` - The solr home directory.
        `xmlStr` - - the text of an XML file to use. If null, use the what's the absolute minimal file.
      Throws:
        `Exception` - Lost of file-type things can go wrong.

    - #### newRandomConfig

          public static void newRandomConfig()

      sets system properties based on `LuceneTestCase.newIndexWriterConfig(org.apache.lucene.analysis.Analyzer)` configs can use these system properties to vary the indexwriter settings

    - #### getWrappedException

          public static Throwable getWrappedException(Throwable e)

    - #### setUp

          public void setUp()
                     throws Exception

      Overrides:
        `setUp` in class `org.apache.lucene.util.LuceneTestCase`
      Throws:
        `Exception`

    - #### tearDown

          public void tearDown()
                        throws Exception

      Overrides:
        `tearDown` in class `org.apache.lucene.util.LuceneTestCase`
      Throws:
        `Exception`

    - #### initCore

          public static void initCore(String config,
                                      String schema)
                               throws Exception

      Call initCore in @BeforeClass to instantiate a solr core in your test class. deleteCore will be called for you via SolrTestCaseJ4 @AfterClass
      Throws:
        `Exception`

    - #### initCore

          public static void initCore(String config,
                                      String schema,
                                      String solrHome)
                               throws Exception

      Call initCore in @BeforeClass to instantiate a solr core in your test class. deleteCore will be called for you via SolrTestCaseJ4 @AfterClass
      Throws:
        `Exception`

    - #### initCore

          public static void initCore(String config,
                                      String schema,
                                      String solrHome,
                                      String pCoreName)
                               throws Exception

      Call initCore in @BeforeClass to instantiate a solr core in your test class. deleteCore will be called for you via SolrTestCaseJ4 @AfterClass
      Throws:
        `Exception`

    - #### startTrackingSearchers

          public static void startTrackingSearchers()

    - #### endTrackingSearchers

          public static void endTrackingSearchers(int waitSeconds,
                                                  boolean failTest)

    - #### ignoreException

          public static void ignoreException(String pattern)

      Causes an exception matching the regex pattern to not be logged.

    - #### unIgnoreException

          public static void unIgnoreException(String pattern)

    - #### resetExceptionIgnores

          public static void resetExceptionIgnores()

    - #### getClassName

          protected static String getClassName()

    - #### getSimpleClassName

          protected static String getSimpleClassName()

    - #### getSchemaFile

          public static String getSchemaFile()

      Subclasses must define this method to return the name of the schema.xml they wish to use.

    - #### getSolrConfigFile

          public static String getSolrConfigFile()

      Subclasses must define this method to return the name of the solrconfig.xml they wish to use.

    - #### initCore

          public static void initCore()
                               throws Exception

      Throws:
        `Exception`

    - #### createCore

          public static void createCore()

    - #### createCoreContainer

          public static org.apache.solr.core.CoreContainer createCoreContainer(Path solrHome,
                                                                               String solrXML)

    - #### createCoreContainer

          public static org.apache.solr.core.CoreContainer createCoreContainer(org.apache.solr.core.NodeConfig config,
                                                                               org.apache.solr.core.CoresLocator locator)

    - #### createCoreContainer

          public static org.apache.solr.core.CoreContainer createCoreContainer(String coreName,
                                                                               String dataDir,
                                                                               String solrConfig,
                                                                               String schema)

    - #### createDefaultCoreContainer

          public static org.apache.solr.core.CoreContainer createDefaultCoreContainer(Path solrHome)

    - #### hasInitException

          public static boolean hasInitException(String message)

    - #### hasInitException

          public static boolean hasInitException(Class<? extends Exception> exceptionType)

    - #### postSetUp

          public void postSetUp()

      Subclasses that override setUp can optionally call this method to log the fact that their setUp process has ended.

    - #### preTearDown

          public void preTearDown()

      Subclasses that override tearDown can optionally call this method to log the fact that the tearDown process has started. This is necessary since subclasses will want to call super.tearDown() at the *end* of their tearDown method.

    - #### deleteCore

          public static void deleteCore()

      Shuts down the test harness, and makes the best attempt possible to delete dataDir, unless the system property "solr.test.leavedatadir" is set.

    - #### 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

    - #### assertQ

          public static void assertQ(org.apache.solr.request.SolrQueryRequest req,
                                     String... tests)

      Validates a query matches some XPath test expressions and closes the query

    - #### assertQ

          public static void assertQ(String message,
                                     org.apache.solr.request.SolrQueryRequest req,
                                     String... tests)

      Validates a query matches some XPath test expressions and closes the query

    - #### JQ

          public static String JQ(org.apache.solr.request.SolrQueryRequest req)
                           throws Exception

      Makes a query request and returns the JSON string response
      Throws:
        `Exception`

    - #### assertJQ

          public static String assertJQ(org.apache.solr.request.SolrQueryRequest req,
                                        String... tests)
                                 throws Exception

      Validates a query matches some JSON test expressions using the default double delta tolerance.
      Returns:
        The request response as a JSON String if all test patterns pass
      Throws:
        `Exception`
      See Also:
        `JSONTestUtil.DEFAULT_DELTA`, `assertJQ(SolrQueryRequest,double,String...)`

    - #### assertJQ

          public static String assertJQ(org.apache.solr.request.SolrQueryRequest req,
                                        double delta,
                                        String... tests)
                                 throws Exception

      Validates a query matches some JSON test expressions and closes the query. The text expression is of the form path:JSON. The Noggit JSON parser used accepts single quoted strings and bare strings to allow easy embedding in Java Strings.

      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:
        `req` - Solr request to execute
        `delta` - tolerance allowed in comparing float/double values
        `tests` - JSON path expression + '==' + expected value
      Returns:
        The request response as a JSON String if all test patterns pass
      Throws:
        `Exception`

    - #### assertQEx

          public static void assertQEx(String message,
                                       org.apache.solr.request.SolrQueryRequest req,
                                       int code)

      Makes sure a query throws a SolrException with the listed response code

    - #### assertQEx

          public static void assertQEx(String message,
                                       org.apache.solr.request.SolrQueryRequest req,
                                       org.apache.solr.common.SolrException.ErrorCode code)

    - #### assertQEx

          public static void assertQEx(String failMessage,
                                       String exceptionMessage,
                                       org.apache.solr.request.SolrQueryRequest req,
                                       org.apache.solr.common.SolrException.ErrorCode code)

      Makes sure a query throws a SolrException with the listed response code and expected message
      Parameters:
        `failMessage` - The assert message to show when the query doesn't throw the expected exception
        `exceptionMessage` - A substring of the message expected in the exception
        `req` - Solr request
        `code` - expected error code for the query

    - #### optimize

          public static String optimize(String... args)

      See Also:
        `BaseTestHarness.optimize(java.lang.String...)`

    - #### commit

          public static String commit(String... args)

      See Also:
        `BaseTestHarness.commit(java.lang.String...)`

    - #### adoc

          public static String adoc(String... fieldsAndValues)

      Generates a simple <add><doc>... XML String with no options
      Parameters:
        `fieldsAndValues` - 0th and Even numbered args are fields names odds are field values.
      See Also:
        `add(org.apache.solr.SolrTestCaseJ4.XmlDoc, java.lang.String...)`, `doc(java.lang.String...)`

    - #### adoc

          public static String adoc(org.apache.solr.common.SolrInputDocument sdoc)

      Generates a simple <add><doc>... XML String with no options

    - #### add

          public static String add(SolrTestCaseJ4.XmlDoc doc,
                                   String... args)

      Generates an <add><doc>... XML String with options on the add.
      Parameters:
        `doc` - the Document to add
        `args` - 0th and Even numbered args are param names, Odds are param values.
      See Also:
        `add(org.apache.solr.SolrTestCaseJ4.XmlDoc, java.lang.String...)`, `doc(java.lang.String...)`

    - #### delI

          public static String delI(String id)

      Generates a <delete>... XML string for an ID
      See Also:
        `BaseTestHarness.deleteById(java.lang.String, java.lang.String...)`

    - #### delQ

          public static String delQ(String q)

      Generates a <delete>... XML string for an query
      See Also:
        `BaseTestHarness.deleteByQuery(java.lang.String, java.lang.String...)`

    - #### doc

          public static SolrTestCaseJ4.XmlDoc doc(String... fieldsAndValues)

      Generates a simple <doc>... XML String with no options
      Parameters:
        `fieldsAndValues` - 0th and Even numbered args are fields names, Odds are field values.
      See Also:
        `BaseTestHarness.makeSimpleDoc(java.lang.String...)`

    - #### params

          public static org.apache.solr.common.params.ModifiableSolrParams params(String... params)

    - #### map

          public static Map map(Object... params)

    - #### req

          public static org.apache.solr.request.SolrQueryRequest req(String... q)

      Generates a SolrQueryRequest using the LocalRequestFactory
      See Also:
        `lrf`

    - #### req

          public static org.apache.solr.request.SolrQueryRequest req(String[] params,
                                                                     String... moreParams)

      Generates a SolrQueryRequest using the LocalRequestFactory
      See Also:
        `lrf`

    - #### req

          public static org.apache.solr.request.SolrQueryRequest req(org.apache.solr.common.params.SolrParams params,
                                                                     String... moreParams)

      Generates a SolrQueryRequest

    - #### clearIndex

          public void clearIndex()

    - #### updateJ

          public static String updateJ(String json,
                                       org.apache.solr.common.params.SolrParams args)
                                throws Exception

      Send JSON update commands
      Throws:
        `Exception`

    - #### sdoc

          public static org.apache.solr.common.SolrInputDocument sdoc(Object... fieldsAndValues)

    - #### sdocs

          public static List<org.apache.solr.common.SolrInputDocument> sdocs(org.apache.solr.common.SolrInputDocument... docs)

    - #### json

          public static String json(String testJSON)

      Converts "test JSON" strings into JSON parseable by our JSON parser. For example, this method changed single quoted strings into double quoted strings before the parser could natively handle them. This transformation is automatically applied to JSON test srings (like assertJQ).

    - #### json

          public static String json(org.apache.solr.common.SolrInputDocument doc)

      Creates JSON from a SolrInputDocument. Doesn't currently handle boosts.
      See Also:
        `json(SolrInputDocument,CharArr)`

    - #### json

          public static void json(org.apache.solr.common.SolrInputDocument doc,
                                  org.noggit.CharArr out)

      Appends to the `out` array with JSON from the `doc`. Doesn't currently handle boosts, but does recursively handle child documents

    - #### jsonAdd

          public static String jsonAdd(org.apache.solr.common.SolrInputDocument... docs)

      Creates a JSON add command from a SolrInputDocument list. Doesn't currently handle boosts.

    - #### jsonDelId

          public static String jsonDelId(Object... ids)

      Creates a JSON delete command from an id list

    - #### jsonDelQ

          public static String jsonDelQ(String... queries)

      Creates a JSON deleteByQuery command

    - #### addAndGetVersion

          public static Long addAndGetVersion(org.apache.solr.common.SolrInputDocument sdoc,
                                              org.apache.solr.common.params.SolrParams params)
                                       throws Exception

      Throws:
        `Exception`

    - #### deleteAndGetVersion

          public static Long deleteAndGetVersion(String id,
                                                 org.apache.solr.common.params.SolrParams params)
                                          throws Exception

      Throws:
        `Exception`

    - #### deleteByQueryAndGetVersion

          public static Long deleteByQueryAndGetVersion(String q,
                                                        org.apache.solr.common.params.SolrParams params)
                                                 throws Exception

      Throws:
        `Exception`

    - #### indexDocs

          public Map<Comparable,SolrTestCaseJ4.Doc> indexDocs(List<SolrTestCaseJ4.FldType> descriptor,
                                                              Map<Comparable,SolrTestCaseJ4.Doc> model,
                                                              int nDocs)
                                                       throws Exception

      Throws:
        `Exception`

    - #### createDoc

          public static SolrTestCaseJ4.Doc createDoc(List<SolrTestCaseJ4.FldType> descriptor)

    - #### createSort

          public static Comparator<SolrTestCaseJ4.Doc> createSort(org.apache.solr.schema.IndexSchema schema,
                                                                  List<SolrTestCaseJ4.FldType> fieldTypes,
                                                                  String[] out)

    - #### createComparator

          public static Comparator<SolrTestCaseJ4.Doc> createComparator(String field,
                                                                        boolean asc,
                                                                        boolean sortMissingLast,
                                                                        boolean sortMissingFirst,
                                                                        boolean sortMissingAsZero)

    - #### createComparator

          public static Comparator<SolrTestCaseJ4.Doc> createComparator(List<Comparator<SolrTestCaseJ4.Doc>> comparators)

    - #### toJSON

          public static String toJSON(SolrTestCaseJ4.Doc doc)

    - #### invertField

          public Map<Comparable,List<Comparable>> invertField(Map<Comparable,SolrTestCaseJ4.Doc> model,
                                                              String field)

      Return a Map from field value to a list of document ids

    - #### getFile

          public static File getFile(String name)

      Gets a resource from the context classloader as `File`. This method should only be used, if a real file is needed. To get a stream, code should prefer `Class.getResourceAsStream(java.lang.String)` using `this.getClass()`.

    - #### TEST_HOME

          public static String TEST_HOME()

    - #### TEST_PATH

          public static Path TEST_PATH()

    - #### configset

          public static Path configset(String name)

    - #### getRootCause

          public static Throwable getRootCause(Throwable t)

    - #### assertXmlFile

          public static void assertXmlFile(File file,
                                           String... xpath)
                                    throws IOException,
                                           SAXException

      Throws:
        `IOException`
        `SAXException`

    - #### assertFieldValues

          public static void assertFieldValues(org.apache.solr.common.SolrDocumentList documents,
                                               String fieldName,
                                               Object... expectedValues)

      Fails if the number of documents in the given SolrDocumentList differs from the given number of expected values, or if any of the values in the given field don't match the expected values in the same order.

    - #### copyMinConf

          public static void copyMinConf(File dstRoot)
                                  throws IOException

      Throws:
        `IOException`

    - #### copyMinConf

          public static void copyMinConf(File dstRoot,
                                         String propertiesContent)
                                  throws IOException

      Throws:
        `IOException`

    - #### copyMinFullSetup

          public static void copyMinFullSetup(File dstRoot)
                                       throws IOException

      Throws:
        `IOException`

    - #### copySolrHomeToTemp

          public static void copySolrHomeToTemp(File dstRoot,
                                                String collection)
                                         throws IOException

      Throws:
        `IOException`

    - #### compareSolrDocument

          public boolean compareSolrDocument(Object expected,
                                             Object actual)

    - #### compareSolrDocumentList

          public boolean compareSolrDocumentList(Object expected,
                                                 Object actual)

    - #### compareSolrInputDocument

          public boolean compareSolrInputDocument(Object expected,
                                                  Object actual)

    - #### assertSolrInputFieldEquals

          public boolean assertSolrInputFieldEquals(Object expected,
                                                    Object actual)

    - #### skewed

          public static Object skewed(Object likely,
                                      Object unlikely)

      Returns `likely` most (1/10) of the time, otherwise `unlikely`

    - #### getCloudSolrClient

          public static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost)

    - #### getCloudSolrClient

          public static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost,
                                                                                             org.apache.http.client.HttpClient httpClient)

    - #### getCloudSolrClient

          public static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost,
                                                                                             boolean shardLeadersOnly)

    - #### getCloudSolrClient

          public static org.apache.solr.client.solrj.impl.CloudSolrClient getCloudSolrClient(String zkHost,
                                                                                             boolean shardLeadersOnly,
                                                                                             org.apache.http.client.HttpClient httpClient)

    - #### getConcurrentUpdateSolrClient

          public static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient getConcurrentUpdateSolrClient(String baseSolrUrl,
                                                                                                                   int queueSize,
                                                                                                                   int threadCount)

    - #### getConcurrentUpdateSolrClient

          public static org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient getConcurrentUpdateSolrClient(String baseSolrUrl,
                                                                                                                   org.apache.http.client.HttpClient httpClient,
                                                                                                                   int queueSize,
                                                                                                                   int threadCount)

    - #### getLBHttpSolrClient

          public static org.apache.solr.client.solrj.impl.LBHttpSolrClient getLBHttpSolrClient(org.apache.http.client.HttpClient client,
                                                                                               String... solrUrls)

    - #### getLBHttpSolrClient

          public static org.apache.solr.client.solrj.impl.LBHttpSolrClient getLBHttpSolrClient(String... solrUrls)
                                                                                        throws MalformedURLException

      Throws:
        `MalformedURLException`

    - #### getHttpSolrClient

          public static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url,
                                                                                           org.apache.http.client.HttpClient httpClient,
                                                                                           org.apache.solr.client.solrj.ResponseParser responseParser,
                                                                                           boolean compression)

    - #### getHttpSolrClient

          public static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url,
                                                                                           org.apache.http.client.HttpClient httpClient,
                                                                                           org.apache.solr.client.solrj.ResponseParser responseParser)

    - #### getHttpSolrClient

          public static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url,
                                                                                           org.apache.http.client.HttpClient httpClient)

    - #### getHttpSolrClient

          public static org.apache.solr.client.solrj.impl.HttpSolrClient getHttpSolrClient(String url)

    - #### randomDate

          public static String randomDate()

      Returns a randomly generated Date in the appropriate Solr external (input) format
      See Also:
        `randomSkewedDate()`

    - #### randomSkewedDate

          public static String randomSkewedDate()

      Returns a Date such that all results from this method always have the same values for year+month+day+hour+minute but the seconds are randomized. This can be helpful for indexing documents with random date values that are biased for a narrow window (one day) to test collisions/overlaps
      See Also:
        `randomDate()`

    - #### randomXmlUsableUnicodeString

          public static String randomXmlUsableUnicodeString()

      We want "realistic" unicode strings beyond simple ascii, but because our updates use XML we need to ensure we don't get "special" code block.

    - #### waitForWarming

          protected void waitForWarming()
                                 throws InterruptedException

      Throws:
        `InterruptedException`

    - #### chooseMPForMP

          public static void chooseMPForMP()
                                    throws Exception

      Throws:
        `Exception`

    - #### unchooseMPForMP

          public static void unchooseMPForMP()

    - #### systemSetPropertySolrTestsMergePolicy

          @Deprecated
          protected static void systemSetPropertySolrTestsMergePolicy(String value)

      Deprecated.

    - #### systemClearPropertySolrTestsMergePolicy

          @Deprecated
          protected static void systemClearPropertySolrTestsMergePolicy()

      Deprecated.

    - #### systemSetPropertySolrTestsMergePolicyFactory

          protected static void systemSetPropertySolrTestsMergePolicyFactory(String value)

    - #### systemClearPropertySolrTestsMergePolicyFactory

          protected static void systemClearPropertySolrTestsMergePolicyFactory()

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