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 ef94f1f Partial but changed application of PR https://github.com/apache/commons-vfs/pull/82 ef94f1f is described below commit ef94f1f9d11729fa94e35a4712fe5a479d8c7479 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Feb 7 18:00:49 2021 -0500 Partial but changed application of PR https://github.com/apache/commons-vfs/pull/82 FTP tests can be configured with a custom FTP server command factory. --- .../vfs2/provider/ftp/FtpProviderTestCase.java | 49 ++++++++++++++++------ .../provider/ftp/MultipleConnectionTestCase.java | 2 +- src/changes/changes.xml | 15 ++++--- 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java index 5eca381..e10fb00 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java @@ -20,17 +20,16 @@ import java.io.IOException; import java.net.URL; import java.time.Duration; +import org.apache.commons.vfs2.AbstractProviderTestCase; import org.apache.commons.vfs2.AbstractProviderTestConfig; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSystemManager; import org.apache.commons.vfs2.FileSystemOptions; import org.apache.commons.vfs2.ProviderTestSuite; import org.apache.commons.vfs2.impl.DefaultFileSystemManager; -import org.apache.commons.vfs2.provider.ftp.FtpFileProvider; -import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; -import org.apache.commons.vfs2.provider.ftp.FtpFileType; import org.apache.ftpserver.FtpServer; import org.apache.ftpserver.FtpServerFactory; +import org.apache.ftpserver.command.CommandFactory; import org.apache.ftpserver.ftplet.FileSystemFactory; import org.apache.ftpserver.ftplet.FtpException; import org.apache.ftpserver.ftplet.UserManager; @@ -73,12 +72,13 @@ public class FtpProviderTestCase extends AbstractProviderTestConfig { /** * Creates and starts an embedded Apache FTP Server (MINA). * - * @param rootDirectory the local FTP server rootDirectory - * @param fileSystemFactory optional local FTP server FileSystemFactory + * @param rootDirectory the local FTP server rootDirectory. + * @param fileSystemFactory optional local FTP server FileSystemFactory. + * @param commandFactory FTP server command factory. * @throws FtpException */ - static void setUpClass(final String rootDirectory, final FileSystemFactory fileSystemFactory) - throws FtpException { + static void setUpClass(final String rootDirectory, final FileSystemFactory fileSystemFactory, + final CommandFactory commandFactory) throws FtpException { if (Server != null) { return; } @@ -97,6 +97,9 @@ public class FtpProviderTestCase extends AbstractProviderTestConfig { if (fileSystemFactory != null) { serverFactory.setFileSystem(fileSystemFactory); } + if (commandFactory != null) { + serverFactory.setCommandFactory(commandFactory); + } final ListenerFactory factory = new ListenerFactory(); // set the port of the listener factory.setPort(0); @@ -112,21 +115,34 @@ public class FtpProviderTestCase extends AbstractProviderTestConfig { } /** - * Creates the test suite for the ftp file system. + * Creates the test suite for the FTP file system. */ public static Test suite() throws Exception { return suite(new FtpProviderTestCase()); } /** - * Creates the test suite for subclasses of the ftp file system. + * Creates the test suite for subclasses of the FTP file system. */ - protected static Test suite(final FtpProviderTestCase testCase) throws Exception { + protected static Test suite(final FtpProviderTestCase testCase, + Class<? extends AbstractProviderTestCase>... testClasses) throws Exception { return new ProviderTestSuite(testCase) { + + @Override + protected void addBaseTests() throws Exception { + if (testClasses.length == 0) { + super.addBaseTests(); + } else { + for (final Class<?> test : testClasses) { + addTests(test); + } + } + } + @Override protected void setUp() throws Exception { if (getSystemTestUriOverride() == null) { - setUpClass(testCase.getFtpRootDir(), testCase.getFtpFileSystem()); + setUpClass(testCase.getFtpRootDir(), testCase.getFtpFileSystem(), testCase.getCommandFactory()); } super.setUp(); } @@ -180,7 +196,7 @@ public class FtpProviderTestCase extends AbstractProviderTestConfig { } /** - * Gets the setting for UserDirIsRoot. + * Gets the setting for UserDirIsRoot. Defaults to false. */ protected boolean getUserDirIsRoot() { return false; @@ -195,6 +211,15 @@ public class FtpProviderTestCase extends AbstractProviderTestConfig { } /** + * Gets the FTP server command factory. Defaults to null for no override. + * + * @return the FTP server command factory or null. + */ + protected CommandFactory getCommandFactory() { + return null; + } + + /** * Gets the root of the local FTP Server file system. */ protected String getFtpRootDir() { diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/MultipleConnectionTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/MultipleConnectionTestCase.java index 93eda48..6705573 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/MultipleConnectionTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/MultipleConnectionTestCase.java @@ -33,7 +33,7 @@ public class MultipleConnectionTestCase { @BeforeClass public static void setUpClass() throws FtpException { - FtpProviderTestCase.setUpClass(AbstractVfsTestCase.getTestDirectory(), null); + FtpProviderTestCase.setUpClass(AbstractVfsTestCase.getTestDirectory(), null, null); } @AfterClass diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 9461bea..d22da4b 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -66,19 +66,22 @@ The <action> type attribute can be add,update,fix,remove. <action dev="ggregory" due-to="Gary Gregory" type="fix"> Fix possible ClassCastException in DefaultFileSystemManager.freeUnusedResources(). </action> + <action issue="VFS-748" dev="ggregory" due-to="PeterAlfredLee, Gary Gregory" type="fix"> + TarProvider Incorrectly marks file IMAGINARY after garbage collection with WeakRefFilesCache, #97. + </action> <!-- ADDS --> - <action dev="ggregory" due-to="Boris Petrov, Gary Gregory" type="update"> + <action dev="ggregory" due-to="Boris Petrov, Gary Gregory" type="add"> Add ability to remove a provider from DefaultFileSystemManager #149. </action> - <action issue="VFS-748" dev="ggregory" due-to="PeterAlfredLee, Gary Gregory" type="update"> - TarProvider Incorrectly marks file IMAGINARY after garbage collection with WeakRefFilesCache, #97. - </action> - <action dev="ggregory" due-to="Gary Gregory" type="update"> + <action dev="ggregory" due-to="Gary Gregory" type="add"> Add and use VFS.close(). </action> - <action dev="ggregory" due-to="Gary Gregory, xiaqingyun" type="update"> + <action dev="ggregory" due-to="Gary Gregory, xiaqingyun" type="add"> Add support for FTP ControlKeepAliveReplyTimeout and ControlKeepAliveTimeout. </action> + <action dev="ggregory" due-to="Gary Gregory, Michael Graham" type="add"> + FTP tests can be configured with a custom FTP server command factory. + </action> <!-- UPDATES --> <action dev="ggregory" due-to="PeterAlfredLee" type="update"> Modify some code use for-each loop and stream API #142.