mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
some tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1913395 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0d1644282f
commit
8142b56fb8
@ -36,6 +36,7 @@ import org.apache.poi.POIDataSamples;
|
||||
import org.apache.poi.common.usermodel.PictureType;
|
||||
import org.apache.poi.ooxml.POIXMLDocumentPart;
|
||||
import org.apache.poi.ooxml.POIXMLProperties;
|
||||
import org.apache.poi.ooxml.TrackingInputStream;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.openxml4j.opc.PackageAccess;
|
||||
@ -480,6 +481,28 @@ public final class TestXWPFDocument {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInputStreamClosed() throws IOException {
|
||||
try (TrackingInputStream stream = new TrackingInputStream(
|
||||
POIDataSamples.getDocumentInstance().openResourceAsStream("EnforcedWith.docx"))) {
|
||||
try (XWPFDocument docx = new XWPFDocument(stream)) {
|
||||
assertNotNull(docx.getDocument());
|
||||
}
|
||||
assertTrue(stream.isClosed(), "stream was closed?");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInputStreamNotClosedWhenOptionUsed() throws IOException {
|
||||
try (TrackingInputStream stream = new TrackingInputStream(
|
||||
POIDataSamples.getDocumentInstance().openResourceAsStream("EnforcedWith.docx"))) {
|
||||
try (XWPFDocument docx = new XWPFDocument(stream, false)) {
|
||||
assertNotNull(docx.getDocument());
|
||||
}
|
||||
assertFalse(stream.isClosed(), "stream was not closed?");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("XWPF should be able to write to a new Stream when opened Read-Only")
|
||||
void testWriteFromReadOnlyOPC() throws Exception {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user