You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/02/05 06:07:24 UTC

svn commit: r741002 - in /poi/trunk: ./ src/ooxml/testcases/org/apache/poi/openxml4j/ src/ooxml/testcases/org/apache/poi/openxml4j/opc/ src/ooxml/testcases/org/apache/poi/openxml4j/opc/OUTPUT/ src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance...

Author: josh
Date: Thu Feb  5 05:07:23 2009
New Revision: 741002

URL: http://svn.apache.org/viewvc?rev=741002&view=rev
Log:
Improvements to OpenXML4J unit tests.  Fixed class names. Refactored code for opening test data files.   Changed test output to go to temp dir.

Added:
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java   (with props)
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java
      - copied, changed from r740524, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllTests.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java
      - copied, changed from r740938, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllTests.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java
      - copied, changed from r740938, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_CoreProperties.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java
      - copied, changed from r740938, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PackageModel.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java
      - copied, changed from r740938, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PartName.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java
      - copied, changed from r740524, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllTests.java
Removed:
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/TestCore.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllTests.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/OUTPUT/
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllTests.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_CoreProperties.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PackageModel.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PartName.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllTests.java
Modified:
    poi/trunk/build.xml
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageThumbnail.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/TestContentTypeManager.java
    poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java

Modified: poi/trunk/build.xml
URL: http://svn.apache.org/viewvc/poi/trunk/build.xml?rev=741002&r1=741001&r2=741002&view=diff
==============================================================================
--- poi/trunk/build.xml (original)
+++ poi/trunk/build.xml Thu Feb  5 05:07:23 2009
@@ -797,7 +797,6 @@
             <sysproperty key="OOXML.testdata.path" file="${ooxml.src.test}/org/apache/poi/ooxml/data"/> 
             <sysproperty key="openxml4j.compliance.input" file="${ooxml.src.test}/org/apache/poi/openxml4j/opc/compliance/input"/> 
             <sysproperty key="openxml4j.testdata.input" file="${ooxml.src.test}/org/apache/poi/openxml4j/opc/INPUT"/> 
-            <sysproperty key="openxml4j.testdata.output" file="${ooxml.src.test}/org/apache/poi/openxml4j/opc/OUTPUT"/> 
             <sysproperty key="java.awt.headless" value="true"/>
             <formatter type="plain"/>
             <formatter type="xml"/>

Added: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java?rev=741002&view=auto
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java (added)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java Thu Feb  5 05:07:23 2009
@@ -0,0 +1,148 @@
+/* ====================================================================
+   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;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+/**
+ * Centralises logic for finding/opening sample files for ooxml4j unit tests 
+ * 
+ * @author jmicich
+ */
+public final class OpenXML4JTestDataSamples {
+
+	private static final String IN_DIR_PROP_NAME = "openxml4j.testdata.input";
+	private static final String COMP_IN_DIR_PROP_NAME = "openxml4j.compliance.input";
+	
+	private static File _sampleInputDir;
+	private static File _sampleOutputDir;
+	private static File _complianceSampleInputDir;
+
+	private OpenXML4JTestDataSamples() {
+		// no instances of this class
+	}
+	
+	public static InputStream openSampleStream(String sampleFileName) {
+		File f = getSampleFile(sampleFileName);
+		try {
+			return new FileInputStream(f);
+		} catch (FileNotFoundException e) {
+			throw new RuntimeException(e);
+		}
+	}
+	public static String getSampleFileName(String sampleFileName) {
+		// TODO - investigate allowing read/write access for package opened on stream
+		return getSampleFile(sampleFileName).getAbsolutePath();
+	}
+	
+	public static File getSampleFile(String sampleFileName) {
+		File dir = getSampleInputDir();
+		File f = new File(dir, sampleFileName);
+		if (!f.exists()) {
+			throw new RuntimeException("Specified sample file '" 
+					+ f.getAbsolutePath() + "' does not exist");
+		}
+		if (f.isDirectory()) {
+			throw new RuntimeException("Specified sample file '" 
+					+ f.getAbsolutePath() + "' is a directory");
+		}
+		return f;
+	}
+	
+	public static File getOutputFile(String outputFileName) {
+		File dir = getSampleOutputDir();
+		return new File(dir, outputFileName);
+	}
+
+
+	public static InputStream openComplianceSampleStream(String sampleFileName) {
+		File f = getComplianceSampleFile(sampleFileName);
+		try {
+			return new FileInputStream(f);
+		} catch (FileNotFoundException e) {
+			throw new RuntimeException(e);
+		}
+	}
+	private static File getComplianceSampleFile(String sampleFileName) {
+		File dir = getComplianceSampleInputDir();
+		File f = new File(dir, sampleFileName);
+		if (!f.exists()) {
+			throw new RuntimeException("Specified sample file '" 
+					+ f.getAbsolutePath() + "' does not exist");
+		}
+		if (f.isDirectory()) {
+			throw new RuntimeException("Specified sample file '" 
+					+ f.getAbsolutePath() + "' is a directory");
+		}
+		return f;
+	}
+	public static String getComplianceSampleFileName(String sampleFileName) {
+		return getComplianceSampleFile(sampleFileName).getAbsolutePath();
+	}
+	private static File getComplianceSampleInputDir() {
+		if (_complianceSampleInputDir == null) {
+			_complianceSampleInputDir = getAndCheckDirByProperty(COMP_IN_DIR_PROP_NAME);
+		}
+		return _complianceSampleInputDir;
+	}
+
+	
+	private static File getSampleInputDir() {
+		if (_sampleInputDir == null) {
+			_sampleInputDir = getAndCheckDirByProperty(IN_DIR_PROP_NAME);
+		}
+		return _sampleInputDir;
+	}
+
+	private static File getAndCheckDirByProperty(String propName) {
+		String dirName = System.getProperty(propName);
+		File dir = new File(dirName);
+		if (!dir.exists()) {
+			throw new RuntimeException("Specified '" + propName + "' directory: '"
+					+ dirName + "' does not exist");
+		}
+		if (!dir.isDirectory()) {
+			throw new RuntimeException("Specified '" + propName + "' directory: '"
+					+ dirName + "' is a not a proper directory");
+		}
+		return dir;
+	}
+
+	private static File getSampleOutputDir() {
+		if (_sampleOutputDir == null) {
+            File dir = new File(System.getProperty("java.io.tmpdir"), "poifiles");
+			if (dir.exists()) {
+    			if (!dir.isDirectory()) {
+    				throw new RuntimeException("Specified output directory: '"
+    						+ dir.getAbsolutePath() + "' is a not a proper directory");
+    			}
+			} else {
+				if (!dir.mkdirs()) {
+					throw new RuntimeException("Failed to create directory: '"
+							+ dir.getAbsolutePath() + "'");
+				}
+			}
+			_sampleOutputDir = dir;
+		}
+		return _sampleOutputDir;
+	}
+
+}

