Author: rmuir
Date: Sat Mar 20 20:11:03 2010
New Revision: 925669
URL: http://svn.apache.org/viewvc?rev=925669&view=rev
Log:
speed up a few more tests with SolrTestCaseJ4
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/EchoParamsTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/MinimalSchemaTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/OutputWriterTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/SampleTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestConfig.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/JSONWriterTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/CopyFieldTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/PolyFieldTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/QueryParsingTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/EchoParamsTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/EchoParamsTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/EchoParamsTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/EchoParamsTest.java
Sat Mar 20 20:11:03 2010
@@ -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/l...@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 Abst
assertQ(req("foo"),"not(//l...@name='params'])");
}
+ @Test
public void testDefaultEchoParamsDefaultVersion() {
lrf.args.put("wt", "xml");
lrf.args.remove("version");
@@ -42,6 +47,7 @@ public class EchoParamsTest extends Abst
assertQ(req("foo"),"not(//l...@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 Abst
assertQ(req("foo"),HEADER_XPATH +
"/l...@name='params']/s...@name='wt'][.='xml']");
}
+ @Test
public void testAllEchoParams() {
lrf = h.getRequestFactory
("crazy_custom_qt", 0, 20,
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/MinimalSchemaTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/MinimalSchemaTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/MinimalSchemaTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/MinimalSchemaTest.java
Sat Mar 20 20:11:03 2010
@@ -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 A
}
/** SOLR-1371 */
+ @Test
public void testLuke() {
assertQ("basic luke request failed",
@@ -104,6 +103,7 @@ public class MinimalSchemaTest extends A
* 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) {
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/OutputWriterTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/OutputWriterTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/OutputWriterTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/OutputWriterTest.java
Sat Mar 20 20:11:03 2010
@@ -24,23 +24,28 @@ import org.apache.solr.common.util.Named
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 Ab
assertQ(req("foo"),
"/response/l...@name='responseHeader']/i...@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");
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/SampleTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/SampleTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
--- lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/SampleTest.java
(original)
+++ lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/SampleTest.java
Sat Mar 20 20:11:03 2010
@@ -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.
- *
- * <p>
- * Note that different tests can use different schemas by refering
- * 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
+ * All subclasses of SolrTestCaseJ4 should initialize the core.
*
* <p>
- * Note that different tests can use different configs 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 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 Abstract
/**
* 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",
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java
Sat Mar 20 20:11:03 2010
@@ -28,30 +28,32 @@ import org.apache.lucene.analysis.TokenS
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 TestReversedWildcardFilterF
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 TestReversedWildcardFilterF
);
}
+ @Test
public void testQueryParsing() throws IOException, ParseException {
SolrQueryParser parserOne = new SolrQueryParser(schema, "one");
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestConfig.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestConfig.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestConfig.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestConfig.java
Sat Mar 20 20:11:03 2010
@@ -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 String getSchemaFile() {
- return "schema.xml";
- }
+public class TestConfig extends SolrTestCaseJ4 {
- //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 Abstract
}
}
+ @Test
public void testJavaProperty() {
// property values defined in build.xml
@@ -91,6 +93,7 @@ public class TestConfig extends Abstract
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 Abstract
}
// 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 Abstract
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 Abstract
assertEquals(256, interval);
}
+ @Test
public void testTermIndexDivisor() throws Exception {
IndexReaderFactory irf = h.getCore().getIndexReaderFactory();
StandardIndexReaderFactory sirf = (StandardIndexReaderFactory) irf;
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/core/TestQuerySenderListener.java
Sat Mar 20 20:11:03 2010
@@ -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 SolrTestCaseJ4 {
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-querysender.xml","schema.xml");
+ }
-public class TestQuerySenderListener extends AbstractSolrTestCase {
-
- @Override public String getSchemaFile() { return "schema.xml"; }
- @Override public String getSolrConfigFile() { return
"solrconfig-querysender.xml"; }
-
+ @Test
public void testRequestHandlerRegistry() {
// property values defined in build.xml
SolrCore core = h.getCore();
@@ -35,6 +41,7 @@ public class TestQuerySenderListener ext
assertEquals( 1, core.newSearcherListeners.size() );
}
+ @Test
public void testSearcherEvents() throws Exception {
SolrCore core = h.getCore();
SolrEventListener newSearcherListener = core.newSearcherListeners.get(0);
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
Sat Mar 20 20:11:03 2010
@@ -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
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 {
- @Override public String getSchemaFile() { return "schema12.xml"; }
- @Override public String getSolrConfigFile() { return
"solrconfig-elevate.xml"; }
+public class QueryElevationComponentTest extends SolrTestCaseJ4 {
+
+ @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
assertEquals( "xxxxyyyy", comp.getAnalyzedQuery( "XXXX YYYY" ) );
}
+ @Test
public void testEmptyQuery() throws Exception {
SolrCore core = h.getCore();
@@ -101,7 +110,7 @@ public class QueryElevationComponentTest
}
-
+ @Test
public void testSorting() throws IOException
{
SolrCore core = h.getCore();
@@ -221,6 +230,7 @@ public class QueryElevationComponentTest
log.info( "OUT:"+file.getAbsolutePath() );
}
+ @Test
public void testElevationReloading() throws Exception
{
SolrCore core = h.getCore();
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
Sat Mar 20 20:11:03 2010
@@ -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.Simpl
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";
- }
-
- @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"));
+public class TermVectorComponentTest extends SolrTestCaseJ4 {
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml","schema.xml");
+
+ 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 ext
}
+ @Test
public void testOptions() throws Exception {
SolrCore core = h.getCore();
SearchComponent tvComp = core.getSearchComponent("tvComponent");
@@ -150,7 +148,7 @@ public class TermVectorComponentTest ext
}
-
+ @Test
public void testNoFields() throws Exception {
SolrCore core = h.getCore();
SearchComponent tvComp = core.getSearchComponent("tvComponent");
@@ -175,6 +173,7 @@ public class TermVectorComponentTest ext
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");
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/highlight/FastVectorHighlighterTest.java
Sat Mar 20 20:11:03 2010
@@ -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 e
assertTrue( solrFbSO instanceof ScoreOrderFragmentsBuilder );
}
+ @Test
public void test() {
HashMap<String,String> args = new HashMap<String,String>();
args.put("hl", "true");
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/JSONWriterTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/JSONWriterTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/JSONWriterTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/request/JSONWriterTest.java
Sat Mar 20 20:11:03 2010
@@ -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.PythonRe
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 Abst
}
+ @Test
public void testPHPS() throws IOException {
SolrQueryRequest req = req("dummy");
SolrQueryResponse rsp = new SolrQueryResponse();
@@ -70,6 +77,7 @@ public class JSONWriterTest extends Abst
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();
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/CopyFieldTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/CopyFieldTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/CopyFieldTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/CopyFieldTest.java
Sat Mar 20 20:11:03 2010
@@ -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() {
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/IndexSchemaTest.java
Sat Mar 20 20:11:03 2010
@@ -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 Abs
,"//*...@numfound='1']"
,"//result/doc[1]/i...@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 Abs
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 Abs
,"//*...@numfound='1']"
,"//result/doc[1]/i...@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 Abs
assertFalse( schema.isDynamicField( "no_such_field" ) );
}
+ @Test
public void testProperties() throws Exception{
SolrCore core = h.getCore();
IndexSchema schema = core.getSchema();
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/PolyFieldTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/PolyFieldTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/PolyFieldTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/PolyFieldTest.java
Sat Mar 20 20:11:03 2010
@@ -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 Abstr
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 Abstr
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 Abstr
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 Abstr
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 Abstr
assertQ(req("fl", "*,score", "q", qry.toString()),
"//*...@numfound='1']");
-
+ clearIndex();
}
}
\ No newline at end of file
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/schema/RequiredFieldsTest.java
Sat Mar 20 20:11:03 2010
@@ -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
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
assertU(commit());
// Check to make sure this submission did not succeed
- assertQ("should not find any", req("id:531") ,"//resu...@numfound=0]" );
+ assertQ("should not find any", req("id:531") ,"//resu...@numfound=0]" );
+ clearIndex();
}
+ @Test
public void testAddMultipleDocumentsWithErrors() {
//Add three documents at once to make sure the baseline succeeds
assertU("adding 3 documents",
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/QueryParsingTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/QueryParsingTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/QueryParsingTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/search/QueryParsingTest.java
Sat Mar 20 20:11:03 2010
@@ -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 Ab
}
+ @Test
public void testBad() throws Exception {
Sort sort;
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
Sat Mar 20 20:11:03 2010
@@ -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 String getSchemaFile() { return "schema.xml"; }
- public String getSolrConfigFile() { return "solrconfig.xml"; }
+public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
- private SpellingQueryConverter queryConverter;
+ private static 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 e
}
+ @Test
public void testFieldType() throws Exception {
FileBasedSpellChecker checker = new FileBasedSpellChecker();
NamedList spellchecker = new NamedList();
@@ -135,6 +141,7 @@ public class FileBasedSpellCheckerTest e
* No indexDir location set
* @throws Exception
*/
+ @Test
public void testRAMDirectory() throws Exception {
FileBasedSpellChecker checker = new FileBasedSpellChecker();
NamedList spellchecker = new NamedList();
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
Sat Mar 20 20:11:03 2010
@@ -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.Ja
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
};
- 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
}
}
+ @Test
public void testExtendedResults() throws Exception {
IndexBasedSpellChecker checker = new IndexBasedSpellChecker();
NamedList spellchecker = new NamedList();
@@ -206,6 +207,7 @@ public class IndexBasedSpellCheckerTest
}
}
+ @Test
public void testAlternateDistance() throws Exception {
TestSpellChecker checker = new TestSpellChecker();
NamedList spellchecker = new NamedList();
@@ -236,6 +238,7 @@ public class IndexBasedSpellCheckerTest
}
}
+ @Test
public void testAlternateLocation() throws Exception {
String[] ALT_DOCS = new String[]{
"jumpin jack flash",
Modified:
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java?rev=925669&r1=925668&r2=925669&view=diff
==============================================================================
---
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
(original)
+++
lucene/solr/branches/newtrunk/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
Sat Mar 20 20:11:03 2010
@@ -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.BooleanQ
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
}
+ @Test
public void testPartialEscape() {
assertEquals("",pe(""));
@@ -91,6 +99,7 @@ public class SolrPluginUtilsTest extends
}
+ @Test
public void testStripUnbalancedQuotes() {
assertEquals("",strip(""));
@@ -102,6 +111,7 @@ public class SolrPluginUtilsTest extends
}
+ @Test
public void testStripIllegalOperators() {
assertEquals("",stripOp(""));
@@ -120,6 +130,7 @@ public class SolrPluginUtilsTest extends
}
+ @Test
public void testParseFieldBoosts() throws Exception {
Map<String,Float> e1 = new HashMap<String,Float>();
@@ -145,7 +156,7 @@ public class SolrPluginUtilsTest extends
(" \t "));
}
-
+ @Test
public void testDisjunctionMaxQueryParser() throws Exception {
Query out;
@@ -277,7 +288,8 @@ public class SolrPluginUtilsTest extends
}
return count;
}
-
+
+ @Test
public void testMinShouldMatchCalculator() {
/* zero is zero is zero */