You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2010/08/04 17:04:28 UTC

svn commit: r982287 - in /lucene/dev/trunk/lucene/src: java/org/apache/lucene/index/codecs/ java/org/apache/lucene/index/codecs/intblock/ java/org/apache/lucene/index/codecs/sep/ test/org/apache/lucene/index/ test/org/apache/lucene/index/codecs/intbloc...

Author: mikemccand
Date: Wed Aug  4 15:04:26 2010
New Revision: 982287

URL: http://svn.apache.org/viewvc?rev=982287&view=rev
Log:
LUCENE-2586: move the mock intblock/sep codecs out of core, into test

Added:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java
      - copied, changed from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/IntBlockCodec.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockFactory.java
      - copied, changed from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockFactory.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexInput.java
      - copied, changed from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexInput.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexOutput.java
      - copied, changed from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexOutput.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java
      - copied, changed from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepCodec.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java
      - copied, changed from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntFactory.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java
      - copied, changed from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java
      - copied, changed from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexOutput.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/sep/
Removed:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/IntBlockCodec.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockFactory.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexInput.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexOutput.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepCodec.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntFactory.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexOutput.java
Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/CodecProvider.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCodecs.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/CodecProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/CodecProvider.java?rev=982287&r1=982286&r2=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/CodecProvider.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/CodecProvider.java Wed Aug  4 15:04:26 2010
@@ -23,10 +23,8 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.lucene.index.SegmentWriteState;
-import org.apache.lucene.index.codecs.intblock.IntBlockCodec;
 import org.apache.lucene.index.codecs.preflex.PreFlexCodec;
 import org.apache.lucene.index.codecs.pulsing.PulsingCodec;
-import org.apache.lucene.index.codecs.sep.SepCodec;
 import org.apache.lucene.index.codecs.standard.StandardCodec;
 
 /** Holds a set of codecs, keyed by name.  You subclass
@@ -47,7 +45,7 @@ public abstract class CodecProvider {
 
   private static String defaultCodec = "Standard";
 
-  public final static String[] CORE_CODECS = new String[] {"Standard", "Sep", "Pulsing", "IntBlock", "PreFlex"};
+  public final static String[] CORE_CODECS = new String[] {"Standard", "Pulsing", "PreFlex"};
 
   public synchronized void register(Codec codec) {
     if (codec.name == null) {
@@ -116,10 +114,8 @@ public abstract class CodecProvider {
 class DefaultCodecProvider extends CodecProvider {
   DefaultCodecProvider() {
     register(new StandardCodec());
-    register(new IntBlockCodec());
     register(new PreFlexCodec());
     register(new PulsingCodec());
-    register(new SepCodec());
   }
 
   @Override

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java?rev=982287&r1=982286&r2=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java Wed Aug  4 15:04:26 2010
@@ -59,15 +59,15 @@ public class SepPostingsReaderImpl exten
     boolean success = false;
     try {
 
-      final String docFileName = IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.DOC_EXTENSION);
+      final String docFileName = IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.DOC_EXTENSION);
       docIn = intFactory.openInput(dir, docFileName);
 
-      skipIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.SKIP_EXTENSION), readBufferSize);
+      skipIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.SKIP_EXTENSION), readBufferSize);
 
       if (segmentInfo.getHasProx()) {
-        freqIn = intFactory.openInput(dir, IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.FREQ_EXTENSION));
-        posIn = intFactory.openInput(dir, IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.POS_EXTENSION), readBufferSize);
-        payloadIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.PAYLOAD_EXTENSION), readBufferSize);
+        freqIn = intFactory.openInput(dir, IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.FREQ_EXTENSION));
+        posIn = intFactory.openInput(dir, IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.POS_EXTENSION), readBufferSize);
+        payloadIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.PAYLOAD_EXTENSION), readBufferSize);
       } else {
         posIn = null;
         payloadIn = null;
@@ -82,13 +82,13 @@ public class SepPostingsReaderImpl exten
   }
 
   public static void files(SegmentInfo segmentInfo, Collection<String> files) {
-    files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.DOC_EXTENSION));
-    files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.SKIP_EXTENSION));
+    files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.DOC_EXTENSION));
+    files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.SKIP_EXTENSION));
 
     if (segmentInfo.getHasProx()) {
-      files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.FREQ_EXTENSION));
-      files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.POS_EXTENSION));
-      files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.PAYLOAD_EXTENSION));
+      files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.FREQ_EXTENSION));
+      files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.POS_EXTENSION));
+      files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.PAYLOAD_EXTENSION));
     }
   }
 

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java?rev=982287&r1=982286&r2=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java Wed Aug  4 15:04:26 2010
@@ -18,6 +18,7 @@ u * contributor license agreements.  See
  */
 
 import java.io.IOException;
