Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 96B17200CF7 for ; Tue, 19 Sep 2017 19:59:03 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 954781609E0; Tue, 19 Sep 2017 17:59:03 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DAB831609BF for ; Tue, 19 Sep 2017 19:59:02 +0200 (CEST) Received: (qmail 34233 invoked by uid 500); 19 Sep 2017 17:59:02 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 34224 invoked by uid 99); 19 Sep 2017 17:59:02 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2017 17:59:02 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 8A5EC3A01A6 for ; Tue, 19 Sep 2017 17:58:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1808921 - /commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ZipFileObjectTestCase.java Date: Tue, 19 Sep 2017 17:58:57 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170919175900.8A5EC3A01A6@svn01-us-west.apache.org> archived-at: Tue, 19 Sep 2017 17:59:03 -0000 Author: ggregory Date: Tue Sep 19 17:58:56 2017 New Revision: 1808921 URL: http://svn.apache.org/viewvc?rev=1808921&view=rev Log: Better assertion messages. Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ZipFileObjectTestCase.java Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ZipFileObjectTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ZipFileObjectTestCase.java?rev=1808921&r1=1808920&r2=1808921&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ZipFileObjectTestCase.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/zip/test/ZipFileObjectTestCase.java Tue Sep 19 17:58:56 2017 @@ -50,14 +50,18 @@ public class ZipFileObjectTestCase { private void getInputStreamAndAssert(final FileObject fileObject, final String expectedId) throws FileSystemException, IOException { - readAndAssert(fileObject.getContent().getInputStream(), expectedId); + readAndAssert(fileObject, fileObject.getContent().getInputStream(), expectedId); } - private void readAndAssert(final InputStream inputStream, final String expectedId) throws IOException { - final String string = IOUtils.toString(inputStream, "UTF-8"); - Assert.assertNotNull(string); - Assert.assertEquals("" + System.lineSeparator() + "foo" + expectedId + "" + System.lineSeparator(), string); + private void readAndAssert(final FileObject fileObject, final InputStream inputStream, final String expectedId) + throws IOException { + final String streamData = IOUtils.toString(inputStream, "UTF-8"); + final String fileObjectString = fileObject.toString(); + Assert.assertNotNull(fileObjectString, streamData); + Assert.assertEquals( + fileObjectString, "" + System.lineSeparator() + "foo" + expectedId + "" + System.lineSeparator(), + streamData); } /** @@ -91,7 +95,7 @@ public class ZipFileObjectTestCase { try (final FileObject zipFileObject = manager.resolveFile("zip:file:" + newZipFile.getAbsolutePath())) { try (final FileObject zipFileObject1 = zipFileObject.resolveFile(NESTED_FILE_1)) { try (final InputStream inputStream = zipFileObject1.getContent().getInputStream()) { - readAndAssert(inputStream, "1"); + readAndAssert(zipFileObject1, inputStream, "1"); } } resolveReadAssert(zipFileObject, NESTED_FILE_2); @@ -103,7 +107,7 @@ public class ZipFileObjectTestCase { throws IOException, FileSystemException { try (final FileObject zipFileObject2 = zipFileObject.resolveFile(path)) { try (final InputStream inputStream = zipFileObject2.getContent().getInputStream()) { - readAndAssert(inputStream, "2"); + readAndAssert(zipFileObject2, inputStream, "2"); } } } @@ -126,7 +130,7 @@ public class ZipFileObjectTestCase { inputStream1 = zipFileObject1.getContent().getInputStream(); } // The zip file is "closed", but we read from the stream now. - readAndAssert(inputStream1, "1"); + readAndAssert(zipFileObject1, inputStream1, "1"); // clean up zipFileObject1.close(); assertDelete(newZipFile); @@ -153,7 +157,7 @@ public class ZipFileObjectTestCase { } // The zip file is "closed", but we read from the stream now, which currently fails. // Solve this by counting open streams and only closing when all streams are closed? - readAndAssert(inputStream1, "1"); + readAndAssert(zipFileObject1, inputStream1, "1"); // clean up zipFileObject1.close(); assertDelete(newZipFile);