diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpFileNameParserTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpFileNameParserTest.java index 8f87b7bb6e..1f31ad2c42 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpFileNameParserTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpFileNameParserTest.java @@ -17,7 +17,7 @@ package org.apache.commons.vfs2.provider.ftp; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import org.apache.commons.vfs2.FileName; import org.apache.commons.vfs2.provider.GenericFileName; @@ -34,7 +34,7 @@ public class FtpFileNameParserTest { public void testGenericFileName1() throws Exception { final String uri = "ftp://blanks:blanks@localhost/path/file_b%20lanks"; final FileName n = FtpFileNameParser.getInstance().parseUri(null, null, uri); - assertTrue(n instanceof GenericFileName); + assertInstanceOf(GenericFileName.class, n); final String genericUri = n.getURI(); assertEquals(genericUri, uri.toString()); } @@ -43,7 +43,7 @@ public void testGenericFileName1() throws Exception { public void testGenericFileName2() throws Exception { final String uri = "ftp://b%20lanks:b%20lanks@localhost/path/file"; final FileName n = FtpFileNameParser.getInstance().parseUri(null, null, uri); - assertTrue(n instanceof GenericFileName); + assertInstanceOf(GenericFileName.class, n); final String genericUri = n.getURI(); assertEquals(genericUri, uri.toString()); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/gzip/GzipTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/gzip/GzipTest.java index cc69d9a6fd..17b2a798c4 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/gzip/GzipTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/gzip/GzipTest.java @@ -39,9 +39,9 @@ public void testCreateGzipFileSystem() throws IOException { try (FileObject localFileObject = manager.resolveFile(gzFile.getAbsolutePath()); FileObject gzFileObjectDir = manager.createFileSystem(localFileObject); FileObject gzFileObject = gzFileObjectDir.resolveFile("好.txt")) { - Assertions.assertTrue(gzFileObjectDir instanceof GzipFileObject); + Assertions.assertInstanceOf(GzipFileObject.class, gzFileObjectDir); Assertions.assertTrue(gzFileObjectDir.isFolder()); - Assertions.assertTrue(gzFileObject instanceof GzipFileObject); + Assertions.assertInstanceOf(GzipFileObject.class, gzFileObject); Assertions.assertFalse(gzFileObject.isFolder()); try (FileContent content = gzFileObject.getContent()) { Assertions.assertEquals("aaa", content.getString(StandardCharsets.UTF_8)); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/tar/CreateFileSystemTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/tar/CreateFileSystemTest.java index 0083f27a01..ab489d9927 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/tar/CreateFileSystemTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/tar/CreateFileSystemTest.java @@ -16,7 +16,7 @@ */ package org.apache.commons.vfs2.provider.tar; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import java.io.File; import java.io.IOException; @@ -48,7 +48,7 @@ public void testTarFile() throws IOException { final String testFilePath = "src/test/resources/test-data/test.tar"; try (FileObject fileObject = createFileSystem(testFilePath)) { - assertTrue(fileObject instanceof TarFileObject); + assertInstanceOf(TarFileObject.class, fileObject); } } @@ -57,7 +57,7 @@ public void testTbz2File() throws IOException { final String testFilePath = "src/test/resources/test-data/test.tbz2"; try (FileObject fileObject = createFileSystem(testFilePath)) { - assertTrue(fileObject instanceof TarFileObject); + assertInstanceOf(TarFileObject.class, fileObject); } } @@ -66,7 +66,7 @@ public void testTgzFile() throws IOException { final String testFilePath = "src/test/resources/test-data/test.tgz"; try (FileObject fileObject = createFileSystem(testFilePath)) { - assertTrue(fileObject instanceof TarFileObject); + assertInstanceOf(TarFileObject.class, fileObject); } } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/Jira733Test.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/Jira733Test.java index f426ad33a4..7390c0836b 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/Jira733Test.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/Jira733Test.java @@ -16,6 +16,7 @@ */ package org.apache.commons.vfs2.provider.zip; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -58,7 +59,7 @@ private void testZipParentLayer(final VfsConsumer consumer) throws E final String nestedPath = "zip:" + file.getAbsolutePath() + "!/read-tests/file1.txt"; try (FileObject fileObject = VFS.getManager().resolveFile(nestedPath); final FileObject wrappedFileObject = new OnCallRefreshFileObject(fileObject)) { - assertTrue(fileObject instanceof ZipFileObject); + assertInstanceOf(ZipFileObject.class, fileObject); @SuppressWarnings({ "unused", "resource" }) final ZipFileObject zipFileObject = (ZipFileObject) fileObject; diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/ZipProviderWithCharsetNullTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/ZipProviderWithCharsetNullTestCase.java index e504d4090a..73d7aaee71 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/ZipProviderWithCharsetNullTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/ZipProviderWithCharsetNullTestCase.java @@ -58,7 +58,7 @@ public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exce final String uri = "zip:file:" + zipFile.getAbsolutePath() + "!/"; final FileObject resolvedFile = manager.resolveFile(uri, opts); final FileSystem fileSystem = resolvedFile.getFileSystem(); - Assertions.assertTrue(fileSystem instanceof ZipFileSystem); + Assertions.assertInstanceOf(ZipFileSystem.class, fileSystem); final ZipFileSystem zipFileSystem = (ZipFileSystem) fileSystem; Assertions.assertEquals(StandardCharsets.UTF_8, zipFileSystem.getCharset()); return resolvedFile; diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/ZipProviderWithCharsetTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/ZipProviderWithCharsetTestCase.java index 820c191313..71a7aa847e 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/ZipProviderWithCharsetTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/ZipProviderWithCharsetTestCase.java @@ -58,7 +58,7 @@ public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exce final String uri = "zip:file:" + zipFile.getAbsolutePath() + "!/"; final FileObject resolvedFile = manager.resolveFile(uri, opts); final FileSystem fileSystem = resolvedFile.getFileSystem(); - Assertions.assertTrue(fileSystem instanceof ZipFileSystem); + Assertions.assertInstanceOf(ZipFileSystem.class, fileSystem); final ZipFileSystem zipFileSystem = (ZipFileSystem) fileSystem; Assertions.assertEquals(StandardCharsets.UTF_8, zipFileSystem.getCharset()); return resolvedFile;