You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2009/08/14 19:27:13 UTC
svn commit: r804305 - in /poi/trunk/src/ooxml/testcases/org/apache/poi: ./
ooxml/data/
Author: yegor
Date: Fri Aug 14 17:27:12 2009
New Revision: 804305
URL: http://svn.apache.org/viewvc?rev=804305&view=rev
Log:
renamed macro-enabled test files to have the correct extentions
Added:
poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/data/ExcelWithAttachments.xlsm
- copied unchanged from r802999, poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/data/ExcelWithAttachments.xlsx
poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/data/PPTWithAttachments.pptm
- copied unchanged from r802999, poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/data/PPTWithAttachments.pptx
Removed:
poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/data/ExcelWithAttachments.xlsx
poi/trunk/src/ooxml/testcases/org/apache/poi/ooxml/data/PPTWithAttachments.pptx
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/TestEmbeded.java
poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java
poi/trunk/src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/TestEmbeded.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/TestEmbeded.java?rev=804305&r1=804304&r2=804305&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/TestEmbeded.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/TestEmbeded.java Fri Aug 14 17:27:12 2009
@@ -44,7 +44,7 @@
}
public void testExcel() throws Exception {
- File f = new File(dirname, "ExcelWithAttachments.xlsx");
+ File f = new File(dirname, "ExcelWithAttachments.xlsm");
assertTrue(f.exists());
POIXMLDocument doc = new XSSFWorkbook(OPCPackage.open(f.toString()));
@@ -60,7 +60,7 @@
}
public void testPowerPoint() throws Exception {
- File f = new File(dirname, "PPTWithAttachments.pptx");
+ File f = new File(dirname, "PPTWithAttachments.pptm");
assertTrue(f.exists());
POIXMLDocument doc = new XSLFSlideShow(OPCPackage.open(f.toString()));
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java?rev=804305&r1=804304&r2=804305&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLDocument.java Fri Aug 14 17:27:12 2009
@@ -24,12 +24,9 @@
import java.io.FileOutputStream;
import java.util.List;
import java.util.ArrayList;
+import java.util.HashMap;
-import org.apache.poi.util.IOUtils;
import org.apache.poi.util.TempFile;
-import org.apache.poi.xslf.XSLFSlideShow;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
@@ -69,12 +66,32 @@
}
+ /**
+ * Recursively traverse a OOXML document and assert that same logical parts have the same physical instances
+ */
+ private static void traverse(POIXMLDocumentPart part, HashMap<String,POIXMLDocumentPart> context) throws IOException{
+ context.put(part.getPackageRelationship().getTargetURI().toString(), part);
+ for(POIXMLDocumentPart p : part.getRelations()){
+ String uri = p.getPackageRelationship().getTargetURI().toString();
+ if (!context.containsKey(uri)) {
+ traverse(p, context);
+ } else {
+ POIXMLDocumentPart prev = context.get(uri);
+ assertSame("Duplicate POIXMLDocumentPart instance for targetURI=" + uri, prev, p);
+ }
+ }
+ }
+
public void assertReadWrite(String path) throws Exception {
OPCPackage pkg1 = OPCPackage.open(path);
OPCParser doc = new OPCParser(pkg1);
doc.parse(new TestFactory());
+ HashMap<String,POIXMLDocumentPart> context = new HashMap<String,POIXMLDocumentPart>();
+ traverse(doc, context);
+ context.clear();
+
File tmp = TempFile.createTempFile("poi-ooxml", ".tmp");
FileOutputStream out = new FileOutputStream(tmp);
doc.write(out);
@@ -82,6 +99,12 @@
OPCPackage pkg2 = OPCPackage.open(tmp.getAbsolutePath());
+ doc = new OPCParser(pkg1);
+ doc.parse(new TestFactory());
+ context = new HashMap<String,POIXMLDocumentPart>();
+ traverse(doc, context);
+ context.clear();
+
assertEquals(pkg1.getRelationships().size(), pkg2.getRelationships().size());
ArrayList<PackagePart> l1 = pkg1.getParts();
@@ -102,12 +125,12 @@
}
public void testPPTX() throws Exception {
- File file = new File(System.getProperty("OOXML.testdata.path"), "PPTWithAttachments.pptx");
+ File file = new File(System.getProperty("OOXML.testdata.path"), "PPTWithAttachments.pptm");
assertReadWrite(file.getAbsolutePath());
}
public void testXLSX() throws Exception {
- File file = new File(System.getProperty("OOXML.testdata.path"), "ExcelWithAttachments.xlsx");
+ File file = new File(System.getProperty("OOXML.testdata.path"), "ExcelWithAttachments.xlsm");
assertReadWrite(file.getAbsolutePath());
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java?rev=804305&r1=804304&r2=804305&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java Fri Aug 14 17:27:12 2009
@@ -34,7 +34,7 @@
public void testGetFromMainExtractor() throws Exception {
OPCPackage pkg = OPCPackage.open(
- (new File(dirname, "ExcelWithAttachments.xlsx")).toString()
+ (new File(dirname, "ExcelWithAttachments.xlsm")).toString()
);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
@@ -55,7 +55,7 @@
public void testCore() throws Exception {
OPCPackage pkg = OPCPackage.open(
- (new File(dirname, "ExcelWithAttachments.xlsx")).toString()
+ (new File(dirname, "ExcelWithAttachments.xlsm")).toString()
);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
@@ -72,7 +72,7 @@
public void testExtended() throws Exception {
OPCPackage pkg = OPCPackage.open(
- (new File(dirname, "ExcelWithAttachments.xlsx")).toString()
+ (new File(dirname, "ExcelWithAttachments.xlsm")).toString()
);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
@@ -82,7 +82,6 @@
// Now check
String text = ext.getText();
String eText = ext.getExtendedPropertiesText();
- System.out.println(eText);
assertTrue(text.contains("Application = Microsoft Excel"));
assertTrue(text.contains("Company = Mera"));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org