Apache Lucene open-source search software
LUCENE-4449: commit current state to calm jenkins
Robert Muir57c572dc8646
diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/appending/TestAppendingPostingsFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/appending/TestAppendingPostingsFormat.javanew file mode 100644index 00000000000..904e2ee1ea5--- /dev/null+++ b/lucene/codecs/src/test/org/apache/lucene/codecs/appending/TestAppendingPostingsFormat.java@@ -0,0 +1,34 @@+package org.apache.lucene.codecs.appending;++/*+ * 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 org.apache.lucene.codecs.Codec;+import org.apache.lucene.codecs.lucene40.Lucene40Codec;+import org.apache.lucene.index.BasePostingsFormatTestCase;++/**+ * Tests AppendingPostingsFormat+ */+public class TestAppendingPostingsFormat extends BasePostingsFormatTestCase {+ private final Codec codec = new AppendingCodec();++ @Override+ protected Codec getCodec() {+ return codec;+ }+}diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/block/TestBlockPostingsFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/block/TestBlockPostingsFormat.javanew file mode 100644index 00000000000..46f7c07a377--- /dev/null+++ b/lucene/codecs/src/test/org/apache/lucene/codecs/block/TestBlockPostingsFormat.java@@ -0,0 +1,43 @@+package org.apache.lucene.codecs.block;++/*+ * 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 org.apache.lucene.codecs.Codec;+import org.apache.lucene.codecs.PostingsFormat;+import org.apache.lucene.codecs.appending.AppendingCodec;+import org.apache.lucene.codecs.block.BlockPostingsFormat;+import org.apache.lucene.codecs.lucene40.Lucene40Codec;+import org.apache.lucene.index.BasePostingsFormatTestCase;++/**+ * Tests BlockPostingsFormat+ */+public class TestBlockPostingsFormat extends BasePostingsFormatTestCase {+ private final PostingsFormat postings = new BlockPostingsFormat();+ private final Codec codec = new Lucene40Codec() {+ @Override+ public PostingsFormat getPostingsFormatForField(String field) {+ return postings;+ }+ };++ @Override+ protected Codec getCodec() {+ return codec;+ }+}diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/blockterms/TestFixedGapPostingsFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/blockterms/TestFixedGapPostingsFormat.javanew file mode 100644index 00000000000..d45b6828d1a--- /dev/null+++ b/lucene/codecs/src/test/org/apache/lucene/codecs/blockterms/TestFixedGapPostingsFormat.java@@ -0,0 +1,44 @@+package org.apache.lucene.codecs.blockterms;++/*+ * 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 org.apache.lucene.codecs.Codec;+import org.apache.lucene.codecs.PostingsFormat;+import org.apache.lucene.codecs.lucene40.Lucene40Codec;+import org.apache.lucene.codecs.lucene40ords.Lucene40WithOrds;+import org.apache.lucene.index.BasePostingsFormatTestCase;++/**+ * Basic tests of a PF using FixedGap terms dictionary+ */+// TODO: we should add an instantiation for VarGap too to TestFramework, and a test in this package+// TODO: ensure both of these are also in rotation in RandomCodec+public class TestFixedGapPostingsFormat extends BasePostingsFormatTestCase {+ private final PostingsFormat postings = new Lucene40WithOrds();+ private final Codec codec = new Lucene40Codec() {+ @Override+ public PostingsFormat getPostingsFormatForField(String field) {+ return postings;+ }+ };++ @Override+ protected Codec getCodec() {+ return codec;+ }+}diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/bloom/TestBloomPostingsFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/bloom/TestBloomPostingsFormat.javanew file mode 100644index 00000000000..3bd9a90935c--- /dev/null+++ b/lucene/codecs/src/test/org/apache/lucene/codecs/bloom/TestBloomPostingsFormat.java@@ -0,0 +1,41 @@+package org.apache.lucene.codecs.bloom;++/*+ * 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 org.apache.lucene.codecs.Codec;+import org.apache.lucene.codecs.PostingsFormat;+import org.apache.lucene.codecs.lucene40.Lucene40Codec;+import org.apache.lucene.index.BasePostingsFormatTestCase;++/**+ * Basic tests for BloomPostingsFormat+ */+public class TestBloomPostingsFormat extends BasePostingsFormatTestCase {+ private final PostingsFormat postings = new TestBloomFilteredLucene40Postings();+ private final Codec codec = new Lucene40Codec() {+ @Override+ public PostingsFormat getPostingsFormatForField(String field) {+ return postings;+ }+ };++ @Override+ protected Codec getCodec() {+ return codec;+ }+}diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/intblock/TestFixedIntBlockPostingsFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/intblock/TestFixedIntBlockPostingsFormat.javanew file mode 100644index 00000000000..e6338a0a674--- /dev/null+++ b/lucene/codecs/src/test/org/apache/lucene/codecs/intblock/TestFixedIntBlockPostingsFormat.java@@ -0,0 +1,43 @@+package org.apache.lucene.codecs.intblock;++/*+ * 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 org.apache.lucene.codecs.Codec;+import org.apache.lucene.codecs.PostingsFormat;+import org.apache.lucene.codecs.lucene40.Lucene40Codec;+import org.apache.lucene.codecs.mockintblock.MockFixedIntBlockPostingsFormat;+import org.apache.lucene.index.BasePostingsFormatTestCase;++/**+ * Basic tests for FixedIntBlock+ */+public class TestFixedIntBlockPostingsFormat extends BasePostingsFormatTestCase {+ // TODO: randomize blocksize+ private final PostingsFormat postings = new MockFixedIntBlockPostingsFormat();+ private final Codec codec = new Lucene40Codec() {+ @Override+ public PostingsFormat getPostingsFormatForField(String field) {+ return postings;+ }+ };++ @Override+ protected Codec getCodec() {+ return codec;+ }+}diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/intblock/TestVariableIntBlockPostingsFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/intblock/TestVariableIntBlockPostingsFormat.javanew file mode 100644index 00000000000..c7955acc9f5--- /dev/null+++ b/lucene/codecs/src/test/org/apache/lucene/codecs/intblock/TestVariableIntBlockPostingsFormat.java@@ -0,0 +1,43 @@+package org.apache.lucene.codecs.intblock;++/*+ * 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 org.apache.lucene.codecs.Codec;+import org.apache.lucene.codecs.PostingsFormat;+import org.apache.lucene.codecs.lucene40.Lucene40Codec;+import org.apache.lucene.codecs.mockintblock.MockVariableIntBlockPostingsFormat;+import org.apache.lucene.index.BasePostingsFormatTestCase;++/**+ * Basic tests for VariableIntBlock+ */+public class TestVariableIntBlockPostingsFormat extends BasePostingsFormatTestCase {+ // TODO: randomize blocksize+ private final PostingsFormat postings = new MockVariableIntBlockPostingsFormat();+ private final Codec codec = new Lucene40Codec() {+ @Override+ public PostingsFormat getPostingsFormatForField(String field) {+ return postings;+ }+ };++ @Override+ protected Codec getCodec() {+ return codec;+ }+}diff --git a/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat.java b/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat.javanew file mode 100644index 00000000000..01ae3c24a0b--- /dev/null+++ b/lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldPostingsFormat.java@@ -0,0 +1,43 @@+package org.apache.lucene.codecs.perfield;++/*+ * 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.Collections;+import java.util.Random;++import org.apache.lucene.codecs.Codec;+import org.apache.lucene.index.BasePostingsFormatTestCase;+import org.apache.lucene.index.RandomCodec;++/**+ * Basic tests of PerFieldPostingsFormat+ */+public class TestPerFieldPostingsFormat extends BasePostingsFormatTestCase {+ private Codec codec;++ @Override+ public void setUp() throws Exception {+ super.setUp();+ codec = new RandomCodec(new Random(random().nextLong()), Collections.EMPTY_SET);+ }++ @Override+ protected Codec getCodec() {+ return codec;+ }+}diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.javaindex 4d0c25ae2e4..dcd1dbea4a6 100644--- a/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java@@ -135,10 +135,10 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase {}// Holds all postings:- private static Map<String,Map<BytesRef,List<Posting>>> fields = new TreeMap<String,Map<BytesRef,List<Posting>>>();+ private static Map<String,Map<BytesRef,List<Posting>>> fields;// Holds only live doc postings:- private static Map<String,Map<BytesRef,List<Posting>>> fieldsLive = new TreeMap<String,Map<BytesRef,List<Posting>>>();+ private static Map<String,Map<BytesRef,List<Posting>>> fieldsLive;private static FieldInfos fieldInfos;@@ -153,6 +153,8 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase {@BeforeClasspublic static void createPostings() throws IOException {+ fields = new TreeMap<String,Map<BytesRef,List<Posting>>>();+ fieldsLive = new TreeMap<String,Map<BytesRef,List<Posting>>>();final int numFields = _TestUtil.nextInt(random(), 1, 5);if (VERBOSE) {@@ -368,7 +370,7 @@ public abstract class BasePostingsFormatTestCase extends LuceneTestCase {for(int fieldUpto=0;fieldUpto<fields.size();fieldUpto++) {FieldInfo oldFieldInfo = fieldInfos.fieldInfo(fieldUpto);- String pf = _TestUtil.getPostingsFormat(oldFieldInfo.name);+ String pf = _TestUtil.getPostingsFormat(codec, oldFieldInfo.name);int fieldMaxIndexOption;if (doesntSupportOffsets.contains(pf)) {fieldMaxIndexOption = Math.min(maxIndexOptionNoOffsets, maxIndexOption);diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.javaindex a5d105b497e..b7051d539c2 100644--- a/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java+++ b/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java@@ -662,7 +662,11 @@ public class _TestUtil {// TODO: generalize all 'test-checks-for-crazy-codecs' to// annotations (LUCENE-3489)public static String getPostingsFormat(String field) {- PostingsFormat p = Codec.getDefault().postingsFormat();+ return getPostingsFormat(Codec.getDefault(), field);+ }++ public static String getPostingsFormat(Codec codec, String field) {+ PostingsFormat p = codec.postingsFormat();if (p instanceof PerFieldPostingsFormat) {return ((PerFieldPostingsFormat)p).getPostingsFormatForField(field).getName();} else {