Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3916311E61 for ; Mon, 22 Sep 2014 14:50:02 +0000 (UTC) Received: (qmail 64283 invoked by uid 500); 22 Sep 2014 14:50:02 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 64274 invoked by uid 99); 22 Sep 2014 14:50:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2014 14:50:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2014 14:50:00 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BC90F23889DA; Mon, 22 Sep 2014 14:49:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1626796 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/core/ lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java Date: Mon, 22 Sep 2014 14:49:40 -0000 To: commits@lucene.apache.org From: rmuir@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140922144940.BC90F23889DA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rmuir Date: Mon Sep 22 14:49:40 2014 New Revision: 1626796 URL: http://svn.apache.org/r1626796 Log: LUCENE-5969: improve this test, we cant uncomment the assert until we fix 5.0 codec Modified: lucene/dev/branches/branch_5x/ (props changed) lucene/dev/branches/branch_5x/lucene/ (props changed) lucene/dev/branches/branch_5x/lucene/core/ (props changed) lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java?rev=1626796&r1=1626795&r2=1626796&view=diff ============================================================================== --- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java (original) +++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java Mon Sep 22 14:49:40 2014 @@ -18,12 +18,16 @@ package org.apache.lucene.index; */ import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.FieldType; import org.apache.lucene.document.NumericDocValuesField; +import org.apache.lucene.document.TextField; import org.apache.lucene.store.CompoundFileDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IndexInput; @@ -48,16 +52,22 @@ public class TestAllFilesHaveCodecHeader conf.setCodec(TestUtil.getDefaultCodec()); RandomIndexWriter riw = new RandomIndexWriter(random(), dir, conf); Document doc = new Document(); - // these fields should sometimes get term vectors, etc - Field idField = newStringField("id", "", Field.Store.NO); - Field bodyField = newTextField("body", "", Field.Store.NO); + Field idField = newStringField("id", "", Field.Store.YES); + Field bodyField = newTextField("body", "", Field.Store.YES); + FieldType vectorsType = new FieldType(TextField.TYPE_STORED); + vectorsType.setStoreTermVectors(true); + vectorsType.setStoreTermVectorPositions(true); + Field vectorsField = new Field("vectors", "", vectorsType); Field dvField = new NumericDocValuesField("dv", 5); doc.add(idField); doc.add(bodyField); + doc.add(vectorsField); doc.add(dvField); for (int i = 0; i < 100; i++) { idField.setStringValue(Integer.toString(i)); bodyField.setStringValue(TestUtil.randomUnicodeString(random())); + dvField.setLongValue(random().nextInt(5)); + vectorsField.setStringValue(TestUtil.randomUnicodeString(random())); riw.addDocument(doc); if (random().nextInt(7) == 0) { riw.commit(); @@ -68,18 +78,18 @@ public class TestAllFilesHaveCodecHeader // } } riw.close(); - checkHeaders(dir); + checkHeaders(dir, new HashMap()); dir.close(); } - private void checkHeaders(Directory dir) throws IOException { + private void checkHeaders(Directory dir, Map namesToExtensions) throws IOException { for (String file : dir.listAll()) { if (file.equals(IndexWriter.WRITE_LOCK_NAME)) { continue; // write.lock has no header, thats ok } if (file.endsWith(IndexFileNames.COMPOUND_FILE_EXTENSION)) { CompoundFileDirectory cfsDir = new CompoundFileDirectory(dir, file, newIOContext(random()), false); - checkHeaders(cfsDir); // recurse into cfs + checkHeaders(cfsDir, namesToExtensions); // recurse into cfs cfsDir.close(); } IndexInput in = null; @@ -88,6 +98,18 @@ public class TestAllFilesHaveCodecHeader in = dir.openInput(file, newIOContext(random())); int val = in.readInt(); assertEquals(file + " has no codec header, instead found: " + val, CodecUtil.CODEC_MAGIC, val); + String codecName = in.readString(); + assertFalse(codecName.isEmpty()); + String extension = IndexFileNames.getExtension(file); + if (extension == null) { + assertTrue(file.startsWith(IndexFileNames.SEGMENTS)); + extension = " (not a real extension, designates segments file)"; + } + String previous = namesToExtensions.put(codecName, extension); + if (previous != null && !previous.equals(extension)) { + //TODO: not yet + // fail("extensions " + previous + " and " + extension + " share same codecName " + codecName); + } success = true; } finally { if (success) {