org.apache.solr.util
Class AbstractSolrTestCase

java.lang.Object
  extended by org.junit.Assert
      extended by org.apache.lucene.util.LuceneTestCase
          extended by org.apache.solr.SolrTestCaseJ4
              extended by org.apache.solr.util.AbstractSolrTestCase

public abstract class AbstractSolrTestCase
extends SolrTestCaseJ4

An Abstract base class that makes writing Solr JUnit tests "easier"

Test classes that subclass this need only specify the path to the schema.xml file (:TODO: the solrconfig.xml as well) and write some testMethods. This class takes care of creating/destroying the index, and provides several assert methods to assist you.

See Also:
SolrTestCaseJ4.setUp(), SolrTestCaseJ4.tearDown()

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.solr.SolrTestCaseJ4
SolrTestCaseJ4.Doc, SolrTestCaseJ4.Fld, SolrTestCaseJ4.FldType, SolrTestCaseJ4.FVal, SolrTestCaseJ4.IRange, SolrTestCaseJ4.IVals, SolrTestCaseJ4.SVal, SolrTestCaseJ4.Vals, SolrTestCaseJ4.XmlDoc
 
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.Nightly, org.apache.lucene.util.LuceneTestCase.Slow, org.apache.lucene.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.util.LuceneTestCase.Weekly
 
Field Summary
static org.slf4j.Logger log
           
protected  org.apache.solr.core.SolrConfig solrConfig
           
 
Fields inherited from class org.apache.solr.SolrTestCaseJ4
configString, dataDir, DEFAULT_CONNECTION_TIMEOUT, formatter, h, lrf, ONE_ONE, schemaString, solrClassRules, solrTestRules, testSolrHome, ZERO_ONE, ZERO_TWO
 
Fields inherited from class org.apache.lucene.util.LuceneTestCase
classRules, DEFAULT_LINE_DOCS_FILE, doesntSupportOffsets, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, PREFLEX_IMPERSONATION_IS_ACTIVE, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_BADAPPLES, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEMP_DIR, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_VERSION_CURRENT, TEST_WEEKLY, VERBOSE
 
Constructor Summary
AbstractSolrTestCase()
           
 
Method Summary
 String adoc(int commitWithin, String... fieldsAndValues)
          Generates a simple <add><doc>...
 String delI(String id, String... args)
          Generates a <delete>...
 String delQ(String q, String... args)
          Generates a <delete>...
static File getFile(String name)
           
 String getSolrHome()
          Subclasses can override this to change a test's solr home (default is in test-files)
static void ignoreException(String pattern)
          Causes an exception matching the regex pattern to not be logged.
 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 boolean recurseDelete(File f)
           
static void resetExceptionIgnores()
           
 
Methods inherited from class org.apache.solr.SolrTestCaseJ4
add, addAndGetVersion, adoc, adoc, assertFailedU, assertFailedU, assertJQ, assertJQ, assertQ, assertQ, assertQEx, assertQEx, assertU, assertU, clearIndex, commit, createComparator, createComparator, createCore, createDoc, createSort, createTempDir, deleteAndGetVersion, deleteByQueryAndGetVersion, deleteCore, delI, delQ, doc, endTrackingSearchers, endTrackingZkClients, getClassName, getRootCause, getSchemaFile, getSimpleClassName, getSolrConfigFile, indexDocs, initCore, initCore, initCore, initCore, JQ, json, jsonAdd, jsonDelId, jsonDelQ, map, optimize, params, req, req, req, resetFactory, sdoc, setLoggingLevel, setUp, setupLogging, startTrackingSearchers, startTrackingZkClients, tearDown, TEST_HOME, toJSON, unIgnoreException, updateJ, useFactory
 
Methods inherited from class org.apache.lucene.util.LuceneTestCase
assertSaneFieldCaches, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, closeAfterSuite, closeAfterTest, defaultCodecSupportsDocValues, defaultCodecSupportsSortedSet, dumpArray, dumpIterator, getDataFile, getOnlySegmentReader, getTestClass, getTestName, isTestThread, localeForName, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMockDirectory, newMockDirectory, newMockFSDirectory, newSearcher, newSearcher, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, random, randomLocale, randomTimeZone, rarely, rarely, usually, usually
 
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

solrConfig

protected org.apache.solr.core.SolrConfig solrConfig

log

public static org.slf4j.Logger log
Constructor Detail

AbstractSolrTestCase

public AbstractSolrTestCase()
Method Detail

getSolrHome

public String getSolrHome()
Subclasses can override this to change a test's solr home (default is in test-files)


ignoreException

public static void ignoreException(String pattern)
Causes an exception matching the regex pattern to not be logged.


resetExceptionIgnores

public static void resetExceptionIgnores()

postSetUp

public void postSetUp()
Subclasses that override setUp can optionally call this method to log the fact that their setUp process has ended.

Overrides:
postSetUp in class SolrTestCaseJ4

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.

Overrides:
preTearDown in class SolrTestCaseJ4

adoc

public String adoc(int commitWithin,
                   String... fieldsAndValues)
Generates a simple <add><doc>... XML String with the commitWithin attribute.

Parameters:
commitWithin - the value of the commitWithin attribute
fieldsAndValues - 0th and Even numbered args are fields names odds are field values.
See Also:
SolrTestCaseJ4.add(org.apache.solr.SolrTestCaseJ4.XmlDoc, java.lang.String...), SolrTestCaseJ4.doc(java.lang.String...)

delI

public String delI(String id,
                   String... args)
Generates a <delete>... XML string for an ID

See Also:
BaseTestHarness.deleteById(java.lang.String, java.lang.String...)

delQ

public String delQ(String q,
                   String... args)
Generates a <delete>... XML string for an query

See Also:
BaseTestHarness.deleteByQuery(java.lang.String, java.lang.String...)

recurseDelete

public static boolean recurseDelete(File f)

getFile

public static File getFile(String name)
See Also:
SolrTestCaseJ4.getFile(java.lang.String)


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