test for presence/absence of physical norms file

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@330177 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2005-11-02 03:22:01 +00:00
parent 5a76aaa06f
commit 9698aac274
1 changed files with 11 additions and 2 deletions

View File

@ -54,9 +54,10 @@ public class TestDocumentWriter extends TestCase {
DocumentWriter writer = new DocumentWriter(dir, analyzer, similarity, 50);
assertTrue(writer != null);
try {
writer.addDocument("test", testDoc);
String segName="test";
writer.addDocument(segName, testDoc);
//After adding the document, we should be able to read it back in
SegmentReader reader = SegmentReader.get(new SegmentInfo("test", 1, dir));
SegmentReader reader = SegmentReader.get(new SegmentInfo(segName, 1, dir));
assertTrue(reader != null);
Document doc = reader.document(0);
assertTrue(doc != null);
@ -84,6 +85,14 @@ public class TestDocumentWriter extends TestCase {
assertTrue(fields != null && fields.length == 1);
assertTrue(fields[0].stringValue().equals(DocHelper.FIELD_3_TEXT));
// test that the norm file is not present if omitNorms is true
for (int i=0; i<reader.fieldInfos.size(); i++) {
FieldInfo fi = reader.fieldInfos.fieldInfo(i);
if (fi.isIndexed) {
assertTrue(fi.omitNorms == !dir.fileExists(segName + ".f" + i));
}
}
} catch (IOException e) {
e.printStackTrace();
assertTrue(false);