Apache Lucene open-source search software
LUCENE-6563: Improve MockFileSystemTestCase.testURI to check if a path can be encoded according to local filesystem requirements. Otherwise stop test execution
Uwe Schindler1f2b51cd964d
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 4313d40bd05..ee826eab756 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -335,6 +335,10 @@ Test Framework* LUCENE-6652: Removed lots of useless Byte(s)TermAttributes all over testinfrastructure. (Uwe Schindler)+* LUCENE-6563: Improve MockFileSystemTestCase.testURI to check if a path+ can be encoded according to local filesystem requirements. Otherwise+ stop test execution. (Christine Poerschke via Uwe Schindler)+Changes in Backwards Compatibility Policy* LUCENE-6553: The iterator returned by the LeafReader.postings method nowdiff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/MockFileSystemTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/MockFileSystemTestCase.javaindex 875b378a56c..f5bb022a7a3 100644--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/MockFileSystemTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/MockFileSystemTestCase.java@@ -23,6 +23,7 @@ import java.net.URI;import java.nio.charset.Charset;import java.nio.file.DirectoryStream;import java.nio.file.Files;+import java.nio.file.InvalidPathException;import java.nio.file.Path;import org.apache.lucene.util.Constants;@@ -58,20 +59,32 @@ public abstract class MockFileSystemTestCase extends LuceneTestCase {/** Test that URIs are not corrumpted */public void testURI() throws IOException {+ implTestURI("file1"); // plain ASCII+ }++ public void testURIumlaute() throws IOException {+ implTestURI("äÄöÖüÜß"); // Umlaute and s-zet+ }++ public void testURIchinese() throws IOException {+ implTestURI("中国"); // chinese+ }++ private void implTestURI(String fileName) throws IOException {assumeFalse("broken on J9: see https://issues.apache.org/jira/browse/LUCENE-6517", Constants.JAVA_VENDOR.startsWith("IBM"));Path dir = wrap(createTempDir());- Path f1 = dir.resolve("file1");+ try {+ dir.resolve(fileName);+ } catch (InvalidPathException ipe) {+ assumeNoException("couldn't resolve '"+fileName+"'", ipe);+ }++ Path f1 = dir.resolve(fileName);URI uri = f1.toUri();Path f2 = dir.getFileSystem().provider().getPath(uri);assertEquals(f1, f2);-- assumeTrue(Charset.defaultCharset().name() + " can't encode chinese",- Charset.defaultCharset().newEncoder().canEncode("中国"));- Path f3 = dir.resolve("中国");- URI uri2 = f3.toUri();- Path f4 = dir.getFileSystem().provider().getPath(uri2);- assertEquals(f3, f4);+dir.getFileSystem().close();}