| Index: solr/contrib/clustering/build.xml
|
| ===================================================================
|
| --- solr/contrib/clustering/build.xml (revision 992397)
|
| +++ solr/contrib/clustering/build.xml (working copy)
|
| @@ -106,6 +106,7 @@
|
| failureProperty="tests.failed" |
| dir="src/test/resources/" |
| tempdir="${junit.output.dir}" |
| + forkmode="perBatch" |
| > |
| <sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/> |
| <sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/> |
| Index: solr/contrib/extraction/build.xml
|
| ===================================================================
|
| --- solr/contrib/extraction/build.xml (revision 992397)
|
| +++ solr/contrib/extraction/build.xml (working copy)
|
| @@ -107,6 +107,7 @@
|
| failureProperty="tests.failed" |
| dir="src/test/resources/" |
| tempdir="${tempDir}" |
| + forkmode="perBatch" |
| > |
| <sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/> |
| <sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/> |
| Index: solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java
|
| ===================================================================
|
| --- solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java (revision 992397)
|
| +++ solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestContentStreamDataSource.java (working copy)
|
| @@ -27,6 +27,10 @@
|
| import org.apache.solr.common.SolrDocumentList; |
| import org.apache.solr.common.params.ModifiableSolrParams; |
| import org.apache.solr.util.AbstractSolrTestCase; |
| +import org.junit.After; |
| +import org.junit.Before; |
| +import org.junit.Test; |
| +import static org.junit.Assert.*; |
| |
| import java.io.File; |
| import java.util.List; |
| @@ -37,19 +41,27 @@
|
| * @version $Id$ |
| * @since solr 1.4 |
| */ |
| -public class TestContentStreamDataSource extends TestCase { |
| +public class TestContentStreamDataSource extends SolrTestCaseJ4 { |
| private static final String CONF_DIR = "." + File.separator + "solr" + File.separator + "conf" + File.separator; |
| SolrInstance instance = null; |
| JettySolrRunner jetty; |
| |
| - |
| + @Before |
| public void setUp() throws Exception { |
| + super.setUp(); |
| instance = new SolrInstance("inst", null); |
| instance.setUp(); |
| jetty = createJetty(instance); |
| - |
| } |
| + |
| + @After |
| + public void tearDown() throws Exception { |
| + jetty.stop(); |
| + instance.tearDown(); |
| + super.tearDown(); |
| + } |
| |
| + @Test |
| public void testSimple() throws Exception { |
| DirectXmlRequest req = new DirectXmlRequest("/dataimport", xml); |
| ModifiableSolrParams params = new ModifiableSolrParams(); |
| @@ -69,12 +81,13 @@
|
| assertEquals("Hello C1", ((List)doc.getFieldValue("desc")).get(0)); |
| } |
| |
| - private class SolrInstance extends AbstractSolrTestCase { |
| + private class SolrInstance { |
| String name; |
| Integer port; |
| File homeDir; |
| File confDir; |
| - |
| + File dataDir; |
| + |
| /** |
| * if masterPort is null, this instance is a master -- otherwise this instance is a slave, and assumes the master is |
| * on localhost at the specified port. |
| @@ -88,7 +101,6 @@
|
| return homeDir.toString(); |
| } |
| |
| - @Override |
| public String getSchemaFile() { |
| return CONF_DIR + "dataimport-schema.xml"; |
| } |
| @@ -101,7 +113,6 @@
|
| return dataDir.toString(); |
| } |
| |
| - @Override |
| public String getSolrConfigFile() { |
| return CONF_DIR + "contentstream-solrconfig.xml"; |
| } |
| @@ -130,7 +141,6 @@
|
| } |
| |
| public void tearDown() throws Exception { |
| - super.tearDown(); |
| AbstractSolrTestCase.recurseDelete(homeDir); |
| } |
| } |
| Index: solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestVariableResolver.java
|
| ===================================================================
|
| --- solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestVariableResolver.java (revision 992397)
|
| +++ solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestVariableResolver.java (working copy)
|
| @@ -113,6 +113,7 @@
|
| |
| SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); |
| format.setTimeZone(TimeZone.getTimeZone("UTC")); |
| + resetEvaluatorBagDateMathParser(); |
| DateMathParser dmp = new DateMathParser(TimeZone.getDefault(), Locale.getDefault()); |
| |
| String s = vri.replaceTokens("${dataimporter.functions.formatDate('NOW/DAY','yyyy-MM-dd HH:mm')}"); |
| @@ -154,6 +155,7 @@
|
| |
| SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); |
| format.setTimeZone(TimeZone.getTimeZone("UTC")); |
| + resetEvaluatorBagDateMathParser(); |
| DateMathParser dmp = new DateMathParser(TimeZone.getDefault(), Locale.getDefault()); |
| |
| resolver.addNamespace("dataimporter.functions", EvaluatorBag |
| @@ -174,4 +176,14 @@
|
| return "Hello World"; |
| } |
| } |
| + |
| + private void resetEvaluatorBagDateMathParser() { |
| + EvaluatorBag.dateMathParser = new DateMathParser(TimeZone |
| + .getDefault(), Locale.getDefault()){ |
| + @Override |
| + public Date getNow() { |
| + return new Date(); |
| + } |
| + }; |
| + } |
| } |
| Index: solr/contrib/dataimporthandler/build.xml
|
| ===================================================================
|
| --- solr/contrib/dataimporthandler/build.xml (revision 992397)
|
| +++ solr/contrib/dataimporthandler/build.xml (working copy)
|
| @@ -158,6 +158,7 @@
|
| failureProperty="tests.failed" |
| dir="src/test/resources/" |
| tempdir="${tempDir}" |
| + forkmode="perBatch" |
| > |
| <sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/> |
| <sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/> |
| @@ -214,6 +215,7 @@
|
| failureProperty="tests.failed" |
| dir="src/extras/test/resources/" |
| tempdir="${tempDir}" |
| + forkmode="perBatch" |
| > |
| <sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/> |
| <sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/> |
| Index: solr/src/test/org/apache/solr/SolrTestCaseJ4.java
|
| ===================================================================
|
| --- solr/src/test/org/apache/solr/SolrTestCaseJ4.java (revision 992397)
|
| +++ solr/src/test/org/apache/solr/SolrTestCaseJ4.java (working copy)
|
| @@ -51,7 +51,7 @@
|
| * Unlike AbstractSolrTestCase, a new core is not created for each test method. |
| * |
| */ |
| -public class SolrTestCaseJ4 extends LuceneTestCaseJ4 { |
| +public abstract class SolrTestCaseJ4 extends LuceneTestCaseJ4 { |
| |
| @BeforeClass |
| public static void beforeClassSolrTestCase() throws Exception { |
| Index: solr/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
|
| ===================================================================
|
| --- solr/src/test/org/apache/solr/schema/BadIndexSchemaTest.java (revision 992397)
|
| +++ solr/src/test/org/apache/solr/schema/BadIndexSchemaTest.java (working copy)
|
| @@ -20,6 +20,7 @@
|
| import org.apache.solr.SolrTestCaseJ4; |
| import org.apache.solr.common.SolrException; |
| import org.apache.solr.common.SolrException.ErrorCode; |
| +import org.apache.solr.core.SolrConfig; |
| |
| import static org.junit.Assert.assertTrue; |
| import static org.junit.Assert.fail; |
| @@ -43,6 +44,8 @@
|
| throw new SolrException |
| (ErrorCode.SERVER_ERROR, |
| "Unexpected error, expected error matching: " + errString, e); |
| + } finally { |
| + SolrConfig.severeErrors.clear(); |
| } |
| fail("Did not encounter any exception from: " + schema); |
| } |
| Index: solr/src/test/org/apache/solr/schema/TestBinaryField.java
|
| ===================================================================
|
| --- solr/src/test/org/apache/solr/schema/TestBinaryField.java (revision 992397)
|
| +++ solr/src/test/org/apache/solr/schema/TestBinaryField.java (working copy)
|
| @@ -17,6 +17,8 @@
|
| package org.apache.solr.schema; |
| |
| import junit.framework.TestCase; |
| + |
| +import org.apache.lucene.util.LuceneTestCase; |
| import org.apache.solr.client.solrj.SolrQuery; |
| import org.apache.solr.client.solrj.beans.Field; |
| import org.apache.solr.client.solrj.embedded.JettySolrRunner; |
| @@ -32,26 +34,19 @@
|
| import java.io.File; |
| import java.util.List; |
| |
| -public class TestBinaryField extends AbstractSolrTestCase { |
| +public class TestBinaryField extends LuceneTestCase { |
| CommonsHttpSolrServer server; |
| JettySolrRunner jetty; |
| |
| int port = 0; |
| static final String context = "/example"; |
| |
| - |
| - public String getSchemaFile() { |
| - return null; |
| - } |
| - public String getSolrConfigFile() { |
| - return null; |
| - } |
| - |
| @Override |
| public void setUp() throws Exception { |
| super.setUp(); |
| |
| - File home = dataDir; |
| + File home = new File(TEMP_DIR, |
| + "solrtest-TestBinaryField-" + System.currentTimeMillis()); |
| |
| File homeDir = new File(home, "example"); |
| File dataDir = new File(homeDir, "data"); |
| @@ -67,21 +62,17 @@
|
| f = new File(confDir, "schema.xml"); |
| fname = "." + File.separator + "solr" + File.separator + "conf" + File.separator + "schema-binaryfield.xml"; |
| FileUtils.copyFile(new File(fname), f); |
| - |
| - jetty = new JettySolrRunner("/solr", port); |
| System.setProperty("solr.solr.home", homeDir.getAbsolutePath()); |
| System.setProperty("solr.data.dir", dataDir.getAbsolutePath()); |
| - jetty.start(); |
| + System.setProperty("solr.test.sys.prop1", "propone"); |
| + System.setProperty("solr.test.sys.prop2", "proptwo"); |
| |
| - |
| jetty = new JettySolrRunner(context, 0); |
| jetty.start(); |
| port = jetty.getLocalPort(); |
| |
| String url = "http://localhost:" + jetty.getLocalPort() + context; |
| server = new CommonsHttpSolrServer(url); |
| -// server.setRequestWriter(new BinaryRequestWriter()); |
| - super.postSetUp(); |
| } |
| |
| public void testSimple() throws Exception { |
| Index: solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java
|
| ===================================================================
|
| --- solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java (revision 992397)
|
| +++ solr/src/test/org/apache/solr/client/solrj/SolrJettyTestBase.java (working copy)
|
| @@ -50,6 +50,7 @@
|
| jetty.stop(); |
| jetty = null; |
| } |
| + server = null; |
| } |
| |
| |
| Index: solr/build.xml
|
| ===================================================================
|
| --- solr/build.xml (revision 992397)
|
| +++ solr/build.xml (working copy)
|
| @@ -427,6 +427,7 @@
|
| failureProperty="tests.failed" |
| dir="src/test/test-files/" |
| tempdir="@{tempDir}/@{threadNum}" |
| + forkmode="perBatch" |
| > |
| <sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/> |
| <sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/> |
| Index: lucene/CHANGES.txt
|
| ===================================================================
|
| --- lucene/CHANGES.txt (revision 992397)
|
| +++ lucene/CHANGES.txt (working copy)
|
| @@ -721,8 +721,9 @@
|
| access to "real" files from the test folder itsself, can use |
| LuceneTestCase(J4).getDataFile(). (Uwe Schindler) |
| |
| -* LUCENE-2398: Improve tests to work better from IDEs such as Eclipse. |
| - (Paolo Castagna via Robert Muir) |
| +* LUCENE-2398, LUCENE-2611: Improve tests to work better from IDEs such |
| + as Eclipse and IntelliJ. |
| + (Paolo Castagna, Steven Rowe via Robert Muir) |
| |
| ================== Release 2.9.3 / 3.0.2 2010-06-18 ==================== |
| |
| Index: lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
|
| ===================================================================
|
| --- lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (revision 992397)
|
| +++ lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (working copy)
|
| @@ -23,23 +23,21 @@
|
| import org.apache.lucene.index.LogDocMergePolicy; |
| import org.apache.lucene.index.LogMergePolicy; |
| import org.apache.lucene.index.SerialMergeScheduler; |
| +import org.apache.lucene.index.codecs.Codec; |
| +import org.apache.lucene.index.codecs.CodecProvider; |
| +import org.apache.lucene.index.codecs.mockintblock.MockFixedIntBlockCodec; |
| +import org.apache.lucene.index.codecs.mockintblock.MockVariableIntBlockCodec; |
| +import org.apache.lucene.index.codecs.mocksep.MockSepCodec; |
| +import org.apache.lucene.index.codecs.preflex.PreFlexCodec; |
| +import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec; |
| +import org.apache.lucene.index.codecs.pulsing.PulsingCodec; |
| import org.apache.lucene.search.BooleanQuery; |
| import org.apache.lucene.search.FieldCache; |
| import org.apache.lucene.search.FieldCache.CacheEntry; |
| import org.apache.lucene.store.Directory; |
| import org.apache.lucene.store.MMapDirectory; |
| import org.apache.lucene.store.MockDirectoryWrapper; |
| -import org.apache.lucene.store.RAMDirectory; |
| import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; |
| -import org.apache.lucene.index.codecs.CodecProvider; |
| -import org.apache.lucene.index.codecs.Codec; |
| -import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec; |
| -import org.apache.lucene.index.codecs.preflex.PreFlexCodec; |
| -import org.apache.lucene.index.codecs.pulsing.PulsingCodec; |
| -import org.apache.lucene.index.codecs.mocksep.MockSepCodec; |
| -import org.apache.lucene.index.codecs.mockintblock.MockFixedIntBlockCodec; |
| -import org.apache.lucene.index.codecs.mockintblock.MockVariableIntBlockCodec; |
| - |
| import org.junit.After; |
| import org.junit.AfterClass; |
| import org.junit.Assert; |
| @@ -58,24 +56,23 @@
|
| import org.junit.runners.model.InitializationError; |
| |
| import java.io.File; |
| -import java.io.PrintStream; |
| import java.io.IOException; |
| +import java.io.PrintStream; |
| +import java.lang.reflect.Constructor; |
| +import java.lang.reflect.Method; |
| +import java.util.ArrayList; |
| import java.util.Arrays; |
| +import java.util.Collections; |
| import java.util.IdentityHashMap; |
| import java.util.Iterator; |
| -import java.util.Locale; |
| -import java.util.Random; |
| -import java.util.ArrayList; |
| import java.util.List; |
| +import java.util.Locale; |
| import java.util.Map; |
| +import java.util.Random; |
| import java.util.TimeZone; |
| import java.util.WeakHashMap; |
| -import java.util.Collections; |
| -import java.util.regex.Pattern; |
| import java.util.regex.Matcher; |
| -import java.lang.reflect.Constructor; |
| -import java.lang.reflect.InvocationTargetException; |
| -import java.lang.reflect.Method; |
| +import java.util.regex.Pattern; |
| |
| import static org.junit.Assert.assertEquals; |
| import static org.junit.Assert.fail; |
| @@ -116,7 +113,7 @@
|
| // get from that override is provided by InterceptTestCaseEvents |
| //@RunWith(RunBareWrapper.class) |
| @RunWith(LuceneTestCaseJ4.LuceneTestCaseRunner.class) |
| -public class LuceneTestCaseJ4 { |
| +public abstract class LuceneTestCaseJ4 { |
| |
| /** |
| * true iff tests are run in verbose mode. Note: if it is false, tests are not |
| @@ -303,6 +300,8 @@
|
| removeTestCodecs(codec); |
| Locale.setDefault(savedLocale); |
| TimeZone.setDefault(savedTimeZone); |
| + System.clearProperty("solr.solr.home"); |
| + System.clearProperty("solr.data.dir"); |
| // now look for unclosed resources |
| for (MockDirectoryWrapper d : stores.keySet()) { |
| if (d.isOpen()) { |
| Index: lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
|
| ===================================================================
|
| --- lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (revision 992397)
|
| +++ lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (working copy)
|
| @@ -186,7 +186,8 @@
|
| LuceneTestCaseJ4.removeTestCodecs(codec); |
| Locale.setDefault(savedLocale); |
| TimeZone.setDefault(savedTimeZone); |
| - |
| + System.clearProperty("solr.solr.home"); |
| + System.clearProperty("solr.data.dir"); |
| try { |
| Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler); |
| if (!uncaughtExceptions.isEmpty()) { |