Apache Lucene open-source search software
LUCENE-10054: Make sure to use Lucene90 codec in unit tests (#699)
Julie Tibshirani4364bdd63ef5
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene90/Lucene90Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene90/Lucene90Codec.javaindex 40ba06606bd..f10e35cf9ce 100644--- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene90/Lucene90Codec.java+++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene90/Lucene90Codec.java@@ -164,7 +164,7 @@ public class Lucene90Codec extends Codec {}@Override- public final KnnVectorsFormat knnVectorsFormat() {+ public KnnVectorsFormat knnVectorsFormat() {return knnVectorsFormat;}diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene90/Lucene90RWCodec.java b/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene90/Lucene90RWCodec.javanew file mode 100644index 00000000000..b7c30361d2e--- /dev/null+++ b/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene90/Lucene90RWCodec.java@@ -0,0 +1,44 @@+/*+ * 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.+ */+package org.apache.lucene.backward_codecs.lucene90;++import org.apache.lucene.codecs.KnnVectorsFormat;+import org.apache.lucene.codecs.perfield.PerFieldKnnVectorsFormat;++public class Lucene90RWCodec extends Lucene90Codec {++ private final KnnVectorsFormat defaultKnnVectorsFormat;+ private final KnnVectorsFormat knnVectorsFormat =+ new PerFieldKnnVectorsFormat() {+ @Override+ public KnnVectorsFormat getKnnVectorsFormatForField(String field) {+ return defaultKnnVectorsFormat;+ }+ };++ public Lucene90RWCodec() {+ this.defaultKnnVectorsFormat =+ new Lucene90RWHnswVectorsFormat(+ Lucene90HnswVectorsFormat.DEFAULT_MAX_CONN,+ Lucene90HnswVectorsFormat.DEFAULT_BEAM_WIDTH);+ }++ @Override+ public KnnVectorsFormat knnVectorsFormat() {+ return knnVectorsFormat;+ }+}diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene90/TestLucene90HnswVectorsFormat.java b/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene90/TestLucene90HnswVectorsFormat.javaindex 8fe6dc24624..49ebbde7595 100644--- a/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene90/TestLucene90HnswVectorsFormat.java+++ b/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene90/TestLucene90HnswVectorsFormat.java@@ -23,12 +23,11 @@ import static org.apache.lucene.backward_codecs.lucene90.Lucene90HnswVectorsFormimport org.apache.lucene.codecs.Codec;import org.apache.lucene.codecs.KnnVectorsFormat;import org.apache.lucene.tests.index.BaseKnnVectorsFormatTestCase;-import org.apache.lucene.tests.util.TestUtil;public class TestLucene90HnswVectorsFormat extends BaseKnnVectorsFormatTestCase {@Overrideprotected Codec getCodec() {- return TestUtil.getDefaultCodec();+ return new Lucene90RWCodec();}public void testToString() {