mirror of https://github.com/apache/lucene.git
SOLR-1677: Add more lenient support for version numbers (also 'V.V') format and add a system property for tests (set by build.xml), that specifies the current lucene version.
TODO: Update all solrconfig.xml files to add the '3.1' luceneMatchVersion. git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/branches/solr@923129 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ad4aae24d
commit
1f28168605
|
@ -35,6 +35,9 @@
|
|||
<property name="clover.report.dir" location="${dest}/tests/clover/reports"/>
|
||||
|
||||
<property name="junit.details" value="1"/>
|
||||
|
||||
<!-- change this together with the default and test's solrconfig.xml after starting a new development branch: -->
|
||||
<property name="tests.luceneMatchVersion" value="3.1"/>
|
||||
|
||||
<available
|
||||
property="clover.present"
|
||||
|
@ -394,6 +397,7 @@
|
|||
dir="src/test/test-files/"
|
||||
>
|
||||
<sysproperty key="java.util.logging.config.file" value="${common.dir}/testlogging.properties"/>
|
||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||
<jvmarg line="${args}"/>
|
||||
<formatter type="brief" usefile="false" if="junit.details"/>
|
||||
<classpath refid="test.run.classpath"/>
|
||||
|
|
|
@ -284,16 +284,20 @@ public class Config {
|
|||
|
||||
private static final AtomicBoolean versionWarningAlreadyLogged = new AtomicBoolean(false);
|
||||
|
||||
public static final Version parseLuceneVersionString(String matchVersion) {
|
||||
matchVersion = matchVersion.toUpperCase();
|
||||
public static final Version parseLuceneVersionString(final String matchVersion) {
|
||||
String parsedMatchVersion = matchVersion.toUpperCase();
|
||||
|
||||
// be lenient with the supplied version parameter
|
||||
parsedMatchVersion = parsedMatchVersion.replaceFirst("^(\\d)\\.(\\d)$", "LUCENE_$1$2");
|
||||
|
||||
final Version version;
|
||||
try {
|
||||
version = Version.valueOf(matchVersion);
|
||||
version = Version.valueOf(parsedMatchVersion);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
||||
"Invalid luceneMatchVersion '" + matchVersion +
|
||||
"' property, valid values are: " + Arrays.toString(Version.values()), iae, false);
|
||||
"', valid values are: " + Arrays.toString(Version.values()) +
|
||||
" or a string in format 'V.V'", iae, false);
|
||||
}
|
||||
|
||||
if (version == Version.LUCENE_CURRENT && !versionWarningAlreadyLogged.getAndSet(true)) {
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
|
|||
public abstract class BaseTokenTestCase extends TestCase
|
||||
{
|
||||
protected static final Map<String,String> DEFAULT_VERSION_PARAM =
|
||||
Collections.singletonMap("luceneMatchVersion", "LUCENE_30");
|
||||
Collections.singletonMap("luceneMatchVersion", System.getProperty("tests.luceneMatchVersion", "LUCENE_CURRENT"));
|
||||
|
||||
// some helpers to test Analyzers and TokenStreams:
|
||||
// these are taken from Lucene's BaseTokenStreamTestCase
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.StringReader;
|
|||
import java.lang.reflect.Field;
|
||||
|
||||
import org.apache.lucene.analysis.standard.StandardTokenizer;
|
||||
import org.apache.solr.core.Config;
|
||||
import org.apache.solr.schema.IndexSchema;
|
||||
import org.apache.solr.schema.FieldType;
|
||||
import org.apache.solr.util.AbstractSolrTestCase;
|
||||
|
@ -42,7 +43,9 @@ public class TestLuceneMatchVersion extends AbstractSolrTestCase {
|
|||
return "solrconfig.xml";
|
||||
}
|
||||
|
||||
public static final Version DEFAULT_VERSION = Version.LUCENE_30;
|
||||
// this must match the solrconfig.xml version for this test
|
||||
public static final Version DEFAULT_VERSION =
|
||||
Config.parseLuceneVersionString(System.getProperty("tests.luceneMatchVersion", "LUCENE_CURRENT"));
|
||||
|
||||
public void testStandardTokenizerVersions() throws Exception {
|
||||
assertEquals(DEFAULT_VERSION, solrConfig.luceneMatchVersion);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tokenizer class="solr.StandardTokenizerFactory" luceneMatchVersion="LUCENE_20"/>
|
||||
<filter class="solr.StandardFilterFactory"/>
|
||||
<filter class="solr.LowerCaseFilterFactory"/>
|
||||
<filter class="solr.StopFilterFactory" luceneMatchVersion="LUCENE_24"/>
|
||||
<filter class="solr.StopFilterFactory" luceneMatchVersion="2.4"/>
|
||||
<filter class="solr.EnglishPorterFilterFactory"/>
|
||||
</analyzer>
|
||||
</fieldtype>
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
not be changed if replication is in use. -->
|
||||
<dataDir>${solr.data.dir:./solr/data}</dataDir>
|
||||
|
||||
<luceneMatchVersion>LUCENE_30</luceneMatchVersion>
|
||||
<luceneMatchVersion>3.1</luceneMatchVersion>
|
||||
|
||||
<indexDefaults>
|
||||
<!-- Values here affect all index writers and act as a default
|
||||
|
|
Loading…
Reference in New Issue