org.apache.solr.util
Class RestTestBase

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.SolrJettyTestBase
                  extended by org.apache.solr.util.RestTestBase

public abstract class RestTestBase
extends SolrJettyTestBase


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.solr.SolrTestCaseJ4
SolrTestCaseJ4.CoreDescriptorBuilder, 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
protected static RestTestHarness restTestHarness
           
 
Fields inherited from class org.apache.solr.SolrJettyTestBase
context, jetty, port, server
 
Fields inherited from class org.apache.solr.SolrTestCaseJ4
configString, dataDir, DEFAULT_CONNECTION_TIMEOUT, formatter, h, hdfsDataDir, lrf, ONE_ONE, schemaString, solrClassRules, solrConfig, 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, OLD_FORMAT_IMPERSONATION_IS_ACTIVE, PREFLEX_IMPERSONATION_IS_ACTIVE, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_BADAPPLES, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, 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
RestTestBase()
           
 
Method Summary
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 assertJPost(String request, String content, double delta, String... tests)
          Validates the response from a PUT request matches some JSON test expressions and closes the query.
static void assertJPost(String request, String content, String... tests)
          Validates the response from a POST request matches some JSON test expressions
static void assertJPut(String request, String content, double delta, String... tests)
          Validates the response from a PUT request matches some JSON test expressions and closes the query.
static void assertJPut(String request, String content, String... tests)
          Validates the response from a PUT request matches some JSON test expressions
static void assertJQ(String request, double delta, String... tests)
          Validates a query matches some JSON test expressions and closes the query.
static void assertJQ(String request, String... tests)
          Validates a query matches some JSON test expressions using the default double delta tolerance.
static void assertQ(String request, String... tests)
          Validates a query matches some XPath test expressions
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 createJettyAndHarness(String solrHome, String configFile, String schemaFile, String context, boolean stopAtShutdown, SortedMap<org.eclipse.jetty.servlet.ServletHolder,String> extraServlets)
           
static String JQ(String request)
          Makes a query request and returns the JSON string response
 
Methods inherited from class org.apache.solr.SolrJettyTestBase
afterSolrJettyTestBase, beforeSolrJettyTestBase, cleanUpJettyHome, createJetty, createJetty, createNewSolrServer, getExampleKeystoreFile, getSolrHome, getSolrServer, setupJettyTestHome
 
Methods inherited from class org.apache.solr.SolrTestCaseJ4
add, addAndGetVersion, adoc, adoc, assertJQ, assertJQ, assertQ, assertQ, assertQEx, assertQEx, assertXmlFile, buildCoreDescriptor, clearIndex, commit, copyMinConf, copyMinConf, copyMinFullSetup, copySolrHomeToTemp, createComparator, createComparator, createCore, createCoreContainer, createDefaultCoreContainer, createDoc, createSort, createTempDir, deleteAndGetVersion, deleteByQueryAndGetVersion, deleteCore, delI, delQ, doc, endTrackingSearchers, endTrackingZkClients, getClassName, getFile, getRootCause, getSchemaFile, getSimpleClassName, getSolrConfigFile, hasInitException, hasInitException, ignoreException, indexDocs, initCore, initCore, initCore, initCore, invertField, JQ, json, json, jsonAdd, jsonDelId, jsonDelQ, map, newRandomConfig, optimize, params, postSetUp, preTearDown, recurseDelete, req, req, req, resetExceptionIgnores, resetFactory, sdoc, sdocs, setLoggingLevel, setUp, setupLogging, setupNoCoreTest, startTrackingSearchers, startTrackingZkClients, tearDown, TEST_HOME, toJSON, unIgnoreException, updateJ, useFactory
 
Methods inherited from class org.apache.lucene.util.LuceneTestCase
assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, assertFieldsEquals, assertFieldStatisticsEquals, assertNormsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertSaneFieldCaches, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, closeAfterSuite, closeAfterTest, defaultCodecSupportsDocsWithField, 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, newMergePolicy, newMergePolicy, newMockDirectory, newMockDirectory, newMockFSDirectory, newSearcher, newSearcher, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, random, randomLocale, randomTimeZone, rarely, rarely, replaceMaxFailureRule, 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

restTestHarness

protected static RestTestHarness restTestHarness
Constructor Detail

RestTestBase

public RestTestBase()
Method Detail

createJettyAndHarness

public static void createJettyAndHarness(String solrHome,
                                         String configFile,
                                         String schemaFile,
                                         String context,
                                         boolean stopAtShutdown,
                                         SortedMap<org.eclipse.jetty.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


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_"

JQ

public static String JQ(String request)
                 throws Exception
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:
Exception

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:
JSONTestUtil.DEFAULT_DELTA, assertJQ(String,double,String...)

assertJQ

public static void assertJQ(String request,
                            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. 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:
Exception

assertJPut

public static void assertJPut(String request,
                              String content,
                              String... tests)
                       throws Exception
Validates the response from a PUT request matches some JSON test expressions

Throws:
Exception
See Also:
JSONTestUtil.DEFAULT_DELTA, assertJQ(String,double,String...)

assertJPut

public static void assertJPut(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

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:
JSONTestUtil.DEFAULT_DELTA, assertJQ(String,double,String...)

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


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