speed up a few more tests with SolrTestCaseJ4

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/branches/newtrunk@925669 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-03-20 20:11:03 +00:00
parent c3d33bc62e
commit 733aabd082
19 changed files with 291 additions and 231 deletions

View File

@ -17,17 +17,21 @@
package org.apache.solr;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.BeforeClass;
import org.junit.Test;
/** Test SOLR-59, echo of query parameters */
public class EchoParamsTest extends AbstractSolrTestCase {
public class EchoParamsTest extends SolrTestCaseJ4 {
public String getSchemaFile() { return "solr/crazy-path-to-schema.xml"; }
public String getSolrConfigFile() { return "solr/crazy-path-to-config.xml"; }
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solr/crazy-path-to-config.xml","solr/crazy-path-to-schema.xml");
}
private static final String HEADER_XPATH = "/response/lst[@name='responseHeader']";
@Test
public void testDefaultEchoParams() {
lrf.args.put("wt", "xml");
lrf.args.put("version", "2.2");
@ -35,6 +39,7 @@ public class EchoParamsTest extends AbstractSolrTestCase {
assertQ(req("foo"),"not(//lst[@name='params'])");
}
@Test
public void testDefaultEchoParamsDefaultVersion() {
lrf.args.put("wt", "xml");
lrf.args.remove("version");
@ -42,6 +47,7 @@ public class EchoParamsTest extends AbstractSolrTestCase {
assertQ(req("foo"),"not(//lst[@name='params'])");
}
@Test
public void testExplicitEchoParams() {
lrf.args.put("wt", "xml");
lrf.args.put("version", "2.2");
@ -51,6 +57,7 @@ public class EchoParamsTest extends AbstractSolrTestCase {
assertQ(req("foo"),HEADER_XPATH + "/lst[@name='params']/str[@name='wt'][.='xml']");
}
@Test
public void testAllEchoParams() {
lrf = h.getRequestFactory
("crazy_custom_qt", 0, 20,

View File

@ -17,52 +17,50 @@
package org.apache.solr;
import org.apache.solr.request.*;
import org.apache.solr.util.*;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.Set;
/**
* A test of basic features using the minial legal solr schema.
*/
public class MinimalSchemaTest extends AbstractSolrTestCase {
public String getSchemaFile() { return "solr/conf/schema-minimal.xml"; }
public class MinimalSchemaTest extends SolrTestCaseJ4 {
/**
* NOTE: we explicilty use the general 'solrconfig.xml' file here, in
* an attempt to test as many braod features as possible.
* NOTE: we explicitly use the general 'solrconfig.xml' file here, in
* an attempt to test as many broad features as possible.
*
* Do not change this to point at some other "simpler" solrconfig.xml
* just because you want to add a new test case using solrconfig.xml,
* but your new testcase adds a feature that breaks this test.
*/
public String getSolrConfigFile() { return "solr/conf/solrconfig.xml"; }
public void setUp() throws Exception {
super.setUp();
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solr/conf/solrconfig.xml","solr/conf/schema-minimal.xml");
/* make sure some missguided soul doesn't inadvertantly give us
a uniqueKey field and defeat the point of hte tests
/* make sure some misguided soul doesn't inadvertently give us
a uniqueKey field and defeat the point of the tests
*/
assertNull("UniqueKey Field isn't null",
h.getCore().getSchema().getUniqueKeyField());
lrf.args.put("version","2.0");
assertU("Simple assertion that adding a document works",
assertNull("Simple assertion that adding a document works", h.validateUpdate(
adoc("id", "4055",
"subject", "Hoss",
"project", "Solr"));
assertU(adoc("id", "4056",
"project", "Solr")));
assertNull(h.validateUpdate(adoc("id", "4056",
"subject", "Yonik",
"project", "Solr"));
assertU(commit());
assertU(optimize());
"project", "Solr")));
assertNull(h.validateUpdate(commit()));
assertNull(h.validateUpdate(optimize()));
}
@Test
public void testSimpleQueries() {
assertQ("couldn't find subject hoss",
@ -79,6 +77,7 @@ public class MinimalSchemaTest extends AbstractSolrTestCase {
}
/** SOLR-1371 */
@Test
public void testLuke() {
assertQ("basic luke request failed",
@ -104,6 +103,7 @@ public class MinimalSchemaTest extends AbstractSolrTestCase {
* them with a request (using some simple params) to verify that they
* don't generate an error against the minimal schema
*/
@Test
public void testAllConfiguredHandlers() {
Set<String> handlerNames = h.getCore().getRequestHandlers().keySet();
for (String handler : handlerNames) {

View File

@ -24,23 +24,28 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/** Tests the ability to configure multiple query output writers, and select those
* at query time.
*
*/
public class OutputWriterTest extends AbstractSolrTestCase {
public class OutputWriterTest extends SolrTestCaseJ4 {
/** The XML string that's output for testing purposes. */
public static final String USELESS_OUTPUT = "useless output";
public String getSchemaFile() { return "solr/crazy-path-to-schema.xml"; }
public String getSolrConfigFile() { return "solr/crazy-path-to-config.xml"; }
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solr/crazy-path-to-config.xml","solr/crazy-path-to-schema.xml");
}
/** responseHeader has changed in SOLR-59, check old and new variants */
@Test
public void testSOLR59responseHeaderVersions() {
// default version is 2.2, with "new" responseHeader
lrf.args.remove("version");
@ -64,12 +69,14 @@ public class OutputWriterTest extends AbstractSolrTestCase {
assertQ(req("foo"), "/response/lst[@name='responseHeader']/int[@name='QTime']");
}
@Test
public void testUselessWriter() throws Exception {
lrf.args.put("wt", "useless");
String out = h.query(req("foo"));
assertEquals(USELESS_OUTPUT, out);
}
@Test
public void testTrivialXsltWriter() throws Exception {
lrf.args.put("wt", "xslt");
lrf.args.put("tr", "dummy.xsl");

View File

@ -19,36 +19,34 @@ package org.apache.solr;
import org.apache.solr.request.*;
import org.apache.solr.util.*;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* This is an example of how to write a JUnit tests for Solr using the
* AbstractSolrTestCase
* SolrTestCaseJ4
*/
public class SampleTest extends AbstractSolrTestCase {
public class SampleTest extends SolrTestCaseJ4 {
/**
* All subclasses of AbstractSolrTestCase must define this method.
* All subclasses of SolrTestCaseJ4 should initialize the core.
*
* <p>
* Note that different tests can use different schemas by refering
* Note that different tests can use different schemas/configs by referring
* to any crazy path they want (as long as it works).
* </p>
*/
public String getSchemaFile() { return "solr/crazy-path-to-schema.xml"; }
/**
* All subclasses of AbstractSolrTestCase must define this method
*
* <p>
* Note that different tests can use different configs by refering
* to any crazy path they want (as long as it works).
* </p>
*/
public String getSolrConfigFile() { return "solr/crazy-path-to-config.xml"; }
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solr/crazy-path-to-config.xml","solr/crazy-path-to-schema.xml");
}
/**
* Demonstration of some of the simple ways to use the base class
*/
@Test
public void testSimple() {
lrf.args.put("version","2.0");
assertU("Simple assertion that adding a document works",
@ -72,6 +70,7 @@ public class SampleTest extends AbstractSolrTestCase {
/**
* Demonstration of some of the more complex ways to use the base class
*/
@Test
public void testAdvanced() throws Exception {
lrf.args.put("version","2.0");
assertU("less common case, a complex addition with options",

View File

@ -28,30 +28,32 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.WhitespaceTokenizer;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.Query;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.search.SolrQueryParser;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.apache.solr.analysis.BaseTokenTestCase.*;
public class TestReversedWildcardFilterFactory extends AbstractSolrTestCase {
public class TestReversedWildcardFilterFactory extends SolrTestCaseJ4 {
Map<String,String> args = new HashMap<String, String>();
ReversedWildcardFilterFactory factory = new ReversedWildcardFilterFactory();
IndexSchema schema;
public String getSchemaFile() {
return "schema-reversed.xml";
}
public String getSolrConfigFile() {
return "solrconfig.xml";
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema-reversed.xml");
}
@Before
public void setUp() throws Exception {
super.setUp();
schema = new IndexSchema(solrConfig, getSchemaFile(), null);
}
@Test
public void testReversedTokens() throws IOException {
String text = "simple text";
args.put("withOriginal", "true");
@ -70,6 +72,7 @@ public class TestReversedWildcardFilterFactory extends AbstractSolrTestCase {
new int[] { 1, 1 });
}
@Test
public void testIndexingAnalysis() throws Exception {
Analyzer a = schema.getAnalyzer();
String text = "one two three si\uD834\uDD1Ex";
@ -101,6 +104,7 @@ public class TestReversedWildcardFilterFactory extends AbstractSolrTestCase {
);
}
@Test
public void testQueryParsing() throws IOException, ParseException {
SolrQueryParser parserOne = new SolrQueryParser(schema, "one");

View File

@ -18,31 +18,32 @@
package org.apache.solr.core;
import org.apache.lucene.index.IndexWriter;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.handler.admin.ShowFileRequestHandler;
import org.apache.solr.search.SolrIndexReader;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.update.SolrIndexConfig;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.RefCounted;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import static org.junit.Assert.*;
import javax.xml.xpath.XPathConstants;
import java.io.IOException;
import java.io.InputStream;
public class TestConfig extends AbstractSolrTestCase {
public class TestConfig extends SolrTestCaseJ4 {
public String getSchemaFile() {
return "schema.xml";
}
//public String getSolrConfigFile() { return "solrconfig.xml"; }
public String getSolrConfigFile() {
return "solrconfig-termindex.xml";
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig-termindex.xml","schema-reversed.xml");
}
@Test
public void testLib() throws IOException {
SolrResourceLoader loader = h.getCore().getResourceLoader();
InputStream data = null;
@ -68,6 +69,7 @@ public class TestConfig extends AbstractSolrTestCase {
}
}
@Test
public void testJavaProperty() {
// property values defined in build.xml
@ -91,6 +93,7 @@ public class TestConfig extends AbstractSolrTestCase {
assertEquals("prefix-proptwo-suffix", node.getTextContent());
}
@Test
public void testLucene23Upgrades() throws Exception {
double bufferSize = solrConfig.getDouble("indexDefaults/ramBufferSizeMB");
assertTrue(bufferSize + " does not equal: " + 32, bufferSize == 32);
@ -103,6 +106,7 @@ public class TestConfig extends AbstractSolrTestCase {
}
// sometime if the config referes to old things, it must be replaced with new stuff
@Test
public void testAutomaticDeprecationSupport() {
// make sure the "admin/file" handler is registered
ShowFileRequestHandler handler = (ShowFileRequestHandler) h.getCore().getRequestHandler("/admin/file");
@ -114,6 +118,7 @@ public class TestConfig extends AbstractSolrTestCase {
assertTrue(handler.getHiddenFiles().contains("PROTWORDS.TXT"));
}
@Test
public void testTermIndexInterval() throws Exception {
class ExposeWriterHandler extends DirectUpdateHandler2 {
public ExposeWriterHandler() throws IOException {
@ -131,6 +136,7 @@ public class TestConfig extends AbstractSolrTestCase {
assertEquals(256, interval);
}
@Test
public void testTermIndexDivisor() throws Exception {
IndexReaderFactory irf = h.getCore().getIndexReaderFactory();
StandardIndexReaderFactory sirf = (StandardIndexReaderFactory) irf;

View File

@ -17,16 +17,22 @@
package org.apache.solr.core;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.common.params.EventParams;
import org.apache.lucene.store.Directory;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestQuerySenderListener extends AbstractSolrTestCase {
public class TestQuerySenderListener extends SolrTestCaseJ4 {
@Override public String getSchemaFile() { return "schema.xml"; }
@Override public String getSolrConfigFile() { return "solrconfig-querysender.xml"; }
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig-querysender.xml","schema.xml");
}
@Test
public void testRequestHandlerRegistry() {
// property values defined in build.xml
SolrCore core = h.getCore();
@ -35,6 +41,7 @@ public class TestQuerySenderListener extends AbstractSolrTestCase {
assertEquals( 1, core.newSearcherListeners.size() );
}
@Test
public void testSearcherEvents() throws Exception {
SolrCore core = h.getCore();
SolrEventListener newSearcherListener = core.newSearcherListeners.get(0);

View File

@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.lucene.index.IndexReader;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.util.NamedList;
@ -34,14 +35,21 @@ import org.apache.solr.handler.component.QueryElevationComponent.ElevationObj;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class QueryElevationComponentTest extends AbstractSolrTestCase {
public class QueryElevationComponentTest extends SolrTestCaseJ4 {
@Override public String getSchemaFile() { return "schema12.xml"; }
@Override public String getSolrConfigFile() { return "solrconfig-elevate.xml"; }
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig-elevate.xml","schema12.xml");
}
@Test
public void testInterface() throws Exception
{
SolrCore core = h.getCore();
@ -86,6 +94,7 @@ public class QueryElevationComponentTest extends AbstractSolrTestCase {
assertEquals( "xxxxyyyy", comp.getAnalyzedQuery( "XXXX YYYY" ) );
}
@Test
public void testEmptyQuery() throws Exception {
SolrCore core = h.getCore();
@ -101,7 +110,7 @@ public class QueryElevationComponentTest extends AbstractSolrTestCase {
}
@Test
public void testSorting() throws IOException
{
SolrCore core = h.getCore();
@ -221,6 +230,7 @@ public class QueryElevationComponentTest extends AbstractSolrTestCase {
log.info( "OUT:"+file.getAbsolutePath() );
}
@Test
public void testElevationReloading() throws Exception
{
SolrCore core = h.getCore();

View File

@ -1,5 +1,6 @@
package org.apache.solr.handler.component;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.core.SolrCore;
import org.apache.solr.common.params.ModifiableSolrParams;
@ -10,6 +11,10 @@ import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.ArrayList;
@ -36,36 +41,28 @@ import java.util.Arrays;
*
*
**/
public class TermVectorComponentTest extends AbstractSolrTestCase {
@Override
public String getSchemaFile() {
return "schema.xml";
}
public class TermVectorComponentTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
@Override
public String getSolrConfigFile() {
return "solrconfig.xml";
}
@Override
public void setUp() throws Exception {
super.setUp();
assertU(adoc("id", "0", "test_posofftv", "This is a title and another title"));
assertU(adoc("id", "1", "test_posofftv",
"The quick reb fox jumped over the lazy brown dogs."));
assertU(adoc("id", "2", "test_posofftv", "This is a document"));
assertU(adoc("id", "3", "test_posofftv", "another document"));
assertNull(h.validateUpdate(adoc("id", "0", "test_posofftv", "This is a title and another title")));
assertNull(h.validateUpdate(adoc("id", "1", "test_posofftv",
"The quick reb fox jumped over the lazy brown dogs.")));
assertNull(h.validateUpdate(adoc("id", "2", "test_posofftv", "This is a document")));
assertNull(h.validateUpdate(adoc("id", "3", "test_posofftv", "another document")));
//bunch of docs that are variants on blue
assertU(adoc("id", "4", "test_posofftv", "blue"));
assertU(adoc("id", "5", "test_posofftv", "blud"));
assertU(adoc("id", "6", "test_posofftv", "boue"));
assertU(adoc("id", "7", "test_posofftv", "glue"));
assertU(adoc("id", "8", "test_posofftv", "blee"));
assertU(adoc("id", "9", "test_posofftv", "blah"));
assertNull(h.validateUpdate(adoc("id", "4", "test_posofftv", "blue")));
assertNull(h.validateUpdate(adoc("id", "5", "test_posofftv", "blud")));
assertNull(h.validateUpdate(adoc("id", "6", "test_posofftv", "boue")));
assertNull(h.validateUpdate(adoc("id", "7", "test_posofftv", "glue")));
assertNull(h.validateUpdate(adoc("id", "8", "test_posofftv", "blee")));
assertNull(h.validateUpdate(adoc("id", "9", "test_posofftv", "blah")));
assertU("commit", commit());
assertNull(h.validateUpdate(commit()));
}
@Test
public void testBasics() throws Exception {
SolrCore core = h.getCore();
SearchComponent tvComp = core.getSearchComponent("tvComponent");
@ -104,6 +101,7 @@ public class TermVectorComponentTest extends AbstractSolrTestCase {
}
@Test
public void testOptions() throws Exception {
SolrCore core = h.getCore();
SearchComponent tvComp = core.getSearchComponent("tvComponent");
@ -150,7 +148,7 @@ public class TermVectorComponentTest extends AbstractSolrTestCase {
}
@Test
public void testNoFields() throws Exception {
SolrCore core = h.getCore();
SearchComponent tvComp = core.getSearchComponent("tvComponent");
@ -175,6 +173,7 @@ public class TermVectorComponentTest extends AbstractSolrTestCase {
assertTrue(doc.size() + " does not equal: " + 1, doc.size() == 1);
}
@Test
public void testDistributed() throws Exception {
SolrCore core = h.getCore();
TermVectorComponent tvComp = (TermVectorComponent) core.getSearchComponent("tvComponent");

View File

@ -19,14 +19,22 @@ package org.apache.solr.highlight;
import java.util.HashMap;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.TestHarness;
import org.junit.BeforeClass;
import org.junit.Test;
public class FastVectorHighlighterTest extends AbstractSolrTestCase {
import static org.junit.Assert.*;
@Override public String getSchemaFile() { return "schema.xml"; }
@Override public String getSolrConfigFile() { return "solrconfig.xml"; }
public class FastVectorHighlighterTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
}
@Test
public void testConfig(){
SolrHighlighter highlighter = h.getCore().getHighlighter();
@ -49,6 +57,7 @@ public class FastVectorHighlighterTest extends AbstractSolrTestCase {
assertTrue( solrFbSO instanceof ScoreOrderFragmentsBuilder );
}
@Test
public void test() {
HashMap<String,String> args = new HashMap<String,String>();
args.put("hl", "true");

View File

@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.Writer;
import java.io.StringWriter;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.response.JSONResponseWriter;
import org.apache.solr.response.PHPSerializedResponseWriter;
@ -28,16 +29,21 @@ import org.apache.solr.response.PythonResponseWriter;
import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.RubyResponseWriter;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/** Test some aspects of JSON/python writer output (very incomplete)
*
*/
public class JSONWriterTest extends AbstractSolrTestCase {
public String getSchemaFile() { return "schema.xml"; }
public String getSolrConfigFile() { return "solrconfig.xml"; }
public class JSONWriterTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
}
@Test
public void testNaNInf() throws IOException {
SolrQueryRequest req = req("dummy");
SolrQueryResponse rsp = new SolrQueryResponse();
@ -57,6 +63,7 @@ public class JSONWriterTest extends AbstractSolrTestCase {
}
@Test
public void testPHPS() throws IOException {
SolrQueryRequest req = req("dummy");
SolrQueryResponse rsp = new SolrQueryResponse();
@ -70,6 +77,7 @@ public class JSONWriterTest extends AbstractSolrTestCase {
assertEquals(buf.toString(), "a:3:{s:5:\"data1\";s:5:\"hello\";s:5:\"data2\";i:42;s:5:\"data3\";b:1;}");
}
@Test
public void testJSON() throws IOException {
SolrQueryRequest req = req("wt","json","json.nl","arrarr");
SolrQueryResponse rsp = new SolrQueryResponse();

View File

@ -20,41 +20,28 @@ package org.apache.solr.schema;
import java.util.HashMap;
import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* This is a simple test to make sure the <code>CopyField</code> works.
* It uses its own special schema file.
*
* @since solr 1.4
*/
public class CopyFieldTest extends AbstractSolrTestCase {
@Override
public String getSchemaFile() {
return "schema-copyfield-test.xml";
}
@Override
public String getSolrConfigFile() {
return "solrconfig.xml";
}
@Override
public void setUp() throws Exception {
super.setUp();
}
@Override
public void tearDown() throws Exception {
super.tearDown();
}
public class CopyFieldTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema-copyfield-test.xml");
}
@Test
public void testCopyFieldSchemaFieldSchemaField() {

View File

@ -20,37 +20,32 @@ package org.apache.solr.schema;
import java.util.HashMap;
import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.lucene.search.Similarity;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class IndexSchemaTest extends AbstractSolrTestCase {
@Override public String getSchemaFile() { return "schema.xml"; }
@Override public String getSolrConfigFile() { return "solrconfig.xml"; }
@Override
public void setUp() throws Exception {
super.setUp();
}
@Override
public void tearDown() throws Exception {
super.tearDown();
}
public class IndexSchemaTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
}
/**
* This test assumes the schema includes:
* <dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>
* <dynamicField name="*_dynamic" type="string" indexed="true" stored="true"/>
*/
@Test
public void testDynamicCopy()
{
SolrCore core = h.getCore();
@ -84,8 +79,10 @@ public class IndexSchemaTest extends AbstractSolrTestCase {
,"//*[@numFound='1']"
,"//result/doc[1]/int[@name='id'][.='10']"
);
clearIndex();
}
@Test
public void testSimilarityFactory() {
SolrCore core = h.getCore();
Similarity similarity = core.getSchema().getSimilarity();
@ -93,6 +90,7 @@ public class IndexSchemaTest extends AbstractSolrTestCase {
assertEquals("is there an echo?", ((MockConfigurableSimilarity)similarity).getPassthrough());
}
@Test
public void testRuntimeFieldCreation()
{
// any field manipulation needs to happen when you know the core will not
@ -128,8 +126,10 @@ public class IndexSchemaTest extends AbstractSolrTestCase {
,"//*[@numFound='1']"
,"//result/doc[1]/int[@name='id'][.='10']"
);
clearIndex();
}
@Test
public void testIsDynamicField() throws Exception {
SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();
@ -138,6 +138,7 @@ public class IndexSchemaTest extends AbstractSolrTestCase {
assertFalse( schema.isDynamicField( "no_such_field" ) );
}
@Test
public void testProperties() throws Exception{
SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();

View File

@ -16,41 +16,34 @@ package org.apache.solr.schema;
* limitations under the License.
*/
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.document.Document;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.spatial.tier.CartesianPolyFilterBuilder;
import org.apache.lucene.spatial.tier.Shape;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.common.SolrException;
import org.apache.solr.search.function.ValueSource;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.Map;
import java.util.Random;
import java.util.List;
/**
* Test a whole slew of things related to PolyFields
*/
public class PolyFieldTest extends AbstractSolrTestCase {
@Override
public String getSchemaFile() {
return "schema.xml";
}
@Override
public String getSolrConfigFile() {
return "solrconfig.xml";
public class PolyFieldTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
}
@Test
public void testSchemaBasics() throws Exception {
IndexSchema schema = h.getCore().getSchema();
@ -83,6 +76,7 @@ public class PolyFieldTest extends AbstractSolrTestCase {
assertTrue(home.isPolyField());
}
@Test
public void testPointFieldType() throws Exception {
SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();
@ -132,6 +126,7 @@ public class PolyFieldTest extends AbstractSolrTestCase {
assertEquals(v1.hashCode(), v2.hashCode());
}
@Test
public void testSearching() throws Exception {
for (int i = 0; i < 50; i++) {
assertU(adoc("id", "" + i, "home", i + "," + (i * 100), "homed", (i * 1000) + "," + (i * 10000)));
@ -162,9 +157,10 @@ public class PolyFieldTest extends AbstractSolrTestCase {
assertQEx("Query should throw an exception due to incorrect dimensions", req("fl", "*,score", "q",
"homed:[1 TO 2000]"), SolrException.ErrorCode.BAD_REQUEST);
clearIndex();
}
@Test
public void testSearchDetails() throws Exception {
SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();
@ -184,10 +180,10 @@ public class PolyFieldTest extends AbstractSolrTestCase {
BooleanQuery bq = (BooleanQuery) q;
BooleanClause[] clauses = bq.getClauses();
assertEquals(clauses.length, 2);
clearIndex();
}
@Test
public void testCartesian() throws Exception {
for (int i = 40; i < 50; i++) {
for (int j = -85; j < -79; j++) {
@ -219,7 +215,7 @@ public class PolyFieldTest extends AbstractSolrTestCase {
assertQ(req("fl", "*,score", "q", qry.toString()),
"//*[@numFound='1']");
clearIndex();
}
}

View File

@ -19,29 +19,23 @@ package org.apache.solr.schema;
import java.util.Collection;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.SolrCore;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
*/
public class RequiredFieldsTest extends AbstractSolrTestCase {
@Override public String getSchemaFile() { return "schema-required-fields.xml"; }
@Override public String getSolrConfigFile() { return "solrconfig.xml"; }
@Override
public void setUp() throws Exception {
super.setUp();
public class RequiredFieldsTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema-required-fields.xml");
}
@Override
public void tearDown() throws Exception {
super.tearDown();
}
@Test
public void testRequiredFieldsConfig() {
SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();
@ -57,6 +51,7 @@ public class RequiredFieldsTest extends AbstractSolrTestCase {
assertEquals( numDefaultFields+1+1, requiredFields.size()); // also the uniqueKey
}
@Test
public void testRequiredFieldsSingleAdd() {
SolrCore core = h.getCore();
// Add a single document
@ -85,9 +80,11 @@ public class RequiredFieldsTest extends AbstractSolrTestCase {
assertU(commit());
// Check to make sure this submission did not succeed
assertQ("should not find any", req("id:531") ,"//result[@numFound=0]" );
assertQ("should not find any", req("id:531") ,"//result[@numFound=0]" );
clearIndex();
}
@Test
public void testAddMultipleDocumentsWithErrors() {
//Add three documents at once to make sure the baseline succeeds
assertU("adding 3 documents",

View File

@ -18,25 +18,25 @@ package org.apache.solr.search;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
*
**/
public class QueryParsingTest extends AbstractSolrTestCase {
public String getSchemaFile() {
return "schema.xml";
public class QueryParsingTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
}
public String getSolrConfigFile() {
return "solrconfig.xml";
}
@Test
public void testSort() throws Exception {
Sort sort;
@ -152,6 +152,7 @@ public class QueryParsingTest extends AbstractSolrTestCase {
}
@Test
public void testBad() throws Exception {
Sort sort;

View File

@ -17,11 +17,16 @@
package org.apache.solr.spelling;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.analysis.Token;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import java.io.File;
import java.util.Date;
@ -32,29 +37,29 @@ import java.util.Collection;
*
* @since solr 1.3
**/
public class FileBasedSpellCheckerTest extends AbstractSolrTestCase{
public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
public String getSchemaFile() { return "schema.xml"; }
public String getSolrConfigFile() { return "solrconfig.xml"; }
private static SpellingQueryConverter queryConverter;
private SpellingQueryConverter queryConverter;
@Override
public void setUp() throws Exception {
super.setUp();
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
//Index something with a title
assertU(adoc("id", "0", "teststop", "This is a title"));
assertU(adoc("id", "1", "teststop", "The quick reb fox jumped over the lazy brown dogs."));
assertU(adoc("id", "2", "teststop", "This is a Solr"));
assertU(adoc("id", "3", "teststop", "solr foo"));
assertU("commit",
commit());
String allq = "id:[0 TO 3]";
assertQ("docs not added", req(allq));
assertNull(h.validateUpdate(adoc("id", "0", "teststop", "This is a title")));
assertNull(h.validateUpdate(adoc("id", "1", "teststop", "The quick reb fox jumped over the lazy brown dogs.")));
assertNull(h.validateUpdate(adoc("id", "2", "teststop", "This is a Solr")));
assertNull(h.validateUpdate(adoc("id", "3", "teststop", "solr foo")));
assertNull(h.validateUpdate(commit()));
queryConverter = new SimpleQueryConverter();
queryConverter.init(new NamedList());
}
@AfterClass
public static void afterClass() throws Exception {
queryConverter = null;
}
@Test
public void test() throws Exception {
FileBasedSpellChecker checker = new FileBasedSpellChecker();
NamedList spellchecker = new NamedList();
@ -92,6 +97,7 @@ public class FileBasedSpellCheckerTest extends AbstractSolrTestCase{
}
@Test
public void testFieldType() throws Exception {
FileBasedSpellChecker checker = new FileBasedSpellChecker();
NamedList spellchecker = new NamedList();
@ -135,6 +141,7 @@ public class FileBasedSpellCheckerTest extends AbstractSolrTestCase{
* No indexDir location set
* @throws Exception
*/
@Test
public void testRAMDirectory() throws Exception {
FileBasedSpellChecker checker = new FileBasedSpellChecker();
NamedList spellchecker = new NamedList();

View File

@ -16,6 +16,8 @@
*/
package org.apache.solr.spelling;
import static org.junit.Assert.*;
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
@ -26,11 +28,14 @@ import org.apache.lucene.search.spell.JaroWinklerDistance;
import org.apache.lucene.search.spell.SpellChecker;
import org.apache.lucene.search.spell.StringDistance;
import org.apache.lucene.store.FSDirectory;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.util.RefCounted;
import org.apache.solr.search.SolrIndexSearcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.util.Collection;
@ -40,8 +45,8 @@ import java.util.Map;
/**
* @since solr 1.3
*/
public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {
protected SpellingQueryConverter queryConverter;
public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
protected static SpellingQueryConverter queryConverter;
protected static String[] DOCS = new String[]{
"This is a title",
@ -54,28 +59,23 @@ public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {
};
public String getSchemaFile() {
return "schema.xml";
}
public String getSolrConfigFile() {
return "solrconfig.xml";
}
@Override
public void setUp() throws Exception {
super.setUp();
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
//Index something with a title
for (int i = 0; i < DOCS.length; i++) {
assertU(adoc("id", String.valueOf(i), "title", DOCS[i]));
assertNull(h.validateUpdate(adoc("id", String.valueOf(i), "title", DOCS[i])));
}
assertU("commit",
commit());
String allq = "id:[0 TO 3]";
assertQ("docs not added", req(allq));
assertNull(h.validateUpdate(commit()));
queryConverter = new SimpleQueryConverter();
}
@AfterClass
public static void afterClass() throws Exception {
queryConverter = null;
}
@Test
public void testSpelling() throws Exception {
IndexBasedSpellChecker checker = new IndexBasedSpellChecker();
@ -151,6 +151,7 @@ public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {
}
}
@Test
public void testExtendedResults() throws Exception {
IndexBasedSpellChecker checker = new IndexBasedSpellChecker();
NamedList spellchecker = new NamedList();
@ -206,6 +207,7 @@ public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {
}
}
@Test
public void testAlternateDistance() throws Exception {
TestSpellChecker checker = new TestSpellChecker();
NamedList spellchecker = new NamedList();
@ -236,6 +238,7 @@ public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {
}
}
@Test
public void testAlternateLocation() throws Exception {
String[] ALT_DOCS = new String[]{
"jumpin jack flash",

View File

@ -17,6 +17,7 @@
package org.apache.solr.util;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.SolrPluginUtils;
import org.apache.solr.util.SolrPluginUtils.DisjunctionMaxQueryParser;
import org.apache.solr.core.SolrCore;
@ -37,6 +38,10 @@ import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.BooleanClause.Occur;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.List;
import java.util.Map;
@ -48,12 +53,14 @@ import java.util.HashSet;
/**
* Tests that the functions in SolrPluginUtils work as advertised.
*/
public class SolrPluginUtilsTest extends AbstractSolrTestCase {
public String getSchemaFile() { return "schema.xml"; }
public String getSolrConfigFile() { return "solrconfig.xml"; }
public class SolrPluginUtilsTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
}
@Test
public void testDocListConversion() throws Exception {
assertU("", adoc("id", "3234", "val_t", "quick red fox"));
assertU("", adoc("id", "3235", "val_t", "quick green fox"));
@ -78,6 +85,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
}
@Test
public void testPartialEscape() {
assertEquals("",pe(""));
@ -91,6 +99,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
}
@Test
public void testStripUnbalancedQuotes() {
assertEquals("",strip(""));
@ -102,6 +111,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
}
@Test
public void testStripIllegalOperators() {
assertEquals("",stripOp(""));
@ -120,6 +130,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
}
@Test
public void testParseFieldBoosts() throws Exception {
Map<String,Float> e1 = new HashMap<String,Float>();
@ -145,7 +156,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
(" \t "));
}
@Test
public void testDisjunctionMaxQueryParser() throws Exception {
Query out;
@ -277,7 +288,8 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
}
return count;
}
@Test
public void testMinShouldMatchCalculator() {
/* zero is zero is zero */