reswqa commented on code in PR #20011:
URL: https://github.com/apache/flink/pull/20011#discussion_r901130871
##########
flink-core/src/test/java/org/apache/flink/core/fs/FileSystemTest.java:
##########
@@ -65,58 +61,63 @@ public void testGet() throws URISyntaxException,
IOException {
}
@Test
- public void testUnsupportedFS() throws Exception {
- Exception e = assertThatCode(() ->
getFileSystemWithoutSafetyNet("unknownfs://authority/"));
- assertThat(e,
Matchers.instanceOf(UnsupportedFileSystemSchemeException.class));
+ public void testUnsupportedFS() {
Review Comment:
```suggestion
void testUnsupportedFS() {
```
##########
flink-core/src/test/java/org/apache/flink/core/fs/FileSystemTest.java:
##########
@@ -65,58 +61,63 @@ public void testGet() throws URISyntaxException,
IOException {
}
@Test
- public void testUnsupportedFS() throws Exception {
- Exception e = assertThatCode(() ->
getFileSystemWithoutSafetyNet("unknownfs://authority/"));
- assertThat(e,
Matchers.instanceOf(UnsupportedFileSystemSchemeException.class));
+ public void testUnsupportedFS() {
+ Exception e =
+ assertThrows(
+ UnsupportedFileSystemSchemeException.class,
+ () ->
getFileSystemWithoutSafetyNet("unknownfs://authority/"));
+ /*
+ exception should be:
+ org.apache.flink.core.fs.UnsupportedFileSystemSchemeException: Could
not find a file system implementation
+ for scheme 'unknownfs'. The scheme is not directly supported by Flink
and no Hadoop file system to support this
+ scheme could be loaded. */
+ assertTrue(e.getMessage().contains("not directly supported"));
+ assertTrue(e.getMessage().contains("no Hadoop file system to support
this scheme"));
}
@Test
- public void testKnownFSWithoutPlugins() throws Exception {
- Exception e = assertThatCode(() ->
getFileSystemWithoutSafetyNet("s3://authority/"));
- assertThat(e,
Matchers.instanceOf(UnsupportedFileSystemSchemeException.class));
+ public void testKnownFSWithoutPlugins() {
+ Exception e =
+ assertThrows(
+ UnsupportedFileSystemSchemeException.class,
+ () ->
getFileSystemWithoutSafetyNet("s3://authority/"));
/*
- exception should be:
- org.apache.flink.core.fs.UnsupportedFileSystemSchemeException: Could
not find a file
+ exception should be:
+ org.apache.flink.core.fs.UnsupportedFileSystemSchemeException: Could
not find a file
system implementation for scheme 's3'. The scheme is directly
supported by Flink through the following
plugins: flink-s3-fs-hadoop, flink-s3-fs-presto. Please ensure that
each plugin resides within its own
subfolder within the plugins directory. See https://ci.apache
.org/projects/flink/flink-docs-master/ops/plugins.html for more
information. */
- assertThat(e.getMessage(), not(containsString("not directly
supported")));
- assertThat(e.getMessage(), containsString("flink-s3-fs-hadoop"));
- assertThat(e.getMessage(), containsString("flink-s3-fs-presto"));
+ assertTrue(e.getMessage().contains("is directly supported"));
+ assertTrue(e.getMessage().contains("flink-s3-fs-hadoop"));
+ assertTrue(e.getMessage().contains("flink-s3-fs-presto"));
+ assertFalse(e.getMessage().contains("no Hadoop file system to support
this scheme"));
}
@Test
- public void testKnownFSWithoutPluginsAndException() throws Exception {
+ public void testKnownFSWithoutPluginsAndException() {
Review Comment:
```suggestion
void testKnownFSWithoutPluginsAndException() {
```
##########
flink-core/src/test/java/org/apache/flink/core/fs/FileSystemTest.java:
##########
@@ -65,58 +61,63 @@ public void testGet() throws URISyntaxException,
IOException {
}
@Test
- public void testUnsupportedFS() throws Exception {
- Exception e = assertThatCode(() ->
getFileSystemWithoutSafetyNet("unknownfs://authority/"));
- assertThat(e,
Matchers.instanceOf(UnsupportedFileSystemSchemeException.class));
+ public void testUnsupportedFS() {
+ Exception e =
+ assertThrows(
+ UnsupportedFileSystemSchemeException.class,
+ () ->
getFileSystemWithoutSafetyNet("unknownfs://authority/"));
+ /*
+ exception should be:
+ org.apache.flink.core.fs.UnsupportedFileSystemSchemeException: Could
not find a file system implementation
+ for scheme 'unknownfs'. The scheme is not directly supported by Flink
and no Hadoop file system to support this
+ scheme could be loaded. */
+ assertTrue(e.getMessage().contains("not directly supported"));
+ assertTrue(e.getMessage().contains("no Hadoop file system to support
this scheme"));
}
@Test
- public void testKnownFSWithoutPlugins() throws Exception {
- Exception e = assertThatCode(() ->
getFileSystemWithoutSafetyNet("s3://authority/"));
- assertThat(e,
Matchers.instanceOf(UnsupportedFileSystemSchemeException.class));
+ public void testKnownFSWithoutPlugins() {
+ Exception e =
+ assertThrows(
Review Comment:
```suggestion
Assertions.assertThatThrownBy(() ->
getFileSystemWithoutSafetyNet("s3://authority/")).isInstanceOf(UnsupportedFileSystemSchemeException.class)
```
##########
flink-core/src/test/java/org/apache/flink/core/fs/FileSystemTest.java:
##########
@@ -23,20 +23,16 @@
import org.apache.flink.core.fs.local.LocalFileSystem;
import org.apache.flink.util.WrappingProxy;
import org.apache.flink.util.WrappingProxyUtil;
-import org.apache.flink.util.function.ThrowingRunnable;
-import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/** Tests for the {@link FileSystem} base class. */
public class FileSystemTest {
Review Comment:
```suggestion
class FileSystemTest {
```
##########
flink-core/src/test/java/org/apache/flink/core/fs/FileSystemTest.java:
##########
@@ -65,58 +61,63 @@ public void testGet() throws URISyntaxException,
IOException {
}
@Test
- public void testUnsupportedFS() throws Exception {
- Exception e = assertThatCode(() ->
getFileSystemWithoutSafetyNet("unknownfs://authority/"));
- assertThat(e,
Matchers.instanceOf(UnsupportedFileSystemSchemeException.class));
+ public void testUnsupportedFS() {
+ Exception e =
+ assertThrows(
+ UnsupportedFileSystemSchemeException.class,
+ () ->
getFileSystemWithoutSafetyNet("unknownfs://authority/"));
+ /*
+ exception should be:
+ org.apache.flink.core.fs.UnsupportedFileSystemSchemeException: Could
not find a file system implementation
+ for scheme 'unknownfs'. The scheme is not directly supported by Flink
and no Hadoop file system to support this
+ scheme could be loaded. */
+ assertTrue(e.getMessage().contains("not directly supported"));
+ assertTrue(e.getMessage().contains("no Hadoop file system to support
this scheme"));
}
@Test
- public void testKnownFSWithoutPlugins() throws Exception {
- Exception e = assertThatCode(() ->
getFileSystemWithoutSafetyNet("s3://authority/"));
- assertThat(e,
Matchers.instanceOf(UnsupportedFileSystemSchemeException.class));
+ public void testKnownFSWithoutPlugins() {
Review Comment:
```suggestion
void testKnownFSWithoutPlugins() {
```
--
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]