Skip to content
Permalink
Browse files
JUnitj v5 more progression (#243)
* JUnit v5 format tests

* JUnit v5 AndFileFilterTest

* JUnit v5 AbstractFileNameTest

* JUnit v5 AbstractFtpsProviderTestCase

* JUnit v5 BasicOperationsTest

* JUnit v5 Bzip2TestCase

* JUnit v5 CanExecuteFileFilterTest

* JUnit v5 CreateFileSystemTest

* JUnit v5 ConversionTest

* JUnit v5 DefaultFileSystemManagerTest

* JUnit v5 DefaultFileContentTest

* JUnit v5 DefaultFileMonitorTest

* JUnit v5 EncryptDecryptTest

* JUnit v5 FileChangeEventTest static imports

(cherry picked from commit 19bd187d6b5a099e2c46862f0bd60f0cab983437)

* JUnit v5 FileExtensionSelectorTest static imports

(cherry picked from commit 8bd6e0b5560d1ec19fa74244a8fbcff321727f8f)

* JUnit v5 FileIteratorTest

* JUnit v5 FileLockTest

* JUnit v5 FileObjectSortTest

* JUnit v5 FileObjectUtilsTest

* JUnit v5 FileSystemOptionsTest

* JUnit v5 FileTypeSelectorTest

* JUnit v5 FileTypeTest

* JUnit v5 FileNameTests

* JUnit v5 FileObjectEscapeCharacterInPathTest

* JUnit v5 FileSystemExceptionTest

* JUnit v5 FtpFileNameParserTest

* JUnit v5 FtpFileSystemConfigBuilderTest

* JUnit v5 FtpMdtmOnRefreshLastModifiedTests

* JUnit v5 FtpProviderTestCase

* JUnit v5 FileLockTest

* JUnit v5 FileTypeTest

* JUnit v5 GetContentInfoFunctionalTest

* JUnit v5 HttpGetContentInfoFunctionalTest

* JUnit v5 HttpsGetContentInfoFunctionalTest

* JUnit v5 HdfsFileProviderTest

* JUnit v5 Http4FilesCacheTest

* JUnit v5 Http4GetContentInfoTest

* JUnit v5 Http4ProviderTestCase

* JUnit v5 Http4sGetContentInfoTest

* JUnit v5 Http5FilesCacheTest

* JUnit v5 Http5GetContentInfoTest

* JUnit v5 Http5ProviderTestCase

* JUnit v5 Http5sGetContentInfoTest

* JUnit v5 HttpFilesCacheTest

* JUnit v5 HttpProviderTestCase

* JUnit v5 InvertIncludeFileSelectorTest

* JUnit v5 JarAttributesTest

* JUnit v5 Jira733Test

* JUnit v5 LocalFileRandomAccessContentTest

* JUnit v5 LastModifiedTests

* JUnit v5 LRUFilesCacheTests

* JUnit v5 LargeTarTest

* JUnit v5 NameFileFilterTest

* JUnit v5 NotFileFilterTest

* JUnit v5 NullFilesCacheTests

* JUnit v5 NamingTests

* JUnit v5 NHttpFileServer

* JUnit v5 OrFileFilterTest

* JUnit v5 PrefixFileFilterTest

* JUnit v5 ParseXmlInZipTest

* JUnit v5 PatternFileSelectorTest

* JUnit v5 PermissionsTests

* JUnit v5 ProviderRandomSetLengthTests

* JUnit v5 ProviderReadTests

* JUnit v5 ProviderWriteTests

* JUnit v5 ProviderWriteTests

* JUnit v5 RegexFileFilterTest

* JUnit v5 RegexFileFilterTest

* JUnit v5 RamFileRandomAccessContentTest

* JUnit v5 ResSchemeTest

* JUnit v5 RandomAccessModeTest

* JUnit v5 SuffixFileFilterTest

* JUnit v5 SymbolicLinkFileFilterTest

* JUnit v5 SymbolicLinkFileFilterTest

* JUnit v5 StandardFileSystemManagerTest

* JUnit v5 SftpFileSystemConfigBuilderTest

* JUnit v5 SftpPermissionExceptionTestCase

* JUnit v5 TarFileObjectTest

* JUnit v5 TarFileSystemTest

* JUnit v5 UriParserTest

* JUnit v5 UrlFileNameParserTest

* JUnit v5 UserAuthenticationDataTest

* JUnit v5 VFSTest

* JUnit v5 Vfs444TestCase

* JUnit v5 VfsClassLoaderTests

* JUnit v5 VfsTestUtils

* JUnit v5 WildcardFileFilterTest

* JUnit v5 WebDav4FilesTest

* JUnit v5 Webdav4FileObjectTest

* JUnit v5 WindowsFileNameTests

* JUnit v5 ZipFileSystemTest

* JUnit v5 ZipProviderWithCharsetNullTestCase

* JUnit v5 ZipProviderWithCharsetTestCase
  • Loading branch information
nhojpatrick committed Mar 5, 2022
1 parent c6a6a5e commit 9c49b835225b9a275490b13892e4667b3ec2d69a
Showing 167 changed files with 989 additions and 903 deletions.
@@ -51,9 +51,9 @@

/**
* Test cases for the WebDAV provider.
*
*/
public class WebdavProviderTestCase extends AbstractProviderTestConfig {

private static final char[] PASSWORD = {};

private static final String USER_ID = "admin";
@@ -37,6 +37,7 @@
* The suite of tests for a file system.
*/
public class WebdavProviderTestSuite extends ProviderTestSuite {

/**
* Adds the tests for a file system to this suite.
*/
@@ -79,4 +80,5 @@ protected void addBaseTests() throws Exception {
// The class loader test requires the classes be uploaded to the webdav repo.
// addTests(VfsClassLoaderTests.class);
}

}
@@ -16,8 +16,8 @@
*/
package org.apache.commons.vfs2.provider.webdav4;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
@@ -16,11 +16,12 @@
*/
package org.apache.commons.vfs2.provider.webdav4.test;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.VFS;
import org.junit.Assert;
import org.junit.jupiter.api.Test;

/**
@@ -37,7 +38,7 @@ public void testUrlWithAuthority() throws FileSystemException {
// We end up converting back to lowercase, but OK per RFC.
final String urlWithAuthority = "webdav4://alice%5C1234:secret@localhost:80";
try (final FileObject file = fileSystemManager.resolveFile(urlWithAuthority)) {
Assert.assertEquals("webdav4://alice%5c1234:secret@localhost/", file.getURL().toExternalForm());
assertEquals("webdav4://alice%5c1234:secret@localhost/", file.getURL().toExternalForm());
}
}
}
@@ -30,6 +30,7 @@
* Tests for the SMB file system.
*/
public class SmbProviderTestCase extends AbstractProviderTestConfig implements ProviderTestConfig {

private static final String TEST_URI = "test.smb.uri";

public static Test suite() throws Exception {
@@ -55,4 +56,5 @@ public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exce
final String uri = System.getProperty(TEST_URI);
return manager.resolveFile(uri);
}

}
@@ -110,7 +110,6 @@ public static boolean checkName(final String basePath, final String path, final
return baseLen <= 1 || path.length() <= baseLen || path.charAt(baseLen) == SEPARATOR_CHAR;
}
throw new IllegalArgumentException();

}

/**
@@ -65,7 +65,6 @@ public int compareTo(final Object o) {
final int h1 = hashCode();
final int h2 = o.hashCode();
return Integer.compare(h1, h2);

}

/**
@@ -359,4 +359,5 @@ public String toString() {
+ writeFolder + ", manager=" + manager + ", providerConfig=" + providerConfig + ", method=" + method
+ ", addEmptyDir=" + addEmptyDir + "]";
}

}
@@ -72,4 +72,5 @@ public void tearDown() throws Exception {
Thread.sleep(20);
}
}

}
@@ -333,4 +333,5 @@ private void validateThreadSnapshot() {
}
// System.in.read();
}

}
@@ -20,6 +20,7 @@
* The suite of tests for a file cache.
*/
public class CacheTestSuite extends AbstractTestSuite {

public CacheTestSuite(final ProviderTestConfig providerConfig) throws Exception {
this(providerConfig, "", false);
}
@@ -28,4 +29,5 @@ protected CacheTestSuite(final ProviderTestConfig providerConfig, final String p
throws Exception {
super(providerConfig, prefix, nested);
}

}
@@ -393,4 +393,5 @@ public void testUnknownContent() throws Exception {
assertSameMessage("vfs.provider/get-size-not-file.error", unknownFile, e);
}
}

}
@@ -16,19 +16,22 @@
*/
package org.apache.commons.vfs2;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.File;

