Author: ggregory Date: Mon Jan 28 15:31:41 2019 New Revision: 1852381 URL: http://svn.apache.org/viewvc?rev=1852381&view=rev Log: Close FileObject resources in HTTP tests. Trying to fix build on Linux. Tests already all pass on Windows 10 and macOS.
Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/GetContentInfoFunctionalTest.java commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpFilesCacheTestCase.java commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpProviderTestCase.java Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/GetContentInfoFunctionalTest.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/GetContentInfoFunctionalTest.java?rev=1852381&r1=1852380&r2=1852381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/GetContentInfoFunctionalTest.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/GetContentInfoFunctionalTest.java Mon Jan 28 15:31:41 2019 @@ -39,10 +39,11 @@ public class GetContentInfoFunctionalTes @Test public void testGetContentInfo() throws FileSystemException { final FileSystemManager fsManager = VFS.getManager(); - final FileObject fo = fsManager.resolveFile("http://www.apache.org/licenses/LICENSE-2.0.txt"); - final FileContent content = fo.getContent(); - Assert.assertNotNull(content); - // Used to NPE before fix: - content.getContentInfo(); + try (final FileObject fo = fsManager.resolveFile("http://www.apache.org/licenses/LICENSE-2.0.txt"); + final FileContent content = fo.getContent();) { + Assert.assertNotNull(content); + // Used to NPE before fix: + content.getContentInfo(); + } } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpFilesCacheTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpFilesCacheTestCase.java?rev=1852381&r1=1852380&r2=1852381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpFilesCacheTestCase.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpFilesCacheTestCase.java Mon Jan 28 15:31:41 2019 @@ -28,7 +28,8 @@ import org.junit.Test; /** * Tests https://issues.apache.org/jira/browse/VFS-426 * - * @version $Id$ + * @version $Id: HttpFilesCacheTestCase.java 1808381 2017-09-14 19:26:39Z + * ggregory $ * @since 2.1 */ public class HttpFilesCacheTestCase extends TestCase { @@ -44,13 +45,16 @@ public class HttpFilesCacheTestCase exte final FileSystemManager fileSystemManager = VFS.getManager(); - final FileObject noQueryFile = fileSystemManager.resolveFile(noQueryStringUrl); - Assert.assertEquals(noQueryStringUrl, noQueryFile.getURL().toExternalForm()); + try (final FileObject noQueryFile = fileSystemManager.resolveFile(noQueryStringUrl)) { + Assert.assertEquals(noQueryStringUrl, noQueryFile.getURL().toExternalForm()); + } - final FileObject queryFile = fileSystemManager.resolveFile(queryStringUrl); - Assert.assertEquals(queryStringUrl, queryFile.getURL().toExternalForm()); // failed for VFS-426 + try (final FileObject queryFile = fileSystemManager.resolveFile(queryStringUrl)) { + Assert.assertEquals(queryStringUrl, queryFile.getURL().toExternalForm()); // failed for VFS-426 + } - final FileObject queryFile2 = fileSystemManager.resolveFile(queryStringUrl2); - Assert.assertEquals(queryStringUrl2, queryFile2.getURL().toExternalForm()); // failed for VFS-426 + try (final FileObject queryFile2 = fileSystemManager.resolveFile(queryStringUrl2)) { + Assert.assertEquals(queryStringUrl2, queryFile2.getURL().toExternalForm()); // failed for VFS-426 + } } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpProviderTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpProviderTestCase.java?rev=1852381&r1=1852380&r2=1852381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpProviderTestCase.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/test/HttpProviderTestCase.java Mon Jan 28 15:31:41 2019 @@ -150,8 +150,7 @@ public class HttpProviderTestCase extend VFS.getManager().getFilesCache().close(); final FileSystemOptions opts = new FileSystemOptions(); HttpFileSystemConfigBuilder.getInstance().setFollowRedirect(opts, followRedirect); - final FileObject file = VFS.getManager().resolveFile(uri, opts); - try { + try (final FileObject file = VFS.getManager().resolveFile(uri, opts)) { checkReadTestsFolder(file); } catch (final FileNotFolderException e) { // Expected: VFS HTTP does not support listing children yet. @@ -176,9 +175,10 @@ public class HttpProviderTestCase extend // Test no longer passing 2016/04/28 public void ignoreTestHttp405() throws FileSystemException { - final FileObject f = VFS.getManager() - .resolveFile("http://www.w3schools.com/webservices/tempconvert.asmx?action=WSDL"); - assert f.getContent().getSize() > 0; + try (final FileObject fileObject = VFS.getManager() + .resolveFile("http://www.w3schools.com/webservices/tempconvert.asmx?action=WSDL")) { + assert fileObject.getContent().getSize() > 0; + } } /** Ensure VFS-453 options are present. */