Skip to content

Commit

Permalink
Use Assertions.assertInstanceOf()
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Sep 1, 2024
1 parent e3d80bc commit da7a876
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -58,7 +59,7 @@ private void testZipParentLayer(final VfsConsumer<FileObject> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit da7a876

Please sign in to comment.