Apache Lucene open-source search software
LUCENE-6989: Disable test if mmap unmapping is not working (otherwise will fail with later Java 9), until we committed real fix for LUCENE-6989; remove useless and broken test
Uwe Schindler19c56f208521
diff --git a/lucene/core/src/test/org/apache/lucene/store/TestMmapDirectory.java b/lucene/core/src/test/org/apache/lucene/store/TestMmapDirectory.javaindex 9962ad1965b..44e6de263d7 100644--- a/lucene/core/src/test/org/apache/lucene/store/TestMmapDirectory.java+++ b/lucene/core/src/test/org/apache/lucene/store/TestMmapDirectory.java@@ -31,4 +31,11 @@ public class TestMmapDirectory extends BaseDirectoryTestCase {m.setPreload(random().nextBoolean());return m;}++ @Override+ public void setUp() throws Exception {+ super.setUp();+ assumeTrue("test requires a jre that supports unmapping", MMapDirectory.UNMAP_SUPPORTED);+ }+}diff --git a/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java b/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.javadeleted file mode 100644index 09636e68150..00000000000--- a/lucene/core/src/test/org/apache/lucene/store/TestWindowsMMap.java+++ /dev/null@@ -1,91 +0,0 @@-/*- * 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.store;---import java.nio.file.Path;--import org.apache.lucene.document.Field;-import org.apache.lucene.util.LuceneTestCase;--import org.apache.lucene.analysis.MockAnalyzer;-import org.apache.lucene.document.Document;-import org.apache.lucene.index.DirectoryReader;-import org.apache.lucene.index.IndexReader;-import org.apache.lucene.index.IndexWriter;-import org.apache.lucene.index.IndexWriterConfig;-import org.apache.lucene.index.IndexWriterConfig.OpenMode;-import org.apache.lucene.search.IndexSearcher;--public class TestWindowsMMap extends LuceneTestCase {-- private final static String alphabet = "abcdefghijklmnopqrstuvwzyz";-- @Override- public void setUp() throws Exception {- super.setUp();- }-- private String randomToken() {- int tl = 1 + random().nextInt(7);- StringBuilder sb = new StringBuilder();- for(int cx = 0; cx < tl; cx ++) {- int c = random().nextInt(25);- sb.append(alphabet.substring(c, c+1));- }- return sb.toString();- }-- private String randomField() {- int fl = 1 + random().nextInt(3);- StringBuilder fb = new StringBuilder();- for(int fx = 0; fx < fl; fx ++) {- fb.append(randomToken());- fb.append(" ");- }- return fb.toString();- }-- public void testMmapIndex() throws Exception {- // sometimes the directory is not cleaned by rmDir, because on Windows it- // may take some time until the files are finally dereferenced. So clean the- // directory up front, or otherwise new IndexWriter will fail.- Path dirPath = createTempDir("testLuceneMmap");- MMapDirectory dir = new MMapDirectory(dirPath);-- // plan to add a set of useful stopwords, consider changing some of the- // interior filters.- MockAnalyzer analyzer = new MockAnalyzer(random());- // TODO: something about lock timeouts and leftover locks.- IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(analyzer)- .setOpenMode(OpenMode.CREATE));- writer.commit();- IndexReader reader = DirectoryReader.open(dir);- IndexSearcher searcher = newSearcher(reader);-- int num = atLeast(1000);- for(int dx = 0; dx < num; dx ++) {- String f = randomField();- Document doc = new Document();- doc.add(newTextField("data", f, Field.Store.YES));- writer.addDocument(doc);- }-- reader.close();- writer.close();- }-}