From 1eda37310470171714c91baf63f26deaf84b7880 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 11 Oct 2023 11:19:56 -0400 Subject: [PATCH] Fix some Checkstyle issues --- .../vfs2/FileExtensionSelectorTest.java | 62 +++++++++---------- .../commons/vfs2/PatternFileSelectorTest.java | 58 ++++++++--------- .../provider/ftp/FtpProviderTestCase.java | 24 +++---- .../ftps/AbstractFtpsProviderTestCase.java | 32 +++++----- .../provider/http/HttpProviderTestCase.java | 26 ++++---- .../provider/http4/Http4ProviderTestCase.java | 26 ++++---- .../provider/http5/Http5ProviderTestCase.java | 26 ++++---- .../sftp/AbstractSftpProviderTestCase.java | 48 +++++++------- .../sftp/SftpPermissionExceptionTestCase.java | 2 +- .../SftpProviderStreamProxyModeTestCase.java | 2 +- .../provider/sftp/SftpPutChannelTestCase.java | 2 +- .../provider/test/FileObjectSortTest.java | 40 ++++++------ .../provider/url/UrlProviderHttpTestCase.java | 18 +++--- .../commons/vfs2/util/NHttpFileServer.java | 2 +- .../vfs2/util/RandomAccessModeTest.java | 10 +-- pom.xml | 2 +- 16 files changed, 190 insertions(+), 190 deletions(-) diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java index bb4f3013d0..60072c1717 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/FileExtensionSelectorTest.java @@ -36,13 +36,13 @@ */ public class FileExtensionSelectorTest { - private static FileObject BaseFolder; + private static FileObject baseFolder; - private static final int FileCount = 9; + private static final int FILE_COUNT = 9; - private static final int ExtensionCount = 3; + private static final int EXTENSION_COUNT = 3; - private static final int FilesPerExtensionCount = 3; + private static final int FILES_PER_EXTENSION_COUNT = 3; /** * Creates a RAM FS. @@ -51,18 +51,18 @@ public class FileExtensionSelectorTest { */ @BeforeAll public static void setUpClass() throws Exception { - BaseFolder = VFS.getManager().resolveFile("ram://" + FileExtensionSelectorTest.class.getName()); - BaseFolder.deleteAll(); - BaseFolder.createFolder(); - BaseFolder.resolveFile("a.htm").createFile(); - BaseFolder.resolveFile("a.html").createFile(); - BaseFolder.resolveFile("a.xhtml").createFile(); - BaseFolder.resolveFile("b.htm").createFile(); - BaseFolder.resolveFile("b.html").createFile(); - BaseFolder.resolveFile("b.xhtml").createFile(); - BaseFolder.resolveFile("c.htm").createFile(); - BaseFolder.resolveFile("c.html").createFile(); - BaseFolder.resolveFile("c.xhtml").createFile(); + baseFolder = VFS.getManager().resolveFile("ram://" + FileExtensionSelectorTest.class.getName()); + baseFolder.deleteAll(); + baseFolder.createFolder(); + baseFolder.resolveFile("a.htm").createFile(); + baseFolder.resolveFile("a.html").createFile(); + baseFolder.resolveFile("a.xhtml").createFile(); + baseFolder.resolveFile("b.htm").createFile(); + baseFolder.resolveFile("b.html").createFile(); + baseFolder.resolveFile("b.xhtml").createFile(); + baseFolder.resolveFile("c.htm").createFile(); + baseFolder.resolveFile("c.html").createFile(); + baseFolder.resolveFile("c.xhtml").createFile(); } /** @@ -72,8 +72,8 @@ public static void setUpClass() throws Exception { */ @AfterAll public static void tearDownClass() throws Exception { - if (BaseFolder != null) { - BaseFolder.deleteAll(); + if (baseFolder != null) { + baseFolder.deleteAll(); } } @@ -85,7 +85,7 @@ public static void tearDownClass() throws Exception { @Test public void testEmpty() throws Exception { final FileSelector selector = new FileExtensionSelector(); - final FileObject[] foList = BaseFolder.findFiles(selector); + final FileObject[] foList = baseFolder.findFiles(selector); assertEquals(0, foList.length); } @@ -96,7 +96,7 @@ public void testEmpty() throws Exception { */ @Test public void testManyExtensions() throws Exception { - final FileObject[] foArray = BaseFolder.findFiles(Selectors.SELECT_FILES); + final FileObject[] foArray = baseFolder.findFiles(Selectors.SELECT_FILES); assertTrue(foArray.length > 0); // gather file extensions. final Set extensionSet = new HashSet<>(); @@ -106,11 +106,11 @@ public void testManyExtensions() throws Exception { final String message = String.format("Extensions: %s; files: %s", extensionSet.toString(), Arrays.asList(foArray).toString()); assertFalse(extensionSet.isEmpty(), message); - assertEquals(ExtensionCount, extensionSet.size(), message); + assertEquals(EXTENSION_COUNT, extensionSet.size(), message); // check all unique extensions final FileSelector selector = new FileExtensionSelector(extensionSet); - final FileObject[] list = BaseFolder.findFiles(selector); - assertEquals(FileCount, list.length); + final FileObject[] list = baseFolder.findFiles(selector); + assertEquals(FILE_COUNT, list.length); } /** @@ -121,7 +121,7 @@ public void testManyExtensions() throws Exception { @Test public void testNullCollection() throws Exception { final FileSelector selector0 = new FileExtensionSelector((Collection) null); - final FileObject[] foList = BaseFolder.findFiles(selector0); + final FileObject[] foList = baseFolder.findFiles(selector0); assertEquals(0, foList.length); } @@ -133,7 +133,7 @@ public void testNullCollection() throws Exception { @Test public void testNullString() throws Exception { final FileSelector selector0 = new FileExtensionSelector((String) null); - final FileObject[] foList = BaseFolder.findFiles(selector0); + final FileObject[] foList = baseFolder.findFiles(selector0); assertEquals(0, foList.length); } @@ -144,7 +144,7 @@ public void testNullString() throws Exception { */ @Test public void testOneExtension() throws Exception { - final FileObject[] foArray = BaseFolder.findFiles(Selectors.SELECT_FILES); + final FileObject[] foArray = baseFolder.findFiles(Selectors.SELECT_FILES); assertTrue(foArray.length > 0); // gather file extensions. final Set extensionSet = new HashSet<>(); @@ -153,18 +153,18 @@ public void testOneExtension() throws Exception { } final String message = String.format("Extensions: %s; files: %s", extensionSet.toString(), Arrays.asList(foArray).toString()); - assertEquals(ExtensionCount, extensionSet.size(), message); + assertEquals(EXTENSION_COUNT, extensionSet.size(), message); // check each extension for (final String extension : extensionSet) { final FileSelector selector = new FileExtensionSelector(extension); - final FileObject[] list = BaseFolder.findFiles(selector); - assertEquals(FilesPerExtensionCount, list.length); + final FileObject[] list = baseFolder.findFiles(selector); + assertEquals(FILES_PER_EXTENSION_COUNT, 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); - assertEquals(FilesPerExtensionCount, list.length); + final FileObject[] list = baseFolder.findFiles(selector); + assertEquals(FILES_PER_EXTENSION_COUNT, list.length); } } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/PatternFileSelectorTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/PatternFileSelectorTest.java index 290319c287..91de2260ec 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/PatternFileSelectorTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/PatternFileSelectorTest.java @@ -35,19 +35,19 @@ */ public class PatternFileSelectorTest { - private static FileObject BaseFolder; + private static FileObject baseFolder; /** * 9 files and 1 directory = 10 */ - private static final int EntryCount = 10; + private static final int ENTRY_COUNT = 10; - private static final int ExtensionCount = 3; + private static final int EXTENSION_COUNT = 3; - private static final int FilesPerExtensionCount = 3; + private static final int FILES_PER_EXTENSION_COUNT = 3; static FileObject getBaseFolder() { - return BaseFolder; + return baseFolder; } /** @@ -57,18 +57,18 @@ static FileObject getBaseFolder() { */ @BeforeAll public static void setUpClass() throws Exception { - BaseFolder = VFS.getManager().resolveFile("ram://" + PatternFileSelectorTest.class.getName()); - BaseFolder.deleteAll(); - BaseFolder.createFolder(); - BaseFolder.resolveFile("aa.htm").createFile(); - BaseFolder.resolveFile("aa.html").createFile(); - BaseFolder.resolveFile("aa.xhtml").createFile(); - BaseFolder.resolveFile("b.htm").createFile(); - BaseFolder.resolveFile("b.html").createFile(); - BaseFolder.resolveFile("b.xhtml").createFile(); - BaseFolder.resolveFile("c.htm").createFile(); - BaseFolder.resolveFile("c.html").createFile(); - BaseFolder.resolveFile("c.xhtml").createFile(); + baseFolder = VFS.getManager().resolveFile("ram://" + PatternFileSelectorTest.class.getName()); + baseFolder.deleteAll(); + baseFolder.createFolder(); + baseFolder.resolveFile("aa.htm").createFile(); + baseFolder.resolveFile("aa.html").createFile(); + baseFolder.resolveFile("aa.xhtml").createFile(); + baseFolder.resolveFile("b.htm").createFile(); + baseFolder.resolveFile("b.html").createFile(); + baseFolder.resolveFile("b.xhtml").createFile(); + baseFolder.resolveFile("c.htm").createFile(); + baseFolder.resolveFile("c.html").createFile(); + baseFolder.resolveFile("c.xhtml").createFile(); } /** @@ -78,8 +78,8 @@ public static void setUpClass() throws Exception { */ @AfterAll public static void tearDownClass() throws Exception { - if (BaseFolder != null) { - BaseFolder.deleteAll(); + if (baseFolder != null) { + baseFolder.deleteAll(); } } @@ -90,7 +90,7 @@ public static void tearDownClass() throws Exception { */ @Test public void testFileExtensions() throws Exception { - final FileObject[] foArray = BaseFolder.findFiles(Selectors.SELECT_FILES); + final FileObject[] foArray = baseFolder.findFiles(Selectors.SELECT_FILES); assertTrue(foArray.length > 0); final String regExPrefix = ".*\\."; // gather file extensions. @@ -100,18 +100,18 @@ public void testFileExtensions() throws Exception { } final String message = String.format("Extensions: %s; files: %s", extensionSet.toString(), Arrays.asList(foArray).toString()); - assertEquals(ExtensionCount, extensionSet.size(), message); + assertEquals(EXTENSION_COUNT, extensionSet.size(), message); // check each extension for (final String extension : extensionSet) { final FileSelector selector = new PatternFileSelector(extension); - final FileObject[] list = BaseFolder.findFiles(selector); - assertEquals(FilesPerExtensionCount, list.length); + final FileObject[] list = baseFolder.findFiles(selector); + assertEquals(FILES_PER_EXTENSION_COUNT, list.length); } // check each file against itself for (final FileObject fo : foArray) { final FileSelector selector = new PatternFileSelector(regExPrefix + fo.getName().getExtension()); - final FileObject[] list = BaseFolder.findFiles(selector); - assertEquals(FilesPerExtensionCount, list.length); + final FileObject[] list = baseFolder.findFiles(selector); + assertEquals(FILES_PER_EXTENSION_COUNT, list.length); } } @@ -122,8 +122,8 @@ public void testFileExtensions() throws Exception { */ @Test public void testMatchAll() throws Exception { - final FileObject[] list = BaseFolder.findFiles(new PatternFileSelector(".*")); - assertEquals(EntryCount, list.length); + final FileObject[] list = baseFolder.findFiles(new PatternFileSelector(".*")); + assertEquals(ENTRY_COUNT, list.length); } /** @@ -133,7 +133,7 @@ public void testMatchAll() throws Exception { */ @Test public void testMatchPartial() throws Exception { - final FileObject[] list = BaseFolder.findFiles(new PatternFileSelector(".*a.htm")); + final FileObject[] list = baseFolder.findFiles(new PatternFileSelector(".*a.htm")); assertEquals(1, list.length); assertEquals("aa.htm", list[0].getName().getBaseName()); } @@ -145,7 +145,7 @@ public void testMatchPartial() throws Exception { */ @Test public void testMatchPartialDelimited() throws Exception { - final FileObject[] list = BaseFolder.findFiles(new PatternFileSelector("^.*\\/b.htm$")); + final FileObject[] list = baseFolder.findFiles(new PatternFileSelector("^.*\\/b.htm$")); assertEquals(1, list.length); assertEquals("b.htm", list[0].getName().getBaseName()); } 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 3d15ee1ea2..3303eaa950 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 @@ -52,9 +52,9 @@ public class FtpProviderTestCase extends AbstractProviderTestConfig { /** * Use %40 for @ in URLs */ - private static String ConnectionUri; + private static String connectionUri; - private static FtpServer Server; + private static FtpServer server; private static final String TEST_URI = "test.ftp.uri"; @@ -71,7 +71,7 @@ public FtpProviderTestCase(final boolean mdtmLastModifiedTime) { } static String getConnectionUri() { - return ConnectionUri; + return connectionUri; } static int getSocketPort() { @@ -92,7 +92,7 @@ private static String getSystemTestUriOverride() { */ static void setUpClass(final String rootDirectory, final FileSystemFactory fileSystemFactory, final CommandFactory commandFactory) throws FtpException { - if (Server != null) { + if (server != null) { return; } final FtpServerFactory serverFactory = new FtpServerFactory(); @@ -121,10 +121,10 @@ static void setUpClass(final String rootDirectory, final FileSystemFactory fileS serverFactory.addListener("default", factory.createListener()); // start the server - Server = serverFactory.createServer(); - Server.start(); - SocketPort = ((org.apache.ftpserver.impl.DefaultFtpServer) Server).getListener("default").getPort(); - ConnectionUri = "ftp://test:test@localhost:" + SocketPort; + server = serverFactory.createServer(); + server.start(); + SocketPort = ((org.apache.ftpserver.impl.DefaultFtpServer) server).getListener("default").getPort(); + connectionUri = "ftp://test:test@localhost:" + SocketPort; } /** @@ -179,9 +179,9 @@ protected void tearDown() throws Exception { * Stops the embedded Apache FTP Server (MINA). */ static void tearDownClass() { - if (Server != null) { - Server.stop(); - Server = null; + if (server != null) { + server.stop(); + server = null; } } @@ -193,7 +193,7 @@ static void tearDownClass() { public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { String uri = getSystemTestUriOverride(); if (uri == null) { - uri = ConnectionUri; + uri = connectionUri; } final FileSystemOptions options = new FileSystemOptions(); final FtpFileSystemConfigBuilder builder = FtpFileSystemConfigBuilder.getInstance(); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java index ecf768595f..9d53bf9b73 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java @@ -83,9 +83,9 @@ protected void tearDown() throws Exception { /** * Use %40 for @ in URLs */ - private static String ConnectionUri; + private static String connectionUri; - private static FtpServer EmbeddedFtpServer; + private static FtpServer embeddedFtpServer; private static final String TEST_URI = "test.ftps.uri"; @@ -96,7 +96,7 @@ protected void tearDown() throws Exception { protected FileSystemOptions fileSystemOptions; static String getConnectionUri() { - return ConnectionUri; + return connectionUri; } static int getSocketPort() { @@ -114,7 +114,7 @@ static String getSystemTestUriOverride() { * @throws FtpException */ synchronized static void setUpClass(final boolean implicit) throws FtpException { - if (EmbeddedFtpServer != null) { + if (embeddedFtpServer != null) { return; } // Let the OS find use an ephemeral port by using 0. @@ -153,40 +153,40 @@ synchronized static void setUpClass(final boolean implicit) throws FtpException serverFactory.addListener(LISTENER_NAME, listenerFactory.createListener()); // start the server - EmbeddedFtpServer = serverFactory.createServer(); - EmbeddedFtpServer.start(); + embeddedFtpServer = serverFactory.createServer(); + embeddedFtpServer.start(); Thread.yield(); - if (EmbeddedFtpServer.isStopped() || EmbeddedFtpServer.isSuspended()) { + if (embeddedFtpServer.isStopped() || embeddedFtpServer.isSuspended()) { try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } } - SocketPort = ((org.apache.ftpserver.impl.DefaultFtpServer) EmbeddedFtpServer).getListener(LISTENER_NAME).getPort(); + SocketPort = ((org.apache.ftpserver.impl.DefaultFtpServer) embeddedFtpServer).getListener(LISTENER_NAME).getPort(); // System.out.println("Using port " + SocketPort); - ConnectionUri = "ftps://test:test@localhost:" + SocketPort; + connectionUri = "ftps://test:test@localhost:" + SocketPort; } /** * Stops the embedded Apache FTP EmbeddedFtpServer (MINA). */ synchronized static void tearDownClass() { - if (EmbeddedFtpServer != null) { - EmbeddedFtpServer.suspend(); - EmbeddedFtpServer.stop(); + if (embeddedFtpServer != null) { + embeddedFtpServer.suspend(); + embeddedFtpServer.stop(); Thread.yield(); int count = 10; - while (count-- > 0 && !EmbeddedFtpServer.isStopped()) { + while (count-- > 0 && !embeddedFtpServer.isStopped()) { final int millis = 200; - System.out.println(String.format("Waiting %,d milliseconds for %s to stop", millis, EmbeddedFtpServer)); + System.out.println(String.format("Waiting %,d milliseconds for %s to stop", millis, embeddedFtpServer)); try { Thread.sleep(millis); } catch (InterruptedException e) { e.printStackTrace(); } } - EmbeddedFtpServer = null; + embeddedFtpServer = null; } } @@ -197,7 +197,7 @@ synchronized static void tearDownClass() { public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { String uri = getSystemTestUriOverride(); if (uri == null) { - uri = ConnectionUri; + uri = connectionUri; } return manager.resolveFile(uri, getFileSystemOptions()); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/HttpProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/HttpProviderTestCase.java index 4d39fa2d9f..eb44b08c0b 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/HttpProviderTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/HttpProviderTestCase.java @@ -41,16 +41,16 @@ public class HttpProviderTestCase extends AbstractProviderTestConfig { private static final Duration ONE_MINUTE = Duration.ofMinutes(1); - private static NHttpFileServer Server; + private static NHttpFileServer server; - private static int SocketPort; + private static int socketPort; private static final String TEST_URI = "test.http.uri"; /** * Use %40 for @ in URLs */ - private static String ConnectionUri; + private static String connectionUri; private static String getSystemTestUriOverride() { return System.getProperty(TEST_URI); @@ -62,9 +62,9 @@ private static String getSystemTestUriOverride() { * @throws Exception */ private static void setUpClass() throws Exception { - Server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000); - SocketPort = Server.getPort(); - ConnectionUri = "http://localhost:" + SocketPort; + server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000); + socketPort = server.getPort(); + connectionUri = "http://localhost:" + socketPort; } /** @@ -104,8 +104,8 @@ protected void tearDown() throws Exception { * Stops the embedded Apache HTTP Server. */ private static void tearDownClass() { - if (Server != null) { - Server.close(); + if (server != null) { + server.close(); } } @@ -121,7 +121,7 @@ private void checkReadTestsFolder(final FileObject file) throws FileSystemExcept public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { String uri = getSystemTestUriOverride(); if (uri == null) { - uri = ConnectionUri; + uri = connectionUri; } return manager.resolveFile(uri); } @@ -194,22 +194,22 @@ private void testResolveFolderSlash(final String uri, final boolean followRedire @Test public void testResolveFolderSlashNoRedirectOff() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests", false); + testResolveFolderSlash(connectionUri + "/read-tests", false); } @Test public void testResolveFolderSlashNoRedirectOn() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests", true); + testResolveFolderSlash(connectionUri + "/read-tests", true); } @Test public void testResolveFolderSlashYesRedirectOff() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests/", false); + testResolveFolderSlash(connectionUri + "/read-tests/", false); } @Test public void testResolveFolderSlashYesRedirectOn() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests/", true); + testResolveFolderSlash(connectionUri + "/read-tests/", true); } } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java index 18c9489fcc..ff62bbd5e0 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java @@ -40,16 +40,16 @@ */ public class Http4ProviderTestCase extends AbstractProviderTestConfig { - private static NHttpFileServer Server; + private static NHttpFileServer server; - private static int SocketPort; + private static int socketPort; private static final String TEST_URI = "test.http.uri"; /** * Use %40 for @ in URLs */ - private static String ConnectionUri; + private static String connectionUri; private static String getSystemTestUriOverride() { return System.getProperty(TEST_URI); @@ -61,9 +61,9 @@ private static String getSystemTestUriOverride() { * @throws Exception */ private static void setUpClass() throws Exception { - Server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000); - SocketPort = Server.getPort(); - ConnectionUri = "http4://localhost:" + SocketPort; + server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000); + socketPort = server.getPort(); + connectionUri = "http4://localhost:" + socketPort; } /** @@ -104,8 +104,8 @@ protected void tearDown() throws Exception { * @throws InterruptedException */ private static void tearDownClass() throws InterruptedException { - if (Server != null) { - Server.shutdown(5000, TimeUnit.SECONDS); + if (server != null) { + server.shutdown(5000, TimeUnit.SECONDS); } } @@ -121,7 +121,7 @@ private void checkReadTestsFolder(final FileObject file) throws FileSystemExcept public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { String uri = getSystemTestUriOverride(); if (uri == null) { - uri = ConnectionUri; + uri = connectionUri; } return manager.resolveFile(uri); } @@ -198,22 +198,22 @@ private void testResolveFolderSlash(final String uri, final boolean followRedire @Test public void testResolveFolderSlashNoRedirectOff() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests", false); + testResolveFolderSlash(connectionUri + "/read-tests", false); } @Test public void testResolveFolderSlashNoRedirectOn() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests", true); + testResolveFolderSlash(connectionUri + "/read-tests", true); } @Test public void testResolveFolderSlashYesRedirectOff() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests/", false); + testResolveFolderSlash(connectionUri + "/read-tests/", false); } @Test public void testResolveFolderSlashYesRedirectOn() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests/", true); + testResolveFolderSlash(connectionUri + "/read-tests/", true); } } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java index 97734a7f36..3eb69c0cc1 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java @@ -40,16 +40,16 @@ */ public class Http5ProviderTestCase extends AbstractProviderTestConfig { - private static NHttpFileServer Server; + private static NHttpFileServer server; - private static int SocketPort; + private static int socketPort; private static final String TEST_URI = "test.http.uri"; /** * Use %40 for @ in URLs */ - private static String ConnectionUri; + private static String connectionUri; private static String getSystemTestUriOverride() { return System.getProperty(TEST_URI); @@ -61,9 +61,9 @@ private static String getSystemTestUriOverride() { * @throws Exception */ private static void setUpClass() throws Exception { - Server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000); - SocketPort = Server.getPort(); - ConnectionUri = "http5://localhost:" + SocketPort; + server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000); + socketPort = server.getPort(); + connectionUri = "http5://localhost:" + socketPort; } /** @@ -104,8 +104,8 @@ protected void tearDown() throws Exception { * @throws InterruptedException */ private static void tearDownClass() throws InterruptedException { - if (Server != null) { - Server.shutdown(5000, TimeUnit.SECONDS); + if (server != null) { + server.shutdown(5000, TimeUnit.SECONDS); } } @@ -121,7 +121,7 @@ private void checkReadTestsFolder(final FileObject file) throws FileSystemExcept public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { String uri = getSystemTestUriOverride(); if (uri == null) { - uri = ConnectionUri; + uri = connectionUri; } return manager.resolveFile(uri); } @@ -192,22 +192,22 @@ private void testResolveFolderSlash(final String uri, final boolean followRedire @Test public void testResolveFolderSlashNoRedirectOff() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests", false); + testResolveFolderSlash(connectionUri + "/read-tests", false); } @Test public void testResolveFolderSlashNoRedirectOn() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests", true); + testResolveFolderSlash(connectionUri + "/read-tests", true); } @Test public void testResolveFolderSlashYesRedirectOff() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests/", false); + testResolveFolderSlash(connectionUri + "/read-tests/", false); } @Test public void testResolveFolderSlashYesRedirectOn() throws FileSystemException { - testResolveFolderSlash(ConnectionUri + "/read-tests/", true); + testResolveFolderSlash(connectionUri + "/read-tests/", true); } } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java index 4492b3a006..c05d4ed21c 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/AbstractSftpProviderTestCase.java @@ -246,7 +246,7 @@ protected void tearDown() throws Exception { // Close all active sessions // Note that it should be done by super.tearDown() // while closing - for (final AbstractSession session : Server.getActiveSessions()) { + for (final AbstractSession session : server.getActiveSessions()) { session.close(true); } tearDownClass(); @@ -421,13 +421,13 @@ static class TestNativeSshFile extends NativeSshFile { } } - private static int SocketPort; + private static int socketPort; private static final String DEFAULT_USER = "testtest"; - protected static String ConnectionUri; + protected static String connectionUri; - protected static SshServer Server; + protected static SshServer server; private static final String TEST_URI = "test.sftp.uri"; @@ -486,14 +486,14 @@ protected static String getSystemTestUriOverride() { * @throws IOException */ private static void setUpClass(final boolean isExecChannelClosed, SessionFactory sessionFactory) throws IOException { - if (Server != null) { + if (server != null) { return; } // System.setProperty("vfs.sftp.sshdir", getTestDirectory() + "/../vfs.sftp.sshdir"); final Path tmpDir = PathUtils.getTempDirectory(); - Server = SshServer.setUpDefaultServer(); - Server.setSessionFactory(sessionFactory); - Server.setPort(0); + server = SshServer.setUpDefaultServer(); + server.setSessionFactory(sessionFactory); + server.setPort(0); if (SecurityUtils.isBouncyCastleRegistered()) { // A temporary file will hold the key final Path keyFile = Files.createTempFile(tmpDir, "key", ".pem"); @@ -502,9 +502,9 @@ private static void setUpClass(final boolean isExecChannelClosed, SessionFactory Files.delete(keyFile); final PEMGeneratorHostKeyProvider keyProvider = new PEMGeneratorHostKeyProvider(keyFile.toAbsolutePath().toString()); - Server.setKeyPairProvider(keyProvider); + server.setKeyPairProvider(keyProvider); } else { - Server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(tmpDir.resolve("key.ser").toString())); + server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(tmpDir.resolve("key.ser").toString())); } final List> list = new ArrayList<>(1); list.add(new NamedFactory() { @@ -519,10 +519,10 @@ public String getName() { return "sftp"; } }); - Server.setSubsystemFactories(list); - Server.setPasswordAuthenticator((username, password, session) -> StringUtils.equals(username, password)); - Server.setPublickeyAuthenticator((username, key, session) -> true); - Server.setForwardingFilter(new ForwardingFilter() { + server.setSubsystemFactories(list); + server.setPasswordAuthenticator((username, password, session) -> StringUtils.equals(username, password)); + server.setPublickeyAuthenticator((username, key, session) -> true); + server.setForwardingFilter(new ForwardingFilter() { @Override public boolean canConnect(final InetSocketAddress address, final ServerSession session) { return true; @@ -544,18 +544,18 @@ public boolean canListen(final InetSocketAddress address, final ServerSession se } }); // Allows the execution of commands - Server.setCommandFactory(new ScpCommandFactory(new TestCommandFactory(isExecChannelClosed))); + server.setCommandFactory(new ScpCommandFactory(new TestCommandFactory(isExecChannelClosed))); // HACK Start // How do we really do simple user to directory matching? - Server.setFileSystemFactory(new TestFileSystemFactory()); + server.setFileSystemFactory(new TestFileSystemFactory()); // HACK End - Server.start(); - SocketPort = Server.getPort(); - ConnectionUri = String.format("sftp://%s@localhost:%d", DEFAULT_USER, SocketPort); + server.start(); + socketPort = server.getPort(); + connectionUri = String.format("sftp://%s@localhost:%d", DEFAULT_USER, socketPort); // HACK Start // How do we really do simple security? // Do this after we start the server to simplify this set up code. - Server.getUserAuthFactories().add(new UserAuthNone.Factory()); + server.getUserAuthFactories().add(new UserAuthNone.Factory()); // HACK End } @@ -565,9 +565,9 @@ public boolean canListen(final InetSocketAddress address, final ServerSession se * @throws InterruptedException */ private static void tearDownClass() throws InterruptedException { - if (Server != null) { - Server.stop(); - Server = null; + if (server != null) { + server.stop(); + server = null; } } @@ -578,7 +578,7 @@ private static void tearDownClass() throws InterruptedException { public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { String uri = getSystemTestUriOverride(); if (uri == null) { - uri = ConnectionUri; + uri = connectionUri; } final FileSystemOptions fileSystemOptions = new FileSystemOptions(); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpPermissionExceptionTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpPermissionExceptionTestCase.java index fb3ba6483b..70169e7893 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpPermissionExceptionTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpPermissionExceptionTestCase.java @@ -106,7 +106,7 @@ public void testGetOutputStreamException() throws Exception { } // try to get created channel number. - final int channelId = Server.getActiveSessions().get(0).registerChannel(new ChannelSession()); + final int channelId = server.getActiveSessions().get(0).registerChannel(new ChannelSession()); Assertions.assertTrue(channelId < 30, "create too many sftp channel more"); // try to set the local file to writable diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpProviderStreamProxyModeTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpProviderStreamProxyModeTestCase.java index f882ce705b..fc5db3bab7 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpProviderStreamProxyModeTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpProviderStreamProxyModeTestCase.java @@ -51,7 +51,7 @@ protected void addBaseTests() throws Exception { public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { String uri = getSystemTestUriOverride(); if (uri == null) { - uri = ConnectionUri; + uri = connectionUri; } final FileSystemOptions fileSystemOptions = new FileSystemOptions(); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpPutChannelTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpPutChannelTestCase.java index 82887d103a..e7b68ca0ee 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpPutChannelTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpPutChannelTestCase.java @@ -103,7 +103,7 @@ public void testDoGetInputStream() throws Exception { Assertions.fail("file should not be exists"); } } catch (final FileSystemException e) { - final int channelsCount = ((CustomServerSession) Server.getActiveSessions().get(0)).getChannelsCount(); + final int channelsCount = ((CustomServerSession) server.getActiveSessions().get(0)).getChannelsCount(); Assertions.assertTrue(channelsCount < MAX_CHANNELS, "channels count expected less than " + MAX_CHANNELS); } } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/test/FileObjectSortTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/test/FileObjectSortTest.java index 15fa550115..fc29c13c5d 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/test/FileObjectSortTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/test/FileObjectSortTest.java @@ -42,13 +42,13 @@ public class FileObjectSortTest { private static final int SIZE = 100; // Consider @Immutable - private static FileSystem VfsFileSystem; + private static FileSystem vfsFileSystem; // Consider @Immutable - private static FileObject[] SortedArray; + private static FileObject[] sortedArray; // Consider @Immutable - private static FileObject[] UnSortedArray; + private static FileObject[] unSortedArray; private static FileObject resolveFile(final FileSystem fs, final int i) throws FileSystemException { return fs.resolveFile(String.format("%010d", i)); @@ -56,14 +56,14 @@ private static FileObject resolveFile(final FileSystem fs, final int i) throws F @BeforeAll public static void setUpClass() throws FileSystemException { - VfsFileSystem = VFS.getManager().createVirtualFileSystem("vfs://").getFileSystem(); - SortedArray = new FileObject[SIZE]; + vfsFileSystem = VFS.getManager().createVirtualFileSystem("vfs://").getFileSystem(); + sortedArray = new FileObject[SIZE]; for (int i = 0; i < SIZE; i++) { - SortedArray[i] = FileObjectSortTest.resolveFile(VfsFileSystem, i); + sortedArray[i] = FileObjectSortTest.resolveFile(vfsFileSystem, i); } - UnSortedArray = new FileObject[SIZE]; + unSortedArray = new FileObject[SIZE]; for (int i = 0; i < SIZE; i++) { - UnSortedArray[i] = FileObjectSortTest.resolveFile(VfsFileSystem, SIZE - i - 1); + unSortedArray[i] = FileObjectSortTest.resolveFile(vfsFileSystem, SIZE - i - 1); } } @@ -74,9 +74,9 @@ public static void setUpClass() throws FileSystemException { */ @Test public void testSortArrayIgnoreCase() throws FileSystemException { - final FileObject file1 = VfsFileSystem.resolveFile("A1"); - final FileObject file2 = VfsFileSystem.resolveFile("a2"); - final FileObject file3 = VfsFileSystem.resolveFile("A3"); + final FileObject file1 = vfsFileSystem.resolveFile("A1"); + final FileObject file2 = vfsFileSystem.resolveFile("a2"); + final FileObject file3 = vfsFileSystem.resolveFile("A3"); final FileObject[] actualArray = { file3, file1, file2, file1, file2 }; final FileObject[] expectedArray = { file1, file1, file2, file2, file3 }; Arrays.sort(actualArray); @@ -88,10 +88,10 @@ public void testSortArrayIgnoreCase() throws FileSystemException { */ @Test public void testSortArrayMoveAll() { - final FileObject[] actualArray = UnSortedArray.clone(); - assertFalse(Arrays.equals(UnSortedArray, SortedArray)); + final FileObject[] actualArray = unSortedArray.clone(); + assertFalse(Arrays.equals(unSortedArray, sortedArray)); Arrays.sort(actualArray); - assertArrayEquals(SortedArray, actualArray); + assertArrayEquals(sortedArray, actualArray); } /** @@ -99,9 +99,9 @@ public void testSortArrayMoveAll() { */ @Test public void testSortArrayMoveNone() { - final FileObject[] actualArray = SortedArray.clone(); + final FileObject[] actualArray = sortedArray.clone(); Arrays.sort(actualArray); - assertArrayEquals(SortedArray, actualArray); + assertArrayEquals(sortedArray, actualArray); } /** @@ -109,8 +109,8 @@ public void testSortArrayMoveNone() { */ @Test public void testSortListMoveAll() { - final List actualList = Arrays.asList(UnSortedArray); - final List expectedSortedList = Arrays.asList(SortedArray); + final List actualList = Arrays.asList(unSortedArray); + final List expectedSortedList = Arrays.asList(sortedArray); assertNotEquals(actualList, expectedSortedList); actualList.sort(null); assertEquals(actualList, expectedSortedList); @@ -121,8 +121,8 @@ public void testSortListMoveAll() { */ @Test public void testSortListMoveNone() { - final List actualList = Arrays.asList(SortedArray); - final List expectedSortedList = Arrays.asList(SortedArray); + final List actualList = Arrays.asList(sortedArray); + final List expectedSortedList = Arrays.asList(sortedArray); actualList.sort(null); assertEquals(actualList, expectedSortedList); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/url/UrlProviderHttpTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/url/UrlProviderHttpTestCase.java index d784f096cf..52ec639d21 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/url/UrlProviderHttpTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/url/UrlProviderHttpTestCase.java @@ -36,16 +36,16 @@ */ public class UrlProviderHttpTestCase extends AbstractProviderTestConfig { - private static NHttpFileServer Server; + private static NHttpFileServer server; - private static int SocketPort; + private static int socketPort; private static final String TEST_URI = "test.http.uri"; /** * Use %40 for @ in URLs */ - private static String ConnectionUri; + private static String connectionUri; public UrlProviderHttpTestCase() throws IOException { // empty @@ -61,9 +61,9 @@ private static String getSystemTestUriOverride() { * @throws Exception */ private static void setUpClass() throws Exception { - Server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000); - SocketPort = Server.getPort(); - ConnectionUri = "http://localhost:" + SocketPort; + server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000); + socketPort = server.getPort(); + connectionUri = "http://localhost:" + socketPort; } public static Test suite() throws Exception { @@ -89,8 +89,8 @@ protected void tearDown() throws Exception { * @throws InterruptedException */ public static void tearDownClass() throws InterruptedException { - if (Server != null) { - Server.shutdown(5000, TimeUnit.SECONDS); + if (server != null) { + server.shutdown(5000, TimeUnit.SECONDS); } } @@ -101,7 +101,7 @@ public static void tearDownClass() throws InterruptedException { public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { String uri = getSystemTestUriOverride(); if (uri == null) { - uri = ConnectionUri; + uri = connectionUri; } return manager.resolveFile(uri); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/NHttpFileServer.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/NHttpFileServer.java index db798d10ad..a2d37579a6 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/NHttpFileServer.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/NHttpFileServer.java @@ -165,7 +165,7 @@ public AsyncRequestConsumer> prepare(final HttpReques } - public static boolean DEBUG = Boolean.getBoolean(NHttpFileServer.class.getSimpleName() + ".debug"); + public static final boolean DEBUG = Boolean.getBoolean(NHttpFileServer.class.getSimpleName() + ".debug"); private final File docRoot; diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/RandomAccessModeTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/RandomAccessModeTest.java index 474894620a..862f50e20f 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/RandomAccessModeTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/RandomAccessModeTest.java @@ -45,29 +45,29 @@ public void test_fromAccessMode() { } @Test - public void test_getModeStringRead() { + public void testGetModeStringRead() { assertEquals("r", RandomAccessMode.READ.getModeString()); } @Test - public void test_getModeStringReadWrite() { + public void testGetModeStringReadWrite() { assertEquals("rw", RandomAccessMode.READWRITE.getModeString()); } @Test - public void test_testRead() { + public void testRead() { assertTrue(RandomAccessMode.READ.requestRead()); assertFalse(RandomAccessMode.READ.requestWrite()); } @Test - public void test_testReadWrite() { + public void testReadWrite() { assertTrue(RandomAccessMode.READWRITE.requestRead()); assertTrue(RandomAccessMode.READWRITE.requestWrite()); } @Test - public void test_toAccessModes() { + public void testToAccessModes() { assertArrayEquals(new AccessMode[] {AccessMode.READ}, RandomAccessMode.READ.toAccessModes()); assertArrayEquals(new AccessMode[] {AccessMode.READ, AccessMode.WRITE}, RandomAccessMode.READWRITE.toAccessModes()); } diff --git a/pom.xml b/pom.xml index d525fa17a9..c4237110f1 100644 --- a/pom.xml +++ b/pom.xml @@ -241,7 +241,7 @@ ${vfs.parent.dir}/checkstyle-suppressions.xml false basedir=${basedir} - + true