lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject lucene-solr:branch_6x: SOLR-9306: give solr/contrib/analysis-extras's test classes access to lucene/analysis's test classes
Date Thu, 14 Jul 2016 10:22:49 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 4edba9463 -> 83bbd32f4


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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/83bbd32f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/83bbd32f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/83bbd32f

Branch: refs/heads/branch_6x
Commit: 83bbd32f4d1d2eac029b260cb5e4b6cb58fbd309
Parents: 4edba94
Author: Christine Poerschke <cpoerschke@apache.org>
Authored: Thu Jul 14 10:20:35 2016 +0100
Committer: Christine Poerschke <cpoerschke@apache.org>
Committed: Thu Jul 14 11:08:38 2016 +0100

----------------------------------------------------------------------
 .../maven/lucene/analysis/common/pom.xml.template    | 13 +++++++++++++
 .../solr/contrib/analysis-extras/pom.xml.template    |  7 +++++++
 solr/common-build.xml                                |  6 ++++++
 solr/contrib/analysis-extras/build.xml               | 10 ++++++++++
 .../org/apache/solr/schema/ICUCollationField.java    |  2 +-
 .../apache/solr/schema/TestICUCollationField.java    | 15 ++++++++++++++-
 6 files changed, 51 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/83bbd32f/dev-tools/maven/lucene/analysis/common/pom.xml.template
----------------------------------------------------------------------
diff --git a/dev-tools/maven/lucene/analysis/common/pom.xml.template b/dev-tools/maven/lucene/analysis/common/pom.xml.template
index 95a0487..cded628 100644
--- a/dev-tools/maven/lucene/analysis/common/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/common/pom.xml.template
@@ -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>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/83bbd32f/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template
----------------------------------------------------------------------
diff --git a/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template b/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template
index 4d0f322..b7a11a8 100644
--- a/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template
@@ -43,6 +43,13 @@
   </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        -->
       <!-- dependencies are always ordered before inherited dependencies.       -->

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/83bbd32f/solr/common-build.xml
----------------------------------------------------------------------
diff --git a/solr/common-build.xml b/solr/common-build.xml
index 235070a..8bf9db7 100644
--- a/solr/common-build.xml
+++ b/solr/common-build.xml
@@ -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"/>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/83bbd32f/solr/contrib/analysis-extras/build.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/analysis-extras/build.xml b/solr/contrib/analysis-extras/build.xml
index 6697fc9..38d67dd 100644
--- a/solr/contrib/analysis-extras/build.xml
+++ b/solr/contrib/analysis-extras/build.xml
@@ -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

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/83bbd32f/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java
b/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java
index b186754..2071163 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java
+++ b/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/83bbd32f/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java
b/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java
index e21b4dd..4cff7fa 100644
--- a/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java
+++ b/solr/contrib/analysis-extras/src/test/org/apache/solr/schema/TestICUCollationField.java
@@ -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;
   }
 


Mime
View raw message