Test from Tim to include PropertyList in poi-ooxml-schemas

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1637548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-11-08 12:21:27 +00:00
parent 24effccc61
commit e2dd7f27c0

View File

@ -29,6 +29,7 @@ import java.util.TimeZone;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.POIDataSamples;
import org.apache.poi.openxml4j.OpenXML4JTestDataSamples; import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@ -36,6 +37,8 @@ import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
import org.apache.poi.openxml4j.util.Nullable; import org.apache.poi.openxml4j.util.Nullable;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty;
public final class TestPackageCoreProperties extends TestCase { public final class TestPackageCoreProperties extends TestCase {
private static final POILogger logger = POILogFactory.getLogger(TestPackageCoreProperties.class); private static final POILogger logger = POILogFactory.getLogger(TestPackageCoreProperties.class);
@ -226,4 +229,20 @@ public final class TestPackageCoreProperties extends TestCase {
// Check // Check
assertEquals("Stefan Kopf", props.getCreatorProperty().getValue()); assertEquals("Stefan Kopf", props.getCreatorProperty().getValue());
} }
public void testListOfCustomProperties() throws Exception {
File inp = POIDataSamples.getSpreadSheetInstance().getFile("ExcelWithAttachments.xlsm");
OPCPackage pkg = OPCPackage.open(inp, PackageAccess.READ);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
assertNotNull(wb.getProperties());
assertNotNull(wb.getProperties().getCustomProperties());
for (CTProperty prop : wb.getProperties().getCustomProperties().getUnderlyingProperties().getPropertyList()) {
assertNotNull(prop);
}
wb.close();
pkg.close();
}
} }