lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r478239 - in /lucene/java/trunk/src/test/org/apache/lucene/index: TestBackwardsCompatibility.java TestIndexFileDeleter.java
Date Wed, 22 Nov 2006 17:01:32 GMT
Author: mikemccand
Date: Wed Nov 22 09:01:31 2006
New Revision: 478239

URL: http://svn.apache.org/viewvc?view=rev&rev=478239
Log:
LUCENE-720: fix two new unit tests (with lockless) to dynamically compute field number since
this number can vary depending on JRE

Modified:
    lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?view=diff&rev=478239&r1=478238&r2=478239
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Wed
Nov 22 09:01:31 2006
@@ -274,7 +274,7 @@
   /* Verifies that the expected file names were produced */
 
   // disable until hardcoded file names are fixes:
-  public void _testExactFileNames() throws IOException {
+  public void testExactFileNames() throws IOException {
 
     String outputDir = "lucene.backwardscompat0.index";
     Directory dir = FSDirectory.getDirectory(outputDir, true);
@@ -295,12 +295,30 @@
     reader.setNorm(21, "content", (float) 1.5);
     reader.close();
 
+    // The numbering of fields can vary depending on which
+    // JRE is in use.  On some JREs we see content bound to
+    // field 0; on others, field 1.  So, here we have to
+    // figure out which field number corresponds to
+    // "content", and then set our expected file names below
+    // accordingly:
+    CompoundFileReader cfsReader = new CompoundFileReader(dir, "_2.cfs");
+    FieldInfos fieldInfos = new FieldInfos(cfsReader, "_2.fnm");
+    int contentFieldIndex = -1;
+    for(int i=0;i<fieldInfos.size();i++) {
+      FieldInfo fi = fieldInfos.fieldInfo(i);
+      if (fi.name.equals("content")) {
+        contentFieldIndex = i;
+        break;
+      }
+    }
+    assertTrue("could not locate the 'content' field number in the _2.cfs segment", contentFieldIndex
!= -1);
+
     // Now verify file names:
     String[] expected = {"_0.cfs",
                          "_0_1.del",
                          "_1.cfs",
                          "_2.cfs",
-                         "_2_1.s0",
+                         "_2_1.s" + contentFieldIndex,
                          "_3.cfs",
                          "segments_a",
                          "segments.gen"};

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java?view=diff&rev=478239&r1=478238&r2=478239
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexFileDeleter.java Wed Nov 22
09:01:31 2006
@@ -29,12 +29,7 @@
 
 public class TestIndexFileDeleter extends TestCase
 {
-  // disable until hardcoded file names are fixes:
-  public void testDummy() {
-    assertTrue(true);
-  }
-
-  public void _testDeleteLeftoverFiles() throws IOException {
+  public void testDeleteLeftoverFiles() throws IOException {
 
     Directory dir = new RAMDirectory();
 
@@ -64,25 +59,45 @@
     }
     */
 
+    // The numbering of fields can vary depending on which
+    // JRE is in use.  On some JREs we see content bound to
+    // field 0; on others, field 1.  So, here we have to
+    // figure out which field number corresponds to
+    // "content", and then set our expected file names below
+    // accordingly:
+    CompoundFileReader cfsReader = new CompoundFileReader(dir, "_2.cfs");
+    FieldInfos fieldInfos = new FieldInfos(cfsReader, "_2.fnm");
+    int contentFieldIndex = -1;
+    for(int i=0;i<fieldInfos.size();i++) {
+      FieldInfo fi = fieldInfos.fieldInfo(i);
+      if (fi.name.equals("content")) {
+        contentFieldIndex = i;
+        break;
+      }
+    }
+    assertTrue("could not locate the 'content' field number in the _2.cfs segment", contentFieldIndex
!= -1);
+
+    String normSuffix = "s" + contentFieldIndex;
+
     // Create a bogus separate norms file for a
     // segment/field that actually has a separate norms file
     // already:
-    copyFile(dir, "_2_1.s0", "_2_2.s0");
+    copyFile(dir, "_2_1." + normSuffix, "_2_2." + normSuffix);
 
     // Create a bogus separate norms file for a
     // segment/field that actually has a separate norms file
     // already, using the "not compound file" extension:
-    copyFile(dir, "_2_1.s0", "_2_2.f0");
+    copyFile(dir, "_2_1." + normSuffix, "_2_2.f" + contentFieldIndex);
 
     // Create a bogus separate norms file for a
     // segment/field that does not have a separate norms
     // file already:
-    copyFile(dir, "_2_1.s0", "_1_1.s0");
+    copyFile(dir, "_2_1." + normSuffix, "_1_1." + normSuffix);
 
     // Create a bogus separate norms file for a
     // segment/field that does not have a separate norms
     // file already using the "not compound file" extension:
-    copyFile(dir, "_2_1.s0", "_1_1.f0");
+    copyFile(dir, "_2_1." + normSuffix, "_1_1.f" + contentFieldIndex);
 
     // Create a bogus separate del file for a
     // segment that already has a separate del file: 



Mime
View raw message