SOLR-9306: give solr/contrib/analysis-extras's test classes access to lucene/analysis's test classes

This commit is contained in:
Christine Poerschke 2016-07-14 10:20:35 +01:00
parent 3a71c7d8df
commit f9c9470641
6 changed files with 51 additions and 2 deletions

View File

@ -69,5 +69,18 @@
</excludes>
</testResource>
</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>
</project>

View File

@ -42,6 +42,13 @@
<url>${vc-browse-base-url};f=${module-directory}</url>
</scm>
<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>
<!-- lucene-test-framework dependency must be declared before lucene-core -->
<!-- This dependency cannot be put into solr-parent, because local -->

View File

@ -467,6 +467,12 @@
</sequential>
</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">
<ant dir="${common.dir}/queryparser" target="compile-test" inheritAll="false">
<propertyset refid="uptodate.and.compiled.properties"/>

View File

@ -25,6 +25,8 @@
<import file="../contrib-build.xml"/>
<target name="compile-test" depends="-compile-test-lucene-analysis,common-solr.compile-test"/>
<path id="analysis.extras.lucene.libs">
<pathelement location="${analyzers-icu.jar}"/>
<!--
@ -43,6 +45,14 @@
<path refid="solr.base.classpath"/>
</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
code in the analysis-extras contrib, they must remain here in order to

View File

@ -198,7 +198,7 @@ public class ICUCollationField extends FieldType {
* Read custom rules from a file, and create a RuleBasedCollator
* 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;
try {
input = loader.openResource(fileName);

View File

@ -21,6 +21,9 @@ import java.io.FileOutputStream;
import org.apache.commons.io.FileUtils;
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.junit.BeforeClass;
@ -80,10 +83,20 @@ public class TestICUCollationField extends SolrTestCaseJ4 {
RuleBasedCollator tailoredCollator = new RuleBasedCollator(baseCollator.getRules() + DIN5007_2_tailorings);
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");
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;
}