This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push: new fe534c4 Start converting from JUnit 3 to 4. fe534c4 is described below commit fe534c45d56d161f52633eca8d609c03be1f4ede Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Oct 18 17:16:07 2020 -0400 Start converting from JUnit 3 to 4. --- .../vfs2/provider/smb/test/FileNameTestCase.java | 4 +++ .../vfs2/impl/test/DefaultFileMonitorTest.java | 33 ++++++++++++++++------ .../provider/test/GenericFileNameTestCase.java | 4 +++ .../test/FileSystemManagerFactoryTestCase.java | 3 ++ 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/commons-vfs2-sandbox/src/test/java/org/apache/commons/vfs2/provider/smb/test/FileNameTestCase.java b/commons-vfs2-sandbox/src/test/java/org/apache/commons/vfs2/provider/smb/test/FileNameTestCase.java index b19cba4..03fde02 100644 --- a/commons-vfs2-sandbox/src/test/java/org/apache/commons/vfs2/provider/smb/test/FileNameTestCase.java +++ b/commons-vfs2-sandbox/src/test/java/org/apache/commons/vfs2/provider/smb/test/FileNameTestCase.java @@ -20,16 +20,19 @@ import org.apache.commons.AbstractVfsTestCase; import org.apache.commons.vfs2.FileSystemException; import org.apache.commons.vfs2.provider.smb.SmbFileName; import org.apache.commons.vfs2.provider.smb.SmbFileNameParser; +import org.junit.Test; /** * Some additional SMB file name test cases. */ public class FileNameTestCase extends AbstractVfsTestCase { + /** * Tests parsing a URI into its parts. * * @throws Exception in case of error */ + @Test public void testParseUri() throws Exception { // Simple name SmbFileName name = (SmbFileName) SmbFileNameParser.getInstance().parseUri(null, null, @@ -115,6 +118,7 @@ public class FileNameTestCase extends AbstractVfsTestCase { * * @throws Exception in case of error */ + @Test public void testBadlyFormedUri() throws Exception { // Does not start with smb:// testBadlyFormedUri("smb:", "vfs.provider/missing-double-slashes.error"); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/test/DefaultFileMonitorTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/test/DefaultFileMonitorTest.java index bf705ef..9cc8747 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/test/DefaultFileMonitorTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/test/DefaultFileMonitorTest.java @@ -16,7 +16,8 @@ */ package org.apache.commons.vfs2.impl.test; -import static org.junit.Assume.assumeFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileWriter; @@ -24,19 +25,22 @@ import java.io.IOException; import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.AbstractVfsTestCase; -import org.apache.commons.lang3.SystemUtils; import org.apache.commons.vfs2.FileChangeEvent; import org.apache.commons.vfs2.FileListener; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSystemManager; import org.apache.commons.vfs2.VFS; import org.apache.commons.vfs2.impl.DefaultFileMonitor; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Ignore; +import org.junit.Test; /** * Test to verify DefaultFileMonitor */ -public class DefaultFileMonitorTest extends AbstractVfsTestCase { +public class DefaultFileMonitorTest { private static final int DELAY_MILLIS = 100; private FileSystemManager fsManager; @@ -44,11 +48,14 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { private volatile Status changeStatus; private File testFile; - @Override - public void setUp() throws Exception { + @BeforeClass + public static void beforeClass() { // Fails randomly on Windows. - assumeFalse(SystemUtils.IS_OS_WINDOWS); - super.setUp(); + //assumeFalse(SystemUtils.IS_OS_WINDOWS); + } + + @Before + public void setUp() throws Exception { fsManager = VFS.getManager(); testDir = AbstractVfsTestCase.getTestDirectoryFile(); changeStatus = null; @@ -59,16 +66,16 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { } } - @Override + @After public void tearDown() throws Exception { if (testFile != null) { if (!testFile.delete()) { testFile.deleteOnExit(); } } - super.tearDown(); } + @Test public void testFileCreated() throws Exception { try (final FileObject fileObject = fsManager.resolveFile(testFile.toURI().toURL().toString())) { final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); @@ -87,6 +94,7 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { } } + @Test public void testFileDeleted() throws Exception { writeToFile(testFile); try (final FileObject fileObject = fsManager.resolveFile(testFile.toURI().toString())) { @@ -106,6 +114,7 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { } } + @Test public void testFileModified() throws Exception { writeToFile(testFile); try (final FileObject fileObject = fsManager.resolveFile(testFile.toURI().toURL().toString())) { @@ -130,6 +139,7 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { } } + @Test public void testFileRecreated() throws Exception { try (final FileObject fileObject = fsManager.resolveFile(testFile.toURI().toURL().toString())) { final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); @@ -160,6 +170,7 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { } } + @Test public void testChildFileRecreated() throws Exception { writeToFile(testFile); try (final FileObject fileObj = fsManager.resolveFile(testDir.toURI().toURL().toString())) { @@ -187,6 +198,7 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { } } + @Test public void testChildFileDeletedWithoutRecursiveChecking() throws Exception { writeToFile(testFile); try (final FileObject fileObject = fsManager.resolveFile(testDir.toURI().toURL().toString())) { @@ -207,6 +219,7 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { } } + @Test public void testFileMonitorRestarted() throws Exception { try (final FileObject fileObject = fsManager.resolveFile(testFile.toURI().toString())) { final DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener()); @@ -240,6 +253,7 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { * As a result, the file monitor will fire two created events. */ @Ignore("VFS-299") + @Test public void ignore_testAddRemove() throws Exception { try (final FileObject fileObject = fsManager.resolveFile(testFile.toURI().toString())) { final CountingListener listener = new CountingListener(); @@ -265,6 +279,7 @@ public class DefaultFileMonitorTest extends AbstractVfsTestCase { * As a result, listeners of stopped monitors still receive events. */ @Ignore("VFS-299") + @Test public void ignore_testStartStop() throws Exception { try (final FileObject fileObject = fsManager.resolveFile(testFile.toURI().toString())) { final CountingListener stoppedListener = new CountingListener(); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/test/GenericFileNameTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/test/GenericFileNameTestCase.java index d522355..6b6cf8e 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/test/GenericFileNameTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/test/GenericFileNameTestCase.java @@ -20,14 +20,17 @@ import org.apache.commons.AbstractVfsTestCase; import org.apache.commons.vfs2.FileSystemException; import org.apache.commons.vfs2.provider.GenericFileName; import org.apache.commons.vfs2.provider.URLFileNameParser; +import org.junit.Test; /** * Some GenericFileName test cases. */ public class GenericFileNameTestCase extends AbstractVfsTestCase { + /** * Tests parsing a URI into its parts. */ + @Test public void testParseUri() throws Exception { final URLFileNameParser urlParser = new URLFileNameParser(21); // Simple name @@ -101,6 +104,7 @@ public class GenericFileNameTestCase extends AbstractVfsTestCase { /** * Tests error handling in URI parser. */ + @Test public void testBadlyFormedUri() throws Exception { // Does not start with ftp:// testBadlyFormedUri("ftp:", "vfs.provider/missing-double-slashes.error"); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java index 1aad2fe..91e790c 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java @@ -24,14 +24,17 @@ import org.apache.commons.vfs2.FileSystemException; import org.apache.commons.vfs2.FileSystemManager; import org.apache.commons.vfs2.FileType; import org.apache.commons.vfs2.VFS; +import org.junit.Test; /** * Test cases for the VFS factory. */ public class FileSystemManagerFactoryTestCase extends AbstractVfsTestCase { + /** * Sanity test. */ + @Test public void testDefaultInstance() throws Exception { // Locate the default manager final FileSystemManager manager = VFS.getManager();