Skip to content

Apache Lucene open-source search software

fixed testcases which failed with -Dtests.multiplier > 1

Simon Willnauer23ad1c0f195b
diff --git a/solr/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java b/solr/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java
index 16258416ba8..5e0eed5313b 100644
--- a/solr/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java
+++ b/solr/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java
@@ -24,6 +24,7 @@ import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.TermsResponse.Term;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -36,6 +37,15 @@ public class TermsResponseTest extends SolrJettyTestBase {
public static void beforeTest() throws Exception {
initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);
}
+
+ @Before
+ @Override
+ public void setUp() throws Exception{
+ super.setUp();
+ clearIndex();
+ assertU(commit());
+ assertU(optimize());
+ }
@Test
public void testTermsResponse() throws Exception {
diff --git a/solr/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java b/solr/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java
index 6e480a65556..9ca8583ea87 100644
--- a/solr/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java
+++ b/solr/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java
@@ -18,6 +18,7 @@
package org.apache.solr.core;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.SingleInstanceLockFactory;
import org.apache.lucene.util.LuceneTestCase;
import java.io.IOException;
@@ -27,7 +28,7 @@ import java.io.IOException;
public class RAMDirectoryFactoryTest extends LuceneTestCase {
public void testOpenReturnsTheSameForSamePath() throws IOException {
final Directory directory = new RefCntRamDirectory();
- RAMDirectoryFactory factory = new RAMDirectoryFactory() {
+ RAMDirectoryFactory factory = new RAMDirectoryFactory() {
@Override
Directory openNew(String path) throws IOException {
return directory;
@@ -40,6 +41,8 @@ public class RAMDirectoryFactoryTest extends LuceneTestCase {
"every time open() is called for the same path", directory, dir1);
assertEquals("RAMDirectoryFactory should not create new instance of RefCntRamDirectory " +
"every time open() is called for the same path", directory, dir2);
+ dir1.close();
+ dir2.close();
}
public void testOpenSucceedForEmptyDir() throws IOException {
diff --git a/solr/src/test/org/apache/solr/handler/TestCSVLoader.java b/solr/src/test/org/apache/solr/handler/TestCSVLoader.java
index c6415c5b065..1339a851c7b 100755
--- a/solr/src/test/org/apache/solr/handler/TestCSVLoader.java
+++ b/solr/src/test/org/apache/solr/handler/TestCSVLoader.java
@@ -76,7 +76,7 @@ public class TestCSVLoader extends SolrTestCaseJ4 {
}
void cleanup() {
- assertU(delQ("id:[100 TO 110]"));
+ assertU(delQ("*:*"));
assertU(commit());
}
diff --git a/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java b/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
index dac3e913562..349521d0901 100644
--- a/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
+++ b/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
@@ -55,6 +55,14 @@ public class QueryElevationComponentTest extends SolrTestCaseJ4 {
clearIndex();
assertU(commit());
assertU(optimize());
+ // make sure this component is initialized correctly for each test
+ QueryElevationComponent comp = (QueryElevationComponent)h.getCore().getSearchComponent("elevate");
+ NamedList<String> args = new NamedList<String>();
+ args.add( QueryElevationComponent.CONFIG_FILE, "elevate.xml" );
+ args.add( QueryElevationComponent.FIELD_TYPE, "string" );
+ comp.init( args );
+ comp.inform( h.getCore() );
+ comp.forceElevation = false;
}
@Test
diff --git a/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java b/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
index 66f353ee497..257aef389a6 100644
--- a/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
+++ b/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
@@ -40,6 +40,10 @@ public class SpellCheckComponentTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig-spellcheckcomponent.xml","schema.xml");
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
assertU(adoc("id", "0", "lowerfilt", "This is a title"));
assertU((adoc("id", "1", "lowerfilt",
"The quick reb fox jumped over the lazy brown dogs.")));
@@ -55,6 +59,14 @@ public class SpellCheckComponentTest extends SolrTestCaseJ4 {
assertU((commit()));
}
+ public void tearDown() throws Exception {
+ super.tearDown();
+ assertU(delQ("*:*"));
+ optimize();
+ assertU((commit()));
+
+ }
+
@Test
public void testExtendedResultsCount() throws Exception {
assertJQ(req("qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "q","bluo", SpellCheckComponent.SPELLCHECK_COUNT,"5", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS,"false")