poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1746653 - in /poi/trunk/src/ooxml: java/org/apache/poi/POIXMLDocument.java testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
Date Thu, 02 Jun 2016 22:59:48 GMT
Author: nick
Date: Thu Jun  2 22:59:47 2016
New Revision: 1746653

URL: http://svn.apache.org/viewvc?rev=1746653&view=rev
Log:
Add disabled test for XWPF writing to a new stream when opened read-only

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java?rev=1746653&r1=1746652&r2=1746653&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java Thu Jun  2 22:59:47 2016
@@ -174,6 +174,7 @@ public abstract class POIXMLDocument ext
      */
     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();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java?rev=1746653&r1=1746652&r2=1746653&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java Thu
Jun  2 22:59:47 2016
@@ -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());
+	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message