davisusanibar commented on code in PR #34312:
URL: https://github.com/apache/arrow/pull/34312#discussion_r1150857387


##########
java/dataset/src/test/java/org/apache/arrow/dataset/file/TestFileSystemDataset.java:
##########
@@ -386,6 +388,27 @@ public void testBaseCsvRead() throws Exception {
     }
   }
 
+  @Test
+  public void testResourceToLoad() throws IOException {
+    if (System.getProperty("os.name").equalsIgnoreCase("Windows")) {
+      assertEquals("\\", File.separator);
+      final String pathWithoutFileSeparator = "/" + "avroschema" + "/" + 
"user.avsc";
+      try (final InputStream stream = 
TestFileSystemDataset.class.getResourceAsStream(pathWithoutFileSeparator)) {
+        if (stream == null) {
+          throw new FileNotFoundException(pathWithoutFileSeparator);
+        }
+      }
+      final String pathWithFileSeparator = File.separator + "avroschema" + 
File.separator + "user.avsc";
+      Assertions.assertThrows(FileNotFoundException.class, () -> {
+        try (final InputStream stream = 
TestFileSystemDataset.class.getResourceAsStream(pathWithFileSeparator)) {
+          if (stream == null) {
+            throw new FileNotFoundException(pathWithFileSeparator);
+          }
+        }
+      }, "FileNotFound \\avroschema\\user.avsc");
+    }
+  }
+

Review Comment:
   `File.separator` cause the problem on Windows OS by 
[ClassLoader](https://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html#getResource-java.lang.String-:~:text=The%20name%20of%20a%20resource%20is%20a%20%27/%27%2Dseparated%20path%20name%20that%20identifies%20the%20resource.)
 java docs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to