+import java.util.Set;
 
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.FieldInfo;
@@ -35,6 +36,12 @@ import org.apache.lucene.util.CodecUtil;
 public final class SepPostingsWriterImpl extends StandardPostingsWriter {
   final static String CODEC = "SepDocFreqSkip";
 
+  final static String DOC_EXTENSION = "doc";
+  final static String SKIP_EXTENSION = "skp";
+  final static String FREQ_EXTENSION = "frq";
+  final static String POS_EXTENSION = "pos";
+  final static String PAYLOAD_EXTENSION = "pyl";
+
   // Increment version to change it:
   final static int VERSION_START = 0;
   final static int VERSION_CURRENT = VERSION_START;
@@ -76,24 +83,24 @@ public final class SepPostingsWriterImpl
   public SepPostingsWriterImpl(SegmentWriteState state, IntStreamFactory factory) throws IOException {
     super();
 
-    final String docFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.DOC_EXTENSION);
+    final String docFileName = IndexFileNames.segmentFileName(state.segmentName, "", DOC_EXTENSION);
     state.flushedFiles.add(docFileName);
     docOut = factory.createOutput(state.directory, docFileName);
     docIndex = docOut.index();
 
     if (state.fieldInfos.hasProx()) {
-      final String frqFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.FREQ_EXTENSION);
+      final String frqFileName = IndexFileNames.segmentFileName(state.segmentName, "", FREQ_EXTENSION);
       state.flushedFiles.add(frqFileName);
       freqOut = factory.createOutput(state.directory, frqFileName);
       freqIndex = freqOut.index();
 
-      final String posFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.POS_EXTENSION);
+      final String posFileName = IndexFileNames.segmentFileName(state.segmentName, "", POS_EXTENSION);
       posOut = factory.createOutput(state.directory, posFileName);
       state.flushedFiles.add(posFileName);
       posIndex = posOut.index();
 
       // TODO: -- only if at least one field stores payloads?
-      final String payloadFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.PAYLOAD_EXTENSION);
+      final String payloadFileName = IndexFileNames.segmentFileName(state.segmentName, "", PAYLOAD_EXTENSION);
       state.flushedFiles.add(payloadFileName);
       payloadOut = state.directory.createOutput(payloadFileName);
 
@@ -105,7 +112,7 @@ public final class SepPostingsWriterImpl
       payloadOut = null;
     }
 
-    final String skipFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.SKIP_EXTENSION);
+    final String skipFileName = IndexFileNames.segmentFileName(state.segmentName, "", SKIP_EXTENSION);
     state.flushedFiles.add(skipFileName);
     skipOut = state.directory.createOutput(skipFileName);
 
@@ -284,4 +291,12 @@ public final class SepPostingsWriterImpl
       }
     }
   }
+
+  public static void getExtensions(Set<String> extensions) {
+    extensions.add(DOC_EXTENSION);
+    extensions.add(FREQ_EXTENSION);
+    extensions.add(SKIP_EXTENSION);
+    extensions.add(POS_EXTENSION);
+    extensions.add(PAYLOAD_EXTENSION);
+  }
 }

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCodecs.java?rev=982287&r1=982286&r2=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCodecs.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestCodecs.java Wed Aug  4 15:04:26 2010
@@ -32,7 +32,7 @@ import org.apache.lucene.index.codecs.Fi
 import org.apache.lucene.index.codecs.FieldsProducer;
 import org.apache.lucene.index.codecs.PostingsConsumer;
 import org.apache.lucene.index.codecs.TermsConsumer;
