Apache Lucene open-source search software
if -Dtests.postingsformat is specified, don't use Lucene3x codec
Michael McCandless2dee011e5853
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.javaindex 027aa681f52..1860ffbe56e 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@@ -1,5 +1,22 @@package org.apache.lucene.util;+/**+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+import java.util.Arrays;import java.util.Date;import java.util.HashMap;@@ -23,28 +40,8 @@ import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;import com.carrotsearch.randomizedtesting.RandomizedContext;import static org.apache.lucene.util.LuceneTestCase.*;-import static org.apache.lucene.util.LuceneTestCase.INFOSTREAM;-import static org.apache.lucene.util.LuceneTestCase.TEST_CODEC;-import static org.apache.lucene.util.LuceneTestCase.VERBOSE;--/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- *//*** Setup and restore suite-level environment (fine grained junk that@@ -89,9 +86,9 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {final Object spiLoader = spiLoaderField.get(null);final java.lang.reflect.Field modifiableServicesField = NamedSPILoader.class.getDeclaredField("modifiableServices");modifiableServicesField.setAccessible(true);+ /* note: re-enable this if we make a Lucene4x impersonator@SuppressWarnings({"unchecked","rawtypes"}) final Map<String,Codec> serviceMap =(Map) modifiableServicesField.get(spiLoader);- /* note: re-enable this if we make a Lucene4x impersonatorif (!(Codec.forName("Lucene3x") instanceof PreFlexRWCodec)) {if (Constants.JAVA_VENDOR.startsWith("IBM")) {// definitely a buggy version@@ -157,7 +154,10 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {savedCodec = Codec.getDefault();int randomVal = random.nextInt(10);/* note: re-enable this if we make a 4.x impersonator- * if ("Lucene3x".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal < 2 && !shouldAvoidCodec("Lucene3x"))) { // preflex-only setup+ if ("Lucene3x".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) &&+ "random".equals(TEST_POSTINGSFORMAT) &&+ randomVal < 2 &&+ !shouldAvoidCodec("Lucene3x"))) { // preflex-only setupcodec = Codec.forName("Lucene3x");assert (codec instanceof PreFlexRWCodec) : "fix your classpath to have tests-framework.jar before lucene-core.jar";PREFLEX_IMPERSONATION_IS_ACTIVE = true;