From 19f90a38ee855a29d4624fe54e483be98fd0df87 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Wed, 22 Nov 2006 17:01:31 +0000 Subject: [PATCH] LUCENE-720: fix two new unit tests (with lockless) to dynamically compute field number since this number can vary depending on JRE git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@478239 13f79535-47bb-0310-9956-ffa450edef68 --- .../index/TestBackwardsCompatibility.java | 22 ++++++++++-- .../lucene/index/TestIndexFileDeleter.java | 35 +++++++++++++------ 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java index 668ba52b3e1..ea75f0a09d8 100644 --- a/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java +++ b/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java @@ -274,7 +274,7 @@ public class TestBackwardsCompatibility extends TestCase /* 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 @@ public class TestBackwardsCompatibility extends TestCase 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