Index: src/test/org/apache/lucene/util/LuceneTestCaseJ4.java =================================================================== --- src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (revision 983417) +++ src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (working copy) @@ -57,6 +57,8 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.Collections; +import java.util.regex.Pattern; +import java.util.regex.Matcher; import java.lang.reflect.Method; import static org.junit.Assert.assertEquals; @@ -125,6 +127,8 @@ /** Gets the codec to run tests with. */ static final String TEST_CODEC = System.getProperty("tests.codec", "random"); + private static final Pattern codecWithParam = Pattern.compile("(.*)\\(\\s*(\\d+)\\s*\\)"); + /** * A random multiplier which you should use when writing random tests: * multiply it by the number of iterations @@ -179,9 +183,24 @@ savedDefaultCodec = CodecProvider.getDefaultCodec(); String codec = TEST_CODEC; + + final boolean codecHasParam; + int codecParam = 0; if (codec.equals("random")) { codec = pickRandomCodec(seedRnd); + codecHasParam = false; + } else { + Matcher m = codecWithParam.matcher(codec); + if (m.matches()) { + // codec has a fixed param + codecHasParam = true; + codec = m.group(1); + codecParam = Integer.parseInt(m.group(2)); + } else { + codecHasParam = false; + } } + CodecProvider.setDefaultCodec(codec); if (codec.equals("PreFlex")) { @@ -192,10 +211,10 @@ } swapCodec(new MockSepCodec()); - swapCodec(new PulsingCodec(_TestUtil.nextInt(seedRnd, 1, 20))); - swapCodec(new MockFixedIntBlockCodec(_TestUtil.nextInt(seedRnd, 1, 2000))); + swapCodec(new PulsingCodec(codecHasParam && "Pulsing".equals(codec) ? codecParam : _TestUtil.nextInt(seedRnd, 1, 20))); + swapCodec(new MockFixedIntBlockCodec(codecHasParam && "MockFixedIntBlock".equals(codec) ? codecParam : _TestUtil.nextInt(seedRnd, 1, 2000))); // baseBlockSize cannot be over 127: - swapCodec(new MockVariableIntBlockCodec(_TestUtil.nextInt(seedRnd, 1, 127))); + swapCodec(new MockVariableIntBlockCodec(codecHasParam && "MockVariableIntBlock".equals(codec) ? codecParam : _TestUtil.nextInt(seedRnd, 1, 127))); return cp.lookup(codec); }