-import org.apache.lucene.index.codecs.sep.SepCodec;
+import org.apache.lucene.index.codecs.mocksep.MockSepCodec;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.PhraseQuery;
@@ -344,7 +344,7 @@ public class TestCodecs extends MultiCod
     final Directory dir = new RAMDirectory();
     final IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_31,
       new MockAnalyzer());
-    config.setCodecProvider(new SepCodecs());
+    config.setCodecProvider(new MockSepCodecs());
     final IndexWriter writer = new IndexWriter(dir, config);
 
     try {
@@ -397,15 +397,15 @@ public class TestCodecs extends MultiCod
     }
   }
 
-  public static class SepCodecs extends CodecProvider {
+  public static class MockSepCodecs extends CodecProvider {
 
-    protected SepCodecs() {
-      this.register(new SepCodec());
+    protected MockSepCodecs() {
+      this.register(new MockSepCodec());
     }
 
     @Override
     public Codec getWriter(final SegmentWriteState state) {
-      return this.lookup("Sep");
+      return this.lookup("MockSep");
     }
 
   }

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java?rev=982287&r1=982286&r2=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java Wed Aug  4 15:04:26 2010
@@ -20,19 +20,20 @@ package org.apache.lucene.index.codecs.i
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.store.*;
 import org.apache.lucene.index.codecs.sep.*;
+import org.apache.lucene.index.codecs.mockintblock.*;
 
 public class TestIntBlockCodec extends LuceneTestCase {
 
   public void testSimpleIntBlocks() throws Exception {
     Directory dir = new MockRAMDirectory();
 
-    IntIndexOutput out = new SimpleIntBlockIndexOutput(dir, "test", 128);
+    IntIndexOutput out = new MockFixedIntBlockIndexOutput(dir, "test", 128);
     for(int i=0;i<11777;i++) {
       out.write(i);
     }
     out.close();
 
-    IntIndexInput in = new SimpleIntBlockIndexInput(dir, "test", 128);
+    IntIndexInput in = new MockFixedIntBlockIndexInput(dir, "test", 128);
     IntIndexInput.Reader r = in.reader();
 
     for(int i=0;i<11777;i++) {
@@ -46,11 +47,11 @@ public class TestIntBlockCodec extends L
   public void testEmptySimpleIntBlocks() throws Exception {
     Directory dir = new MockRAMDirectory();
 
-    IntIndexOutput out = new SimpleIntBlockIndexOutput(dir, "test", 128);
+    IntIndexOutput out = new MockFixedIntBlockIndexOutput(dir, "test", 128);
     // write no ints
     out.close();
 
-    IntIndexInput in = new SimpleIntBlockIndexInput(dir, "test", 128);
+    IntIndexInput in = new MockFixedIntBlockIndexInput(dir, "test", 128);
     in.reader();
     // read no ints
     in.close();

Copied: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java (from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/IntBlockCodec.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/IntBlockCodec.java&r1=981930&r2=982287&rev=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/IntBlockCodec.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java Wed Aug  4 15:04:26 2010
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.intblock;
+package org.apache.lucene.index.codecs.mockintblock;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,7 +26,6 @@ import org.apache.lucene.index.SegmentRe
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.FieldsConsumer;
 import org.apache.lucene.index.codecs.FieldsProducer;
-import org.apache.lucene.index.codecs.sep.SepCodec;
 import org.apache.lucene.index.codecs.sep.SepPostingsReaderImpl;
 import org.apache.lucene.index.codecs.sep.SepPostingsWriterImpl;
 import org.apache.lucene.index.codecs.standard.SimpleStandardTermsIndexReader;
@@ -42,17 +41,20 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.BytesRef;
 
 /**
- * @lucene.experimental
+ * A silly codec that simply writes each block as a series
+ * of vInts.  Don't use this (performance will be poor)!
+ * This is here just to test the core intblock codec
+ * classes.
  */
-public class IntBlockCodec extends Codec {
+public class MockFixedIntBlockCodec extends Codec {
 
-  public IntBlockCodec() {
-    name = "IntBlock";
+  public MockFixedIntBlockCodec() {
+    name = "MockFixedIntBlock";
   }
 
   @Override
   public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
-    StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new SimpleIntBlockFactory(1024));
+    StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new MockFixedIntBlockFactory(1024));
 
     boolean success = false;
     StandardTermsIndexWriter indexWriter;
@@ -86,7 +88,7 @@ public class IntBlockCodec extends Codec
     StandardPostingsReader postingsReader = new SepPostingsReaderImpl(state.dir,
                                                                       state.segmentInfo,
                                                                       state.readBufferSize,
-                                                                      new SimpleIntBlockFactory(1024));
+                                                                      new MockFixedIntBlockFactory(1024));
 
     StandardTermsIndexReader indexReader;
     boolean success = false;
@@ -135,6 +137,8 @@ public class IntBlockCodec extends Codec
 
   @Override
   public void getExtensions(Set<String> extensions) {
-    SepCodec.getSepExtensions(extensions);
+    SepPostingsWriterImpl.getExtensions(extensions);
+    StandardTermsDictReader.getExtensions(extensions);
+    SimpleStandardTermsIndexReader.getIndexExtensions(extensions);
   }
 }

Copied: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockFactory.java (from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockFactory.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockFactory.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockFactory.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockFactory.java&r1=981930&r2=982287&rev=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockFactory.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockFactory.java Wed Aug  4 15:04:26 2010
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.intblock;
+package org.apache.lucene.index.codecs.mockintblock;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,18 +24,21 @@ import org.apache.lucene.index.codecs.se
 
 import java.io.IOException;
 
-/** @lucene.experimental */
-public class SimpleIntBlockFactory extends IntStreamFactory {
+/** Silly int factory that reads/writes block of ints by
+ *  simply encoding each as vInt.  Don't use this
+ *  (performance will be poor)!  This is here just to test
+ *  the core intblock codec classes.*/
+public class MockFixedIntBlockFactory extends IntStreamFactory {
   private final int blockSize;
-  public SimpleIntBlockFactory(int blockSize) {
+  public MockFixedIntBlockFactory(int blockSize) {
     this.blockSize = blockSize;
   }
   @Override
   public IntIndexInput openInput(Directory dir, String fileName, int readBufferSize) throws IOException {
-    return new SimpleIntBlockIndexInput(dir, fileName, readBufferSize);
+    return new MockFixedIntBlockIndexInput(dir, fileName, readBufferSize);
   }
   @Override
   public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException {
-    return new SimpleIntBlockIndexOutput(dir, fileName, blockSize);
+    return new MockFixedIntBlockIndexOutput(dir, fileName, blockSize);
   }
 }

Copied: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexInput.java (from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexInput.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexInput.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexInput.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexInput.java&r1=981930&r2=982287&rev=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexInput.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexInput.java Wed Aug  4 15:04:26 2010
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.intblock;
+package org.apache.lucene.index.codecs.mockintblock;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,21 +24,18 @@ package org.apache.lucene.index.codecs.i
 import org.apache.lucene.util.CodecUtil;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.index.codecs.intblock.FixedIntBlockIndexInput;
 
 import java.io.IOException;
 
-/**
- * Don't use this class!!  It naively encodes ints one vInt
- * at a time.  Use it only for testing.
- *
- * @lucene.experimental
- */
-public class SimpleIntBlockIndexInput extends FixedIntBlockIndexInput {
+/** Don't use this class!!  It naively encodes ints one vInt
+ * at a time.  Use it only for testing. */
+public class MockFixedIntBlockIndexInput extends FixedIntBlockIndexInput {
 
-  public SimpleIntBlockIndexInput(Directory dir, String fileName, int readBufferSize) throws IOException {
+  public MockFixedIntBlockIndexInput(Directory dir, String fileName, int readBufferSize) throws IOException {
     IndexInput in = dir.openInput(fileName, readBufferSize);
-    CodecUtil.checkHeader(in, SimpleIntBlockIndexOutput.CODEC,
-      SimpleIntBlockIndexOutput.VERSION_START, SimpleIntBlockIndexOutput.VERSION_START);
+    CodecUtil.checkHeader(in, MockFixedIntBlockIndexOutput.CODEC,
+      MockFixedIntBlockIndexOutput.VERSION_START, MockFixedIntBlockIndexOutput.VERSION_START);
     init(in);
   }
 

Copied: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexOutput.java (from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexOutput.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexOutput.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexOutput.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexOutput.java&r1=981930&r2=982287&rev=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexOutput.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexOutput.java Wed Aug  4 15:04:26 2010
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.intblock;
+package org.apache.lucene.index.codecs.mockintblock;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -24,22 +24,19 @@ package org.apache.lucene.index.codecs.i
 import org.apache.lucene.util.CodecUtil;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.index.codecs.intblock.FixedIntBlockIndexOutput;
 
 import java.io.IOException;
 
-/**
- * Don't use this class!!  It naively encodes ints one vInt
- * at a time.  Use it only for testing.
- *
- * @lucene.experimental
- */
-public class SimpleIntBlockIndexOutput extends FixedIntBlockIndexOutput {
+/** Don't use this class!!  It naively encodes ints one vInt
+ * at a time.  Use it only for testing. */
+public class MockFixedIntBlockIndexOutput extends FixedIntBlockIndexOutput {
 
   public final static String CODEC = "SIMPLE_INT_BLOCKS";
   public final static int VERSION_START = 0;
   public final static int VERSION_CURRENT = VERSION_START;
 
-  public SimpleIntBlockIndexOutput(Directory dir, String fileName, int blockSize) throws IOException {
+  public MockFixedIntBlockIndexOutput(Directory dir, String fileName, int blockSize) throws IOException {
     IndexOutput out = dir.createOutput(fileName);
     CodecUtil.writeHeader(out, CODEC, VERSION_CURRENT);
     init(out, blockSize);

Copied: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java (from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepCodec.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepCodec.java&r1=981930&r2=982287&rev=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SepCodec.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java Wed Aug  4 15:04:26 2010
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.sep;
+package org.apache.lucene.index.codecs.mocksep;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -35,20 +35,27 @@ import org.apache.lucene.index.codecs.st
 import org.apache.lucene.index.codecs.standard.StandardTermsIndexReader;
 import org.apache.lucene.index.codecs.standard.StandardTermsIndexWriter;
 import org.apache.lucene.index.codecs.standard.StandardCodec;
+import org.apache.lucene.index.codecs.sep.SepPostingsWriterImpl;
+import org.apache.lucene.index.codecs.sep.SepPostingsReaderImpl;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 
-/** @lucene.experimental */
-public class SepCodec extends Codec {
+/**
+ * A silly codec that simply writes each file separately as
+ * single vInts.  Don't use this (performance will be poor)!
+ * This is here just to test the core sep codec
+ * classes.
+ */
+public class MockSepCodec extends Codec {
 
-  public SepCodec() {
-    name = "Sep";
+  public MockSepCodec() {
+    name = "MockSep";
   }
 
   @Override
   public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
 
-    StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new SingleIntFactory());
+    StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new MockSingleIntFactory());
 
     boolean success = false;
     StandardTermsIndexWriter indexWriter;
@@ -77,16 +84,10 @@ public class SepCodec extends Codec {
     }
   }
 
-  final static String DOC_EXTENSION = "doc";
-  final static String SKIP_EXTENSION = "skp";
-  final static String FREQ_EXTENSION = "frq";
-  final static String POS_EXTENSION = "pos";
-  final static String PAYLOAD_EXTENSION = "pyl";
-
   @Override
   public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
 
-    StandardPostingsReader postingsReader = new SepPostingsReaderImpl(state.dir, state.segmentInfo, state.readBufferSize, new SingleIntFactory());
+    StandardPostingsReader postingsReader = new SepPostingsReaderImpl(state.dir, state.segmentInfo, state.readBufferSize, new MockSingleIntFactory());
 
     StandardTermsIndexReader indexReader;
     boolean success = false;
@@ -139,11 +140,7 @@ public class SepCodec extends Codec {
   }
 
   public static void getSepExtensions(Set<String> extensions) {
-    extensions.add(DOC_EXTENSION);
-    extensions.add(FREQ_EXTENSION);
-    extensions.add(SKIP_EXTENSION);
-    extensions.add(POS_EXTENSION);
-    extensions.add(PAYLOAD_EXTENSION);
+    SepPostingsWriterImpl.getExtensions(extensions);
     StandardTermsDictReader.getExtensions(extensions);
     SimpleStandardTermsIndexReader.getIndexExtensions(extensions);
   }

Copied: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java (from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntFactory.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntFactory.java&r1=981930&r2=982287&rev=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntFactory.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java Wed Aug  4 15:04:26 2010
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.sep;
+package org.apache.lucene.index.codecs.mocksep;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,16 +18,20 @@ package org.apache.lucene.index.codecs.s
  */
 
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.index.codecs.sep.IntStreamFactory;
+import org.apache.lucene.index.codecs.sep.IntIndexInput;
+import org.apache.lucene.index.codecs.sep.IntIndexOutput;
+
 import java.io.IOException;
 
 /** @lucene.experimental */
-public class SingleIntFactory extends IntStreamFactory {
+public class MockSingleIntFactory extends IntStreamFactory {
   @Override
   public IntIndexInput openInput(Directory dir, String fileName, int readBufferSize) throws IOException {
-    return new SingleIntIndexInput(dir, fileName, readBufferSize);
+    return new MockSingleIntIndexInput(dir, fileName, readBufferSize);
   }
   @Override
   public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException {
-    return new SingleIntIndexOutput(dir, fileName);
+    return new MockSingleIntIndexOutput(dir, fileName);
   }
 }

Copied: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java (from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java&r1=981930&r2=982287&rev=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java Wed Aug  4 15:04:26 2010
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.sep;
+package org.apache.lucene.index.codecs.mocksep;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -22,6 +22,7 @@ import java.io.IOException;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.util.CodecUtil;
+import org.apache.lucene.index.codecs.sep.IntIndexInput;
 
 /** Reads IndexInputs written with {@link
  *  SingleIntIndexOutput}.  NOTE: this class is just for
@@ -30,14 +31,15 @@ import org.apache.lucene.util.CodecUtil;
  *
  * @lucene.experimental
  */
-public class SingleIntIndexInput extends IntIndexInput {
+public class MockSingleIntIndexInput extends IntIndexInput {
   private final IndexInput in;
 
-  public SingleIntIndexInput(Directory dir, String fileName, int readBufferSize)
+  public MockSingleIntIndexInput(Directory dir, String fileName, int readBufferSize)
     throws IOException {
     in = dir.openInput(fileName, readBufferSize);
-    CodecUtil.checkHeader(in, SingleIntIndexOutput.CODEC,
-      SingleIntIndexOutput.VERSION_START, SingleIntIndexOutput.VERSION_START);
+    CodecUtil.checkHeader(in, MockSingleIntIndexOutput.CODEC,
+                          MockSingleIntIndexOutput.VERSION_START,
+                          MockSingleIntIndexOutput.VERSION_START);
   }
 
   @Override

Copied: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java (from r981930, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexOutput.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java?p2=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexOutput.java&r1=981930&r2=982287&rev=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexOutput.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java Wed Aug  4 15:04:26 2010
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.sep;
+package org.apache.lucene.index.codecs.mocksep;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,7 +20,7 @@ package org.apache.lucene.index.codecs.s
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.CodecUtil;
-
+import org.apache.lucene.index.codecs.sep.IntIndexOutput;
 import java.io.IOException;
 
 /** Writes ints directly to the file (not in blocks) as
@@ -28,13 +28,13 @@ import java.io.IOException;
  * 
  * @lucene.experimental
 */
-public class SingleIntIndexOutput extends IntIndexOutput {
+public class MockSingleIntIndexOutput extends IntIndexOutput {
   private final IndexOutput out;
   final static String CODEC = "SINGLE_INTS";
   final static int VERSION_START = 0;
   final static int VERSION_CURRENT = VERSION_START;
 
-  public SingleIntIndexOutput(Directory dir, String fileName) throws IOException {
+  public MockSingleIntIndexOutput(Directory dir, String fileName) throws IOException {
     out = dir.createOutput(fileName);
     CodecUtil.writeHeader(out, CODEC, VERSION_CURRENT);
   }

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=982287&r1=982286&r2=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java Wed Aug  4 15:04:26 2010
@@ -36,8 +36,6 @@ import org.apache.lucene.search.BooleanQ
 import org.apache.lucene.search.FieldCache;
 import org.apache.lucene.search.FieldCache.CacheEntry;
 import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
-import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.Codec;
 
 /** 
  * Base class for all Lucene unit tests.  
@@ -85,9 +83,7 @@ public abstract class LuceneTestCase ext
   
   private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null;
   
-  private String savedDefaultCodec;
   private String codec;
-  private Codec preFlexSav;
 
   /** Used to track if setUp and tearDown are called correctly from subclasses */
   private boolean setup;
@@ -127,19 +123,7 @@ public abstract class LuceneTestCase ext
     
     ConcurrentMergeScheduler.setTestMode();
     savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount();
-    savedDefaultCodec = CodecProvider.getDefaultCodec();
-
-    codec = TEST_CODEC;
-    if (codec.equals("random"))
-      codec = CodecProvider.CORE_CODECS[seedRnd.nextInt(CodecProvider.CORE_CODECS.length)];
-
-    // If we're running w/ PreFlex codec we must swap in the
-    // test-only PreFlexRW codec (since core PreFlex can
-    // only read segments):
-    if (codec.equals("PreFlex")) {
-      preFlexSav = LuceneTestCaseJ4.installPreFlexRW();
-    } 
-    CodecProvider.setDefaultCodec(codec);
+    codec = LuceneTestCaseJ4.installTestCodecs();
   }
 
   /**
@@ -165,11 +149,7 @@ public abstract class LuceneTestCase ext
     assertTrue("ensure your setUp() calls super.setUp()!!!", setup);
     setup = false;
     BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
-    // Restore read-only PreFlex codec:
-    if (codec.equals("PreFlex")) {
-      LuceneTestCaseJ4.restorePreFlex(preFlexSav);
-    } 
-    CodecProvider.setDefaultCodec(savedDefaultCodec);
+    LuceneTestCaseJ4.removeTestCodecs(codec);
     
     try {
       Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler);

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java?rev=982287&r1=982286&r2=982287&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java Wed Aug  4 15:04:26 2010
@@ -30,6 +30,9 @@ import org.apache.lucene.util.FieldCache
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
+import org.apache.lucene.index.codecs.preflex.PreFlexCodec;
+import org.apache.lucene.index.codecs.mocksep.MockSepCodec;
+import org.apache.lucene.index.codecs.mockintblock.MockFixedIntBlockCodec;
 
 import org.junit.After;
 import org.junit.AfterClass;
@@ -152,51 +155,81 @@ public class LuceneTestCaseJ4 {
   // saves default codec: we do this statically as many build indexes in @beforeClass
   private static String savedDefaultCodec;
   private static String codec;
-  private static Codec preFlexSav;
   
-  // returns current PreFlex codec
-  public static Codec installPreFlexRW() {
-    final Codec preFlex = CodecProvider.getDefault().lookup("PreFlex");
-    if (preFlex != null) {
-      CodecProvider.getDefault().unregister(preFlex);
+  private static final String[] TEST_CODECS = new String[] {"MockSep", "MockFixedIntBlock"};
+
+  private static void swapCodec(Codec c) {
+    final CodecProvider cp = CodecProvider.getDefault();
+    Codec prior = null;
+    try {
+      prior = cp.lookup(c.name);
+    } catch (IllegalArgumentException iae) {
+    }
+    if (prior != null) {
+      cp.unregister(prior);
+    }
+    cp.register(c);
+  }
+
+  // returns current default codec
+  static String installTestCodecs() {
+    final CodecProvider cp = CodecProvider.getDefault();
+
+    savedDefaultCodec = CodecProvider.getDefaultCodec();
+    String codec = TEST_CODEC;
+    if (codec.equals("random")) {
+      codec = pickRandomCodec(seedRnd);
     }
-    CodecProvider.getDefault().register(new PreFlexRWCodec());
-    return preFlex;
+    CodecProvider.setDefaultCodec(codec);
+
+    if (codec.equals("PreFlex")) {
+      // If we're running w/ PreFlex codec we must swap in the
+      // test-only PreFlexRW codec (since core PreFlex can
+      // only read segments):
+      swapCodec(new PreFlexRWCodec());
+    }
+
+    swapCodec(new MockSepCodec());
+    swapCodec(new MockFixedIntBlockCodec());
+
+    return codec;
   }
 
   // returns current PreFlex codec
-  public static void restorePreFlex(Codec preFlex) {
-    Codec preFlexRW = CodecProvider.getDefault().lookup("PreFlex");
-    if (preFlexRW != null) {
-      CodecProvider.getDefault().unregister(preFlexRW);
+  static void removeTestCodecs(String codec) {
+    System.out.println("remove");
+    final CodecProvider cp = CodecProvider.getDefault();
+    if (codec.equals("PreFlex")) {
+      final Codec preFlex = cp.lookup("PreFlex");
+      if (preFlex != null) {
+        cp.unregister(preFlex);
+      }
+      cp.register(new PreFlexCodec());
+    }
+    cp.unregister(cp.lookup("MockSep"));
+    cp.unregister(cp.lookup("MockFixedIntBlock"));
+    CodecProvider.setDefaultCodec(savedDefaultCodec);
+  }
+
+  // randomly picks from core and test codecs
+  static String pickRandomCodec(Random rnd) {
+    int idx = rnd.nextInt(CodecProvider.CORE_CODECS.length + 
+                          TEST_CODECS.length);
+    if (idx < CodecProvider.CORE_CODECS.length) {
+      return CodecProvider.CORE_CODECS[idx];
+    } else {
+      return TEST_CODECS[idx - CodecProvider.CORE_CODECS.length];
     }
-    CodecProvider.getDefault().register(preFlex);
   }
 
   @BeforeClass
   public static void beforeClassLuceneTestCaseJ4() {
-    savedDefaultCodec = CodecProvider.getDefaultCodec();
-    codec = TEST_CODEC;
-    if (codec.equals("random"))
-      codec = CodecProvider.CORE_CODECS[seedRnd.nextInt(CodecProvider.CORE_CODECS.length)];
-
-    // If we're running w/ PreFlex codec we must swap in the
-    // test-only PreFlexRW codec (since core PreFlex can
-    // only read segments):
-    if (codec.equals("PreFlex")) {
-      preFlexSav = installPreFlexRW();
-    } 
-
-    CodecProvider.setDefaultCodec(codec);
+    codec = installTestCodecs();
   }
   
   @AfterClass
   public static void afterClassLuceneTestCaseJ4() {
-    // Restore read-only PreFlex codec:
-    if (codec.equals("PreFlex")) {
-      restorePreFlex(preFlexSav);
-    } 
-    CodecProvider.setDefaultCodec(savedDefaultCodec);
+    removeTestCodecs(codec);
   }
 
   // This is how we get control when errors occur.