import org.junit.Assert;
import org.junit.jupiter.api.Test;

public class FileChangeEventTest {

@Test
public void testFileObject() throws FileSystemException {
try (FileObject baseFile = VFS.getManager().toFileObject(new File("."))) {
Assert.assertNotNull(baseFile);
assertNotNull(baseFile);
final FileChangeEvent fileChangeEvent = new FileChangeEvent(baseFile);
Assert.assertEquals(fileChangeEvent.getFile(), fileChangeEvent.getFileObject());
assertEquals(fileChangeEvent.getFile(), fileChangeEvent.getFileObject());
}
}

}
@@ -16,12 +16,15 @@
*/
package org.apache.commons.vfs2;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.junit.Assert;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -83,7 +86,7 @@ public static void tearDownClass() throws Exception {
public void testEmpty() throws Exception {
final FileSelector selector = new FileExtensionSelector();
final FileObject[] foList = BaseFolder.findFiles(selector);
Assert.assertEquals(0, foList.length);
assertEquals(0, foList.length);
}

/**
@@ -94,20 +97,20 @@ public void testEmpty() throws Exception {
@Test
public void testManyExtensions() throws Exception {
final FileObject[] foArray = BaseFolder.findFiles(Selectors.SELECT_FILES);
Assert.assertTrue(foArray.length > 0);
assertTrue(foArray.length > 0);
// gather file extensions.
final Set<String> extensionSet = new HashSet<>();
for (final FileObject fo : foArray) {
extensionSet.add(fo.getName().getExtension());
}
final String message = String.format("Extensions: %s; files: %s", extensionSet.toString(),
Arrays.asList(foArray).toString());
Assert.assertFalse(message, extensionSet.isEmpty());
Assert.assertEquals(message, ExtensionCount, extensionSet.size());
assertFalse(extensionSet.isEmpty(), message);
assertEquals(ExtensionCount, extensionSet.size(), message);
// check all unique extensions
final FileSelector selector = new FileExtensionSelector(extensionSet);
final FileObject[] list = BaseFolder.findFiles(selector);
Assert.assertEquals(FileCount, list.length);
assertEquals(FileCount, list.length);
}

/**
@@ -119,7 +122,7 @@ public void testManyExtensions() throws Exception {
public void testNullCollection() throws Exception {
final FileSelector selector0 = new FileExtensionSelector((Collection<String>) null);
final FileObject[] foList = BaseFolder.findFiles(selector0);
Assert.assertEquals(0, foList.length);
assertEquals(0, foList.length);
}

/**
@@ -131,7 +134,7 @@ public void testNullCollection() throws Exception {
public void testNullString() throws Exception {
final FileSelector selector0 = new FileExtensionSelector((String) null);
final FileObject[] foList = BaseFolder.findFiles(selector0);
Assert.assertEquals(0, foList.length);
assertEquals(0, foList.length);
}

/**
@@ -142,26 +145,26 @@ public void testNullString() throws Exception {
@Test
public void testOneExtension() throws Exception {
final FileObject[] foArray = BaseFolder.findFiles(Selectors.SELECT_FILES);
Assert.assertTrue(foArray.length > 0);
assertTrue(foArray.length > 0);
// gather file extensions.
final Set<String> extensionSet = new HashSet<>();
for (final FileObject fo : foArray) {
extensionSet.add(fo.getName().getExtension());
}
final String message = String.format("Extensions: %s; files: %s", extensionSet.toString(),
Arrays.asList(foArray).toString());
Assert.assertEquals(message, ExtensionCount, extensionSet.size());
assertEquals(ExtensionCount, extensionSet.size(), message);
// check each extension
for (final String extension : extensionSet) {
final FileSelector selector = new FileExtensionSelector(extension);
final FileObject[] list = BaseFolder.findFiles(selector);
Assert.assertEquals(FilesPerExtensionCount, list.length);
assertEquals(FilesPerExtensionCount, list.length);
}
// check each file against itself
for (final FileObject fo : foArray) {
final FileSelector selector = new FileExtensionSelector(fo.getName().getExtension());
final FileObject[] list = BaseFolder.findFiles(selector);
Assert.assertEquals(FilesPerExtensionCount, list.length);
assertEquals(FilesPerExtensionCount, list.length);
}
}

@@ -106,4 +106,5 @@ public FileInfo getParent() {
public FileType getType() {
return type;
}

}
@@ -16,9 +16,11 @@
*/
package org.apache.commons.vfs2;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Iterator;

import org.junit.Assert;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -72,21 +74,22 @@ public static void tearDownClass() throws Exception {
@Test
public void testIterator() throws FileSystemException {
final FileObject[] findFiles = BaseFolder.findFiles(Selectors.SELECT_ALL);
Assert.assertEquals(FileCount, findFiles.length);
assertEquals(FileCount, findFiles.length);
final FileObject[] listFiles = BaseFolder.getChildren();
Assert.assertTrue(FileCount > listFiles.length);
assertTrue(FileCount > listFiles.length);
int i = 0;
for (final FileObject actualFile : BaseFolder) {
final FileObject expectedFile = findFiles[i];
Assert.assertEquals(expectedFile, actualFile);
assertEquals(expectedFile, actualFile);
i++;
}
final Iterator<FileObject> iter = BaseFolder.iterator();
i = 0;
while (iter.hasNext()) {
final FileObject expectedFile = findFiles[i];
Assert.assertEquals(expectedFile, iter.next());
assertEquals(expectedFile, iter.next());
i++;
}
}

}