Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/LastModifiedTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/LastModifiedTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/LastModifiedTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/LastModifiedTests.java Thu Sep 14 19:26:39 2017 @@ -28,17 +28,16 @@ import org.junit.Assert; /** * Test cases for getting and setting file last modified time. */ -public class LastModifiedTests extends AbstractProviderTestCase -{ - private void assertDelta(final String message, final long expected, final long actual, final long delta) - { - if (expected == actual) - { +public class LastModifiedTests extends AbstractProviderTestCase { + private void assertDelta(final String message, final long expected, final long actual, final long delta) { + if (expected == actual) { return; } if (Math.abs(expected - actual) > Math.max(delta, 1000)) // getLastModTimeAccuracy() is not accurate { - Assert.fail(String.format("%s expected=%d (%s), actual=%d (%s), delta=%d", message, Long.valueOf(expected), new Date(expected).toString(), Long.valueOf(actual), new Date(actual).toString(), Long.valueOf(delta))); + Assert.fail(String.format("%s expected=%d (%s), actual=%d (%s), delta=%d", message, Long.valueOf(expected), + new Date(expected).toString(), Long.valueOf(actual), new Date(actual).toString(), + Long.valueOf(delta))); } } @@ -46,59 +45,57 @@ public class LastModifiedTests extends A * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { Capability.GET_LAST_MODIFIED }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.GET_LAST_MODIFIED }; } /** * Tests FileSystem#getLastModTimeAccuracy for sane values. + * * @throws FileSystemException if error occurred */ - public void testGetAccurary() throws FileSystemException - { + public void testGetAccurary() throws FileSystemException { final FileObject file = getReadFolder().resolveFile("file1.txt"); - final long lastModTimeAccuracy = (long)file.getFileSystem().getLastModTimeAccuracy(); - // System.out.println("Accuracy on " + file.getFileSystem().getRootURI() + " is " + lastModTimeAccuracy + " as told by " + file.getFileSystem().getClass().getCanonicalName()); - assertTrue("Accuracy must be positive", lastModTimeAccuracy >= 0); - assertTrue("Accuracy must be < 2m", lastModTimeAccuracy < 2 * 60 * 1000); // just any sane limit + final long lastModTimeAccuracy = (long) file.getFileSystem().getLastModTimeAccuracy(); + // System.out.println("Accuracy on " + file.getFileSystem().getRootURI() + " is " + lastModTimeAccuracy + " as + // told by " + file.getFileSystem().getClass().getCanonicalName()); + assertTrue("Accuracy must be positive", lastModTimeAccuracy >= 0); + assertTrue("Accuracy must be < 2m", lastModTimeAccuracy < 2 * 60 * 1000); // just any sane limit } /** * Tests getting the last modified time of a folder. + * * @throws FileSystemException if error occurred */ - public void testGetLastModifiedFolder() throws FileSystemException - { + public void testGetLastModifiedFolder() throws FileSystemException { final FileObject file = getReadFolder().resolveFile("dir1"); - assertNotEquals(0L, file.getContent().getLastModifiedTime()); + assertNotEquals(0L, file.getContent().getLastModifiedTime()); } /** * Tests getting the last modified time of a file. + * * @throws FileSystemException if error occurred */ - public void testGetLastModifiedFile() throws FileSystemException - { + public void testGetLastModifiedFile() throws FileSystemException { final FileObject file = getReadFolder().resolveFile("file1.txt"); - assertNotEquals(0L, file.getContent().getLastModifiedTime()); + assertNotEquals(0L, file.getContent().getLastModifiedTime()); } /** * Tests setting the last modified time of a folder. + * * @throws FileSystemException if error occurred */ - public void testSetLastModifiedFolder() throws FileSystemException - { - final long yesterday = System.currentTimeMillis() - 24*60*60*1000; + public void testSetLastModifiedFolder() throws FileSystemException { + final long yesterday = System.currentTimeMillis() - 24 * 60 * 60 * 1000; - if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER)) - { + if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER)) { // Try a folder final FileObject folder = getReadFolder().resolveFile("dir1"); folder.getContent().setLastModifiedTime(yesterday); - final long lastModTimeAccuracy = (long)folder.getFileSystem().getLastModTimeAccuracy(); + final long lastModTimeAccuracy = (long) folder.getFileSystem().getLastModTimeAccuracy(); // folder.refresh(); TODO: does not work with SSH VFS-563 final long lastModifiedTime = folder.getContent().getLastModifiedTime(); assertDelta("set/getLastModified on Folder", yesterday, lastModifiedTime, lastModTimeAccuracy); @@ -107,18 +104,17 @@ public class LastModifiedTests extends A /** * Tests setting the last modified time of file. + * * @throws FileSystemException if error occurred */ - public void testSetLastModifiedFile() throws FileSystemException - { - final long yesterday = System.currentTimeMillis() - 24*60*60*1000; + public void testSetLastModifiedFile() throws FileSystemException { + final long yesterday = System.currentTimeMillis() - 24 * 60 * 60 * 1000; - if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) - { + if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { // Try a file final FileObject file = getReadFolder().resolveFile("file1.txt"); file.getContent().setLastModifiedTime(yesterday); - final long lastModTimeAccuracy = (long)file.getFileSystem().getLastModTimeAccuracy(); + final long lastModTimeAccuracy = (long) file.getFileSystem().getLastModTimeAccuracy(); // folder.refresh(); TODO: does not work with SSH VFS-563 final long lastModifiedTime = file.getContent().getLastModifiedTime(); assertDelta("set/getLastModified on File", yesterday, lastModifiedTime, lastModTimeAccuracy);
Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/NamingTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/NamingTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/NamingTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/NamingTests.java Thu Sep 14 19:26:39 2017 @@ -26,14 +26,11 @@ import org.apache.commons.vfs2.NameScope * <p> * TODO - Add tests for all FileName methods. */ -public class NamingTests - extends AbstractProviderTestCase -{ +public class NamingTests extends AbstractProviderTestCase { /** * Tests resolution of relative file names via the FS manager */ - public void testRelativeURI() throws Exception - { + public void testRelativeURI() throws Exception { // Build base dir getManager().setBaseFile(getReadFolder()); @@ -60,8 +57,7 @@ public class NamingTests /** * Tests encoding of relative URI. */ - public void testRelativeUriEncoding() throws Exception - { + public void testRelativeUriEncoding() throws Exception { // Build base dir getManager().setBaseFile(getReadFolder()); final String path = getReadFolder().getName().getPath(); @@ -93,33 +89,24 @@ public class NamingTests assertEquals(path + "/dir/child", file.getName().getPathDecoded()); // §6 Use "%" literal - try - { + try { getManager().resolveFile("%"); fail(); - } - catch (final FileSystemException e) - { + } catch (final FileSystemException e) { } // §7 Not enough digits in encoded char - try - { + try { getManager().resolveFile("%5"); fail(); - } - catch (final FileSystemException e) - { + } catch (final FileSystemException e) { } // §8 Invalid digit in encoded char - try - { + try { getManager().resolveFile("%q"); fail(); - } - catch (final FileSystemException e) - { + } catch (final FileSystemException e) { } // free basefile @@ -129,8 +116,7 @@ public class NamingTests /** * Tests the root file name. */ - public void testRootFileName() throws Exception - { + public void testRootFileName() throws Exception { // Locate the root file final FileName rootName = getReadFolder().getFileSystem().getRoot().getName(); @@ -147,8 +133,7 @@ public class NamingTests /** * Tests child file names. */ - public void testChildName() throws Exception - { + public void testChildName() throws Exception { final FileName baseName = getReadFolder().getName(); final String basePath = baseName.getPath(); final FileName name = getManager().resolveName(baseName, "some-child", NameScope.CHILD); @@ -175,10 +160,7 @@ public class NamingTests /** * Name resolution tests that are common for CHILD or DESCENDENT scope. */ - private void checkDescendentNames(final FileName name, - final NameScope scope) - throws Exception - { + private void checkDescendentNames(final FileName name, final NameScope scope) throws Exception { // Make some assumptions about the name assertTrue(!name.getPath().equals("/")); assertTrue(!name.getPath().endsWith("/a")); @@ -211,15 +193,10 @@ public class NamingTests } /** - * Checks that a relative name resolves to the expected absolute path. - * Tests both forward and back slashes. + * Checks that a relative name resolves to the expected absolute path. Tests both forward and back slashes. */ - private void assertSameName(final String expectedPath, - final FileName baseName, - final String relName, - final NameScope scope) - throws Exception - { + private void assertSameName(final String expectedPath, final FileName baseName, final String relName, + final NameScope scope) throws Exception { // Try the supplied name FileName name = getManager().resolveName(baseName, relName, scope); assertEquals(expectedPath, name.getPath()); @@ -238,21 +215,17 @@ public class NamingTests } /** - * Checks that a relative name resolves to the expected absolute path. - * Tests both forward and back slashes. + * Checks that a relative name resolves to the expected absolute path. Tests both forward and back slashes. */ - private void assertSameName(final String expectedPath, - final FileName baseName, - final String relName) throws Exception - { + private void assertSameName(final String expectedPath, final FileName baseName, final String relName) + throws Exception { assertSameName(expectedPath, baseName, relName, NameScope.FILE_SYSTEM); } /** * Tests relative name resolution, relative to the base folder. */ - public void testNameResolution() throws Exception - { + public void testNameResolution() throws Exception { final FileName baseName = getReadFolder().getName(); final String parentPath = baseName.getParent().getPath(); final String path = baseName.getPath(); @@ -312,9 +285,7 @@ public class NamingTests /** * Tests descendent name resolution. */ - public void testDescendentName() - throws Exception - { + public void testDescendentName() throws Exception { final FileName baseName = getReadFolder().getName(); // Test direct child @@ -337,8 +308,7 @@ public class NamingTests /** * Tests resolution of absolute names. */ - public void testAbsoluteNames() throws Exception - { + public void testAbsoluteNames() throws Exception { // Test against the base folder FileName name = getReadFolder().getName(); checkAbsoluteNames(name); @@ -355,8 +325,7 @@ public class NamingTests /** * Tests resolution of absolute names. */ - private void checkAbsoluteNames(final FileName name) throws Exception - { + private void checkAbsoluteNames(final FileName name) throws Exception { // Root assertSameName("/", name, "/"); assertSameName("/", name, "//"); @@ -375,20 +344,13 @@ public class NamingTests } /** - * Asserts that a particular relative name is invalid for a particular - * scope. + * Asserts that a particular relative name is invalid for a particular scope. */ - private void assertBadName(final FileName name, - final String relName, - final NameScope scope) - { - try - { + private void assertBadName(final FileName name, final String relName, final NameScope scope) { + try { getManager().resolveName(name, relName, scope); fail("expected failure"); - } - catch (final FileSystemException e) - { + } catch (final FileSystemException e) { // TODO - should check error message } } @@ -396,8 +358,7 @@ public class NamingTests /** * Tests conversion from absolute to relative names. */ - public void testAbsoluteNameConvert() throws Exception - { + public void testAbsoluteNameConvert() throws Exception { final FileName baseName = getReadFolder().getName(); String path = "/test1/test2"; @@ -446,10 +407,7 @@ public class NamingTests /** * Checks that a file name converts to an expected relative path */ - private void testRelName(final FileName baseName, - final String relPath) - throws Exception - { + private void testRelName(final FileName baseName, final String relPath) throws Exception { final FileName expectedName = getManager().resolveName(baseName, relPath); // Convert to relative path, and check Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/PermissionsTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/PermissionsTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/PermissionsTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/PermissionsTests.java Thu Sep 14 19:26:39 2017 @@ -32,39 +32,29 @@ import org.apache.commons.vfs2.provider. * * @since 2.1 */ -public class PermissionsTests extends AbstractProviderTestCase -{ +public class PermissionsTests extends AbstractProviderTestCase { public static final String FILENAME = "permission.txt"; /** * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.CREATE, - Capability.DELETE, - Capability.READ_CONTENT, - Capability.WRITE_CONTENT, - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.CREATE, Capability.DELETE, Capability.READ_CONTENT, + Capability.WRITE_CONTENT, }; } /** * Tests for the execution permission. */ - public void testExecutable() throws Exception - { + public void testExecutable() throws Exception { final FileObject file = createTestFile(); // On Windows, all files are executable - if (isWindows()) - { + if (isWindows()) { Assert.assertTrue(file.isExecutable()); - } else - { + } else { // Set the executable flag for owner file.setExecutable(true, true); Assert.assertTrue(file.isExecutable()); @@ -79,12 +69,10 @@ public class PermissionsTests extends Ab } } - /** * Tests for the writeable permission */ - public void testWriteable() throws Exception - { + public void testWriteable() throws Exception { final FileObject file = createTestFile(); // Set the write permission for owner @@ -100,21 +88,16 @@ public class PermissionsTests extends Ab Assert.assertFalse(file.isWriteable()); } - /** * Tests for the readable permission */ - public void testReadable() throws Exception - { + public void testReadable() throws Exception { final FileObject file = createTestFile(); - if (isWindows()) - { + if (isWindows()) { // On Windows, all owned files are readable Assert.assertTrue(file.isReadable()); - } - else - { + } else { // Set the readable permission for owner file.setReadable(true, true); Assert.assertTrue(file.isReadable()); @@ -129,14 +112,11 @@ public class PermissionsTests extends Ab } } - /** * Clean up the permission-modified file to not affect other tests. */ @Override - protected void tearDown() - throws Exception - { + protected void tearDown() throws Exception { final FileObject scratchFolder = getWriteFolder(); final FileObject file = scratchFolder.resolveFile(FILENAME); file.setWritable(true, true); @@ -145,9 +125,7 @@ public class PermissionsTests extends Ab super.tearDown(); } - - private FileObject createTestFile() throws Exception - { + private FileObject createTestFile() throws Exception { // Get the scratch folder final FileObject scratchFolder = getWriteFolder(); assertNotNull(scratchFolder); @@ -164,23 +142,18 @@ public class PermissionsTests extends Ab final String content = "Here is some sample content for the file. Blah Blah Blah."; final OutputStream os = file.getContent().getOutputStream(); - try - { + try { os.write(content.getBytes("utf-8")); - } - finally - { + } finally { os.close(); } return file; } - /** * Returns true if the filesystem is a LocalFileSystem on Windows */ - private boolean isWindows() - { + private boolean isWindows() { return SystemUtils.IS_OS_WINDOWS && this.getFileSystem() instanceof LocalFileSystem; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderCacheStrategyTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderCacheStrategyTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderCacheStrategyTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderCacheStrategyTests.java Thu Sep 14 19:26:39 2017 @@ -28,32 +28,22 @@ import org.apache.commons.vfs2.util.File /** * Test the cache stragey */ -public class ProviderCacheStrategyTests - extends AbstractProviderTestCase -{ +public class ProviderCacheStrategyTests extends AbstractProviderTestCase { /** * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.CREATE, - Capability.GET_TYPE, - Capability.LIST_CHILDREN, - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.CREATE, Capability.GET_TYPE, Capability.LIST_CHILDREN, }; } /** * Test the manual cache strategy */ - public void testManualCache() throws Exception - { + public void testManualCache() throws Exception { final FileObject scratchFolder = getWriteFolder(); - if (FileObjectUtils.isInstanceOf(getBaseFolder(), RamFileObject.class) || - scratchFolder.getFileSystem() instanceof VirtualFileSystem) - { + if (FileObjectUtils.isInstanceOf(getBaseFolder(), RamFileObject.class) + || scratchFolder.getFileSystem() instanceof VirtualFileSystem) { // cant check ram filesystem as every manager holds its own ram filesystem data return; } @@ -83,12 +73,10 @@ public class ProviderCacheStrategyTests /** * Test the on_resolve strategy */ - public void testOnResolveCache() throws Exception - { + public void testOnResolveCache() throws Exception { final FileObject scratchFolder = getWriteFolder(); - if (FileObjectUtils.isInstanceOf(getBaseFolder(), RamFileObject.class) || - scratchFolder.getFileSystem() instanceof VirtualFileSystem) - { + if (FileObjectUtils.isInstanceOf(getBaseFolder(), RamFileObject.class) + || scratchFolder.getFileSystem() instanceof VirtualFileSystem) { // cant check ram filesystem as every manager holds its own ram filesystem data return; } @@ -118,12 +106,10 @@ public class ProviderCacheStrategyTests /** * Test the on_call strategy */ - public void testOnCallCache() throws Exception - { + public void testOnCallCache() throws Exception { final FileObject scratchFolder = getWriteFolder(); - if (FileObjectUtils.isInstanceOf(getBaseFolder(), RamFileObject.class) || - scratchFolder.getFileSystem() instanceof VirtualFileSystem) - { + if (FileObjectUtils.isInstanceOf(getBaseFolder(), RamFileObject.class) + || scratchFolder.getFileSystem() instanceof VirtualFileSystem) { // cant check ram filesystem as every manager holds its own ram filesystem data return; } @@ -146,23 +132,17 @@ public class ProviderCacheStrategyTests assertContains(fos, "file1.txt"); } - public void assertContainsNot(final FileObject[] fos, final String string) - { - for (final FileObject fo : fos) - { - if (string.equals(fo.getName().getBaseName())) - { + public void assertContainsNot(final FileObject[] fos, final String string) { + for (final FileObject fo : fos) { + if (string.equals(fo.getName().getBaseName())) { fail(string + " should not be seen"); } } } - public void assertContains(final FileObject[] fos, final String string) - { - for (final FileObject fo : fos) - { - if (string.equals(fo.getName().getBaseName())) - { + public void assertContains(final FileObject[] fos, final String string) { + for (final FileObject fo : fos) { + if (string.equals(fo.getName().getBaseName())) { return; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderDeleteTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderDeleteTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderDeleteTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderDeleteTests.java Thu Sep 14 19:26:39 2017 @@ -27,27 +27,21 @@ import org.apache.commons.vfs2.Selectors /** * File system test that do some delete operations. */ -public class ProviderDeleteTests - extends AbstractProviderTestCase -{ - private class FileNameSelector implements FileSelector - { +public class ProviderDeleteTests extends AbstractProviderTestCase { + private class FileNameSelector implements FileSelector { final String basename; - private FileNameSelector(final String basename) - { + private FileNameSelector(final String basename) { this.basename = basename; } @Override - public boolean includeFile(final FileSelectInfo fileInfo) throws Exception - { + public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { return this.basename.equals(fileInfo.getFile().getName().getBaseName()); } @Override - public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception - { + public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception { return true; } } @@ -56,22 +50,15 @@ public class ProviderDeleteTests * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.CREATE, - Capability.DELETE, - Capability.GET_TYPE, - Capability.LIST_CHILDREN, - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.CREATE, Capability.DELETE, Capability.GET_TYPE, + Capability.LIST_CHILDREN, }; } /** * Sets up a scratch folder for the test to use. */ - protected FileObject createScratchFolder() throws Exception - { + protected FileObject createScratchFolder() throws Exception { final FileObject scratchFolder = getWriteFolder(); // Make sure the test folder is empty @@ -93,8 +80,7 @@ public class ProviderDeleteTests /** * deletes the complete structure */ - public void testDeleteFiles() throws Exception - { + public void testDeleteFiles() throws Exception { final FileObject scratchFolder = createScratchFolder(); assertEquals(scratchFolder.delete(Selectors.EXCLUDE_SELF), 4); @@ -103,8 +89,7 @@ public class ProviderDeleteTests /** * deletes a single file */ - public void testDeleteFile() throws Exception - { + public void testDeleteFile() throws Exception { final FileObject scratchFolder = createScratchFolder(); final FileObject file = scratchFolder.resolveFile("dir1/a.txt"); @@ -115,8 +100,7 @@ public class ProviderDeleteTests /** * Deletes a non existent file */ - public void testDeleteNonExistantFile() throws Exception - { + public void testDeleteNonExistantFile() throws Exception { final FileObject scratchFolder = createScratchFolder(); final FileObject file = scratchFolder.resolveFile("dir1/aa.txt"); @@ -127,8 +111,7 @@ public class ProviderDeleteTests /** * deletes files */ - public void testDeleteAllFiles() throws Exception - { + public void testDeleteAllFiles() throws Exception { final FileObject scratchFolder = createScratchFolder(); assertEquals(scratchFolder.delete(new FileTypeSelector(FileType.FILE)), 2); @@ -137,8 +120,7 @@ public class ProviderDeleteTests /** * deletes a.txt */ - public void testDeleteOneFiles() throws Exception - { + public void testDeleteOneFiles() throws Exception { final FileObject scratchFolder = createScratchFolder(); assertEquals(scratchFolder.delete(new FileNameSelector("a.txt")), 1); Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomReadTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomReadTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomReadTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomReadTests.java Thu Sep 14 19:26:39 2017 @@ -26,32 +26,23 @@ import org.apache.commons.vfs2.util.Rand * * @version $Id$ */ -public class ProviderRandomReadTests - extends AbstractProviderTestCase -{ +public class ProviderRandomReadTests extends AbstractProviderTestCase { private static final String TEST_DATA = "This is a test file."; /** * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.GET_TYPE, - Capability.RANDOM_ACCESS_READ - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.GET_TYPE, Capability.RANDOM_ACCESS_READ }; } /** * Read a file */ - public void testRandomRead() throws Exception - { + public void testRandomRead() throws Exception { FileObject file = null; - try - { + try { file = getReadFolder().resolveFile("file1.txt"); final RandomAccessContent ra = file.getContent().getRandomAccessContent(RandomAccessMode.READ); @@ -89,11 +80,8 @@ public class ProviderRandomReadTests c = ra.readByte(); assertEquals(c, TEST_DATA.charAt(11)); assertEquals("fp", ra.getFilePointer(), 12); - } - finally - { - if (file != null) - { + } finally { + if (file != null) { file.close(); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomReadWriteTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomReadWriteTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomReadWriteTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomReadWriteTests.java Thu Sep 14 19:26:39 2017 @@ -27,31 +27,22 @@ import org.apache.commons.vfs2.util.Rand * * @version $Id$ */ -public class ProviderRandomReadWriteTests - extends AbstractProviderTestCase -{ +public class ProviderRandomReadWriteTests extends AbstractProviderTestCase { private static final String TEST_DATA = "This is a test file."; /** * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.GET_TYPE, - Capability.CREATE, - Capability.RANDOM_ACCESS_READ, - Capability.RANDOM_ACCESS_WRITE - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.GET_TYPE, Capability.CREATE, Capability.RANDOM_ACCESS_READ, + Capability.RANDOM_ACCESS_WRITE }; } /** * Sets up a scratch folder for the test to use. */ - protected FileObject createScratchFolder() throws Exception - { + protected FileObject createScratchFolder() throws Exception { final FileObject scratchFolder = getWriteFolder(); // Make sure the test folder is empty @@ -64,11 +55,9 @@ public class ProviderRandomReadWriteTest /** * Writes a file */ - public void testRandomWrite() throws Exception - { + public void testRandomWrite() throws Exception { FileObject file = null; - try - { + try { file = createScratchFolder().resolveFile("random_write.txt"); file.createFile(); final RandomAccessContent ra = file.getContent().getRandomAccessContent(RandomAccessMode.READWRITE); @@ -102,11 +91,8 @@ public class ProviderRandomReadWriteTest ra.seek(10); assertEquals(ra.readByte(), TEST_DATA.charAt(10)); assertEquals(ra.readByte(), TEST_DATA.charAt(11)); - } - finally - { - if (file != null) - { + } finally { + if (file != null) { file.close(); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomSetLengthTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomSetLengthTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomSetLengthTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRandomSetLengthTests.java Thu Sep 14 19:26:39 2017 @@ -30,15 +30,13 @@ import org.junit.Assert; * * @version $Id$ */ -public class ProviderRandomSetLengthTests extends AbstractProviderTestCase -{ +public class ProviderRandomSetLengthTests extends AbstractProviderTestCase { private static final String TEST_DATA = "This is a test file."; /** * Sets up a scratch folder for the test to use. */ - protected FileObject createScratchFolder() throws Exception - { + protected FileObject createScratchFolder() throws Exception { final FileObject scratchFolder = this.getWriteFolder(); // Make sure the test folder is empty @@ -52,24 +50,17 @@ public class ProviderRandomSetLengthTest * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.GET_TYPE, - Capability.RANDOM_ACCESS_READ, - Capability.RANDOM_ACCESS_WRITE, + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.GET_TYPE, Capability.RANDOM_ACCESS_READ, Capability.RANDOM_ACCESS_WRITE, Capability.RANDOM_ACCESS_SET_LENGTH }; } /** * Writes a file */ - public void testRandomSetLength() throws Exception - { + public void testRandomSetLength() throws Exception { FileObject file = null; - try - { + try { file = this.createScratchFolder().resolveFile("random_write.txt"); file.createFile(); final RandomAccessContent ra = file.getContent().getRandomAccessContent(RandomAccessMode.READWRITE); @@ -85,12 +76,10 @@ public class ProviderRandomSetLengthTest ra.seek(0); Assert.assertEquals(ra.readByte(), TEST_DATA.charAt(0)); - try - { + try { ra.readByte(); Assert.fail("Expected " + Exception.class.getName()); - } catch (final IOException e) - { + } catch (final IOException e) { // Expected } @@ -101,10 +90,8 @@ public class ProviderRandomSetLengthTest ra.seek(1); ra.readByte(); - } finally - { - if (file != null) - { + } finally { + if (file != null) { file.close(); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java Thu Sep 14 19:26:39 2017 @@ -36,8 +36,7 @@ import org.junit.Assert; * <p> * TODO - Test getLastModified(), getAttribute(). */ -public class ProviderReadTests extends AbstractProviderTestCase -{ +public class ProviderReadTests extends AbstractProviderTestCase { /** * Returns the read folder named "dir1". @@ -45,8 +44,7 @@ public class ProviderReadTests extends A * @return the read folder named "dir1". * @throws FileSystemException */ - protected FileObject getReadFolderDir1() throws FileSystemException - { + protected FileObject getReadFolderDir1() throws FileSystemException { return getReadFolder().resolveFile("dir1"); } @@ -54,17 +52,14 @@ public class ProviderReadTests extends A * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { Capability.GET_TYPE, Capability.LIST_CHILDREN, Capability.READ_CONTENT }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.GET_TYPE, Capability.LIST_CHILDREN, Capability.READ_CONTENT }; } /** * Walks the base folder structure, asserting it contains exactly the expected files and folders. */ - public void testStructure() throws Exception - { + public void testStructure() throws Exception { final FileInfo baseInfo = buildExpectedStructure(); assertSameStructure(getReadFolder(), baseInfo); } @@ -72,8 +67,7 @@ public class ProviderReadTests extends A /** * Walks a folder structure, asserting it contains exactly the expected files and folders. */ - protected void assertSameStructure(final FileObject folder, final FileInfo expected) throws Exception - { + protected void assertSameStructure(final FileObject folder, final FileInfo expected) throws Exception { // Setup the structure final List<FileInfo> queueExpected = new ArrayList<>(); queueExpected.add(expected); @@ -81,16 +75,14 @@ public class ProviderReadTests extends A final List<FileObject> queueActual = new ArrayList<>(); queueActual.add(folder); - while (queueActual.size() > 0) - { + while (queueActual.size() > 0) { final FileObject file = queueActual.remove(0); final FileInfo info = queueExpected.remove(0); // Check the type is correct assertSame(info.type, file.getType()); - if (info.type == FileType.FILE) - { + if (info.type == FileType.FILE) { continue; } @@ -100,12 +92,9 @@ public class ProviderReadTests extends A // Make sure all children were found assertNotNull(children); int length = children.length; - if (info.children.size() != children.length) - { - for (final FileObject element : children) - { - if (element.getName().getBaseName().startsWith(".")) - { + if (info.children.size() != children.length) { + for (final FileObject element : children) { + if (element.getName().getBaseName().startsWith(".")) { --length; continue; } @@ -116,11 +105,9 @@ public class ProviderReadTests extends A assertEquals("count children of \"" + file.getName() + "\"", info.children.size(), length); // Recursively check each child - for (final FileObject child : children) - { + for (final FileObject child : children) { final String childName = child.getName().getBaseName(); - if (childName.startsWith(".")) - { + if (childName.startsWith(".")) { continue; } final FileInfo childInfo = info.children.get(childName); @@ -138,8 +125,7 @@ public class ProviderReadTests extends A /** * Tests type determination. */ - public void testType() throws Exception - { + public void testType() throws Exception { // Test a file FileObject file = resolveFile1Txt(); assertSame(FileType.FILE, file.getType()); @@ -158,10 +144,8 @@ public class ProviderReadTests extends A /** * Tests the contents of root of file system can be listed. */ - public void testRoot() throws FileSystemException - { - if (!this.getProviderConfig().isFileSystemRootAccessible()) - { + public void testRoot() throws FileSystemException { + if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } final FileSystem fs = getFileSystem(); @@ -173,8 +157,7 @@ public class ProviderReadTests extends A /** * Tests that FileObjects can be sorted. */ - public void testSort() throws FileSystemException - { + public void testSort() throws FileSystemException { final FileInfo fileInfo = buildExpectedStructure(); final VerifyingFileSelector selector = new VerifyingFileSelector(fileInfo); @@ -182,8 +165,7 @@ public class ProviderReadTests extends A final FileObject[] actualFiles = getReadFolder().findFiles(selector); Arrays.sort(actualFiles); FileObject prevActualFile = actualFiles[0]; - for (final FileObject actualFile : actualFiles) - { + for (final FileObject actualFile : actualFiles) { assertTrue(prevActualFile.toString().compareTo(actualFile.toString()) <= 0); prevActualFile = actualFile; } @@ -193,8 +175,7 @@ public class ProviderReadTests extends A Collections.sort(expectedFiles); assertEquals(expectedFiles.size(), actualFiles.length); final int count = expectedFiles.size(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { final FileObject expected = expectedFiles.get(i); final FileObject actual = actualFiles[i]; assertEquals(expected, actual); @@ -204,22 +185,18 @@ public class ProviderReadTests extends A /** * Tests that folders have no content. */ - public void testFolderContent() throws Exception - { - if (getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT)) - { + public void testFolderContent() throws Exception { + if (getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT)) { // test wont fail return; } // Try getting the content of a folder final FileObject folder = getReadFolderDir1(); - try - { + try { folder.getContent().getInputStream(); fail(); - } catch (final FileSystemException e) - { + } catch (final FileSystemException e) { assertSameMessage("vfs.provider/read-not-file.error", folder, e); } } @@ -227,8 +204,7 @@ public class ProviderReadTests extends A /** * Tests that test read folder is not hidden. */ - public void testFolderIsHidden() throws Exception - { + public void testFolderIsHidden() throws Exception { final FileObject folder = getReadFolderDir1(); Assert.assertFalse(folder.isHidden()); } @@ -236,22 +212,19 @@ public class ProviderReadTests extends A /** * Tests that test read folder is readable. */ - public void testFolderIsReadable() throws Exception - { + public void testFolderIsReadable() throws Exception { final FileObject folder = getReadFolderDir1(); Assert.assertTrue(folder.isReadable()); } - public void testGetContent() throws Exception - { + public void testGetContent() throws Exception { final FileObject file = resolveFile1Txt(); assertTrue(file.exists()); final FileContent content = file.getContent(); assertNotNull(content); } - public void testGetContentInfo() throws Exception - { + public void testGetContentInfo() throws Exception { final FileObject file = resolveFile1Txt(); assertTrue(file.exists()); final FileContent content = file.getContent(); @@ -260,32 +233,26 @@ public class ProviderReadTests extends A assertNotNull(contentInfo); } - private FileObject resolveFile1Txt() throws FileSystemException - { + private FileObject resolveFile1Txt() throws FileSystemException { return getReadFolder().resolveFile("file1.txt"); } /** * Tests can read multiple time end of stream of empty file */ - public void testReadEmptyMultipleEOF() throws Exception - { + public void testReadEmptyMultipleEOF() throws Exception { final FileObject file = getReadFolder().resolveFile("empty.txt"); assertTrue(file.exists()); // Start reading from the file final InputStream instr = file.getContent().getInputStream(); - try - { + try { assertEquals("read() from empty file should return EOF", -1, instr.read()); - for(int i=0;i<5;i++) - { + for (int i = 0; i < 5; i++) { assertEquals("multiple read() at EOF should return EOF", -1, instr.read()); } - } - finally - { + } finally { instr.close(); } } @@ -293,26 +260,21 @@ public class ProviderReadTests extends A /** * Tests can read multiple time end of stream */ - public void testReadFileEOFMultiple() throws Exception - { + public void testReadFileEOFMultiple() throws Exception { final FileObject file = getReadFolder().resolveFile("file1.txt"); assertTrue(file.exists()); assertEquals("Expecting 20 bytes test-data file1.txt", 20, file.getContent().getSize()); // Start reading from the file final InputStream instr = file.getContent().getInputStream(); - try - { + try { final byte[] buf = new byte[25]; assertEquals(20, instr.read(buf)); - for(int i=0;i<5;i++) - { + for (int i = 0; i < 5; i++) { assertEquals("multiple read(byte[]) at EOF should return EOF", -1, instr.read(buf)); } - } - finally - { + } finally { instr.close(); } } @@ -320,8 +282,7 @@ public class ProviderReadTests extends A /** * Tests can perform operations on a folder while reading from a different files. */ - public void testConcurrentReadFolder() throws Exception - { + public void testConcurrentReadFolder() throws Exception { final FileObject file = resolveFile1Txt(); assertTrue(file.exists()); final FileObject folder = getReadFolderDir1(); @@ -329,14 +290,12 @@ public class ProviderReadTests extends A // Start reading from the file final InputStream instr = file.getContent().getInputStream(); - try - { + try { // Do some operations folder.exists(); folder.getType(); folder.getChildren(); - } finally - { + } finally { instr.close(); } } @@ -344,8 +303,7 @@ public class ProviderReadTests extends A /** * Tests that findFiles() works. */ - public void testFindFiles() throws Exception - { + public void testFindFiles() throws Exception { final FileInfo fileInfo = buildExpectedStructure(); final VerifyingFileSelector selector = new VerifyingFileSelector(fileInfo); @@ -356,8 +314,7 @@ public class ProviderReadTests extends A final List<FileObject> expectedFiles = selector.finish(); assertEquals(expectedFiles.size(), actualFiles.length); final int count = expectedFiles.size(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { final FileObject expected = expectedFiles.get(i); final FileObject actual = actualFiles[i]; assertEquals(expected, actual); @@ -367,8 +324,7 @@ public class ProviderReadTests extends A /** * Tests that we can traverse a folder that has JAR name. */ - public void testDotJarFolderName() throws Exception - { + public void testDotJarFolderName() throws Exception { final FileObject folder = getReadFolderDir1().resolveFile("subdir4.jar"); Assert.assertTrue(folder.exists()); final FileObject file = folder.resolveFile("file1.txt"); @@ -378,19 +334,16 @@ public class ProviderReadTests extends A /** * Tests that a folder can't be layered. */ - public void testDotJarFolderNameLayer() throws Exception - { + public void testDotJarFolderNameLayer() throws Exception { final FileObject folder = getReadFolderDir1().resolveFile("subdir4.jar"); Assert.assertTrue("subdir4.jar/ must exist as folder, check test setup.", folder.isFolder()); Assert.assertFalse("subdir4.jar/ must not be layerable", getManager().canCreateFileSystem(folder)); - try - { + try { final FileObject ignored = getManager().createFileSystem(folder); fail("Should not be able to create a layered filesystem on a directory. " + ignored); - } - catch (final FileSystemException e) - { - assertSame("Creation of layered filesystem should fail" + e, "vfs.impl/no-provider-for-file.error", e.getCode()); + } catch (final FileSystemException e) { + assertSame("Creation of layered filesystem should fail" + e, "vfs.impl/no-provider-for-file.error", + e.getCode()); } } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRenameTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRenameTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRenameTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderRenameTests.java Thu Sep 14 19:26:39 2017 @@ -28,32 +28,20 @@ import org.apache.commons.vfs2.Selectors /** * File system test that check that a file system can be renamed. */ -public class ProviderRenameTests - extends AbstractProviderTestCase -{ +public class ProviderRenameTests extends AbstractProviderTestCase { /** * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.CREATE, - Capability.DELETE, - Capability.GET_TYPE, - Capability.LIST_CHILDREN, - Capability.READ_CONTENT, - Capability.WRITE_CONTENT, - Capability.RENAME - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.CREATE, Capability.DELETE, Capability.GET_TYPE, Capability.LIST_CHILDREN, + Capability.READ_CONTENT, Capability.WRITE_CONTENT, Capability.RENAME }; } /** * Sets up a scratch folder for the test to use. */ - protected FileObject createScratchFolder() throws Exception - { + protected FileObject createScratchFolder() throws Exception { final FileObject scratchFolder = getWriteFolder(); // Make sure the test folder is empty @@ -64,8 +52,7 @@ public class ProviderRenameTests } private void moveFile(final FileObject scratchFolder, final FileObject file, final String content) - throws FileSystemException, Exception - { + throws FileSystemException, Exception { final FileObject fileMove = scratchFolder.resolveFile("file1move.txt"); assertTrue(!fileMove.exists()); @@ -81,19 +68,15 @@ public class ProviderRenameTests assertTrue(fileMove.delete()); } - private String createTestFile(final FileObject file) throws FileSystemException, IOException, - UnsupportedEncodingException, Exception - { + private String createTestFile(final FileObject file) + throws FileSystemException, IOException, UnsupportedEncodingException, Exception { // Create the source file final String content = "Here is some sample content for the file. Blah Blah Blah."; final OutputStream os = file.getContent().getOutputStream(); - try - { + try { os.write(content.getBytes("utf-8")); - } - finally - { + } finally { os.close(); } assertSameContent(content, file); @@ -103,8 +86,7 @@ public class ProviderRenameTests /** * Tests create-delete-create-a-file sequence on the same file system. */ - public void testRenameFile() throws Exception - { + public void testRenameFile() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -122,8 +104,7 @@ public class ProviderRenameTests * <P> * This fails with VFS-558, but only with a CacheStrategy.ON_CALL. */ - public void testRenameFileIntoEmptyFolder() throws Exception - { + public void testRenameFileIntoEmptyFolder() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -145,8 +126,7 @@ public class ProviderRenameTests * * See [VFS-298] FTP: Exception is thrown when renaming a file. */ - public void testRenameFileAndLeaveFolderEmpty() throws Exception - { + public void testRenameFileAndLeaveFolderEmpty() throws Exception { final FileObject scratchFolder = createScratchFolder(); final FileObject folder = scratchFolder.resolveFile("folder"); folder.createFolder(); Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderTestSuite.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderTestSuite.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderTestSuite.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderTestSuite.java Thu Sep 14 19:26:39 2017 @@ -21,34 +21,23 @@ import org.apache.commons.vfs2.impl.test /** * The suite of tests for a file system. */ -public class ProviderTestSuite - extends AbstractTestSuite -{ +public class ProviderTestSuite extends AbstractTestSuite { /** * Adds the tests for a file system to this suite. */ - public ProviderTestSuite(final ProviderTestConfig providerConfig) throws Exception - { + public ProviderTestSuite(final ProviderTestConfig providerConfig) throws Exception { this(providerConfig, "", false, false); } /** * Adds the tests for a file system to this suite. Provider has an empty directory. */ - public ProviderTestSuite(final ProviderTestConfig providerConfig, - final boolean addEmptyDir) throws Exception - { + public ProviderTestSuite(final ProviderTestConfig providerConfig, final boolean addEmptyDir) throws Exception { this(providerConfig, "", false, addEmptyDir); } - - - protected ProviderTestSuite(final ProviderTestConfig providerConfig, - final String prefix, - final boolean nested, - final boolean addEmptyDir) - throws Exception - { + protected ProviderTestSuite(final ProviderTestConfig providerConfig, final String prefix, final boolean nested, + final boolean addEmptyDir) throws Exception { super(providerConfig, prefix, nested, addEmptyDir); } @@ -56,8 +45,7 @@ public class ProviderTestSuite * Adds base tests - excludes the nested test cases. */ @Override - protected void addBaseTests() throws Exception - { + protected void addBaseTests() throws Exception { addTests(ProviderCacheStrategyTests.class); addTests(UriTests.class); addTests(NamingTests.class); Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderWriteAppendTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderWriteAppendTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderWriteAppendTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderWriteAppendTests.java Thu Sep 14 19:26:39 2017 @@ -25,32 +25,20 @@ import org.apache.commons.vfs2.Selectors /** * File system test that check that a file system can be modified. */ -public class ProviderWriteAppendTests - extends AbstractProviderTestCase -{ +public class ProviderWriteAppendTests extends AbstractProviderTestCase { /** * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.CREATE, - Capability.DELETE, - Capability.GET_TYPE, - Capability.LIST_CHILDREN, - Capability.READ_CONTENT, - Capability.WRITE_CONTENT, - Capability.APPEND_CONTENT - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.CREATE, Capability.DELETE, Capability.GET_TYPE, Capability.LIST_CHILDREN, + Capability.READ_CONTENT, Capability.WRITE_CONTENT, Capability.APPEND_CONTENT }; } /** * Sets up a scratch folder for the test to use. */ - protected FileObject createScratchFolder() throws Exception - { + protected FileObject createScratchFolder() throws Exception { final FileObject scratchFolder = getWriteFolder(); // Make sure the test folder is empty @@ -63,8 +51,7 @@ public class ProviderWriteAppendTests /** * Tests create-delete-create-a-file sequence on the same file system. */ - public void testAppendContent() throws Exception - { + public void testAppendContent() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -76,24 +63,18 @@ public class ProviderWriteAppendTests final String contentAppend = content + content; final OutputStream os = file.getContent().getOutputStream(); - try - { + try { os.write(content.getBytes("utf-8")); - } - finally - { + } finally { os.close(); } assertSameContent(content, file); // Append to the new file final OutputStream os2 = file.getContent().getOutputStream(true); - try - { + try { os2.write(content.getBytes("utf-8")); - } - finally - { + } finally { os2.close(); } assertSameContent(contentAppend, file); Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java Thu Sep 14 19:26:39 2017 @@ -35,12 +35,9 @@ import org.junit.Assert; /** * File system test that check that a file system can be modified. */ -public class ProviderWriteTests - extends AbstractProviderTestCase -{ +public class ProviderWriteTests extends AbstractProviderTestCase { - protected FileObject getReadFolderDir1() throws FileSystemException - { + protected FileObject getReadFolderDir1() throws FileSystemException { return getReadFolder().resolveFile("dir1"); } @@ -48,24 +45,15 @@ public class ProviderWriteTests * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.CREATE, - Capability.DELETE, - Capability.GET_TYPE, - Capability.LIST_CHILDREN, - Capability.READ_CONTENT, - Capability.WRITE_CONTENT - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.CREATE, Capability.DELETE, Capability.GET_TYPE, Capability.LIST_CHILDREN, + Capability.READ_CONTENT, Capability.WRITE_CONTENT }; } /** * Sets up a scratch folder for the test to use. */ - protected FileObject createScratchFolder() throws Exception - { + protected FileObject createScratchFolder() throws Exception { final FileObject scratchFolder = getWriteFolder(); // Make sure the test folder is empty @@ -78,8 +66,7 @@ public class ProviderWriteTests /** * Tests folder creation. */ - public void testFolderCreate() throws Exception - { + public void testFolderCreate() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -112,8 +99,7 @@ public class ProviderWriteTests /** * Tests file creation */ - public void testFileCreate() throws Exception - { + public void testFileCreate() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -166,8 +152,7 @@ public class ProviderWriteTests /** * Tests file/folder creation with mismatched types. */ - public void testFileCreateMismatched() throws Exception - { + public void testFileCreateMismatched() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create a test file and folder @@ -182,42 +167,32 @@ public class ProviderWriteTests assertTrue(folder.isFolder()); // Attempt to create a file that already exists as a folder - try - { + try { folder.createFile(); fail(); - } - catch (final FileSystemException exc) - { + } catch (final FileSystemException exc) { } // Attempt to create a folder that already exists as a file - try - { + try { file.createFolder(); fail(); - } - catch (final FileSystemException exc) - { + } catch (final FileSystemException exc) { } // Attempt to create a folder as a child of a file final FileObject folder2 = file.resolveFile("some-child"); - try - { + try { folder2.createFolder(); fail(); - } - catch (final FileSystemException exc) - { + } catch (final FileSystemException exc) { } } /** * Tests deletion */ - public void testDelete() throws Exception - { + public void testDelete() throws Exception { // Set-up the test structure final FileObject folder = createScratchFolder(); folder.resolveFile("file1.txt").createFile(); @@ -263,8 +238,7 @@ public class ProviderWriteTests /** * Tests deletion */ - public void testDeleteAllDescendents() throws Exception - { + public void testDeleteAllDescendents() throws Exception { // Set-up the test structure final FileObject folder = createScratchFolder(); folder.resolveFile("file1.txt").createFile(); @@ -310,79 +284,44 @@ public class ProviderWriteTests /** * Tests concurrent read and write on the same file fails. */ - /* [email protected] leave this to some sort of LockManager - public void testConcurrentReadWrite() throws Exception - { - final FileObject scratchFolder = createScratchFolder(); - - final FileObject file = scratchFolder.resolveFile("file1.txt"); - file.createFile(); - - // Start reading from the file - final InputStream instr = file.getContent().getInputStream(); - - try - { - // Try to write to the file - file.getContent().getOutputStream(); - fail(); - } - catch (final FileSystemException e) - { - // Check error message - assertSameMessage("vfs.provider/write-in-use.error", file, e); - } - finally - { - instr.close(); - } - } - */ + /* + * [email protected] leave this to some sort of LockManager public void testConcurrentReadWrite() throws Exception { + * final FileObject scratchFolder = createScratchFolder(); + * + * final FileObject file = scratchFolder.resolveFile("file1.txt"); file.createFile(); + * + * // Start reading from the file final InputStream instr = file.getContent().getInputStream(); + * + * try { // Try to write to the file file.getContent().getOutputStream(); fail(); } catch (final FileSystemException + * e) { // Check error message assertSameMessage("vfs.provider/write-in-use.error", file, e); } finally { + * instr.close(); } } + */ /** * Tests concurrent writes on the same file fails. */ - /* [email protected] leave this to some sort of LockManager - public void testConcurrentWrite() throws Exception - { - final FileObject scratchFolder = createScratchFolder(); - - final FileObject file = scratchFolder.resolveFile("file1.txt"); - file.createFile(); - - // Start writing to the file - final OutputStream outstr = file.getContent().getOutputStream(); - final String testContent = "some content"; - try - { - // Write some content to the first stream - outstr.write(testContent.getBytes()); - - // Try to open another output stream - file.getContent().getOutputStream(); - fail(); - } - catch (final FileSystemException e) - { - // Check error message - assertSameMessage("vfs.provider/write-in-use.error", file, e); - } - finally - { - outstr.close(); - } - - // Make sure that the content written to the first stream is actually applied - assertSameContent(testContent, file); - } - */ + /* + * [email protected] leave this to some sort of LockManager public void testConcurrentWrite() throws Exception { + * final FileObject scratchFolder = createScratchFolder(); + * + * final FileObject file = scratchFolder.resolveFile("file1.txt"); file.createFile(); + * + * // Start writing to the file final OutputStream outstr = file.getContent().getOutputStream(); final String + * testContent = "some content"; try { // Write some content to the first stream + * outstr.write(testContent.getBytes()); + * + * // Try to open another output stream file.getContent().getOutputStream(); fail(); } catch (final + * FileSystemException e) { // Check error message assertSameMessage("vfs.provider/write-in-use.error", file, e); } + * finally { outstr.close(); } + * + * // Make sure that the content written to the first stream is actually applied assertSameContent(testContent, + * file); } + */ /** - * Tests file copy to and from the same filesystem type. This was a problem - * w/ FTP. + * Tests file copy to and from the same filesystem type. This was a problem w/ FTP. */ - public void testCopySameFileSystem() throws Exception - { + public void testCopySameFileSystem() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -392,12 +331,9 @@ public class ProviderWriteTests // Create the source file final String content = "Here is some sample content for the file. Blah Blah Blah."; final OutputStream os = file.getContent().getOutputStream(); - try - { + try { os.write(content.getBytes("utf-8")); - } - finally - { + } finally { os.close(); } @@ -414,8 +350,7 @@ public class ProviderWriteTests /** * Tests overwriting a file on the same file system. */ - public void testCopyFromOverwriteSameFileSystem() throws Exception - { + public void testCopyFromOverwriteSameFileSystem() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -425,12 +360,9 @@ public class ProviderWriteTests // Create the source file final String content = "Here is some sample content for the file. Blah Blah Blah."; final OutputStream os = file.getContent().getOutputStream(); - try - { + try { os.write(content.getBytes("utf-8")); - } - finally - { + } finally { os.close(); } @@ -453,8 +385,7 @@ public class ProviderWriteTests /** * Tests create-delete-create-a-file sequence on the same file system. */ - public void testCreateDeleteCreateSameFileSystem() throws Exception - { + public void testCreateDeleteCreateSameFileSystem() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -464,12 +395,9 @@ public class ProviderWriteTests // Create the source file final String content = "Here is some sample content for the file. Blah Blah Blah."; final OutputStream os = file.getContent().getOutputStream(); - try - { + try { os.write(content.getBytes("utf-8")); - } - finally - { + } finally { os.close(); } @@ -496,8 +424,7 @@ public class ProviderWriteTests /** * Tests that test read folder is not hidden. */ - public void testFolderIsHidden() throws Exception - { + public void testFolderIsHidden() throws Exception { final FileObject folder = getReadFolderDir1(); Assert.assertFalse(folder.isHidden()); } @@ -505,8 +432,7 @@ public class ProviderWriteTests /** * Tests that test read folder is readable. */ - public void testFolderIsReadable() throws Exception - { + public void testFolderIsReadable() throws Exception { final FileObject folder = getReadFolderDir1(); Assert.assertTrue(folder.isReadable()); } @@ -514,8 +440,7 @@ public class ProviderWriteTests /** * Tests that test folder iswritable. */ - public void testFolderIsWritable() throws Exception - { + public void testFolderIsWritable() throws Exception { final FileObject folder = getWriteFolder().resolveFile("dir1"); Assert.assertTrue(folder.isWriteable()); } @@ -523,8 +448,7 @@ public class ProviderWriteTests /** * Test that children are handled correctly by create and delete. */ - public void testListChildren() throws Exception - { + public void testListChildren() throws Exception { final FileObject folder = createScratchFolder(); final HashSet<String> names = new HashSet<>(); @@ -571,8 +495,7 @@ public class ProviderWriteTests /** * Check listeners are notified of changes. */ - public void testListener() throws Exception - { + public void testListener() throws Exception { final FileObject baseFile = createScratchFolder(); final FileObject child = baseFile.resolveFile("newfile.txt"); @@ -581,8 +504,7 @@ public class ProviderWriteTests final FileSystem fs = baseFile.getFileSystem(); final TestListener listener = new TestListener(child); fs.addListener(child, listener); - try - { + try { // Create as a folder listener.addCreateEvent(); child.createFolder(); @@ -626,23 +548,20 @@ public class ProviderWriteTests child.copyFrom(otherChild, Selectors.SELECT_SELF); listener.assertFinished(); + } finally { + fs.removeListener(child, listener); } - finally - { - fs.removeListener(child, listener);} } /** * Ensures the names of a set of files match an expected set. */ - private void assertSameFileSet(final Set<String> names, final FileObject[] files) - { + private void assertSameFileSet(final Set<String> names, final FileObject[] files) { // Make sure the sets are the same length assertEquals(names.size(), files.length); // Check for unexpected names - for (final FileObject file : files) - { + for (final FileObject file : files) { assertTrue(names.contains(file.getName().getBaseName())); } } @@ -650,16 +569,14 @@ public class ProviderWriteTests /** * A test listener. */ - private static class TestListener implements FileListener - { + private static class TestListener implements FileListener { private final FileObject file; private final ArrayList<Object> events = new ArrayList<>(); private static final Object CREATE = "create"; private static final Object DELETE = "delete"; private static final Object CHANGED = "changed"; - public TestListener(final FileObject file) - { + public TestListener(final FileObject file) { this.file = file; } @@ -667,17 +584,13 @@ public class ProviderWriteTests * Called when a file is created. */ @Override - public void fileCreated(final FileChangeEvent event) - { + public void fileCreated(final FileChangeEvent event) { assertTrue("Unexpected create event", events.size() > 0); assertSame("Expecting a create event", CREATE, events.remove(0)); assertEquals(file, event.getFile()); - try - { + try { assertTrue(file.exists()); - } - catch (final FileSystemException e) - { + } catch (final FileSystemException e) { fail(); } } @@ -686,49 +599,38 @@ public class ProviderWriteTests * Called when a file is deleted. */ @Override - public void fileDeleted(final FileChangeEvent event) - { + public void fileDeleted(final FileChangeEvent event) { assertTrue("Unexpected delete event", events.size() > 0); assertSame("Expecting a delete event", DELETE, events.remove(0)); assertEquals(file, event.getFile()); - try - { + try { assertTrue(!file.exists()); - } - catch (final FileSystemException e) - { + } catch (final FileSystemException e) { fail(); } } @Override - public void fileChanged(final FileChangeEvent event) throws Exception - { + public void fileChanged(final FileChangeEvent event) throws Exception { assertTrue("Unexpected changed event", events.size() > 0); assertSame("Expecting a changed event", CHANGED, events.remove(0)); assertEquals(file, event.getFile()); - try - { + try { assertTrue(!file.exists()); - } - catch (final FileSystemException e) - { + } catch (final FileSystemException e) { fail(); } } - public void addCreateEvent() - { + public void addCreateEvent() { events.add(CREATE); } - public void addDeleteEvent() - { + public void addDeleteEvent() { events.add(DELETE); } - public void assertFinished() - { + public void assertFinished() { assertEquals("Missing event", 0, events.size()); } } @@ -736,8 +638,7 @@ public class ProviderWriteTests /** * Tests file write to and from the same filesystem type */ - public void testWriteSameFileSystem() throws Exception - { + public void testWriteSameFileSystem() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -747,12 +648,9 @@ public class ProviderWriteTests // Create the source file final String expectedString = "Here is some sample content for the file. Blah Blah Blah."; final OutputStream expectedOutputStream = fileSource.getContent().getOutputStream(); - try - { + try { expectedOutputStream.write(expectedString.getBytes("utf-8")); - } - finally - { + } finally { expectedOutputStream.close(); } @@ -790,8 +688,7 @@ public class ProviderWriteTests /** * Tests overwriting a file on the same file system. */ - public void testOverwriteSameFileSystem() throws Exception - { + public void testOverwriteSameFileSystem() throws Exception { final FileObject scratchFolder = createScratchFolder(); // Create direct child of the test folder @@ -801,12 +698,9 @@ public class ProviderWriteTests // Create the source file final String content = "Here is some sample content for the file. Blah Blah Blah."; final OutputStream os = file.getContent().getOutputStream(); - try - { + try { os.write(content.getBytes("utf-8")); - } - finally - { + } finally { os.close(); } @@ -836,8 +730,7 @@ public class ProviderWriteTests OutputStream outputStream = fileCopy.getContent().getOutputStream(); try { file.getContent().write(outputStream); - } - finally { + } finally { outputStream.close(); } assertSameContent(content, fileCopy); @@ -847,11 +740,10 @@ public class ProviderWriteTests outputStream = fileCopy.getContent().getOutputStream(); try { file.getContent().write(outputStream, 1234); - } - finally { + } finally { outputStream.close(); } assertSameContent(content, fileCopy); - } + } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UriTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UriTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UriTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UriTests.java Thu Sep 14 19:26:39 2017 @@ -23,23 +23,19 @@ import org.apache.commons.vfs2.FileObjec /** * Absolute URI test cases. */ -public class UriTests - extends AbstractProviderTestCase -{ +public class UriTests extends AbstractProviderTestCase { /** * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[]{Capability.URI}; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.URI }; } /** * Tests resolution of absolute URI. */ - public void testAbsoluteURI() throws Exception - { + public void testAbsoluteURI() throws Exception { final FileObject readFolder = getReadFolder(); // Try fetching base folder again by its URI Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UrlStructureTests.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UrlStructureTests.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UrlStructureTests.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/test/UrlStructureTests.java Thu Sep 14 19:26:39 2017 @@ -24,30 +24,21 @@ import org.apache.commons.vfs2.FileObjec /** * URL Test cases for providers that supply structural info. */ -public class UrlStructureTests - extends AbstractProviderTestCase -{ +public class UrlStructureTests extends AbstractProviderTestCase { /** * Returns the capabilities required by the tests of this test case. */ @Override - protected Capability[] getRequiredCaps() - { - return new Capability[] - { - Capability.GET_TYPE, - Capability.URI - }; + protected Capability[] getRequiredCaps() { + return new Capability[] { Capability.GET_TYPE, Capability.URI }; } /** * Tests that folders have no content. */ - public void testFolderURL() throws Exception - { + public void testFolderURL() throws Exception { final FileObject folder = getReadFolder().resolveFile("dir1"); - if (folder.getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT)) - { + if (folder.getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT)) { // test might not fail on e.g. HttpFileSystem as there are no direcotries. // A Directory do have a content on http. e.g a generated directory listing or the index.html page. return; @@ -56,13 +47,10 @@ public class UrlStructureTests assertTrue(folder.exists()); // Try getting the content of a folder - try - { + try { folder.getURL().openConnection().getInputStream(); fail(); - } - catch (final IOException e) - { + } catch (final IOException e) { assertSameMessage("vfs.provider/read-not-file.error", folder, e); } }