Propchange: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/OpenXML4JTestDataSamples.java
------------------------------------------------------------------------------
    svn:executable = *

Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java (from r740524, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllTests.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java&p1=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllTests.java&r1=740524&r2=741002&rev=741002&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllTests.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java Thu Feb  5 05:07:23 2009
@@ -20,19 +20,25 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-public class AllTests {
+import org.apache.poi.openxml4j.opc.compliance.AllOpenXML4JComplianceTests;
+import org.apache.poi.openxml4j.opc.internal.AllOpenXML4JInternalTests;
+
+public final class AllOpenXML4JTests {
 
 	public static Test suite() {
-		TestSuite suite = new TestSuite(
-				"Functional tests for org.apache.poi.openxml4j.opc");
-		suite.addTestSuite(TestListParts.class);
+		
+		TestSuite suite = new TestSuite(AllOpenXML4JTests.class.getName());
+		suite.addTestSuite(TestContentType.class);
 		suite.addTestSuite(TestFileHelper.class);
+		suite.addTestSuite(TestListParts.class);
 		suite.addTestSuite(TestPackage.class);
 		suite.addTestSuite(TestPackageCoreProperties.class);
 		suite.addTestSuite(TestPackagePartName.class);
-		suite.addTestSuite(TestPackagingURIHelper.class);
-		suite.addTestSuite(TestContentType.class);
 		suite.addTestSuite(TestPackageThumbnail.class);
+		suite.addTestSuite(TestPackagingURIHelper.class);
+		suite.addTestSuite(TestRelationships.class);
+		suite.addTest(AllOpenXML4JComplianceTests.suite());
+		suite.addTest(AllOpenXML4JInternalTests.suite());
 		return suite;
 	}
 }

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=741002&r1=741001&r2=741002&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 Thu Feb  5 05:07:23 2009
@@ -17,27 +17,22 @@
 
 package org.apache.poi.openxml4j.opc;
 
-import java.io.File;
+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;
-import org.apache.poi.openxml4j.opc.Package;
-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.PackagingURIHelper;
 
-import org.apache.poi.openxml4j.TestCore;
+public final class TestListParts extends TestCase {
+	private static Logger logger = Logger.getLogger("org.apache.poi.openxml4j.test");
 
-public class TestListParts extends TestCase {
+	private TreeMap<PackagePartName, String> expectedValues;
 
-	TestCore testCore = new TestCore(this.getClass());
-
-	TreeMap<PackagePartName, String> expectedValues;
-
-	TreeMap<PackagePartName, String> values;
+	private TreeMap<PackagePartName, String> values;
 
 	@Override
 	protected void setUp() throws Exception {
@@ -86,13 +81,17 @@
 	 * List all parts of a package.
 	 */
 	public void testListParts() throws InvalidFormatException {
-		String filepath = System.getProperty("openxml4j.testdata.input") + File.separator
-				+ "sample.docx";
+		InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.docx");
 
-		Package p = Package.open(filepath, PackageAccess.READ);
+		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());
-			TestCore.getLogger().debug(part.getPartName());
+			logger.debug(part.getPartName());
 		}
 
 		// Compare expected values with values return by the package

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=741002&r1=741001&r2=741002&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 Thu Feb  5 05:07:23 2009
@@ -30,33 +30,28 @@
 
 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;
-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.apache.poi.openxml4j.TestCore;
-
-public class TestPackage extends TestCase {
 
-	TestCore testCore = new TestCore(this.getClass());
+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 {
-		File originalFile = new File(System.getProperty("openxml4j.testdata.input") + File.separator
-				+ "TestPackageCommon.docx");
-		File targetFile = new File(System.getProperty("openxml4j.testdata.output")
-				+ File.separator + "TestPackageOpenSaveTMP.docx");
-		assertTrue("Source file " + originalFile + " doesn't exist!", originalFile.exists());
+		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageOpenSaveTMP.docx");
 
-		Package p = Package.open(originalFile.getAbsolutePath(),
-				PackageAccess.READ_WRITE);
+		Package p = Package.open(originalFile, PackageAccess.READ_WRITE);
 		p.save(targetFile.getAbsoluteFile());
 
 		// Compare the original and newly saved document
@@ -70,8 +65,7 @@
 	 *  the correct default content types
 	 */
 	public void testCreateGetsContentTypes() throws Exception {
-		File targetFile = new File(System.getProperty("openxml4j.testdata.output") + File.separator 
-				+ "TestCreatePackageTMP.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageTMP.docx");
 		
 		// Zap the target file, in case of an earlier run
 		if(targetFile.exists()) targetFile.delete();
@@ -103,11 +97,9 @@
 	 * Test package creation.
 	 */
 	public void testCreatePackageAddPart() throws Exception {
-		File targetFile = new File(System.getProperty("openxml4j.testdata.output") + File.separator
-				+ "TestCreatePackageTMP.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageTMP.docx");
 
-		File expectedFile = new File(System.getProperty("openxml4j.testdata.output") + File.separator
-				+ "TestCreatePackageOUTPUT.docx");
+		File expectedFileFile = OpenXML4JTestDataSamples.getOutputFile("TestCreatePackageOUTPUT.docx");
 
 		// Zap the target file, in case of an earlier run
 		if(targetFile.exists()) targetFile.delete();
@@ -208,14 +200,11 @@
 	 * Test package opening.
 	 */
 	public void testOpenPackage() throws Exception {
-		File targetFile = new File(System.getProperty("openxml4j.testdata.output")
-				+ File.separator + "TestOpenPackageTMP.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestOpenPackageTMP.docx");
 
-		File inputFile = new File(System.getProperty("openxml4j.testdata.input")
-				+ File.separator + "TestOpenPackageINPUT.docx");
+		File inputFile = OpenXML4JTestDataSamples.getSampleFile("TestOpenPackageINPUT.docx");
 
-		File expectedFile = new File(System.getProperty("openxml4j.testdata.output")
-                + File.separator + "TestOpenPackageOUTPUT.docx");
+		File expectedFile = OpenXML4JTestDataSamples.getOutputFile("TestOpenPackageOUTPUT.docx");
 
 		// Copy the input file in the output directory
 		FileHelper.copyFile(inputFile, targetFile);
@@ -271,14 +260,10 @@
 	 *  to a file
 	 */
 	public void testSaveToOutputStream() throws Exception {
-		File originalFile = new File(System.getProperty("openxml4j.testdata.input") + File.separator
-				+ "TestPackageCommon.docx");
-		File targetFile = new File(System.getProperty("openxml4j.testdata.output") + File.separator
-                + "TestPackageOpenSaveTMP.docx");
-		assertTrue("Source file " + originalFile + " doesn't exist!", originalFile.exists());
+		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageOpenSaveTMP.docx");
 
-		Package p = Package.open(originalFile.getAbsolutePath(),
-				PackageAccess.READ_WRITE);
+		Package p = Package.open(originalFile, PackageAccess.READ_WRITE);
 		FileOutputStream fout = new FileOutputStream(targetFile);
 		p.save(fout);
 		fout.close();
@@ -295,9 +280,7 @@
 	 *  reading from a file
 	 */
 	public void testOpenFromInputStream() throws Exception {
-		File originalFile = new File(System.getProperty("openxml4j.testdata.input") + File.separator
-				+ "TestPackageCommon.docx");
-		assertTrue("Source file " + originalFile + " doesn't exist!", originalFile.exists());
+		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
 		
 		FileInputStream finp = new FileInputStream(originalFile);
 		
@@ -313,18 +296,14 @@
 	}
 
     /**
-     * TODO: fix and unable
+     * TODO: fix and enable
      */
     public void disabled_testRemovePartRecursive() throws Exception {
-		File originalFile = new File(System.getProperty("openxml4j.testdata.input") + File.separator
-				+ "TestPackageCommon.docx");
-		File targetFile = new File(System.getProperty("openxml4j.testdata.output") + File.separator
-				+ "TestPackageRemovePartRecursiveOUTPUT.docx");
-		File tempFile = new File(System.getProperty("openxml4j.testdata.output") + File.separator
-				+ "TestPackageRemovePartRecursiveTMP.docx");
+		String originalFile = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCommon.docx");
+		File targetFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageRemovePartRecursiveOUTPUT.docx");
+		File tempFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageRemovePartRecursiveTMP.docx");
 
-		Package p = Package.open(originalFile.getAbsolutePath(),
-				PackageAccess.READ_WRITE);
+		Package p = Package.open(originalFile, PackageAccess.READ_WRITE);
 		p.removePartRecursive(PackagingURIHelper.createPartName(new URI(
 				"/word/document.xml")));
 		p.save(tempFile.getAbsoluteFile());
@@ -372,8 +351,7 @@
 								.createPartName("/word/webSettings.xml"),
 						"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml");
 
-		String filepath = System.getProperty("openxml4j.testdata.input") + File.separator
-				+ "sample.docx";
+		String filepath =  OpenXML4JTestDataSamples.getSampleFileName("sample.docx");
 
 		Package p = Package.open(filepath, PackageAccess.READ_WRITE);
 		// Remove the core part
@@ -381,7 +359,7 @@
 
 		for (PackagePart part : p.getParts()) {
 			values.put(part.getPartName(), part.getContentType());
-			TestCore.getLogger().debug(part.getPartName());
+			logger.debug(part.getPartName());
 		}
 
 		// Compare expected values with values return by the package
@@ -389,7 +367,7 @@
 			assertNotNull(values.get(partName));
 			assertEquals(expectedValues.get(partName), values.get(partName));
 		}
-		// Don't save modfications
+		// Don't save modifications
 		p.revert();
 	}
 	
@@ -411,8 +389,7 @@
 				.createPartName("/docProps/core.xml"),
 				"application/vnd.openxmlformats-package.core-properties+xml");
 
-		String filepath = System.getProperty("openxml4j.testdata.input") + File.separator
-				+ "sample.docx";
+		String filepath = OpenXML4JTestDataSamples.getSampleFileName("sample.docx");
 
 		Package p = Package.open(filepath, PackageAccess.READ_WRITE);
 		// Remove the core part
@@ -420,7 +397,7 @@
 
 		for (PackagePart part : p.getParts()) {
 			values.put(part.getPartName(), part.getContentType());
-			TestCore.getLogger().debug(part.getPartName());
+			logger.debug(part.getPartName());
 		}
 
 		// Compare expected values with values return by the package
@@ -428,7 +405,7 @@
 			assertNotNull(values.get(partName));
 			assertEquals(expectedValues.get(partName), values.get(partName));
 		}
-		// Don't save modfications
+		// Don't save modifications
 		p.revert();
 	}
 	

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=741002&r1=741001&r2=741002&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 Thu Feb  5 05:07:23 2009
@@ -18,22 +18,20 @@
 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;
 
-import org.apache.poi.openxml4j.TestCore;
-import org.apache.log4j.Logger;
-
-public class TestPackageCoreProperties extends TestCase {
-
-	TestCore testCore = new TestCore(this.getClass());
+public final class TestPackageCoreProperties extends TestCase {
 
 	/**
 	 * Test package core properties getters.
@@ -41,13 +39,14 @@
 	public void testGetProperties() {
 		try {
 			// Open the package
-			Package p = Package.open(System.getProperty("openxml4j.testdata.input") + File.separator
-					+ "TestPackageCoreProperiesGetters.docx",
-					PackageAccess.READ);
+			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);
 		}
 	}
 
@@ -55,11 +54,9 @@
 	 * Test package core properties setters.
 	 */
 	public void testSetProperties() throws Exception {
-		String inputPath = System.getProperty("openxml4j.testdata.input")
-				+ File.separator + "TestPackageCoreProperiesSetters.docx";
+		String inputPath = OpenXML4JTestDataSamples.getSampleFileName("TestPackageCoreProperiesSetters.docx");
 
-		String outputFilename = System.getProperty("openxml4j.testdata.input")
-				+ File.separator + "TestPackageCoreProperiesSettersOUTPUT.docx";
+		File outputFile = OpenXML4JTestDataSamples.getOutputFile("TestPackageCoreProperiesSettersOUTPUT.docx");
 
 		// Open package
 		Package p = Package.open(inputPath, PackageAccess.READ_WRITE);
@@ -86,14 +83,13 @@
 		props.setSubjectProperty("MySubject");
 		props.setVersionProperty("2");
 		// Save the package in the output directory
-		p.save(new File(outputFilename));
+		p.save(outputFile);
 
 		// Open the newly created file to check core properties saved values.
-		File fOut = new File(outputFilename);
-		Package p2 = Package.open(outputFilename, PackageAccess.READ);
+		Package p2 = Package.open(outputFile.getAbsolutePath(), PackageAccess.READ);
 		compareProperties(p2);
 		p2.revert();
-		fOut.delete();
+		outputFile.delete();
 	}
 
 	private void compareProperties(Package p) throws InvalidFormatException {

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=741002&r1=741001&r2=741002&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 Thu Feb  5 05:07:23 2009
@@ -21,47 +21,37 @@
 
 import junit.framework.TestCase;
 
-import org.apache.poi.openxml4j.opc.Package;
-import org.apache.poi.openxml4j.opc.PackageAccess;
-import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
-
-import org.apache.poi.openxml4j.TestCore;
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
 
 /**
  * Test the addition of thumbnail in a package.
  * 
  * @author Julien Chable
  */
-public class TestPackageThumbnail extends TestCase {
-
-	TestCore testCore = new TestCore(this.getClass());
+public final class TestPackageThumbnail extends TestCase {
 
 	/**
 	 * Test package addThumbnail() method.
 	 */
 	public void testSetProperties() throws Exception {
-		String inputPath = System.getProperty("openxml4j.testdata.input")
-				+ File.separator + "TestPackageThumbnail.docx";
+		String inputPath = OpenXML4JTestDataSamples.getSampleFileName("TestPackageThumbnail.docx");
 
-		String imagePath = System.getProperty("openxml4j.testdata.input")
-				+ File.separator + "thumbnail.jpg";
+		String imagePath = OpenXML4JTestDataSamples.getSampleFileName("thumbnail.jpg");
 
-		String outputFilename = System.getProperty("openxml4j.testdata.output")
-				+ File.separator + "TestPackageThumbnailOUTPUT.docx";
+		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(new File(outputFilename));
+		p.save(outputFile);
 
 		// Open the newly created file to check core properties saved values.
-		File fOut = new File(outputFilename);
-		Package p2 = Package.open(outputFilename, PackageAccess.READ);
+		Package p2 = Package.open(outputFile.getAbsolutePath(), PackageAccess.READ);
 		if (p2.getRelationshipsByType(PackageRelationshipTypes.THUMBNAIL)
 				.size() == 0)
 			fail("Thumbnail not added to the package !");
 		p2.revert();
-		//fOut.delete();
+		outputFile.delete();
 	}
 }

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=741002&r1=741001&r2=741002&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 Thu Feb  5 05:07:23 2009
@@ -19,32 +19,23 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
+import java.io.InputStream;
 
 import junit.framework.TestCase;
 
-import org.apache.poi.openxml4j.opc.Package;
-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.PackageRelationshipCollection;
-import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
-import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-import org.apache.poi.openxml4j.opc.TargetMode;
-
-import org.apache.poi.openxml4j.TestCore;
+import org.apache.log4j.Logger;
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
 
 
 public class TestRelationships extends TestCase {
-	public static final String HYPERLINK_REL_TYPE =
+	private static final String HYPERLINK_REL_TYPE =
 		"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
-	public static final String COMMENTS_REL_TYPE =
+	private static final String COMMENTS_REL_TYPE =
 		"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
-	public static final String SHEET_WITH_COMMENTS =
+	private static final String SHEET_WITH_COMMENTS =
 		"/xl/worksheets/sheet1.xml";
 
-    TestCore testCore = new TestCore(this.getClass());
+	private static Logger logger = Logger.getLogger("org.apache.poi.openxml4j.test");
 
     /**
      * Test relationships are correctly loaded. This at the moment fails (as of r499)
@@ -53,10 +44,9 @@
      * really look also for not yet loaded parts.
      */
     public void testLoadRelationships() throws Exception {
-        String filepath = System.getProperty("openxml4j.testdata.input") + File.separator
-            + "sample.xlsx";
-        Package pkg = Package.open(filepath, PackageAccess.READ);
-        TestCore.getLogger().debug("1: " + pkg);
+        InputStream is = OpenXML4JTestDataSamples.openSampleStream("sample.xlsx");
+        Package pkg = Package.open(is);
+        logger.debug("1: " + pkg);
         PackageRelationshipCollection rels = pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
         PackageRelationship coreDocRelationship = rels.getRelationship(0);
         PackagePart corePart = pkg.getPart(coreDocRelationship);
@@ -75,10 +65,8 @@
      *  type, then grab from within there by id
      */
     public void testFetchFromCollection() throws Exception {
-        String filepath = System.getProperty("openxml4j.testdata.input") + File.separator
-        	+ "ExcelWithHyperlinks.xlsx";
-    	
-        Package pkg = Package.open(filepath, PackageAccess.READ);
+        InputStream is = OpenXML4JTestDataSamples.openSampleStream("ExcelWithHyperlinks.xlsx");
+        Package pkg = Package.open(is);
         PackagePart sheet = pkg.getPart(
         		PackagingURIHelper.createPartName(SHEET_WITH_COMMENTS));
         assertNotNull(sheet);
@@ -118,10 +106,8 @@
      *  external hyperlinks. Check we can load these ok.
      */
     public void testLoadExcelHyperlinkRelations() throws Exception {
-        String filepath = System.getProperty("openxml4j.testdata.input") + File.separator
-	    	+ "ExcelWithHyperlinks.xlsx";
-		
-	    Package pkg = Package.open(filepath, PackageAccess.READ);
+        InputStream is = OpenXML4JTestDataSamples.openSampleStream("ExcelWithHyperlinks.xlsx");
+        Package pkg = Package.open(is);
 	    PackagePart sheet = pkg.getPart(
 	    		PackagingURIHelper.createPartName(SHEET_WITH_COMMENTS));
 	    assertNotNull(sheet);
@@ -150,13 +136,11 @@
     
     /*
      * Excel uses relations on sheets to store the details of 
-     *  external hyperlinks. Check we can create these ok, 
+     *  external hyperlinks. Check we can create these OK, 
      *  then still read them later
      */
     public void testCreateExcelHyperlinkRelations() throws Exception {
-        String filepath = System.getProperty("openxml4j.testdata.input") + File.separator
-	    	+ "ExcelWithHyperlinks.xlsx";
-		
+    	String filepath = OpenXML4JTestDataSamples.getSampleFileName("ExcelWithHyperlinks.xlsx");
 	    Package pkg = Package.open(filepath, PackageAccess.READ_WRITE);
 	    PackagePart sheet = pkg.getPart(
 	    		PackagingURIHelper.createPartName(SHEET_WITH_COMMENTS));

Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java (from r740938, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllTests.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java&p1=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllTests.java&r1=740938&r2=741002&rev=741002&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllTests.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java Thu Feb  5 05:07:23 2009
@@ -20,16 +20,13 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-public class AllTests {
+public class AllOpenXML4JComplianceTests {
 
 	public static Test suite() {
-		TestSuite suite = new TestSuite(
-				"Test for test.org.apache.poi.openxml4j.opc.compliance");
-		// $JUnit-BEGIN$
-		suite.addTestSuite(OPCCompliance_PartName.class);
-		suite.addTestSuite(OPCCompliance_CoreProperties.class);
-		suite.addTestSuite(OPCCompliance_PackageModel.class);
-		// $JUnit-END$
+		TestSuite suite = new TestSuite(AllOpenXML4JComplianceTests.class.getName());
+		suite.addTestSuite(TestOPCCompliancePartName.class);
+		suite.addTestSuite(TestOPCComplianceCoreProperties.class);
+		suite.addTestSuite(TestOPCCompliancePackageModel.class);
 		return suite;
 	}
 

Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java (from r740938, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_CoreProperties.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java&p1=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_CoreProperties.java&r1=740938&r2=741002&rev=741002&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_CoreProperties.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java Thu Feb  5 05:07:23 2009
@@ -17,10 +17,15 @@
 
 package org.apache.poi.openxml4j.opc.compliance;
 
-import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
 import org.apache.poi.openxml4j.opc.ContentTypes;
@@ -29,9 +34,6 @@
 import org.apache.poi.openxml4j.opc.PackagingURIHelper;
 import org.apache.poi.openxml4j.opc.TargetMode;
 
-import org.apache.poi.openxml4j.TestCore;
-import junit.framework.TestCase;
-
 /**
  * Test core properties Open Packaging Convention compliance.
  * 
@@ -62,44 +64,52 @@
  * this constraint to be an error.
  * 
  * @author Julien Chable
- * @version 1.0
  */
-public class OPCCompliance_CoreProperties extends TestCase {
-
-	TestCore testCore = new TestCore(this.getClass());
+public final class TestOPCComplianceCoreProperties extends TestCase {
 
 	public void testCorePropertiesPart() {
-		Package pkg = null;
+		Package pkg;
 		try {
-			String filepath = System.getProperty("openxml4j.compliance.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_OnlyOneCorePropertiesPart.docx";
-			pkg = Package.open(filepath);
-			// Normally must thrown an InvalidFormatException exception.
-		} catch (InvalidFormatException e) {
-			fail("OPC compliance failure: the core properties is considered as invalid than it's not !");
-		} finally {
-			pkg.revert();
+			InputStream is = OpenXML4JTestDataSamples.openComplianceSampleStream("OPCCompliance_CoreProperties_OnlyOneCorePropertiesPart.docx");
+			pkg = Package.open(is);
+		} catch (InvalidFormatException e) {
+			throw new RuntimeException(e);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
 		}
+		pkg.revert();
 	}
 
+	private static String extractInvalidFormatMessage(String sampleNameSuffix) {
+
+		InputStream is = OpenXML4JTestDataSamples.openComplianceSampleStream("OPCCompliance_CoreProperties_" + sampleNameSuffix);
+		Package pkg;
+		try {
+			pkg = Package.open(is);
+		} catch (InvalidFormatException e) {
+			// expected during successful test
+			return e.getMessage();
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		pkg.revert();
+		// Normally must thrown an InvalidFormatException exception.
+		throw new AssertionFailedError("expected OPC compliance exception was not thrown");
+	}
+	
 	/**
 	 * Test M4.1 rule.
 	 */
 	public void testOnlyOneCorePropertiesPart() {
-		Package pkg = null;
+		String msg = extractInvalidFormatMessage("OnlyOneCorePropertiesPartFAIL.docx");
+		assertEquals("OPC Compliance error [M4.1]: there is more than one core properties relationship in the package !", msg);
+	}
+	
+	private static URI createURI(String text) {
 		try {
-			String filepath = System.getProperty("openxml4j.compliance.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_OnlyOneCorePropertiesPartFAIL.docx";
-			pkg = Package.open(filepath);
-			// Normally must thrown an InvalidFormatException exception.
-			fail("OPC compliance failure: M4.1 -> A format consumer shall consider more than one core properties relationship for a package to be an error.");
-		} catch (InvalidFormatException e) {
-			// DO nothing, it's the normal behavior
-		} finally {
-			if (pkg != null)
-				pkg.revert();
+			return new URI(text);
+		} catch (URISyntaxException e) {
+			throw new RuntimeException(e);
 		}
 	}
 
@@ -107,152 +117,92 @@
 	 * Test M4.1 rule.
 	 */
 	public void testOnlyOneCorePropertiesPart_AddRelationship() {
-		Package pkg = null;
+		InputStream is = OpenXML4JTestDataSamples.openComplianceSampleStream("OPCCompliance_CoreProperties_OnlyOneCorePropertiesPart.docx");
+		Package pkg;
 		try {
-			String filepath = System.getProperty("openxml4j.testdata.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_OnlyOneCorePropertiesPart.docx";
-			pkg = Package.open(filepath);
-			pkg.addRelationship(PackagingURIHelper.createPartName(new URI(
-					"/docProps/core2.xml")), TargetMode.INTERNAL,
+			pkg = Package.open(is);
+		} catch (InvalidFormatException e) {
+			throw new RuntimeException(e);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		URI partUri = createURI("/docProps/core2.xml");
+		try {
+			pkg.addRelationship(PackagingURIHelper.createPartName(partUri), TargetMode.INTERNAL,
 					PackageRelationshipTypes.CORE_PROPERTIES);
-			// Normally must thrown an InvalidFormatException exception.
-			fail("OPC compliance failure: M4.1 -> A format consumer shall consider more than one core properties relationship for a package to be an error.");
-		} catch (InvalidOperationException e) {
-			// Do nothing, it's the normal behavior
+			fail("expected OPC compliance exception was not thrown");
 		} catch (InvalidFormatException e) {
-			// Do nothing, it's the normal behavior
-		} catch (URISyntaxException e) {
-			// Should never happen
-		} finally {
-			if (pkg != null)
-				pkg.revert();
+			throw new RuntimeException(e);
+		} catch (InvalidOperationException e) {
+			// expected during successful test
+			assertEquals("OPC Compliance error [M4.1]: can't add another core properties part ! Use the built-in package method instead.", e.getMessage());
 		}
+		pkg.revert();
 	}
 
 	/**
 	 * Test M4.1 rule.
 	 */
 	public void testOnlyOneCorePropertiesPart_AddPart() {
+		String sampleFileName = OpenXML4JTestDataSamples.getComplianceSampleFileName("OPCCompliance_CoreProperties_OnlyOneCorePropertiesPart.docx");
 		Package pkg = null;
 		try {
-			String filepath = System.getProperty("openxml4j.testdata.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_OnlyOneCorePropertiesPart.docx";
-			pkg = Package.open(filepath);
-			pkg.createPart(PackagingURIHelper.createPartName(new URI(
-					"/docProps/core2.xml")), ContentTypes.CORE_PROPERTIES_PART);
-			// Normally must thrown an InvalidFormatException exception.
-			fail("OPC compliance failure: M4.1 -> A format consumer shall consider more than one core properties relationship for a package to be an error.");
+			pkg = Package.open(sampleFileName);
 		} catch (InvalidFormatException e) {
-			// Do nothing, it's the normal behavior
+			throw new RuntimeException(e);
+		}
+		
+		URI partUri = createURI("/docProps/core2.xml");
+		try {
+			pkg.createPart(PackagingURIHelper.createPartName(partUri),
+					ContentTypes.CORE_PROPERTIES_PART);
+			fail("expected OPC compliance exception was not thrown");
+		} catch (InvalidFormatException e) {
+			throw new RuntimeException(e);
 		} catch (InvalidOperationException e) {
-			// Do nothing, it's the normal behavior
-		} catch (URISyntaxException e) {
-			// Should never happen
-		} finally {
-			if (pkg != null)
-				pkg.revert();
+			// expected during successful test
+			assertEquals("OPC Compliance error [M4.1]: you try to add more than one core properties relationship in the package !", e.getMessage());
 		}
+		pkg.revert();
 	}
 
 	/**
 	 * Test M4.2 rule.
 	 */
 	public void testDoNotUseCompatibilityMarkup() {
-		Package pkg = null;
-		try {
-			String filepath = System.getProperty("openxml4j.compliance.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_DoNotUseCompatibilityMarkupFAIL.docx";
-			pkg = Package.open(filepath);
-			// Normally must thrown an InvalidFormatException exception.
-			fail("OPC compliance failure: M4.2 -> A format consumer shall consider the use of the Markup Compatibility namespace to be an error.");
-		} catch (InvalidFormatException e) {
-			// Do nothing, it's the normal behavior
-		} finally {
-			if (pkg != null)
-				pkg.revert();
-		}
+		String msg = extractInvalidFormatMessage("DoNotUseCompatibilityMarkupFAIL.docx");
+		assertEquals("OPC Compliance error [M4.2]: A format consumer shall consider the use of the Markup Compatibility namespace to be an error.", msg);
 	}
 
 	/**
 	 * Test M4.3 rule.
 	 */
 	public void testDCTermsNamespaceLimitedUse() {
-		Package pkg = null;
-		try {
-			String filepath = System.getProperty("openxml4j.compliance.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_DCTermsNamespaceLimitedUseFAIL.docx";
-			pkg = Package.open(filepath);
-			// Normally must thrown an InvalidFormatException exception.
-			fail("OPC compliance failure: M4.3 -> Producers shall not create a document element that contains refinements to the Dublin Core elements, except for the two specified in the schema: <dcterms:created> and <dcterms:modified> Consumers shall consider a document element that violates this constraint to be an error.");
-		} catch (InvalidFormatException e) {
-			// Do nothing, it's the normal behavior
-		} finally {
-			if (pkg != null)
-				pkg.revert();
-		}
+		String msg = extractInvalidFormatMessage("DCTermsNamespaceLimitedUseFAIL.docx");
+		assertEquals("OPC Compliance error [M4.3]: Producers shall not create a document element that contains refinements to the Dublin Core elements, except for the two specified in the schema: <dcterms:created> and <dcterms:modified> Consumers shall consider a document element that violates this constraint to be an error.", msg);
 	}
 
 	/**
 	 * Test M4.4 rule.
 	 */
 	public void testUnauthorizedXMLLangAttribute() {
-		Package pkg = null;
-		try {
-			String filepath = System.getProperty("openxml4j.compliance.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_UnauthorizedXMLLangAttributeFAIL.docx";
-			pkg = Package.open(filepath);
-			// Normally must thrown an InvalidFormatException exception.
-			fail("OPC compliance failure: M4.4 -> Producers shall not create a document element that contains refinements to the Dublin Core elements, except for the two specified in the schema: <dcterms:created> and <dcterms:modified> Consumers shall consider a document element that violates this constraint to be an error.");
-		} catch (InvalidFormatException e) {
-			// Do nothing, it's the normal behavior
-		} finally {
-			if (pkg != null)
-				pkg.revert();
-		}
+		String msg = extractInvalidFormatMessage("UnauthorizedXMLLangAttributeFAIL.docx");
+		assertEquals("OPC Compliance error [M4.4]: Producers shall not create a document element that contains the xml:lang attribute. Consumers shall consider a document element that violates this constraint to be an error.", msg);
 	}
 
 	/**
 	 * Test M4.5 rule.
 	 */
 	public void testLimitedXSITypeAttribute_NotPresent() {
-		Package pkg = null;
-		try {
-			String filepath = System.getProperty("openxml4j.compliance.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_LimitedXSITypeAttribute_NotPresentFAIL.docx";
-			pkg = Package.open(filepath);
-			// Normally must thrown an InvalidFormatException exception.
-			fail("OPC compliance failure: M4.5 -> Producers shall not create a document element that contains refinements to the Dublin Core elements, except for the two specified in the schema: <dcterms:created> and <dcterms:modified> Consumers shall consider a document element that violates this constraint to be an error.");
-		} catch (InvalidFormatException e) {
-			// Do nothing, it's the normal behavior
-		} finally {
-			if (pkg != null)
-				pkg.revert();
-		}
+		String msg = extractInvalidFormatMessage("LimitedXSITypeAttribute_NotPresentFAIL.docx");
+		assertEquals("The element 'created' must have the 'xsi:type' attribute present !", msg);
 	}
 
 	/**
 	 * Test M4.5 rule.
 	 */
 	public void testLimitedXSITypeAttribute_PresentWithUnauthorizedValue() {
-		Package pkg = null;
-		try {
-			String filepath = System.getProperty("openxml4j.compliance.input")
-					+ File.separator
-					+ "OPCCompliance_CoreProperties_LimitedXSITypeAttribute_PresentWithUnauthorizedValueFAIL.docx";
-			pkg = Package.open(filepath);
-			// Normally must thrown an InvalidFormatException exception.
-			fail("OPC compliance failure: M4.5 -> Producers shall not create a document element that contains refinements to the Dublin Core elements, except for the two specified in the schema: <dcterms:created> and <dcterms:modified> Consumers shall consider a document element that violates this constraint to be an error.");
-		} catch (InvalidFormatException e) {
-			// Do nothing, it's the normal behavior
-		} finally {
-			if (pkg != null)
-				pkg.revert();
-		}
+		String msg = extractInvalidFormatMessage("LimitedXSITypeAttribute_PresentWithUnauthorizedValueFAIL.docx");
+		assertEquals("The element 'modified' must have the 'xsi:type' attribute with the value 'dcterms:W3CDTF' !", msg);
 	}
 }

Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java (from r740938, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PackageModel.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java&p1=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PackageModel.java&r1=740938&r2=741002&rev=741002&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PackageModel.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePackageModel.java Thu Feb  5 05:07:23 2009
@@ -30,8 +30,6 @@
 import org.apache.poi.openxml4j.opc.PackagingURIHelper;
 import org.apache.poi.openxml4j.opc.TargetMode;
 
-import org.apache.poi.openxml4j.TestCore;
-
 /**
  * Test Open Packaging Convention package model compliance.
  * 
@@ -40,11 +38,9 @@
  * 
  * @author Julien Chable
  */
-public class OPCCompliance_PackageModel extends TestCase {
-
-	TestCore testCore = new TestCore(this.getClass());
+public class TestOPCCompliancePackageModel extends TestCase {
 
-	public OPCCompliance_PackageModel(String name) {
+	public TestOPCCompliancePackageModel(String name) {
 		super(name);
 	}
 
@@ -54,9 +50,8 @@
 	 * [M1.11]
 	 */
 	public void testPartNameDerivationAdditionFailure() {
-		Package pkg = null;
+		Package pkg = Package.create("TODELETEIFEXIST.docx");
 		try {
-			pkg = Package.create("TODELETEIFEXIST.docx");
 			PackagePartName name = PackagingURIHelper
 					.createPartName("/word/document.xml");
 			PackagePartName nameDerived = PackagingURIHelper

Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java (from r740938, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PartName.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java&p1=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PartName.java&r1=740938&r2=741002&rev=741002&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/OPCCompliance_PartName.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java Thu Feb  5 05:07:23 2009
@@ -78,9 +78,9 @@
  * @author Julien Chable
  * @version 1.0
  */
-public class OPCCompliance_PartName extends TestCase {
+public class TestOPCCompliancePartName extends TestCase {
 
-	public OPCCompliance_PartName(String name) {
+	public TestOPCCompliancePartName(String name) {
 		super(name);
 	}
 

Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java (from r740524, poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllTests.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java&p1=poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllTests.java&r1=740524&r2=741002&rev=741002&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllTests.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java Thu Feb  5 05:07:23 2009
@@ -20,14 +20,11 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-public class AllTests {
+public class AllOpenXML4JInternalTests {
 
 	public static Test suite() {
-		TestSuite suite = new TestSuite(
-				"Test for test.org.apache.poi.openxml4j.opc.internal");
-		//$JUnit-BEGIN$
+		TestSuite suite = new TestSuite(AllOpenXML4JInternalTests.class.getName());
 		suite.addTestSuite(TestContentTypeManager.class);
-		//$JUnit-END$
 		return suite;
 	}
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/TestContentTypeManager.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/TestContentTypeManager.java?rev=741002&r1=741001&r2=741002&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/TestContentTypeManager.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/TestContentTypeManager.java Thu Feb  5 05:07:23 2009
@@ -21,15 +21,9 @@
 
 import org.apache.poi.openxml4j.opc.PackagePartName;
 import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-import org.apache.poi.openxml4j.opc.internal.ContentTypeManager;
-import org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager;
-
-import org.apache.poi.openxml4j.TestCore;
 
 public class TestContentTypeManager extends TestCase {
 
-	TestCore testCore = new TestCore(this.getClass());
-
 	/**
 	 * Test the properties part content parsing.
 	 */

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java?rev=741002&r1=741001&r2=741002&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java Thu Feb  5 05:07:23 2009
@@ -62,10 +62,10 @@
 		assertEquals(
 				"Sheet1\n" +
 				"1000.0\t1.0\t5.0\n" +
-				"2000.0\t2.0\t\n" +	
-				"3000.0\t3.0\t\n" +
-				"4000.0\t4.0\t\n" + 
-				"5000.0\t5.0\t\n" +
+				"2000.0\t2.0\n" +	
+				"3000.0\t3.0\n" +
+				"4000.0\t4.0\n" + 
+				"5000.0\t5.0\n" +
 				"Sheet2\nSheet3\n", 
 				extractor.getText()
 		);
@@ -75,10 +75,10 @@
 		assertEquals(
 				"Sheet1\n" +
 				"1000.0\t1.0\tSUMIF(A1:A5,\">4000\",B1:B5)\n" +
-				"2000.0\t2.0\t\n" +	
-				"3000.0\t3.0\t\n" +
-				"4000.0\t4.0\t\n" + 
-				"5000.0\t5.0\t\n" +
+				"2000.0\t2.0\n" +	
+				"3000.0\t3.0\n" +
+				"4000.0\t4.0\n" + 
+				"5000.0\t5.0\n" +
 				"Sheet2\nSheet3\n", 
 				extractor.getText()
 		);
@@ -196,15 +196,15 @@
 		assertTrue(def.startsWith(
 				"Sheet1\n" +
 				"&[TAB]\t\n" +
-				"Hello\t\n" +
-				"11.0\t23.0\t\n"
+				"Hello\n" +
+				"11.0\t23.0\n"
 		));
 		
 		assertTrue(padded.startsWith(
 				"Sheet1\n" +
 				"&[TAB]\t\n" +
-				"Hello\t\t\t\t\t\t\t\t\t\t\t\n" +
-				"11.0\t\t\t23.0\t\t\t\t\t\t\t\t\n"
+				"Hello\n" +
+				"11.0\t\t\t23.0\n"
 		));
 	}
 	



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