You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2011/10/29 18:50:42 UTC
svn commit: r1194932 - in /lucene/dev/branches/lucene2621/lucene/src:
test-framework/org/apache/lucene/util/ test/org/apache/lucene/index/
test/org/apache/lucene/index/codecs/preflex/
test/org/apache/lucene/index/codecs/pulsing/ test/org/apache/lucene/...
Author: rmuir
Date: Sat Oct 29 16:50:42 2011
New Revision: 1194932
URL: http://svn.apache.org/viewvc?rev=1194932&view=rev
Log:
LUCENE-3490: fix more tests
Modified:
lucene/dev/branches/lucene2621/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java
Modified: lucene/dev/branches/lucene2621/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java Sat Oct 29 16:50:42 2011
@@ -48,6 +48,7 @@ import org.apache.lucene.index.codecs.Co
import org.apache.lucene.index.codecs.CoreCodecProvider;
import org.apache.lucene.index.codecs.PostingsFormat;
import org.apache.lucene.index.codecs.CodecProvider;
+import org.apache.lucene.index.codecs.lucene40.Lucene40Codec;
import org.apache.lucene.index.codecs.perfield.PerFieldPostingsFormat;
import org.apache.lucene.search.FieldDoc;
import org.apache.lucene.search.ScoreDoc;
@@ -354,8 +355,6 @@ public class _TestUtil {
return new String(buffer, 0, i);
}
- // TODO: do we really want an alwaysPostingsFormat?
-
public static CodecProvider alwaysCodec(final Codec c) {
return new CoreCodecProvider() {
@Override
@@ -365,7 +364,7 @@ public class _TestUtil {
if (name.equals(c.getName())) {
return c;
} else {
- return CodecProvider.getDefault().lookup(name);
+ return super.lookup(name);
}
}
@@ -383,6 +382,43 @@ public class _TestUtil {
return alwaysCodec(CodecProvider.getDefault().lookup(codec));
}
+ /** Return a CodecProvider that can read any of the
+ * default codecs and formats, but always writes in the specified
+ * format. */
+ public static CodecProvider alwaysFormat(final PostingsFormat format) {
+ final Codec codec = new Lucene40Codec() {
+ @Override
+ public PostingsFormat getPostingsFormat(String formatName) {
+ if (formatName == format.name) {
+ return format;
+ } else {
+ return super.getPostingsFormat(formatName);
+ }
+ }
+
+ @Override
+ public String getPostingsFormatForField(String field) {
+ return format.name;
+ }
+ };
+
+ return new CoreCodecProvider() {
+ @Override
+ public Codec getDefaultCodec() {
+ return codec;
+ }
+
+ @Override
+ public Codec lookup(String name) {
+ if (name == codec.getName()) {
+ return codec;
+ } else {
+ return super.lookup(name);
+ }
+ }
+ };
+ }
+
public static String getPostingsFormat(String field) {
PostingsFormat p = CodecProvider.getDefault().getDefaultCodec().postingsFormat();
if (p instanceof PerFieldPostingsFormat) {
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java Sat Oct 29 16:50:42 2011
@@ -34,6 +34,7 @@ import org.apache.lucene.index.DocTermOr
import org.apache.lucene.index.codecs.BlockTermsReader;
import org.apache.lucene.index.codecs.BlockTermsWriter;
import org.apache.lucene.index.codecs.Codec;
+import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.index.codecs.DefaultDocValuesFormat;
import org.apache.lucene.index.codecs.DefaultFieldsFormat;
import org.apache.lucene.index.codecs.DocValuesFormat;
@@ -107,31 +108,6 @@ public class TestDocTermOrds extends Luc
dir.close();
}
- private static class StandardCodecWithOrds extends Codec {
- private final PostingsFormat postings = new StandardPostingsFormatWithOrds();
- private final FieldsFormat fields = new DefaultFieldsFormat();
- private final DocValuesFormat docValues = new DefaultDocValuesFormat();
-
- public StandardCodecWithOrds() {
- super("StandardOrds");
- }
-
- @Override
- public PostingsFormat postingsFormat() {
- return postings;
- }
-
- @Override
- public FieldsFormat fieldsFormat() {
- return fields;
- }
-
- @Override
- public DocValuesFormat docValuesFormat() {
- return docValues;
- }
- }
-
private static class StandardPostingsFormatWithOrds extends PostingsFormat {
public StandardPostingsFormatWithOrds() {
@@ -254,17 +230,7 @@ public class TestDocTermOrds extends Luc
// Sometimes swap in codec that impls ord():
if (random.nextInt(10) == 7) {
// Make sure terms index has ords:
- CoreCodecProvider cp = new CoreCodecProvider() {
- {
- register(new StandardCodecWithOrds());
- }
-
- @Override
- public Codec getDefaultCodec() {
- return lookup("StandardOrds");
- }
- };
-
+ CodecProvider cp = _TestUtil.alwaysFormat(new StandardPostingsFormatWithOrds());
// So checkIndex on close works
dir.setCodecProvider(cp);
conf.setCodecProvider(cp);
@@ -363,18 +329,7 @@ public class TestDocTermOrds extends Luc
// Sometimes swap in codec that impls ord():
if (random.nextInt(10) == 7) {
- // Make sure terms index has ords:
- CoreCodecProvider cp = new CoreCodecProvider() {
- {
- register(new StandardCodecWithOrds());
- }
-
- @Override
- public Codec getDefaultCodec() {
- return lookup("StandardOrds");
- }
- };
-
+ CodecProvider cp = _TestUtil.alwaysFormat(new StandardPostingsFormatWithOrds());
// So checkIndex on close works
dir.setCodecProvider(cp);
conf.setCodecProvider(cp);
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java Sat Oct 29 16:50:42 2011
@@ -28,9 +28,6 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.index.codecs.Codec;
-import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.perfield.PerFieldCodec;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
@@ -172,15 +169,9 @@ public class TestIndexWriterCommit exten
// sum because the merged FST may use array encoding for
// some arcs (which uses more space):
- // nocommit: make some kind of idiom for this?
- // or can we just use the annotation?
- Codec codec = CodecProvider.getDefault().getDefaultCodec();
- if (codec instanceof PerFieldCodec) {
- PerFieldCodec perField = (PerFieldCodec) codec;
- final String idFormat = perField.getPostingsFormat("id");
- final String contentFormat = perField.getPostingsFormat("content");
- assumeFalse("This test cannot run with Memory codec", idFormat.equals("Memory") || contentFormat.equals("Memory"));
- }
+ final String idFormat = _TestUtil.getPostingsFormat("id");
+ final String contentFormat = _TestUtil.getPostingsFormat("content");
+ assumeFalse("This test cannot run with Memory codec", idFormat.equals("Memory") || contentFormat.equals("Memory"));
MockDirectoryWrapper dir = newDirectory();
Analyzer analyzer;
if (random.nextBoolean()) {
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java Sat Oct 29 16:50:42 2011
@@ -33,7 +33,6 @@ import org.apache.lucene.document.String
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.codecs.Codec;
import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.perfield.PerFieldCodec;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
@@ -899,15 +898,9 @@ public class TestIndexWriterDelete exten
}
public void testIndexingThenDeleting() throws Exception {
- // nocommit: make some kind of idiom for this?
- // or can we just use the annotation?
- Codec codec = CodecProvider.getDefault().getDefaultCodec();
- if (codec instanceof PerFieldCodec) {
- PerFieldCodec perField = (PerFieldCodec) codec;
- final String fieldFormat = perField.getPostingsFormat("field");
- assumeFalse("This test cannot run with Memory codec", fieldFormat.equals("Memory"));
- assumeFalse("This test cannot run with SimpleText codec", fieldFormat.equals("SimpleText"));
- }
+ final String fieldFormat = _TestUtil.getPostingsFormat("field");
+ assumeFalse("This test cannot run with Memory codec", fieldFormat.equals("Memory"));
+ assumeFalse("This test cannot run with SimpleText codec", fieldFormat.equals("SimpleText"));
final Random r = random;
Directory dir = newDirectory();
// note this test explicitly disables payloads
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java Sat Oct 29 16:50:42 2011
@@ -26,7 +26,6 @@ import org.apache.lucene.document.TextFi
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.codecs.Codec;
import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.perfield.PerFieldCodec;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
@@ -157,15 +156,9 @@ public class TestIndexWriterOnDiskFull e
// sum because the merged FST may use array encoding for
// some arcs (which uses more space):
- // nocommit: make some kind of idiom for this?
- // or can we just use the annotation?
- Codec codec = CodecProvider.getDefault().getDefaultCodec();
- if (codec instanceof PerFieldCodec) {
- PerFieldCodec perField = (PerFieldCodec) codec;
- final String idFormat = perField.getPostingsFormat("id");
- final String contentFormat = perField.getPostingsFormat("content");
- assumeFalse("This test cannot run with Memory codec", idFormat.equals("Memory") || contentFormat.equals("Memory"));
- }
+ final String idFormat = _TestUtil.getPostingsFormat("id");
+ final String contentFormat = _TestUtil.getPostingsFormat("content");
+ assumeFalse("This test cannot run with Memory codec", idFormat.equals("Memory") || contentFormat.equals("Memory"));
int START_COUNT = 57;
int NUM_DIR = TEST_NIGHTLY ? 50 : 5;
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java Sat Oct 29 16:50:42 2011
@@ -32,7 +32,6 @@ import org.apache.lucene.document.String
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.codecs.Codec;
import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.perfield.PerFieldCodec;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
@@ -997,18 +996,10 @@ public class TestIndexWriterReader exten
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(random)).setReaderTermsIndexDivisor(-1);
- // nocommit: make some kind of idiom for this?
- // or can we just use the annotation?
- Codec codec = CodecProvider.getDefault().getDefaultCodec();
-
// Don't proceed if picked Codec is in the list of illegal ones.
- if (codec instanceof PerFieldCodec) {
- PerFieldCodec perField = (PerFieldCodec) codec;
- final String format = perField.getPostingsFormat("f");
- assumeFalse("Format: " + format + " does not support ReaderTermsIndexDivisor!",
- (format.equals("SimpleText") || format.equals("Memory")));
- }
-
+ final String format = _TestUtil.getPostingsFormat("f");
+ assumeFalse("Format: " + format + " does not support ReaderTermsIndexDivisor!",
+ (format.equals("SimpleText") || format.equals("Memory")));
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, conf);
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java Sat Oct 29 16:50:42 2011
@@ -23,9 +23,6 @@ import java.io.Reader;
import org.apache.lucene.analysis.*;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.codecs.Codec;
-import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.perfield.PerFieldCodec;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.ScoreDoc;
@@ -36,6 +33,7 @@ import org.apache.lucene.store.MockDirec
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util._TestUtil;
/**
* Tests lazy skipping on the proximity file.
@@ -133,15 +131,10 @@ public class TestLazyProxSkipping extend
}
public void testLazySkipping() throws IOException {
- // nocommit: make some kind of idiom for this?
- // or can we just use the annotation?
- Codec codec = CodecProvider.getDefault().getDefaultCodec();
- if (codec instanceof PerFieldCodec) {
- PerFieldCodec perField = (PerFieldCodec) codec;
- final String fieldFormat = perField.getPostingsFormat(this.field);
- assumeFalse("This test cannot run with Memory codec", fieldFormat.equals("Memory"));
- assumeFalse("This test cannot run with SimpleText codec", fieldFormat.equals("SimpleText"));
- };
+ final String fieldFormat = _TestUtil.getPostingsFormat(this.field);
+ assumeFalse("This test cannot run with Memory codec", fieldFormat.equals("Memory"));
+ assumeFalse("This test cannot run with SimpleText codec", fieldFormat.equals("SimpleText"));
+
// test whether only the minimum amount of seeks()
// are performed
performTest(5);
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java Sat Oct 29 16:50:42 2011
@@ -21,7 +21,7 @@ import org.apache.lucene.store.*;
import org.apache.lucene.document.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.index.*;
-import org.apache.lucene.index.codecs.preflexrw.PreFlexRWPostingsFormat;
+import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
import org.apache.lucene.util.*;
import java.util.*;
@@ -282,7 +282,7 @@ public class TestSurrogates extends Luce
RandomIndexWriter w = new RandomIndexWriter(random,
dir,
newIndexWriterConfig( TEST_VERSION_CURRENT,
- new MockAnalyzer(random)).setCodecProvider(_TestUtil.alwaysCodec(new PreFlexRWPostingsFormat())));
+ new MockAnalyzer(random)).setCodecProvider(_TestUtil.alwaysCodec(new PreFlexRWCodec())));
final int numField = _TestUtil.nextInt(random, 2, 5);
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/Test10KPulsings.java Sat Oct 29 16:50:42 2011
@@ -51,7 +51,7 @@ import org.junit.Ignore;
public class Test10KPulsings extends LuceneTestCase {
public void test10kPulsed() throws Exception {
// we always run this test with pulsing codec.
- CodecProvider cp = _TestUtil.alwaysCodec(new PulsingPostingsFormat(1));
+ CodecProvider cp = _TestUtil.alwaysFormat(new PulsingPostingsFormat(1));
File f = _TestUtil.getTempDir("10kpulsed");
MockDirectoryWrapper dir = newFSDirectory(f);
@@ -101,7 +101,7 @@ public class Test10KPulsings extends Luc
*/
public void test10kNotPulsed() throws Exception {
// we always run this test with pulsing codec.
- CodecProvider cp = _TestUtil.alwaysCodec(new PulsingPostingsFormat(1));
+ CodecProvider cp = _TestUtil.alwaysFormat(new PulsingPostingsFormat(1));
File f = _TestUtil.getTempDir("10knotpulsed");
MockDirectoryWrapper dir = newFSDirectory(f);
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/pulsing/TestPulsingReuse.java Sat Oct 29 16:50:42 2011
@@ -30,7 +30,6 @@ import org.apache.lucene.index.CheckInde
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.PerDocWriteState;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SegmentInfo;
import org.apache.lucene.index.SegmentReadState;
@@ -40,15 +39,10 @@ import org.apache.lucene.index.codecs.Bl
import org.apache.lucene.index.codecs.BlockTreeTermsWriter;
import org.apache.lucene.index.codecs.PostingsFormat;
import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.DefaultDocValuesConsumer;
-import org.apache.lucene.index.codecs.DefaultDocValuesProducer;
import org.apache.lucene.index.codecs.FieldsConsumer;
import org.apache.lucene.index.codecs.FieldsProducer;
-import org.apache.lucene.index.codecs.PerDocConsumer;
-import org.apache.lucene.index.codecs.PerDocValues;
import org.apache.lucene.index.codecs.PostingsReaderBase;
import org.apache.lucene.index.codecs.PostingsWriterBase;
-import org.apache.lucene.index.codecs.lucene40.Lucene40PostingsFormat;
import org.apache.lucene.index.codecs.lucene40.Lucene40PostingsReader;
import org.apache.lucene.index.codecs.lucene40.Lucene40PostingsWriter;
import org.apache.lucene.store.Directory;
@@ -63,7 +57,7 @@ public class TestPulsingReuse extends Lu
// TODO: this is a basic test. this thing is complicated, add more
public void testSophisticatedReuse() throws Exception {
// we always run this test with pulsing codec.
- CodecProvider cp = _TestUtil.alwaysCodec(new PulsingPostingsFormat(1));
+ CodecProvider cp = _TestUtil.alwaysFormat(new PulsingPostingsFormat(1));
Directory dir = newDirectory();
RandomIndexWriter iw = new RandomIndexWriter(random, dir,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setCodecProvider(cp));
@@ -101,7 +95,7 @@ public class TestPulsingReuse extends Lu
/** tests reuse with Pulsing1(Pulsing2(Standard)) */
public void testNestedPulsing() throws Exception {
// we always run this test with pulsing codec.
- CodecProvider cp = _TestUtil.alwaysCodec(new NestedPulsing());
+ CodecProvider cp = _TestUtil.alwaysFormat(new NestedPulsing());
MockDirectoryWrapper dir = newDirectory();
dir.setCheckIndexOnClose(false); // will do this ourselves, custom codec
RandomIndexWriter iw = new RandomIndexWriter(random, dir,
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java?rev=1194932&r1=1194931&r2=1194932&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java Sat Oct 29 16:50:42 2011
@@ -40,9 +40,7 @@ import org.apache.lucene.index.RandomInd
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.index.codecs.Codec;
import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.perfield.PerFieldCodec;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
@@ -1015,17 +1013,10 @@ public class TestFSTs extends LuceneTest
// file, up until a time limit
public void testRealTerms() throws Exception {
- // nocommit: make some kind of idiom for this?
- // this test already sets the annotation? is this even needed?!
- Codec codec = CodecProvider.getDefault().getDefaultCodec();
-
- if (codec instanceof PerFieldCodec) {
- PerFieldCodec perField = (PerFieldCodec) codec;
- final String defaultFormat = perField.getDefaultPostingsFormat();
- if (defaultFormat.equals("SimpleText") || defaultFormat.equals("Memory")) {
- // no
- CodecProvider.setDefault(_TestUtil.alwaysCodec("Lucene40"));
- }
+ final String defaultFormat = _TestUtil.getPostingsFormat("abracadabra");
+ if (defaultFormat.equals("SimpleText") || defaultFormat.equals("Memory")) {
+ // no
+ CodecProvider.setDefault(_TestUtil.alwaysCodec("Lucene40"));
}
final LineFileDocs docs = new LineFileDocs(random);