poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r755699 [6/7] - in /poi/trunk/src: examples/src/org/apache/poi/xssf/eventusermodel/examples/ ooxml/java/org/apache/poi/ ooxml/java/org/apache/poi/dev/ ooxml/java/org/apache/poi/extractor/ ooxml/java/org/apache/poi/openxml4j/opc/ ooxml/java/...
Date Wed, 18 Mar 2009 18:54:02 GMT
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java?rev=755699&r1=755698&r2=755699&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java Wed Mar 18 18:54:01 2009
@@ -1,103 +1,103 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-
-package org.apache.poi.openxml4j.opc;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-
-public final class TestListParts extends TestCase {
-	private static Logger logger = Logger.getLogger("org.apache.poi.openxml4j.test");
-
-	private TreeMap<PackagePartName, String> expectedValues;
-
-	private TreeMap<PackagePartName, String> values;
-
-	@Override
-	protected void setUp() throws Exception {
-		values = new TreeMap<PackagePartName, String>();
-
-		// Expected values
-		expectedValues = new TreeMap<PackagePartName, String>();
-		expectedValues.put(PackagingURIHelper.createPartName("/_rels/.rels"),
-				"application/vnd.openxmlformats-package.relationships+xml");
-
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/docProps/app.xml"),
-						"application/vnd.openxmlformats-officedocument.extended-properties+xml");
-		expectedValues.put(PackagingURIHelper
-				.createPartName("/docProps/core.xml"),
-				"application/vnd.openxmlformats-package.core-properties+xml");
-		expectedValues.put(PackagingURIHelper
-				.createPartName("/word/_rels/document.xml.rels"),
-				"application/vnd.openxmlformats-package.relationships+xml");
-		expectedValues
-				.put(
-						PackagingURIHelper.createPartName("/word/document.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/word/fontTable.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
-		expectedValues.put(PackagingURIHelper
-				.createPartName("/word/media/image1.gif"), "image/gif");
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/word/settings.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/word/styles.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
-		expectedValues.put(PackagingURIHelper
-				.createPartName("/word/theme/theme1.xml"),
-				"application/vnd.openxmlformats-officedocument.theme+xml");
-		expectedValues
-				.put(
-						PackagingURIHelper
-								.createPartName("/word/webSettings.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml");
-	}
-
-	/**
-	 * List all parts of a package.
-	 */
-	public void testListParts() throws InvalidFormatException {
-		InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.docx");
-
-		Package p;
-		try {
-			p = Package.open(is);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		for (PackagePart part : p.getParts()) {
-			values.put(part.getPartName(), part.getContentType());
-			logger.debug(part.getPartName());
-		}
-
-		// Compare expected values with values return by the package
-		for (PackagePartName partName : expectedValues.keySet()) {
-			assertNotNull(values.get(partName));
-			assertEquals(expectedValues.get(partName), values.get(partName));
-		}
-	}
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.openxml4j.opc;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+
+public final class TestListParts extends TestCase {
+	private static Logger logger = Logger.getLogger("org.apache.poi.openxml4j.test");
+
+	private TreeMap<PackagePartName, String> expectedValues;
+
+	private TreeMap<PackagePartName, String> values;
+
+	@Override
+	protected void setUp() throws Exception {
+		values = new TreeMap<PackagePartName, String>();
+
+		// Expected values
+		expectedValues = new TreeMap<PackagePartName, String>();
+		expectedValues.put(PackagingURIHelper.createPartName("/_rels/.rels"),
+				"application/vnd.openxmlformats-package.relationships+xml");
+
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/docProps/app.xml"),
+						"application/vnd.openxmlformats-officedocument.extended-properties+xml");
+		expectedValues.put(PackagingURIHelper
+				.createPartName("/docProps/core.xml"),
+				"application/vnd.openxmlformats-package.core-properties+xml");
+		expectedValues.put(PackagingURIHelper
+				.createPartName("/word/_rels/document.xml.rels"),
+				"application/vnd.openxmlformats-package.relationships+xml");
+		expectedValues
+				.put(
+						PackagingURIHelper.createPartName("/word/document.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/word/fontTable.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
+		expectedValues.put(PackagingURIHelper
+				.createPartName("/word/media/image1.gif"), "image/gif");
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/word/settings.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/word/styles.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
+		expectedValues.put(PackagingURIHelper
+				.createPartName("/word/theme/theme1.xml"),
+				"application/vnd.openxmlformats-officedocument.theme+xml");
+		expectedValues
+				.put(
+						PackagingURIHelper
+								.createPartName("/word/webSettings.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml");
+	}
+
+	/**
+	 * List all parts of a package.
+	 */
+	public void testListParts() throws InvalidFormatException {
+		InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.docx");
+
+		OPCPackage p;
+		try {
+			p = OPCPackage.open(is);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		for (PackagePart part : p.getParts()) {
+			values.put(part.getPartName(), part.getContentType());
+			logger.debug(part.getPartName());
+		}
+
+		// Compare expected values with values return by the package
+		for (PackagePartName partName : expectedValues.keySet()) {
+			assertNotNull(values.get(partName));
+			assertEquals(expectedValues.get(partName), values.get(partName));
+		}
+	}
+}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java?rev=755699&r1=755698&r2=755699&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java Wed Mar 18 18:54:01 2009
@@ -1,417 +1,417 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-
-package org.apache.poi.openxml4j.opc;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.reflect.Field;
-import java.net.URI;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.openxml4j.opc.internal.ContentTypeManager;
-import org.apache.poi.openxml4j.opc.internal.FileHelper;
-import org.dom4j.Document;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.dom4j.QName;
-
-public final class TestPackage extends TestCase {
-	private static Logger logger = Logger.getLogger("org.apache.poi.openxml4j.test");
-
-	/**
-	 * Test that just opening and closing the file doesn't alter the document.
-	 */
-	public void testOpenSave() throws Exception {
-		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
-		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageOpenSaveTMP.docx");
-
-		Package p = Package.open(originalFile, PackageAccess.READ_WRITE);
-		p.save(targetFile.getAbsoluteFile());
-
-		// Compare the original and newly saved document
-		assertTrue(targetFile.exists());
-		//ZipFileAssert.assertEquals(originalFile, targetFile);
-		assertTrue(targetFile.delete());
-	}
-	
-	/**
-	 * Test that when we create a new Package, we give it
-	 *  the correct default content types
-	 */
-	public void testCreateGetsContentTypes() throws Exception {
-		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageTMP.docx");
-		
-		// Zap the target file, in case of an earlier run
-		if(targetFile.exists()) targetFile.delete();
-		
-		Package pkg = Package.create(targetFile);
-		
-		// Check it has content types for rels and xml
-		ContentTypeManager ctm = getContentTypeManager(pkg);
-		assertEquals(
-				"application/xml",
-				ctm.getContentType(
-						PackagingURIHelper.createPartName("/foo.xml")
-				)
-		);
-		assertEquals(
-				ContentTypes.RELATIONSHIPS_PART,
-				ctm.getContentType(
-						PackagingURIHelper.createPartName("/foo.rels")
-				)
-		);
-		assertNull(
-				ctm.getContentType(
-						PackagingURIHelper.createPartName("/foo.txt")
-				)
-		);
-	}
-
-	/**
-	 * Test package creation.
-	 */
-	public void testCreatePackageAddPart() throws Exception {
-		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageTMP.docx");
-
-		File expectedFileFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageOUTPUT.docx");
-
-		// Zap the target file, in case of an earlier run
-		if(targetFile.exists()) targetFile.delete();
-		
-		// Create a package
-		Package pkg = Package.create(targetFile);
-		PackagePartName corePartName = PackagingURIHelper
-				.createPartName("/word/document.xml");
-
-		pkg.addRelationship(corePartName, TargetMode.INTERNAL,
-				PackageRelationshipTypes.CORE_DOCUMENT, "rId1");
-
-		PackagePart corePart = pkg
-				.createPart(
-						corePartName,
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
-
-		Document doc = DocumentHelper.createDocument();
-		Namespace nsWordprocessinML = new Namespace("w",
-				"http://schemas.openxmlformats.org/wordprocessingml/2006/main");
-		Element elDocument = doc.addElement(new QName("document",
-				nsWordprocessinML));
-		Element elBody = elDocument.addElement(new QName("body",
-				nsWordprocessinML));
-		Element elParagraph = elBody.addElement(new QName("p",
-				nsWordprocessinML));
-		Element elRun = elParagraph
-				.addElement(new QName("r", nsWordprocessinML));
-		Element elText = elRun.addElement(new QName("t", nsWordprocessinML));
-		elText.setText("Hello Open XML !");
-
-		StreamHelper.saveXmlInStream(doc, corePart.getOutputStream());
-		pkg.close();
-
-		//ZipFileAssert.assertEquals(expectedFile, targetFile);
-		assertTrue(targetFile.delete());
-	}
-	
-	/**
-	 * Tests that we can create a new package, add a core
-	 *  document and another part, save and re-load and
-	 *  have everything setup as expected
-	 */
-	public void testCreatePackageWithCoreDocument() throws Exception {
-		ByteArrayOutputStream baos = new ByteArrayOutputStream();
-		Package pkg = Package.create(baos);
-		
-		// Add a core document
-        PackagePartName corePartName = PackagingURIHelper.createPartName("/xl/workbook.xml");
-        // Create main part relationship
-        pkg.addRelationship(corePartName, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT, "rId1");
-        // Create main document part
-        PackagePart corePart = pkg.createPart(corePartName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml");
-        // Put in some dummy content
-        OutputStream coreOut = corePart.getOutputStream();
-        coreOut.write("<dummy-xml />".getBytes());
-        coreOut.close();
-		
-		// And another bit
-        PackagePartName sheetPartName = PackagingURIHelper.createPartName("/xl/worksheets/sheet1.xml");
-        PackageRelationship rel =
-        	 corePart.addRelationship(sheetPartName, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", "rSheet1");
-        PackagePart part = pkg.createPart(sheetPartName, "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
-        // Dummy content again
-        coreOut = corePart.getOutputStream();
-        coreOut.write("<dummy-xml2 />".getBytes());
-        coreOut.close();
-        
-        
-        // Check things are as expected
-        PackageRelationshipCollection coreRels =
-        	pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
-        assertEquals(1, coreRels.size());
-        PackageRelationship coreRel = coreRels.getRelationship(0);
-        assertEquals("/", coreRel.getSourceURI().toString());
-        assertEquals("/xl/workbook.xml", coreRel.getTargetURI().toString());
-        assertNotNull(pkg.getPart(coreRel));
-        
-        
-        // Save and re-load
-        pkg.close();
-        FileOutputStream fout = new FileOutputStream(File.createTempFile("testCreatePackageWithCoreDocument", ".zip"));
-        fout.write(baos.toByteArray());
-        fout.close();
-        pkg = Package.open(new ByteArrayInputStream(baos.toByteArray()));
-        
-        
-        // Check still right
-        coreRels = pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
-        assertEquals(1, coreRels.size());
-        coreRel = coreRels.getRelationship(0);
-        assertEquals("/", coreRel.getSourceURI().toString());
-        assertEquals("/xl/workbook.xml", coreRel.getTargetURI().toString());
-        assertNotNull(pkg.getPart(coreRel));
-	}
-
-	/**
-	 * Test package opening.
-	 */
-	public void testOpenPackage() throws Exception {
-		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestOpenPackageTMP.docx");
-
-		File inputFile = OpenXML4JTestDataSamples.getSampleFile("TestOpenPackageINPUT.docx");
-
-		File expectedFile = OpenXML4JTestDataSamples.getOutputFile("TestOpenPackageOUTPUT.docx");
-
-		// Copy the input file in the output directory
-		FileHelper.copyFile(inputFile, targetFile);
-
-		// Create a package
-		Package pkg = Package.open(targetFile.getAbsolutePath());
-
-		// Modify core part
-		PackagePartName corePartName = PackagingURIHelper
-				.createPartName("/word/document.xml");
-
-		PackagePart corePart = pkg.getPart(corePartName);
-
-		// Delete some part to have a valid document
-		for (PackageRelationship rel : corePart.getRelationships()) {
-			corePart.removeRelationship(rel.getId());
-			pkg.removePart(PackagingURIHelper.createPartName(PackagingURIHelper
-					.resolvePartUri(corePart.getPartName().getURI(), rel
-							.getTargetURI())));
-		}
-
-		// Create a content
-		Document doc = DocumentHelper.createDocument();
-		Namespace nsWordprocessinML = new Namespace("w",
-				"http://schemas.openxmlformats.org/wordprocessingml/2006/main");
-		Element elDocument = doc.addElement(new QName("document",
-				nsWordprocessinML));
-		Element elBody = elDocument.addElement(new QName("body",
-				nsWordprocessinML));
-		Element elParagraph = elBody.addElement(new QName("p",
-				nsWordprocessinML));
-		Element elRun = elParagraph
-				.addElement(new QName("r", nsWordprocessinML));
-		Element elText = elRun.addElement(new QName("t", nsWordprocessinML));
-		elText.setText("Hello Open XML !");
-
-		StreamHelper.saveXmlInStream(doc, corePart.getOutputStream());
-
-		// Save and close
-		try {
-			pkg.close();
-		} catch (IOException e) {
-			fail();
-		}
-
-		//ZipFileAssert.assertEquals(expectedFile, targetFile);
-		assertTrue(targetFile.delete());
-	}
-	
-	/**
-	 * Checks that we can write a package to a simple
-	 *  OutputStream, in addition to the normal writing
-	 *  to a file
-	 */
-	public void testSaveToOutputStream() throws Exception {
-		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
-		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageOpenSaveTMP.docx");
-
-		Package p = Package.open(originalFile, PackageAccess.READ_WRITE);
-		FileOutputStream fout = new FileOutputStream(targetFile);
-		p.save(fout);
-		fout.close();
-
-		// Compare the original and newly saved document
-		assertTrue(targetFile.exists());
-		//ZipFileAssert.assertEquals(originalFile, targetFile);
-		assertTrue(targetFile.delete());
-	}
-
-	/**
-	 * Checks that we can open+read a package from a
-	 *  simple InputStream, in addition to the normal
-	 *  reading from a file
-	 */
-	public void testOpenFromInputStream() throws Exception {
-		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
-		
-		FileInputStream finp = new FileInputStream(originalFile);
-		
-		Package p = Package.open(finp);
-		
-		assertNotNull(p);
-		assertNotNull(p.getRelationships());
-		assertEquals(12, p.getParts().size());
-		
-		// Check it has the usual bits
-		assertTrue(p.hasRelationships());
-		assertTrue(p.containPart(PackagingURIHelper.createPartName("/_rels/.rels")));
-	}
-
-    /**
-     * TODO: fix and enable
-     */
-    public void disabled_testRemovePartRecursive() throws Exception {
-		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
-		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageRemovePartRecursiveOUTPUT.docx");
-		File tempFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageRemovePartRecursiveTMP.docx");
-
-		Package p = Package.open(originalFile, PackageAccess.READ_WRITE);
-		p.removePartRecursive(PackagingURIHelper.createPartName(new URI(
-				"/word/document.xml")));
-		p.save(tempFile.getAbsoluteFile());
-
-		// Compare the original and newly saved document
-		assertTrue(targetFile.exists());
-		//ZipFileAssert.assertEquals(targetFile, tempFile);
-		assertTrue(targetFile.delete());
-	}
-
-	public void testDeletePart() throws InvalidFormatException {
-		TreeMap<PackagePartName, String> expectedValues;
-		TreeMap<PackagePartName, String> values;
-
-		values = new TreeMap<PackagePartName, String>();
-
-		// Expected values
-		expectedValues = new TreeMap<PackagePartName, String>();
-		expectedValues.put(PackagingURIHelper.createPartName("/_rels/.rels"),
-				"application/vnd.openxmlformats-package.relationships+xml");
-
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/docProps/app.xml"),
-						"application/vnd.openxmlformats-officedocument.extended-properties+xml");
-		expectedValues.put(PackagingURIHelper
-				.createPartName("/docProps/core.xml"),
-				"application/vnd.openxmlformats-package.core-properties+xml");
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/word/fontTable.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
-		expectedValues.put(PackagingURIHelper
-				.createPartName("/word/media/image1.gif"), "image/gif");
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/word/settings.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/word/styles.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
-		expectedValues.put(PackagingURIHelper
-				.createPartName("/word/theme/theme1.xml"),
-				"application/vnd.openxmlformats-officedocument.theme+xml");
-		expectedValues
-				.put(
-						PackagingURIHelper
-								.createPartName("/word/webSettings.xml"),
-						"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml");
-
-		String filepath =  OpenXML4JTestDataSamples.getSampleFileName("sample.docx");
-
-		Package p = Package.open(filepath, PackageAccess.READ_WRITE);
-		// Remove the core part
-		p.deletePart(PackagingURIHelper.createPartName("/word/document.xml"));
-
-		for (PackagePart part : p.getParts()) {
-			values.put(part.getPartName(), part.getContentType());
-			logger.debug(part.getPartName());
-		}
-
-		// Compare expected values with values return by the package
-		for (PackagePartName partName : expectedValues.keySet()) {
-			assertNotNull(values.get(partName));
-			assertEquals(expectedValues.get(partName), values.get(partName));
-		}
-		// Don't save modifications
-		p.revert();
-	}
-	
-	public void testDeletePartRecursive() throws InvalidFormatException {
-		TreeMap<PackagePartName, String> expectedValues;
-		TreeMap<PackagePartName, String> values;
-
-		values = new TreeMap<PackagePartName, String>();
-
-		// Expected values
-		expectedValues = new TreeMap<PackagePartName, String>();
-		expectedValues.put(PackagingURIHelper.createPartName("/_rels/.rels"),
-				"application/vnd.openxmlformats-package.relationships+xml");
-
-		expectedValues
-				.put(PackagingURIHelper.createPartName("/docProps/app.xml"),
-						"application/vnd.openxmlformats-officedocument.extended-properties+xml");
-		expectedValues.put(PackagingURIHelper
-				.createPartName("/docProps/core.xml"),
-				"application/vnd.openxmlformats-package.core-properties+xml");
-
-		String filepath = OpenXML4JTestDataSamples.getSampleFileName("sample.docx");
-
-		Package p = Package.open(filepath, PackageAccess.READ_WRITE);
-		// Remove the core part
-		p.deletePartRecursive(PackagingURIHelper.createPartName("/word/document.xml"));
-
-		for (PackagePart part : p.getParts()) {
-			values.put(part.getPartName(), part.getContentType());
-			logger.debug(part.getPartName());
-		}
-
-		// Compare expected values with values return by the package
-		for (PackagePartName partName : expectedValues.keySet()) {
-			assertNotNull(values.get(partName));
-			assertEquals(expectedValues.get(partName), values.get(partName));
-		}
-		// Don't save modifications
-		p.revert();
-	}
-	
-	private static ContentTypeManager getContentTypeManager(Package pkg) throws Exception {
-		Field f = Package.class.getDeclaredField("contentTypeManager");
-		f.setAccessible(true);
-		return (ContentTypeManager)f.get(pkg);
-	}
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.openxml4j.opc;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.openxml4j.opc.internal.ContentTypeManager;
+import org.apache.poi.openxml4j.opc.internal.FileHelper;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+
+public final class TestPackage extends TestCase {
+	private static Logger logger = Logger.getLogger("org.apache.poi.openxml4j.test");
+
+	/**
+	 * Test that just opening and closing the file doesn't alter the document.
+	 */
+	public void testOpenSave() throws Exception {
+		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageOpenSaveTMP.docx");
+
+		OPCPackage p = OPCPackage.open(originalFile, PackageAccess.READ_WRITE);
+		p.save(targetFile.getAbsoluteFile());
+
+		// Compare the original and newly saved document
+		assertTrue(targetFile.exists());
+		//ZipFileAssert.assertEquals(originalFile, targetFile);
+		assertTrue(targetFile.delete());
+	}
+	
+	/**
+	 * Test that when we create a new Package, we give it
+	 *  the correct default content types
+	 */
+	public void testCreateGetsContentTypes() throws Exception {
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageTMP.docx");
+		
+		// Zap the target file, in case of an earlier run
+		if(targetFile.exists()) targetFile.delete();
+		
+		OPCPackage pkg = OPCPackage.create(targetFile);
+		
+		// Check it has content types for rels and xml
+		ContentTypeManager ctm = getContentTypeManager(pkg);
+		assertEquals(
+				"application/xml",
+				ctm.getContentType(
+						PackagingURIHelper.createPartName("/foo.xml")
+				)
+		);
+		assertEquals(
+				ContentTypes.RELATIONSHIPS_PART,
+				ctm.getContentType(
+						PackagingURIHelper.createPartName("/foo.rels")
+				)
+		);
+		assertNull(
+				ctm.getContentType(
+						PackagingURIHelper.createPartName("/foo.txt")
+				)
+		);
+	}
+
+	/**
+	 * Test package creation.
+	 */
+	public void testCreatePackageAddPart() throws Exception {
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageTMP.docx");
+
+		File expectedFileFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageOUTPUT.docx");
+
+		// Zap the target file, in case of an earlier run
+		if(targetFile.exists()) targetFile.delete();
+		
+		// Create a package
+		OPCPackage pkg = OPCPackage.create(targetFile);
+		PackagePartName corePartName = PackagingURIHelper
+				.createPartName("/word/document.xml");
+
+		pkg.addRelationship(corePartName, TargetMode.INTERNAL,
+				PackageRelationshipTypes.CORE_DOCUMENT, "rId1");
+
+		PackagePart corePart = pkg
+				.createPart(
+						corePartName,
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
+
+		Document doc = DocumentHelper.createDocument();
+		Namespace nsWordprocessinML = new Namespace("w",
+				"http://schemas.openxmlformats.org/wordprocessingml/2006/main");
+		Element elDocument = doc.addElement(new QName("document",
+				nsWordprocessinML));
+		Element elBody = elDocument.addElement(new QName("body",
+				nsWordprocessinML));
+		Element elParagraph = elBody.addElement(new QName("p",
+				nsWordprocessinML));
+		Element elRun = elParagraph
+				.addElement(new QName("r", nsWordprocessinML));
+		Element elText = elRun.addElement(new QName("t", nsWordprocessinML));
+		elText.setText("Hello Open XML !");
+
+		StreamHelper.saveXmlInStream(doc, corePart.getOutputStream());
+		pkg.close();
+
+		//ZipFileAssert.assertEquals(expectedFile, targetFile);
+		assertTrue(targetFile.delete());
+	}
+	
+	/**
+	 * Tests that we can create a new package, add a core
+	 *  document and another part, save and re-load and
+	 *  have everything setup as expected
+	 */
+	public void testCreatePackageWithCoreDocument() throws Exception {
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		OPCPackage pkg = OPCPackage.create(baos);
+		
+		// Add a core document
+        PackagePartName corePartName = PackagingURIHelper.createPartName("/xl/workbook.xml");
+        // Create main part relationship
+        pkg.addRelationship(corePartName, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT, "rId1");
+        // Create main document part
+        PackagePart corePart = pkg.createPart(corePartName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml");
+        // Put in some dummy content
+        OutputStream coreOut = corePart.getOutputStream();
+        coreOut.write("<dummy-xml />".getBytes());
+        coreOut.close();
+		
+		// And another bit
+        PackagePartName sheetPartName = PackagingURIHelper.createPartName("/xl/worksheets/sheet1.xml");
+        PackageRelationship rel =
+        	 corePart.addRelationship(sheetPartName, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", "rSheet1");
+        PackagePart part = pkg.createPart(sheetPartName, "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
+        // Dummy content again
+        coreOut = corePart.getOutputStream();
+        coreOut.write("<dummy-xml2 />".getBytes());
+        coreOut.close();
+        
+        
+        // Check things are as expected
+        PackageRelationshipCollection coreRels =
+        	pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
+        assertEquals(1, coreRels.size());
+        PackageRelationship coreRel = coreRels.getRelationship(0);
+        assertEquals("/", coreRel.getSourceURI().toString());
+        assertEquals("/xl/workbook.xml", coreRel.getTargetURI().toString());
+        assertNotNull(pkg.getPart(coreRel));
+        
+        
+        // Save and re-load
+        pkg.close();
+        FileOutputStream fout = new FileOutputStream(File.createTempFile("testCreatePackageWithCoreDocument", ".zip"));
+        fout.write(baos.toByteArray());
+        fout.close();
+        pkg = OPCPackage.open(new ByteArrayInputStream(baos.toByteArray()));
+        
+        
+        // Check still right
+        coreRels = pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
+        assertEquals(1, coreRels.size());
+        coreRel = coreRels.getRelationship(0);
+        assertEquals("/", coreRel.getSourceURI().toString());
+        assertEquals("/xl/workbook.xml", coreRel.getTargetURI().toString());
+        assertNotNull(pkg.getPart(coreRel));
+	}
+
+	/**
+	 * Test package opening.
+	 */
+	public void testOpenPackage() throws Exception {
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestOpenPackageTMP.docx");
+
+		File inputFile = OpenXML4JTestDataSamples.getSampleFile("TestOpenPackageINPUT.docx");
+
+		File expectedFile = OpenXML4JTestDataSamples.getOutputFile("TestOpenPackageOUTPUT.docx");
+
+		// Copy the input file in the output directory
+		FileHelper.copyFile(inputFile, targetFile);
+
+		// Create a package
+		OPCPackage pkg = OPCPackage.open(targetFile.getAbsolutePath());
+
+		// Modify core part
+		PackagePartName corePartName = PackagingURIHelper
+				.createPartName("/word/document.xml");
+
+		PackagePart corePart = pkg.getPart(corePartName);
+
+		// Delete some part to have a valid document
+		for (PackageRelationship rel : corePart.getRelationships()) {
+			corePart.removeRelationship(rel.getId());
+			pkg.removePart(PackagingURIHelper.createPartName(PackagingURIHelper
+					.resolvePartUri(corePart.getPartName().getURI(), rel
+							.getTargetURI())));
+		}
+
+		// Create a content
+		Document doc = DocumentHelper.createDocument();
+		Namespace nsWordprocessinML = new Namespace("w",
+				"http://schemas.openxmlformats.org/wordprocessingml/2006/main");
+		Element elDocument = doc.addElement(new QName("document",
+				nsWordprocessinML));
+		Element elBody = elDocument.addElement(new QName("body",
+				nsWordprocessinML));
+		Element elParagraph = elBody.addElement(new QName("p",
+				nsWordprocessinML));
+		Element elRun = elParagraph
+				.addElement(new QName("r", nsWordprocessinML));
+		Element elText = elRun.addElement(new QName("t", nsWordprocessinML));
+		elText.setText("Hello Open XML !");
+
+		StreamHelper.saveXmlInStream(doc, corePart.getOutputStream());
+
+		// Save and close
+		try {
+			pkg.close();
+		} catch (IOException e) {
+			fail();
+		}
+
+		//ZipFileAssert.assertEquals(expectedFile, targetFile);
+		assertTrue(targetFile.delete());
+	}
+	
+	/**
+	 * Checks that we can write a package to a simple
+	 *  OutputStream, in addition to the normal writing
+	 *  to a file
+	 */
+	public void testSaveToOutputStream() throws Exception {
+		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageOpenSaveTMP.docx");
+
+		OPCPackage p = OPCPackage.open(originalFile, PackageAccess.READ_WRITE);
+		FileOutputStream fout = new FileOutputStream(targetFile);
+		p.save(fout);
+		fout.close();
+
+		// Compare the original and newly saved document
+		assertTrue(targetFile.exists());
+		//ZipFileAssert.assertEquals(originalFile, targetFile);
+		assertTrue(targetFile.delete());
+	}
+
+	/**
+	 * Checks that we can open+read a package from a
+	 *  simple InputStream, in addition to the normal
+	 *  reading from a file
+	 */
+	public void testOpenFromInputStream() throws Exception {
+		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
+		
+		FileInputStream finp = new FileInputStream(originalFile);
+		
+		OPCPackage p = OPCPackage.open(finp);
+		
+		assertNotNull(p);
+		assertNotNull(p.getRelationships());
+		assertEquals(12, p.getParts().size());
+		
+		// Check it has the usual bits
+		assertTrue(p.hasRelationships());
+		assertTrue(p.containPart(PackagingURIHelper.createPartName("/_rels/.rels")));
+	}
+
+    /**
+     * TODO: fix and enable
+     */
+    public void disabled_testRemovePartRecursive() throws Exception {
+		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageRemovePartRecursiveOUTPUT.docx");
+		File tempFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageRemovePartRecursiveTMP.docx");
+
+		OPCPackage p = OPCPackage.open(originalFile, PackageAccess.READ_WRITE);
+		p.removePartRecursive(PackagingURIHelper.createPartName(new URI(
+				"/word/document.xml")));
+		p.save(tempFile.getAbsoluteFile());
+
+		// Compare the original and newly saved document
+		assertTrue(targetFile.exists());
+		//ZipFileAssert.assertEquals(targetFile, tempFile);
+		assertTrue(targetFile.delete());
+	}
+
+	public void testDeletePart() throws InvalidFormatException {
+		TreeMap<PackagePartName, String> expectedValues;
+		TreeMap<PackagePartName, String> values;
+
+		values = new TreeMap<PackagePartName, String>();
+
+		// Expected values
+		expectedValues = new TreeMap<PackagePartName, String>();
+		expectedValues.put(PackagingURIHelper.createPartName("/_rels/.rels"),
+				"application/vnd.openxmlformats-package.relationships+xml");
+
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/docProps/app.xml"),
+						"application/vnd.openxmlformats-officedocument.extended-properties+xml");
+		expectedValues.put(PackagingURIHelper
+				.createPartName("/docProps/core.xml"),
+				"application/vnd.openxmlformats-package.core-properties+xml");
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/word/fontTable.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
+		expectedValues.put(PackagingURIHelper
+				.createPartName("/word/media/image1.gif"), "image/gif");
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/word/settings.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/word/styles.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
+		expectedValues.put(PackagingURIHelper
+				.createPartName("/word/theme/theme1.xml"),
+				"application/vnd.openxmlformats-officedocument.theme+xml");
+		expectedValues
+				.put(
+						PackagingURIHelper
+								.createPartName("/word/webSettings.xml"),
+						"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml");
+
+		String filepath =  OpenXML4JTestDataSamples.getSampleFileName("sample.docx");
+
+		OPCPackage p = OPCPackage.open(filepath, PackageAccess.READ_WRITE);
+		// Remove the core part
+		p.deletePart(PackagingURIHelper.createPartName("/word/document.xml"));
+
+		for (PackagePart part : p.getParts()) {
+			values.put(part.getPartName(), part.getContentType());
+			logger.debug(part.getPartName());
+		}
+
+		// Compare expected values with values return by the package
+		for (PackagePartName partName : expectedValues.keySet()) {
+			assertNotNull(values.get(partName));
+			assertEquals(expectedValues.get(partName), values.get(partName));
+		}
+		// Don't save modifications
+		p.revert();
+	}
+	
+	public void testDeletePartRecursive() throws InvalidFormatException {
+		TreeMap<PackagePartName, String> expectedValues;
+		TreeMap<PackagePartName, String> values;
+
+		values = new TreeMap<PackagePartName, String>();
+
+		// Expected values
+		expectedValues = new TreeMap<PackagePartName, String>();
+		expectedValues.put(PackagingURIHelper.createPartName("/_rels/.rels"),
+				"application/vnd.openxmlformats-package.relationships+xml");
+
+		expectedValues
+				.put(PackagingURIHelper.createPartName("/docProps/app.xml"),
+						"application/vnd.openxmlformats-officedocument.extended-properties+xml");
+		expectedValues.put(PackagingURIHelper
+				.createPartName("/docProps/core.xml"),
+				"application/vnd.openxmlformats-package.core-properties+xml");
+
+		String filepath = OpenXML4JTestDataSamples.getSampleFileName("sample.docx");
+
+		OPCPackage p = OPCPackage.open(filepath, PackageAccess.READ_WRITE);
+		// Remove the core part
+		p.deletePartRecursive(PackagingURIHelper.createPartName("/word/document.xml"));
+
+		for (PackagePart part : p.getParts()) {
+			values.put(part.getPartName(), part.getContentType());
+			logger.debug(part.getPartName());
+		}
+
+		// Compare expected values with values return by the package
+		for (PackagePartName partName : expectedValues.keySet()) {
+			assertNotNull(values.get(partName));
+			assertEquals(expectedValues.get(partName), values.get(partName));
+		}
+		// Don't save modifications
+		p.revert();
+	}
+	
+	private static ContentTypeManager getContentTypeManager(OPCPackage pkg) throws Exception {
+		Field f = OPCPackage.class.getDeclaredField("contentTypeManager");
+		f.setAccessible(true);
+		return (ContentTypeManager)f.get(pkg);
+	}
+}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java?rev=755699&r1=755698&r2=755699&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java Wed Mar 18 18:54:01 2009
@@ -1,121 +1,121 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-
-package org.apache.poi.openxml4j.opc;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
-import org.apache.poi.openxml4j.util.Nullable;
-
-public final class TestPackageCoreProperties extends TestCase {
-
-	/**
-	 * Test package core properties getters.
-	 */
-	public void testGetProperties() {
-		try {
-			// Open the package
-			Package p = Package.open(OpenXML4JTestDataSamples.openSampleStream("TestPackageCoreProperiesGetters.docx"));
-			compareProperties(p);
-			p.revert();
-		} catch (OpenXML4JException e) {
-			Logger.getLogger("org.apache.poi.openxml4j.demo").debug(e.getMessage());
-			throw new RuntimeException(e);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-	}
-
-	/**
-	 * Test package core properties setters.
-	 */
-	public void testSetProperties() throws Exception {
-		String inputPath = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCoreProperiesSetters.docx");
-
-		File outputFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageCoreProperiesSettersOUTPUT.docx");
-
-		// Open package
-		Package p = Package.open(inputPath, PackageAccess.READ_WRITE);
-
-		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
-		Date dateToInsert = df.parse("2007-05-12T08:00:00Z", new ParsePosition(
-				0));
-
-		PackageProperties props = p.getPackageProperties();
-		props.setCategoryProperty("MyCategory");
-		props.setContentStatusProperty("MyContentStatus");
-		props.setContentTypeProperty("MyContentType");
-		props.setCreatedProperty(new Nullable<Date>(dateToInsert));
-		props.setCreatorProperty("MyCreator");
-		props.setDescriptionProperty("MyDescription");
-		props.setIdentifierProperty("MyIdentifier");
-		props.setKeywordsProperty("MyKeywords");
-		props.setLanguageProperty("MyLanguage");
-		props.setLastModifiedByProperty("Julien Chable");
-		props.setLastPrintedProperty(new Nullable<Date>(dateToInsert));
-		props.setModifiedProperty(new Nullable<Date>(dateToInsert));
-		props.setRevisionProperty("2");
-		props.setTitleProperty("MyTitle");
-		props.setSubjectProperty("MySubject");
-		props.setVersionProperty("2");
-		// Save the package in the output directory
-		p.save(outputFile);
-
-		// Open the newly created file to check core properties saved values.
-		Package p2 = Package.open(outputFile.getAbsolutePath(), PackageAccess.READ);
-		compareProperties(p2);
-		p2.revert();
-		outputFile.delete();
-	}
-
-	private void compareProperties(Package p) throws InvalidFormatException {
-		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
-		Date expectedDate = df.parse("2007-05-12T08:00:00Z", new ParsePosition(
-				0));
-
-		// Gets the core properties
-		PackageProperties props = p.getPackageProperties();
-		assertEquals("MyCategory", props.getCategoryProperty().getValue());
-		assertEquals("MyContentStatus", props.getContentStatusProperty()
-				.getValue());
-		assertEquals("MyContentType", props.getContentTypeProperty().getValue());
-		assertEquals(expectedDate, props.getCreatedProperty().getValue());
-		assertEquals("MyCreator", props.getCreatorProperty().getValue());
-		assertEquals("MyDescription", props.getDescriptionProperty().getValue());
-		assertEquals("MyIdentifier", props.getIdentifierProperty().getValue());
-		assertEquals("MyKeywords", props.getKeywordsProperty().getValue());
-		assertEquals("MyLanguage", props.getLanguageProperty().getValue());
-		assertEquals("Julien Chable", props.getLastModifiedByProperty()
-				.getValue());
-		assertEquals(expectedDate, props.getLastPrintedProperty().getValue());
-		assertEquals(expectedDate, props.getModifiedProperty().getValue());
-		assertEquals("2", props.getRevisionProperty().getValue());
-		assertEquals("MySubject", props.getSubjectProperty().getValue());
-		assertEquals("MyTitle", props.getTitleProperty().getValue());
-		assertEquals("2", props.getVersionProperty().getValue());
-	}
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.openxml4j.opc;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
+import org.apache.poi.openxml4j.util.Nullable;
+
+public final class TestPackageCoreProperties extends TestCase {
+
+	/**
+	 * Test package core properties getters.
+	 */
+	public void testGetProperties() {
+		try {
+			// Open the package
+			OPCPackage p = OPCPackage.open(OpenXML4JTestDataSamples.openSampleStream("TestPackageCoreProperiesGetters.docx"));
+			compareProperties(p);
+			p.revert();
+		} catch (OpenXML4JException e) {
+			Logger.getLogger("org.apache.poi.openxml4j.demo").debug(e.getMessage());
+			throw new RuntimeException(e);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * Test package core properties setters.
+	 */
+	public void testSetProperties() throws Exception {
+		String inputPath = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCoreProperiesSetters.docx");
+
+		File outputFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageCoreProperiesSettersOUTPUT.docx");
+
+		// Open package
+		OPCPackage p = OPCPackage.open(inputPath, PackageAccess.READ_WRITE);
+
+		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+		Date dateToInsert = df.parse("2007-05-12T08:00:00Z", new ParsePosition(
+				0));
+
+		PackageProperties props = p.getPackageProperties();
+		props.setCategoryProperty("MyCategory");
+		props.setContentStatusProperty("MyContentStatus");
+		props.setContentTypeProperty("MyContentType");
+		props.setCreatedProperty(new Nullable<Date>(dateToInsert));
+		props.setCreatorProperty("MyCreator");
+		props.setDescriptionProperty("MyDescription");
+		props.setIdentifierProperty("MyIdentifier");
+		props.setKeywordsProperty("MyKeywords");
+		props.setLanguageProperty("MyLanguage");
+		props.setLastModifiedByProperty("Julien Chable");
+		props.setLastPrintedProperty(new Nullable<Date>(dateToInsert));
+		props.setModifiedProperty(new Nullable<Date>(dateToInsert));
+		props.setRevisionProperty("2");
+		props.setTitleProperty("MyTitle");
+		props.setSubjectProperty("MySubject");
+		props.setVersionProperty("2");
+		// Save the package in the output directory
+		p.save(outputFile);
+
+		// Open the newly created file to check core properties saved values.
+		OPCPackage p2 = OPCPackage.open(outputFile.getAbsolutePath(), PackageAccess.READ);
+		compareProperties(p2);
+		p2.revert();
+		outputFile.delete();
+	}
+
+	private void compareProperties(OPCPackage p) throws InvalidFormatException {
+		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+		Date expectedDate = df.parse("2007-05-12T08:00:00Z", new ParsePosition(
+				0));
+
+		// Gets the core properties
+		PackageProperties props = p.getPackageProperties();
+		assertEquals("MyCategory", props.getCategoryProperty().getValue());
+		assertEquals("MyContentStatus", props.getContentStatusProperty()
+				.getValue());
+		assertEquals("MyContentType", props.getContentTypeProperty().getValue());
+		assertEquals(expectedDate, props.getCreatedProperty().getValue());
+		assertEquals("MyCreator", props.getCreatorProperty().getValue());
+		assertEquals("MyDescription", props.getDescriptionProperty().getValue());
+		assertEquals("MyIdentifier", props.getIdentifierProperty().getValue());
+		assertEquals("MyKeywords", props.getKeywordsProperty().getValue());
+		assertEquals("MyLanguage", props.getLanguageProperty().getValue());
+		assertEquals("Julien Chable", props.getLastModifiedByProperty()
+				.getValue());
+		assertEquals(expectedDate, props.getLastPrintedProperty().getValue());
+		assertEquals(expectedDate, props.getModifiedProperty().getValue());
+		assertEquals("2", props.getRevisionProperty().getValue());
+		assertEquals("MySubject", props.getSubjectProperty().getValue());
+		assertEquals("MyTitle", props.getTitleProperty().getValue());
+		assertEquals("2", props.getVersionProperty().getValue());
+	}
+}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageThumbnail.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageThumbnail.java?rev=755699&r1=755698&r2=755699&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageThumbnail.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageThumbnail.java Wed Mar 18 18:54:01 2009
@@ -1,57 +1,57 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-
-package org.apache.poi.openxml4j.opc;
-
-import java.io.File;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
-
-/**
- * Test the addition of thumbnail in a package.
- * 
- * @author Julien Chable
- */
-public final class TestPackageThumbnail extends TestCase {
-
-	/**
-	 * Test package addThumbnail() method.
-	 */
-	public void testSetProperties() throws Exception {
-		String inputPath = OpenXML4JTestDataSamples.getSampleFileName("TestPackageThumbnail.docx");
-
-		String imagePath = OpenXML4JTestDataSamples.getSampleFileName("thumbnail.jpg");
-
-		File outputFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageThumbnailOUTPUT.docx");
-
-		// Open package
-		Package p = Package.open(inputPath, PackageAccess.READ_WRITE);
-		p.addThumbnail(imagePath);
-		// Save the package in the output directory
-		p.save(outputFile);
-
-		// Open the newly created file to check core properties saved values.
-		Package p2 = Package.open(outputFile.getAbsolutePath(), PackageAccess.READ);
-		if (p2.getRelationshipsByType(PackageRelationshipTypes.THUMBNAIL)
-				.size() == 0)
-			fail("Thumbnail not added to the package !");
-		p2.revert();
-		outputFile.delete();
-	}
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.openxml4j.opc;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
+
+/**
+ * Test the addition of thumbnail in a package.
+ * 
+ * @author Julien Chable
+ */
+public final class TestPackageThumbnail extends TestCase {
+
+	/**
+	 * Test package addThumbnail() method.
+	 */
+	public void testSetProperties() throws Exception {
+		String inputPath = OpenXML4JTestDataSamples.getSampleFileName("TestPackageThumbnail.docx");
+
+		String imagePath = OpenXML4JTestDataSamples.getSampleFileName("thumbnail.jpg");
+
+		File outputFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageThumbnailOUTPUT.docx");
+
+		// Open package
+		OPCPackage p = OPCPackage.open(inputPath, PackageAccess.READ_WRITE);
+		p.addThumbnail(imagePath);
+		// Save the package in the output directory
+		p.save(outputFile);
+
+		// Open the newly created file to check core properties saved values.
+		OPCPackage p2 = OPCPackage.open(outputFile.getAbsolutePath(), PackageAccess.READ);
+		if (p2.getRelationshipsByType(PackageRelationshipTypes.THUMBNAIL)
+				.size() == 0)
+			fail("Thumbnail not added to the package !");
+		p2.revert();
+		outputFile.delete();
+	}
+}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java?rev=755699&r1=755698&r2=755699&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java Wed Mar 18 18:54:01 2009
@@ -1,117 +1,117 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.openxml4j.opc;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.openxml4j.opc.ContentTypes;
-import org.apache.poi.openxml4j.opc.Package;
-import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.openxml4j.opc.PackagePartName;
-import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-
-public class TestPackagingURIHelper extends TestCase {
-
-	/**
-	 * Test relativizePartName() method.
-     *
-     * TODO: fix and unable
-	 */
-	public void testRelativizeURI() throws Exception {
-		URI uri1 = new URI("/word/document.xml");
-		URI uri2 = new URI("/word/media/image1.gif");
-		
-		// Document to image is down a directory
-		URI retURI1to2 = PackagingURIHelper.relativizeURI(uri1, uri2);
-		assertEquals("media/image1.gif", retURI1to2.getPath());
-		// Image to document is up a directory
-		URI retURI2to1 = PackagingURIHelper.relativizeURI(uri2, uri1);
-		assertEquals("../document.xml", retURI2to1.getPath());
-		
-		// Document and CustomXML parts totally different [Julien C.]
-		URI uriCustomXml = new URI("/customXml/item1.xml");
-		URI uriRes = PackagingURIHelper.relativizeURI(uri1, uriCustomXml);
-		assertEquals("../customXml/item1.xml", uriRes.toString());
-
-		// Document to itself is the same place (empty URI)
-		URI retURI2 = PackagingURIHelper.relativizeURI(uri1, uri1);
-		assertEquals("", retURI2.getPath());
-
-		// Document and root totally different
-		URI uri4 = new URI("/");
-		try {
-			PackagingURIHelper.relativizeURI(uri1, uri4);
-			//TODO: figure oout why the assertion fails
-            //fail("Must throw an exception ! Can't relativize with an empty URI");
-		} catch (Exception e) {
-			// Do nothing
-		}
-		try {
-			PackagingURIHelper.relativizeURI(uri4, uri1);
-            //TODO: figure oout why the assertion fails
-			//fail("Must throw an exception ! Can't relativize with an empty URI");
-		} catch (Exception e) {
-			// Do nothing
-		}
-	}
-
-	/**
-	 * Test createPartName(String, y)
-	 */
-	public void testCreatePartNameRelativeString()
-			throws InvalidFormatException {
-		PackagePartName partNameToValid = PackagingURIHelper
-				.createPartName("/word/media/image1.gif");
-
-		Package pkg = Package.create("DELETEIFEXISTS.docx");
-		// Base part
-		PackagePartName nameBase = PackagingURIHelper
-				.createPartName("/word/document.xml");
-		PackagePart partBase = pkg.createPart(nameBase, ContentTypes.XML);
-		// Relative part name
-		PackagePartName relativeName = PackagingURIHelper.createPartName(
-				"media/image1.gif", partBase);
-		assertTrue("The part name must be equal to "
-				+ partNameToValid.getName(), partNameToValid
-				.equals(relativeName));
-		pkg.revert();
-	}
-
-	/**
-	 * Test createPartName(URI, y)
-	 */
-	public void testCreatePartNameRelativeURI() throws Exception {
-		PackagePartName partNameToValid = PackagingURIHelper
-				.createPartName("/word/media/image1.gif");
-
-		Package pkg = Package.create("DELETEIFEXISTS.docx");
-		// Base part
-		PackagePartName nameBase = PackagingURIHelper
-				.createPartName("/word/document.xml");
-		PackagePart partBase = pkg.createPart(nameBase, ContentTypes.XML);
-		// Relative part name
-		PackagePartName relativeName = PackagingURIHelper.createPartName(
-				new URI("media/image1.gif"), partBase);
-		assertTrue("The part name must be equal to "
-				+ partNameToValid.getName(), partNameToValid
-				.equals(relativeName));
-		pkg.revert();
-	}
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.openxml4j.opc;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.openxml4j.opc.ContentTypes;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackagePartName;
+import org.apache.poi.openxml4j.opc.PackagingURIHelper;
+
+public class TestPackagingURIHelper extends TestCase {
+
+	/**
+	 * Test relativizePartName() method.
+     *
+     * TODO: fix and unable
+	 */
+	public void testRelativizeURI() throws Exception {
+		URI uri1 = new URI("/word/document.xml");
+		URI uri2 = new URI("/word/media/image1.gif");
+		
+		// Document to image is down a directory
+		URI retURI1to2 = PackagingURIHelper.relativizeURI(uri1, uri2);
+		assertEquals("media/image1.gif", retURI1to2.getPath());
+		// Image to document is up a directory
+		URI retURI2to1 = PackagingURIHelper.relativizeURI(uri2, uri1);
+		assertEquals("../document.xml", retURI2to1.getPath());
+		
+		// Document and CustomXML parts totally different [Julien C.]
+		URI uriCustomXml = new URI("/customXml/item1.xml");
+		URI uriRes = PackagingURIHelper.relativizeURI(uri1, uriCustomXml);
+		assertEquals("../customXml/item1.xml", uriRes.toString());
+
+		// Document to itself is the same place (empty URI)
+		URI retURI2 = PackagingURIHelper.relativizeURI(uri1, uri1);
+		assertEquals("", retURI2.getPath());
+
+		// Document and root totally different
+		URI uri4 = new URI("/");
+		try {
+			PackagingURIHelper.relativizeURI(uri1, uri4);
+			//TODO: figure oout why the assertion fails
+            //fail("Must throw an exception ! Can't relativize with an empty URI");
+		} catch (Exception e) {
+			// Do nothing
+		}
+		try {
+			PackagingURIHelper.relativizeURI(uri4, uri1);
+            //TODO: figure oout why the assertion fails
+			//fail("Must throw an exception ! Can't relativize with an empty URI");
+		} catch (Exception e) {
+			// Do nothing
+		}
+	}
+
+	/**
+	 * Test createPartName(String, y)
+	 */
+	public void testCreatePartNameRelativeString()
+			throws InvalidFormatException {
+		PackagePartName partNameToValid = PackagingURIHelper
+				.createPartName("/word/media/image1.gif");
+
+		OPCPackage pkg = OPCPackage.create("DELETEIFEXISTS.docx");
+		// Base part
+		PackagePartName nameBase = PackagingURIHelper
+				.createPartName("/word/document.xml");
+		PackagePart partBase = pkg.createPart(nameBase, ContentTypes.XML);
+		// Relative part name
+		PackagePartName relativeName = PackagingURIHelper.createPartName(
+				"media/image1.gif", partBase);
+		assertTrue("The part name must be equal to "
+				+ partNameToValid.getName(), partNameToValid
+				.equals(relativeName));
+		pkg.revert();
+	}
+
+	/**
+	 * Test createPartName(URI, y)
+	 */
+	public void testCreatePartNameRelativeURI() throws Exception {
+		PackagePartName partNameToValid = PackagingURIHelper
+				.createPartName("/word/media/image1.gif");
+
+		OPCPackage pkg = OPCPackage.create("DELETEIFEXISTS.docx");
+		// Base part
+		PackagePartName nameBase = PackagingURIHelper
+				.createPartName("/word/document.xml");
+		PackagePart partBase = pkg.createPart(nameBase, ContentTypes.XML);
+		// Relative part name
+		PackagePartName relativeName = PackagingURIHelper.createPartName(
+				new URI("media/image1.gif"), partBase);
+		assertTrue("The part name must be equal to "
+				+ partNameToValid.getName(), partNameToValid
+				.equals(relativeName));
+		pkg.revert();
+	}
+}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java?rev=755699&r1=755698&r2=755699&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java Wed Mar 18 18:54:01 2009
@@ -45,7 +45,7 @@
      */
     public void testLoadRelationships() throws Exception {
         InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.xlsx");
-        Package pkg = Package.open(is);
+        OPCPackage pkg = OPCPackage.open(is);
         logger.debug("1: " + pkg);
         PackageRelationshipCollection rels = pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
         PackageRelationship coreDocRelationship = rels.getRelationship(0);
@@ -66,7 +66,7 @@
      */
     public void testFetchFromCollection() throws Exception {
         InputStream is = OpenXML4JTestDataSamples.openSampleStream("ExcelWithHyperlinks.xlsx");
-        Package pkg = Package.open(is);
+        OPCPackage pkg = OPCPackage.open(is);
         PackagePart sheet = pkg.getPart(
         		PackagingURIHelper.createPartName(SHEET_WITH_COMMENTS));
         assertNotNull(sheet);
@@ -107,7 +107,7 @@
      */
     public void testLoadExcelHyperlinkRelations() throws Exception {
         InputStream is = OpenXML4JTestDataSamples.openSampleStream("ExcelWithHyperlinks.xlsx");
-        Package pkg = Package.open(is);
+        OPCPackage pkg = OPCPackage.open(is);
 	    PackagePart sheet = pkg.getPart(
 	    		PackagingURIHelper.createPartName(SHEET_WITH_COMMENTS));
 	    assertNotNull(sheet);
@@ -141,7 +141,7 @@
      */
     public void testCreateExcelHyperlinkRelations() throws Exception {
     	String filepath = OpenXML4JTestDataSamples.getSampleFileName("ExcelWithHyperlinks.xlsx");
-	    Package pkg = Package.open(filepath, PackageAccess.READ_WRITE);
+	    OPCPackage pkg = OPCPackage.open(filepath, PackageAccess.READ_WRITE);
 	    PackagePart sheet = pkg.getPart(
 	    		PackagingURIHelper.createPartName(SHEET_WITH_COMMENTS));
 	    assertNotNull(sheet);
@@ -185,7 +185,7 @@
 	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
 	    pkg.save(baos);
 	    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-	    pkg = Package.open(bais);
+	    pkg = OPCPackage.open(bais);
 	    
 	    // Check again
 	    sheet = pkg.getPart(
@@ -208,7 +208,7 @@
 
     public void testCreateRelationsFromScratch() throws Exception {
     	ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    	Package pkg = Package.create(baos);
+    	OPCPackage pkg = OPCPackage.create(baos);
     	
     	PackagePart partA =
     		pkg.createPart(PackagingURIHelper.createPartName("/partA"), "text/plain");
@@ -235,7 +235,7 @@
     	// Save, and re-load
     	pkg.close();
     	ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-    	pkg = Package.open(bais);
+    	pkg = OPCPackage.open(bais);
     	
     	partA = pkg.getPart(PackagingURIHelper.createPartName("/partA"));
     	partB = pkg.getPart(PackagingURIHelper.createPartName("/partB"));



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


Mime
View raw message