From fec2c7982adf3e7758246918e379a7210027235a Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 21 Jan 2013 19:18:26 +0000 Subject: [PATCH] enable impersonator git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1436563 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/util/TestRuleSetupAndRestoreClassEnv.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java index 84a8ff0dc81..5674b2fbac0 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java @@ -34,6 +34,7 @@ import org.apache.lucene.codecs.compressing.CompressingCodec; import org.apache.lucene.codecs.lucene40.Lucene40Codec; import org.apache.lucene.codecs.lucene40.Lucene40RWPostingsFormat; import org.apache.lucene.codecs.lucene41.Lucene41Codec; +import org.apache.lucene.codecs.lucene41.Lucene41RWCodec; import org.apache.lucene.codecs.lucene42.Lucene42Codec; import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat; import org.apache.lucene.codecs.simpletext.SimpleTextCodec; @@ -134,13 +135,18 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule { savedCodec = Codec.getDefault(); int randomVal = random.nextInt(10); - // nocommit: add 41 impersonation if ("Lucene40".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && "random".equals(TEST_POSTINGSFORMAT) && - randomVal < 2 && + randomVal == 0 && !shouldAvoidCodec("Lucene40"))) { codec = Codec.forName("Lucene40"); assert (PostingsFormat.forName("Lucene40") instanceof Lucene40RWPostingsFormat) : "fix your classpath to have tests-framework.jar before lucene-core.jar"; + } else if ("Lucene41".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && + "random".equals(TEST_POSTINGSFORMAT) && + randomVal == 1 && + !shouldAvoidCodec("Lucene41"))) { + codec = Codec.forName("Lucene41"); + assert codec instanceof Lucene41RWCodec : "fix your classpath to have tests-framework.jar before lucene-core.jar"; } else if (!"random".equals(TEST_POSTINGSFORMAT)) { final PostingsFormat format; if ("MockRandom".equals(TEST_POSTINGSFORMAT)) {