diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-10-09 13:33:11 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-10-09 13:33:11 +0000 |
commit | 2d7053d6673763b9cf067e639c7e1c555e74abc3 (patch) | |
tree | 98998511be6ee5c48712b253fd746bad00d304ce /poi/src | |
parent | 6659536325b4976f709e95fa372f82bfcda6754c (diff) | |
download | poi-2d7053d6673763b9cf067e639c7e1c555e74abc3.tar.gz poi-2d7053d6673763b9cf067e639c7e1c555e74abc3.zip |
add tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894070 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r-- | poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java index 19314dac17..907529a5d2 100644 --- a/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java +++ b/poi/src/test/java/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java @@ -18,15 +18,11 @@ package org.apache.poi.poifs.filesystem; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; +import static org.junit.jupiter.api.Assertions.*; + +import java.io.*; import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; import java.util.HashMap; import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; @@ -46,7 +42,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; /** - * Tests for the older OPOIFS-based POIFSFileSystem + * Tests for the POIFSFileSystem */ final class TestPOIFSFileSystem { private final POIDataSamples _samples = POIDataSamples.getPOIFSInstance(); @@ -305,6 +301,26 @@ final class TestPOIFSFileSystem { } } + @Test + void test64542CloseChannelFalse() throws IOException { + File file = _samples.getFile("64322.ole2"); + try (FileChannel channel = new RandomAccessFile(file, "r").getChannel()) { + POIFSFileSystem poiFS = new POIFSFileSystem(channel, true, false); + poiFS.close(); + assertTrue(channel.isOpen(), "channel should still be open"); + } + } + + @Test + void test64542CloseChannelTrue() throws IOException { + File file = _samples.getFile("64322.ole2"); + try (FileChannel channel = new RandomAccessFile(file, "r").getChannel()) { + POIFSFileSystem poiFS = new POIFSFileSystem(channel, true, true); + poiFS.close(); + assertFalse(channel.isOpen(), "channel should be closed"); + } + } + private static int recurseDir(DirectoryEntry dir) throws IOException, NoPropertySetStreamException { int count = 0; for (Entry entry : dir) { |