mirror of https://github.com/apache/lucene.git
SOLR-9306: give solr/contrib/analysis-extras's test classes access to lucene/analysis's test classes
This commit is contained in:
parent
3a71c7d8df
commit
f9c9470641
|
@ -69,5 +69,18 @@
|
||||||
</excludes>
|
</excludes>
|
||||||
</testResource>
|
</testResource>
|
||||||
</testResources>
|
</testResources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>test-jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -42,6 +42,13 @@
|
||||||
<url>${vc-browse-base-url};f=${module-directory}</url>
|
<url>${vc-browse-base-url};f=${module-directory}</url>
|
||||||
</scm>
|
</scm>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.lucene</groupId>
|
||||||
|
<artifactId>lucene-analyzers-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<!-- lucene-test-framework dependency must be declared before lucene-core -->
|
<!-- lucene-test-framework dependency must be declared before lucene-core -->
|
||||||
<!-- This dependency cannot be put into solr-parent, because local -->
|
<!-- This dependency cannot be put into solr-parent, because local -->
|
||||||
|
|
|
@ -467,6 +467,12 @@
|
||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</macrodef>
|
||||||
|
|
||||||
|
<target name="-compile-test-lucene-analysis">
|
||||||
|
<ant dir="${common.dir}/analysis" target="compile-test" inheritAll="false">
|
||||||
|
<propertyset refid="uptodate.and.compiled.properties"/>
|
||||||
|
</ant>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="-compile-test-lucene-queryparser">
|
<target name="-compile-test-lucene-queryparser">
|
||||||
<ant dir="${common.dir}/queryparser" target="compile-test" inheritAll="false">
|
<ant dir="${common.dir}/queryparser" target="compile-test" inheritAll="false">
|
||||||
<propertyset refid="uptodate.and.compiled.properties"/>
|
<propertyset refid="uptodate.and.compiled.properties"/>
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
<import file="../contrib-build.xml"/>
|
<import file="../contrib-build.xml"/>
|
||||||
|
|
||||||
|
<target name="compile-test" depends="-compile-test-lucene-analysis,common-solr.compile-test"/>
|
||||||
|
|
||||||
<path id="analysis.extras.lucene.libs">
|
<path id="analysis.extras.lucene.libs">
|
||||||
<pathelement location="${analyzers-icu.jar}"/>
|
<pathelement location="${analyzers-icu.jar}"/>
|
||||||
<!--
|
<!--
|
||||||
|
@ -43,6 +45,14 @@
|
||||||
<path refid="solr.base.classpath"/>
|
<path refid="solr.base.classpath"/>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
|
<path id="test.classpath">
|
||||||
|
<path refid="solr.test.base.classpath"/>
|
||||||
|
<dirset dir="${common.dir}/build/analysis/">
|
||||||
|
<include name="**/classes/java"/>
|
||||||
|
<include name="**/classes/test"/>
|
||||||
|
</dirset>
|
||||||
|
</path>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Although the smartcn, stempel, and morfologik jars are not dependencies of
|
Although the smartcn, stempel, and morfologik jars are not dependencies of
|
||||||
code in the analysis-extras contrib, they must remain here in order to
|
code in the analysis-extras contrib, they must remain here in order to
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class ICUCollationField extends FieldType {
|
||||||
* Read custom rules from a file, and create a RuleBasedCollator
|
* Read custom rules from a file, and create a RuleBasedCollator
|
||||||
* The file cannot support comments, as # might be in the rules!
|
* The file cannot support comments, as # might be in the rules!
|
||||||
*/
|
*/
|
||||||
private Collator createFromRules(String fileName, ResourceLoader loader) {
|
static Collator createFromRules(String fileName, ResourceLoader loader) {
|
||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
try {
|
try {
|
||||||
input = loader.openResource(fileName);
|
input = loader.openResource(fileName);
|
||||||
|
|
|
@ -21,6 +21,9 @@ import java.io.FileOutputStream;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.lucene.analysis.util.FilesystemResourceLoader;
|
||||||
|
import org.apache.lucene.analysis.util.ResourceLoader;
|
||||||
|
import org.apache.lucene.analysis.util.StringMockResourceLoader;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
|
@ -80,10 +83,20 @@ public class TestICUCollationField extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
RuleBasedCollator tailoredCollator = new RuleBasedCollator(baseCollator.getRules() + DIN5007_2_tailorings);
|
RuleBasedCollator tailoredCollator = new RuleBasedCollator(baseCollator.getRules() + DIN5007_2_tailorings);
|
||||||
String tailoredRules = tailoredCollator.getRules();
|
String tailoredRules = tailoredCollator.getRules();
|
||||||
FileOutputStream os = new FileOutputStream(new File(confDir, "customrules.dat"));
|
final String osFileName = "customrules.dat";
|
||||||
|
final FileOutputStream os = new FileOutputStream(new File(confDir, osFileName));
|
||||||
IOUtils.write(tailoredRules, os, "UTF-8");
|
IOUtils.write(tailoredRules, os, "UTF-8");
|
||||||
os.close();
|
os.close();
|
||||||
|
|
||||||
|
final ResourceLoader loader;
|
||||||
|
if (random().nextBoolean()) {
|
||||||
|
loader = new StringMockResourceLoader(tailoredRules);
|
||||||
|
} else {
|
||||||
|
loader = new FilesystemResourceLoader(confDir.toPath());
|
||||||
|
}
|
||||||
|
final Collator readCollator = ICUCollationField.createFromRules(osFileName, loader);
|
||||||
|
assertEquals(tailoredCollator, readCollator);
|
||||||
|
|
||||||
return tmpFile;
|
return tmpFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue