Add disabled test for XWPF writing to a new stream when opened read-only
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1746653 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1fdbf14e1e
commit
52537ae58e
@ -174,6 +174,7 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
|
||||
*/
|
||||
public final void write(OutputStream stream) throws IOException {
|
||||
//force all children to commit their changes into the underlying OOXML Package
|
||||
// TODO Shouldn't they be committing to the new one instead?
|
||||
Set<PackagePart> context = new HashSet<PackagePart>();
|
||||
onSave(context);
|
||||
context.clear();
|
||||
|
@ -19,22 +19,27 @@ package org.apache.poi.xwpf.usermodel;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.POIDataSamples;
|
||||
import org.apache.poi.POIXMLDocumentPart;
|
||||
import org.apache.poi.POIXMLProperties;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.openxml4j.opc.PackageAccess;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackagePartName;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
|
||||
import org.apache.poi.openxml4j.opc.TargetMode;
|
||||
import org.apache.poi.xwpf.XWPFTestDataSamples;
|
||||
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
||||
import org.apache.xmlbeans.XmlCursor;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
|
||||
|
||||
@ -423,4 +428,21 @@ public final class TestXWPFDocument {
|
||||
assertTrue(docx.isEnforcedProtection());
|
||||
docx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("XWPF should be able to write to a new Stream when opened Read-Only")
|
||||
public void testWriteFromReadOnlyOPC() throws Exception {
|
||||
OPCPackage opc = OPCPackage.open(
|
||||
POIDataSamples.getDocumentInstance().getFile("SampleDoc.docx"),
|
||||
PackageAccess.READ
|
||||
);
|
||||
XWPFDocument doc = new XWPFDocument(opc);
|
||||
XWPFWordExtractor ext = new XWPFWordExtractor(doc);
|
||||
String origText = ext.getText();
|
||||
|
||||
doc = XWPFTestDataSamples.writeOutAndReadBack(doc);
|
||||
ext = new XWPFWordExtractor(doc);
|
||||
|
||||
assertEquals(origText, ext.getText());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user