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/05/21 02:55:56 UTC
svn commit: r776905 [1/2] - in
/poi/trunk/src/ooxml/testcases/org/apache/poi: openxml4j/opc/
openxml4j/opc/compliance/ openxml4j/opc/internal/ xssf/ xssf/model/
xssf/usermodel/
Author: josh
Date: Thu May 21 00:55:56 2009
New Revision: 776905
URL: http://svn.apache.org/viewvc?rev=776905&view=rev
Log:
Changed CRLF to LF in ooxml/testcases. Minor fixes for compiler warnings and formatting
Modified:
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestFileHelper.java
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagePartName.java
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java
poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/TestContentTypeManager.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetShiftRows.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPictureData.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/AllOpenXML4JTests.java Thu May 21 00:55:56 2009
@@ -1,44 +1,44 @@
-/* ====================================================================
- 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 junit.framework.Test;
-import junit.framework.TestSuite;
-
-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(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(TestPackageThumbnail.class);
- suite.addTestSuite(TestPackagingURIHelper.class);
- suite.addTestSuite(TestRelationships.class);
- suite.addTest(AllOpenXML4JComplianceTests.suite());
- suite.addTest(AllOpenXML4JInternalTests.suite());
- return suite;
- }
-}
+/* ====================================================================
+ 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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+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(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(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/TestContentType.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java Thu May 21 00:55:56 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 junit.framework.TestCase;
-
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.openxml4j.opc.internal.ContentType;
-
-/**
- * Tests for content type (ContentType class).
- *
- * @author Julien Chable
- */
-public class TestContentType extends TestCase {
-
- /**
- * Check rule M1.13: Package implementers shall only create and only
- * recognize parts with a content type; format designers shall specify a
- * content type for each part included in the format. Content types for
- * package parts shall fit the definition and syntax for media types as
- * specified in RFC 2616, \u00A73.7.
- */
- public void testContentTypeValidation() throws InvalidFormatException {
- String[] contentTypesToTest = new String[] { "text/xml",
- "application/pgp-key", "application/vnd.hp-PCLXL",
- "application/vnd.lotus-1-2-3" };
- for (int i = 0; i < contentTypesToTest.length; ++i) {
- new ContentType(contentTypesToTest[i]);
- }
- }
-
- /**
- * Check rule M1.13 : Package implementers shall only create and only
- * recognize parts with a content type; format designers shall specify a
- * content type for each part included in the format. Content types for
- * package parts shall fit the definition and syntax for media types as
- * specified in RFC 2616, \u00A3.7.
- *
- * Check rule M1.14: Content types shall not use linear white space either
- * between the type and subtype or between an attribute and its value.
- * Content types also shall not have leading or trailing white spaces.
- * Package implementers shall create only such content types and shall
- * require such content types when retrieving a part from a package; format
- * designers shall specify only such content types for inclusion in the
- * format.
- */
- public void testContentTypeValidationFailure() {
- String[] contentTypesToTest = new String[] { "text/xml/app", "",
- "test", "text(xml/xml", "text)xml/xml", "text<xml/xml",
- "text>/xml", "text@/xml", "text,/xml", "text;/xml",
- "text:/xml", "text\\/xml", "t/ext/xml", "t\"ext/xml",
- "text[/xml", "text]/xml", "text?/xml", "tex=t/xml",
- "te{xt/xml", "tex}t/xml", "te xt/xml",
- "text" + (char) 9 + "/xml", "text xml", " text/xml " };
- for (int i = 0; i < contentTypesToTest.length; ++i) {
- try {
- new ContentType(contentTypesToTest[i]);
- } catch (InvalidFormatException e) {
- continue;
- }
- fail("Must have fail for content type: '" + contentTypesToTest[i]
- + "' !");
- }
- }
-
- /**
- * Check rule [O1.2]: Format designers might restrict the usage of
- * parameters for content types.
- */
- public void testContentTypeParameterFailure() {
- String[] contentTypesToTest = new String[] { "mail/toto;titi=tata",
- "text/xml;a=b;c=d", "mail/toto;\"titi=tata\"" };
- for (int i = 0; i < contentTypesToTest.length; ++i) {
- try {
- new ContentType(contentTypesToTest[i]);
- } catch (InvalidFormatException e) {
- continue;
- }
- fail("Must have fail for content type: '" + contentTypesToTest[i]
- + "' !");
- }
- }
-
- /**
- * Check rule M1.15: The package implementer shall require a content type
- * that does not include comments and the format designer shall specify such
- * a content type.
- */
- public void testContentTypeCommentFailure() {
- String[] contentTypesToTest = new String[] { "text/xml(comment)" };
- for (int i = 0; i < contentTypesToTest.length; ++i) {
- try {
- new ContentType(contentTypesToTest[i]);
- } catch (InvalidFormatException e) {
- continue;
- }
- fail("Must have fail for content type: '" + contentTypesToTest[i]
- + "' !");
- }
- }
-}
+/* ====================================================================
+ 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 junit.framework.TestCase;
+
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.openxml4j.opc.internal.ContentType;
+
+/**
+ * Tests for content type (ContentType class).
+ *
+ * @author Julien Chable
+ */
+public final class TestContentType extends TestCase {
+
+ /**
+ * Check rule M1.13: Package implementers shall only create and only
+ * recognize parts with a content type; format designers shall specify a
+ * content type for each part included in the format. Content types for
+ * package parts shall fit the definition and syntax for media types as
+ * specified in RFC 2616, \u00A73.7.
+ */
+ public void testContentTypeValidation() throws InvalidFormatException {
+ String[] contentTypesToTest = new String[] { "text/xml",
+ "application/pgp-key", "application/vnd.hp-PCLXL",
+ "application/vnd.lotus-1-2-3" };
+ for (int i = 0; i < contentTypesToTest.length; ++i) {
+ new ContentType(contentTypesToTest[i]);
+ }
+ }
+
+ /**
+ * Check rule M1.13 : Package implementers shall only create and only
+ * recognize parts with a content type; format designers shall specify a
+ * content type for each part included in the format. Content types for
+ * package parts shall fit the definition and syntax for media types as
+ * specified in RFC 2616, \u00A3.7.
+ *
+ * Check rule M1.14: Content types shall not use linear white space either
+ * between the type and subtype or between an attribute and its value.
+ * Content types also shall not have leading or trailing white spaces.
+ * Package implementers shall create only such content types and shall
+ * require such content types when retrieving a part from a package; format
+ * designers shall specify only such content types for inclusion in the
+ * format.
+ */
+ public void testContentTypeValidationFailure() {
+ String[] contentTypesToTest = new String[] { "text/xml/app", "",
+ "test", "text(xml/xml", "text)xml/xml", "text<xml/xml",
+ "text>/xml", "text@/xml", "text,/xml", "text;/xml",
+ "text:/xml", "text\\/xml", "t/ext/xml", "t\"ext/xml",
+ "text[/xml", "text]/xml", "text?/xml", "tex=t/xml",
+ "te{xt/xml", "tex}t/xml", "te xt/xml",
+ "text" + (char) 9 + "/xml", "text xml", " text/xml " };
+ for (int i = 0; i < contentTypesToTest.length; ++i) {
+ try {
+ new ContentType(contentTypesToTest[i]);
+ } catch (InvalidFormatException e) {
+ continue;
+ }
+ fail("Must have fail for content type: '" + contentTypesToTest[i]
+ + "' !");
+ }
+ }
+
+ /**
+ * Check rule [O1.2]: Format designers might restrict the usage of
+ * parameters for content types.
+ */
+ public void testContentTypeParameterFailure() {
+ String[] contentTypesToTest = new String[] { "mail/toto;titi=tata",
+ "text/xml;a=b;c=d", "mail/toto;\"titi=tata\"" };
+ for (int i = 0; i < contentTypesToTest.length; ++i) {
+ try {
+ new ContentType(contentTypesToTest[i]);
+ } catch (InvalidFormatException e) {
+ continue;
+ }
+ fail("Must have fail for content type: '" + contentTypesToTest[i]
+ + "' !");
+ }
+ }
+
+ /**
+ * Check rule M1.15: The package implementer shall require a content type
+ * that does not include comments and the format designer shall specify such
+ * a content type.
+ */
+ public void testContentTypeCommentFailure() {
+ String[] contentTypesToTest = new String[] { "text/xml(comment)" };
+ for (int i = 0; i < contentTypesToTest.length; ++i) {
+ try {
+ new ContentType(contentTypesToTest[i]);
+ } catch (InvalidFormatException e) {
+ continue;
+ }
+ fail("Must have fail for content type: '" + contentTypesToTest[i]
+ + "' !");
+ }
+ }
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestFileHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestFileHelper.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestFileHelper.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestFileHelper.java Thu May 21 00:55:56 2009
@@ -1,55 +1,56 @@
-/* ====================================================================
- 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.util.TreeMap;
-
-import org.apache.poi.openxml4j.opc.internal.FileHelper;
-
-import junit.framework.TestCase;
-
-/**
- * Test TestFileHelper class.
- *
- * @author Julien Chable
- */
-public class TestFileHelper extends TestCase {
-
- public void testGetDirectory() {
- TreeMap<String, String> expectedValue = new TreeMap<String, String>();
- expectedValue.put("/dir1/test.doc", "/dir1");
- expectedValue.put("/dir1/dir2/test.doc.xml", "/dir1/dir2");
-
- for (String filename : expectedValue.keySet()) {
- File f1 = new File(expectedValue.get(filename));
- File f2 = FileHelper.getDirectory(new File(filename));
-
- /*
- * YK: The original version asserted expected values against File#getAbsolutePath():
- * assertTrue(expectedValue.get(filename).equalsIgnoreCase(
- * FileHelper.getDirectory(new File(filename))
- * .getAbsolutePath()));
- *
- * This comparison is platform dependent and resulted in build errors in Gump since 21/02/2009.
- * Assertion via File#equals(File otherFile) is a better approach.
- */
- assertTrue(f1.equals(f2));
- }
- }
-}
+/* ====================================================================
+ 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.util.TreeMap;
+
+import org.apache.poi.openxml4j.opc.internal.FileHelper;
+
+import junit.framework.TestCase;
+
+/**
+ * Test TestFileHelper class.
+ *
+ * @author Julien Chable
+ */
+public final class TestFileHelper extends TestCase {
+
+ /**
+ * TODO - use simple JDK methods on {@link File} instead:<br/>
+ * {@link File#getParentFile()} instead of {@link FileHelper#getDirectory(File)
+ * {@link File#getName()} instead of {@link FileHelper#getFilename(File)
+ */
+ public void testGetDirectory() {
+ TreeMap<String, String> expectedValue = new TreeMap<String, String>();
+ expectedValue.put("/dir1/test.doc", "/dir1");
+ expectedValue.put("/dir1/dir2/test.doc.xml", "/dir1/dir2");
+
+ for (String filename : expectedValue.keySet()) {
+ File f1 = new File(expectedValue.get(filename));
+ File f2 = FileHelper.getDirectory(new File(filename));
+
+ if (false) {
+ // YK: The original version asserted expected values against File#getAbsolutePath():
+ assertTrue(expectedValue.get(filename).equalsIgnoreCase(f2.getAbsolutePath()));
+ // This comparison is platform dependent. A better approach is below
+ }
+ assertTrue(f1.equals(f2));
+ }
+ }
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagePartName.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagePartName.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagePartName.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagePartName.java Thu May 21 00:55:56 2009
@@ -1,35 +1,36 @@
-/* ====================================================================
- 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 org.apache.poi.openxml4j.opc.PackagePartName;
-import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-
-import junit.framework.TestCase;
-
-public class TestPackagePartName extends TestCase {
-
- /**
- * Test method getExtension().
- */
- public void testGetExtension() throws Exception{
- PackagePartName name1 = PackagingURIHelper.createPartName("/doc/props/document.xml");
- PackagePartName name2 = PackagingURIHelper.createPartName("/root/document");
- assertEquals("xml", name1.getExtension());
- assertEquals("", name2.getExtension());
- }
-}
+/* ====================================================================
+ 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 org.apache.poi.openxml4j.opc.PackagePartName;
+import org.apache.poi.openxml4j.opc.PackagingURIHelper;
+
+import junit.framework.TestCase;
+
+public final class TestPackagePartName extends TestCase {
+
+ /**
+ * Test method getExtension().
+ */
+ public void testGetExtension() throws Exception{
+ PackagePartName name1 = PackagingURIHelper.createPartName("/doc/props/document.xml");
+ PackagePartName name2 = PackagingURIHelper.createPartName("/root/document");
+ assertEquals("xml", name1.getExtension());
+ assertEquals("", name2.getExtension());
+ }
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/AllOpenXML4JComplianceTests.java Thu May 21 00:55:56 2009
@@ -1,33 +1,33 @@
-/* ====================================================================
- 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.compliance;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllOpenXML4JComplianceTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllOpenXML4JComplianceTests.class.getName());
- suite.addTestSuite(TestOPCCompliancePartName.class);
- suite.addTestSuite(TestOPCComplianceCoreProperties.class);
- suite.addTestSuite(TestOPCCompliancePackageModel.class);
- return suite;
- }
-
-}
+/* ====================================================================
+ 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.compliance;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public final class AllOpenXML4JComplianceTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllOpenXML4JComplianceTests.class.getName());
+ suite.addTestSuite(TestOPCCompliancePartName.class);
+ suite.addTestSuite(TestOPCComplianceCoreProperties.class);
+ suite.addTestSuite(TestOPCCompliancePackageModel.class);
+ return suite;
+ }
+
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/internal/AllOpenXML4JInternalTests.java Thu May 21 00:55:56 2009
@@ -1,30 +1,30 @@
-/* ====================================================================
- 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.internal;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllOpenXML4JInternalTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllOpenXML4JInternalTests.class.getName());
- suite.addTestSuite(TestContentTypeManager.class);
- return suite;
- }
-}
+/* ====================================================================
+ 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.internal;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public final class AllOpenXML4JInternalTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllOpenXML4JInternalTests.class.getName());
+ suite.addTestSuite(TestContentTypeManager.class);
+ 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=776905&r1=776904&r2=776905&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 May 21 00:55:56 2009
@@ -1,116 +1,116 @@
-/* ====================================================================
- 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.internal;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.openxml4j.opc.PackagePartName;
-import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-
-public class TestContentTypeManager extends TestCase {
-
- /**
- * Test the properties part content parsing.
- */
- public void testContentType() throws Exception {
- // File originalFile = new File(testCore.getTestRootPath() +
- // File.separator +
- // "sample.docx");
- //
- // // Retrieves core properties part
- // Package p = Package.open(originalFile.getAbsolutePath(),
- // PackageAccess.READ);
- // PackageRelationship corePropertiesRelationship = p
- // .getRelationshipsByType(
- // PackageRelationshipTypes.CORE_PROPERTIES)
- // .getRelationship(0);
- // PackagePart coreDocument = p.getPart(corePropertiesRelationship);
- //
- // ContentTypeManager ctm = new ZipContentTypeManager(coreDocument
- // .getInputStream());
- //
- // // TODO
- //fail();
- }
-
- /**
- * Test the addition of several default and override content types.
- */
- public void testContentTypeAddition() throws Exception {
- ContentTypeManager ctm = new ZipContentTypeManager(null, null);
-
- PackagePartName name1 = PackagingURIHelper
- .createPartName("/foo/foo.XML");
- PackagePartName name2 = PackagingURIHelper
- .createPartName("/foo/foo2.xml");
- PackagePartName name3 = PackagingURIHelper
- .createPartName("/foo/doc.rels");
- PackagePartName name4 = PackagingURIHelper
- .createPartName("/foo/doc.RELS");
-
- // Add content types
- ctm.addContentType(name1, "foo-type1");
- ctm.addContentType(name2, "foo-type2");
- ctm.addContentType(name3, "text/xml+rel");
- ctm.addContentType(name4, "text/xml+rel");
-
- assertEquals(ctm.getContentType(name1), "foo-type1");
- assertEquals(ctm.getContentType(name2), "foo-type2");
- assertEquals(ctm.getContentType(name3), "text/xml+rel");
- assertEquals(ctm.getContentType(name3), "text/xml+rel");
- }
-
- /**
- * Test the addition then removal of content types.
- */
- public void testContentTypeRemoval() throws Exception {
- ContentTypeManager ctm = new ZipContentTypeManager(null, null);
-
- PackagePartName name1 = PackagingURIHelper
- .createPartName("/foo/foo.xml");
- PackagePartName name2 = PackagingURIHelper
- .createPartName("/foo/foo2.xml");
- PackagePartName name3 = PackagingURIHelper
- .createPartName("/foo/doc.rels");
- PackagePartName name4 = PackagingURIHelper
- .createPartName("/foo/doc.RELS");
-
- // Add content types
- ctm.addContentType(name1, "foo-type1");
- ctm.addContentType(name2, "foo-type2");
- ctm.addContentType(name3, "text/xml+rel");
- ctm.addContentType(name4, "text/xml+rel");
- ctm.removeContentType(name2);
- ctm.removeContentType(name3);
-
- assertEquals(ctm.getContentType(name1), "foo-type1");
- assertEquals(ctm.getContentType(name2), "foo-type1");
- assertEquals(ctm.getContentType(name3), null);
-
- ctm.removeContentType(name1);
- assertEquals(ctm.getContentType(name1), null);
- assertEquals(ctm.getContentType(name2), null);
- }
-
- /**
- * Test the addition then removal of content types in a package.
- */
- public void testContentTypeRemovalPackage() throws Exception {
- // TODO
- }
-}
+/* ====================================================================
+ 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.internal;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.openxml4j.opc.PackagePartName;
+import org.apache.poi.openxml4j.opc.PackagingURIHelper;
+
+public final class TestContentTypeManager extends TestCase {
+
+ /**
+ * Test the properties part content parsing.
+ */
+ public void testContentType() throws Exception {
+ // File originalFile = new File(testCore.getTestRootPath() +
+ // File.separator +
+ // "sample.docx");
+ //
+ // // Retrieves core properties part
+ // Package p = Package.open(originalFile.getAbsolutePath(),
+ // PackageAccess.READ);
+ // PackageRelationship corePropertiesRelationship = p
+ // .getRelationshipsByType(
+ // PackageRelationshipTypes.CORE_PROPERTIES)
+ // .getRelationship(0);
+ // PackagePart coreDocument = p.getPart(corePropertiesRelationship);
+ //
+ // ContentTypeManager ctm = new ZipContentTypeManager(coreDocument
+ // .getInputStream());
+ //
+ // // TODO
+ //fail();
+ }
+
+ /**
+ * Test the addition of several default and override content types.
+ */
+ public void testContentTypeAddition() throws Exception {
+ ContentTypeManager ctm = new ZipContentTypeManager(null, null);
+
+ PackagePartName name1 = PackagingURIHelper
+ .createPartName("/foo/foo.XML");
+ PackagePartName name2 = PackagingURIHelper
+ .createPartName("/foo/foo2.xml");
+ PackagePartName name3 = PackagingURIHelper
+ .createPartName("/foo/doc.rels");
+ PackagePartName name4 = PackagingURIHelper
+ .createPartName("/foo/doc.RELS");
+
+ // Add content types
+ ctm.addContentType(name1, "foo-type1");
+ ctm.addContentType(name2, "foo-type2");
+ ctm.addContentType(name3, "text/xml+rel");
+ ctm.addContentType(name4, "text/xml+rel");
+
+ assertEquals(ctm.getContentType(name1), "foo-type1");
+ assertEquals(ctm.getContentType(name2), "foo-type2");
+ assertEquals(ctm.getContentType(name3), "text/xml+rel");
+ assertEquals(ctm.getContentType(name3), "text/xml+rel");
+ }
+
+ /**
+ * Test the addition then removal of content types.
+ */
+ public void testContentTypeRemoval() throws Exception {
+ ContentTypeManager ctm = new ZipContentTypeManager(null, null);
+
+ PackagePartName name1 = PackagingURIHelper
+ .createPartName("/foo/foo.xml");
+ PackagePartName name2 = PackagingURIHelper
+ .createPartName("/foo/foo2.xml");
+ PackagePartName name3 = PackagingURIHelper
+ .createPartName("/foo/doc.rels");
+ PackagePartName name4 = PackagingURIHelper
+ .createPartName("/foo/doc.RELS");
+
+ // Add content types
+ ctm.addContentType(name1, "foo-type1");
+ ctm.addContentType(name2, "foo-type2");
+ ctm.addContentType(name3, "text/xml+rel");
+ ctm.addContentType(name4, "text/xml+rel");
+ ctm.removeContentType(name2);
+ ctm.removeContentType(name3);
+
+ assertEquals(ctm.getContentType(name1), "foo-type1");
+ assertEquals(ctm.getContentType(name2), "foo-type1");
+ assertEquals(ctm.getContentType(name3), null);
+
+ ctm.removeContentType(name1);
+ assertEquals(ctm.getContentType(name1), null);
+ assertEquals(ctm.getContentType(name2), null);
+ }
+
+ /**
+ * Test the addition then removal of content types in a package.
+ */
+ public void testContentTypeRemovalPackage() throws Exception {
+ // TODO
+ }
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java Thu May 21 00:55:56 2009
@@ -1,59 +1,62 @@
-/* ====================================================================
- 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.xssf;
-
-import org.apache.poi.ss.ITestDataProvider;
-import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-
-/**
- * @author Yegor Kozlov
- */
-public final class XSSFITestDataProvider implements ITestDataProvider {
-
- public XSSFWorkbook openSampleWorkbook(String sampleFileName) {
- return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
- }
-
- public XSSFWorkbook writeOutAndReadBack(Workbook original) {
- if(!(original instanceof XSSFWorkbook)) {
- throw new IllegalArgumentException("Expected an instance of XSSFWorkbook");
- }
-
- return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original);
- }
-
- public XSSFWorkbook createWorkbook(){
- return new XSSFWorkbook();
- }
-
- public byte[] getTestDataFileContent(String fileName) {
- return HSSFTestDataSamples.getTestDataFileContent(fileName);
- }
-
- public SpreadsheetVersion getSpreadsheetVersion(){
- return SpreadsheetVersion.EXCEL2007;
- }
-
- private XSSFITestDataProvider(){}
- private static XSSFITestDataProvider inst = new XSSFITestDataProvider();
- public static XSSFITestDataProvider getInstance(){
- return inst;
- }
-}
+/* ====================================================================
+ 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.xssf;
+
+import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.SpreadsheetVersion;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.hssf.HSSFTestDataSamples;
+
+/**
+ * @author Yegor Kozlov
+ */
+public final class XSSFITestDataProvider implements ITestDataProvider {
+
+ public XSSFWorkbook openSampleWorkbook(String sampleFileName) {
+ return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
+ }
+
+ public XSSFWorkbook writeOutAndReadBack(Workbook original) {
+ if(!(original instanceof XSSFWorkbook)) {
+ throw new IllegalArgumentException("Expected an instance of XSSFWorkbook");
+ }
+
+ return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original);
+ }
+
+ public XSSFWorkbook createWorkbook(){
+ return new XSSFWorkbook();
+ }
+
+ public byte[] getTestDataFileContent(String fileName) {
+ return HSSFTestDataSamples.getTestDataFileContent(fileName);
+ }
+
+ public SpreadsheetVersion getSpreadsheetVersion(){
+ return SpreadsheetVersion.EXCEL2007;
+ }
+
+ private XSSFITestDataProvider() {
+ // enforce singleton
+ }
+ private static XSSFITestDataProvider inst = new XSSFITestDataProvider();
+ public static XSSFITestDataProvider getInstance(){
+ return inst;
+ }
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java Thu May 21 00:55:56 2009
@@ -1,131 +1,128 @@
-/* ====================================================================
- 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.xssf.model;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.usermodel.XSSFRichTextString;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRElt;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
-
-/**
- * Test {@link SharedStringsTable}, the cache of strings in a workbook
- *
- * @author Yegor Kozlov
- */
-public final class TestSharedStringsTable extends TestCase {
-
- public void testCreateNew() {
- SharedStringsTable sst = new SharedStringsTable();
-
- CTRst st;
- int idx;
-
- // Check defaults
- assertNotNull(sst.getItems());
- assertEquals(0, sst.getItems().size());
- assertEquals(0, sst.getCount());
- assertEquals(0, sst.getUniqueCount());
-
- st = CTRst.Factory.newInstance();
- st.setT("Hello, World!");
-
- idx = sst.addEntry(st);
- assertEquals(0, idx);
- assertEquals(1, sst.getCount());
- assertEquals(1, sst.getUniqueCount());
-
- //add the same entry egain
- idx = sst.addEntry(st);
- assertEquals(0, idx);
- assertEquals(2, sst.getCount());
- assertEquals(1, sst.getUniqueCount());
-
- //and egain
- idx = sst.addEntry(st);
- assertEquals(0, idx);
- assertEquals(3, sst.getCount());
- assertEquals(1, sst.getUniqueCount());
-
- st = CTRst.Factory.newInstance();
- st.setT("Second string");
-
- idx = sst.addEntry(st);
- assertEquals(1, idx);
- assertEquals(4, sst.getCount());
- assertEquals(2, sst.getUniqueCount());
-
- //add the same entry egain
- idx = sst.addEntry(st);
- assertEquals(1, idx);
- assertEquals(5, sst.getCount());
- assertEquals(2, sst.getUniqueCount());
-
- st = CTRst.Factory.newInstance();
- CTRElt r = st.addNewR();
- CTRPrElt pr = r.addNewRPr();
- pr.addNewColor().setRgb(new byte[]{(byte)0xFF, 0, 0}); //red
- pr.addNewI().setVal(true); //bold
- pr.addNewB().setVal(true); //italic
- r.setT("Second string");
-
- idx = sst.addEntry(st);
- assertEquals(2, idx);
- assertEquals(6, sst.getCount());
- assertEquals(3, sst.getUniqueCount());
-
- idx = sst.addEntry(st);
- assertEquals(2, idx);
- assertEquals(7, sst.getCount());
- assertEquals(3, sst.getUniqueCount());
-
- //ok. the sst table is filled, check the contents
- assertEquals(3, sst.getItems().size());
- assertEquals("Hello, World!", new XSSFRichTextString(sst.getEntryAt(0)).toString());
- assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(1)).toString());
- assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(2)).toString());
- }
-
- public void testReadWrite() {
- XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx");
- SharedStringsTable sst1 = wb.getSharedStringSource();
-
- //serialize, read back and compare with the original
- SharedStringsTable sst2 = XSSFTestDataSamples.writeOutAndReadBack(wb).getSharedStringSource();
-
- assertEquals(sst1.getCount(), sst2.getCount());
- assertEquals(sst1.getUniqueCount(), sst2.getUniqueCount());
-
- List<CTRst> items1 = sst1.getItems();
- List<CTRst> items2 = sst2.getItems();
- assertEquals(items1.size(), items2.size());
- for (int i = 0; i < items1.size(); i++) {
- CTRst st1 = items1.get(i);
- CTRst st2 = items2.get(i);
- assertEquals(st1.toString(), st2.toString());
- }
- }
-}
+/* ====================================================================
+ 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.xssf.model;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRElt;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
+
+/**
+ * Test {@link SharedStringsTable}, the cache of strings in a workbook
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestSharedStringsTable extends TestCase {
+
+ public void testCreateNew() {
+ SharedStringsTable sst = new SharedStringsTable();
+
+ CTRst st;
+ int idx;
+
+ // Check defaults
+ assertNotNull(sst.getItems());
+ assertEquals(0, sst.getItems().size());
+ assertEquals(0, sst.getCount());
+ assertEquals(0, sst.getUniqueCount());
+
+ st = CTRst.Factory.newInstance();
+ st.setT("Hello, World!");
+
+ idx = sst.addEntry(st);
+ assertEquals(0, idx);
+ assertEquals(1, sst.getCount());
+ assertEquals(1, sst.getUniqueCount());
+
+ //add the same entry again
+ idx = sst.addEntry(st);
+ assertEquals(0, idx);
+ assertEquals(2, sst.getCount());
+ assertEquals(1, sst.getUniqueCount());
+
+ //and again
+ idx = sst.addEntry(st);
+ assertEquals(0, idx);
+ assertEquals(3, sst.getCount());
+ assertEquals(1, sst.getUniqueCount());
+
+ st = CTRst.Factory.newInstance();
+ st.setT("Second string");
+
+ idx = sst.addEntry(st);
+ assertEquals(1, idx);
+ assertEquals(4, sst.getCount());
+ assertEquals(2, sst.getUniqueCount());
+
+ //add the same entry again
+ idx = sst.addEntry(st);
+ assertEquals(1, idx);
+ assertEquals(5, sst.getCount());
+ assertEquals(2, sst.getUniqueCount());
+
+ st = CTRst.Factory.newInstance();
+ CTRElt r = st.addNewR();
+ CTRPrElt pr = r.addNewRPr();
+ pr.addNewColor().setRgb(new byte[]{(byte)0xFF, 0, 0}); //red
+ pr.addNewI().setVal(true); //bold
+ pr.addNewB().setVal(true); //italic
+ r.setT("Second string");
+
+ idx = sst.addEntry(st);
+ assertEquals(2, idx);
+ assertEquals(6, sst.getCount());
+ assertEquals(3, sst.getUniqueCount());
+
+ idx = sst.addEntry(st);
+ assertEquals(2, idx);
+ assertEquals(7, sst.getCount());
+ assertEquals(3, sst.getUniqueCount());
+
+ //OK. the sst table is filled, check the contents
+ assertEquals(3, sst.getItems().size());
+ assertEquals("Hello, World!", new XSSFRichTextString(sst.getEntryAt(0)).toString());
+ assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(1)).toString());
+ assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(2)).toString());
+ }
+
+ public void testReadWrite() {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx");
+ SharedStringsTable sst1 = wb.getSharedStringSource();
+
+ //serialize, read back and compare with the original
+ SharedStringsTable sst2 = XSSFTestDataSamples.writeOutAndReadBack(wb).getSharedStringSource();
+
+ assertEquals(sst1.getCount(), sst2.getCount());
+ assertEquals(sst1.getUniqueCount(), sst2.getUniqueCount());
+
+ List<CTRst> items1 = sst1.getItems();
+ List<CTRst> items2 = sst2.getItems();
+ assertEquals(items1.size(), items2.size());
+ for (int i = 0; i < items1.size(); i++) {
+ CTRst st1 = items1.get(i);
+ CTRst st2 = items2.get(i);
+ assertEquals(st1.toString(), st2.toString());
+ }
+ }
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java Thu May 21 00:55:56 2009
@@ -1,99 +1,100 @@
-/* ====================================================================
- 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.xssf.usermodel;
-
-import junit.framework.TestCase;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-
-/**
- * @author Yegor Kozlov
- */
-public class TestSheetHiding extends TestCase {
- private XSSFWorkbook wbH;
- private XSSFWorkbook wbU;
-
- protected void setUp() {
- wbH = XSSFTestDataSamples.openSampleWorkbook("TwoSheetsOneHidden.xlsx");
- wbU = XSSFTestDataSamples.openSampleWorkbook("TwoSheetsNoneHidden.xlsx");
- }
-
- /**
- * Test that we get the right number of sheets,
- * with the right text on them, no matter what
- * the hidden flags are
- */
- public void testTextSheets() throws Exception {
- // Both should have two sheets
- assertEquals(2, wbH.getNumberOfSheets());
- assertEquals(2, wbU.getNumberOfSheets());
-
- // All sheets should have one row
- assertEquals(0, wbH.getSheetAt(0).getLastRowNum());
- assertEquals(0, wbH.getSheetAt(1).getLastRowNum());
- assertEquals(0, wbU.getSheetAt(0).getLastRowNum());
- assertEquals(0, wbU.getSheetAt(1).getLastRowNum());
-
- // All rows should have one column
- assertEquals(1, wbH.getSheetAt(0).getRow(0).getLastCellNum());
- assertEquals(1, wbH.getSheetAt(1).getRow(0).getLastCellNum());
- assertEquals(1, wbU.getSheetAt(0).getRow(0).getLastCellNum());
- assertEquals(1, wbU.getSheetAt(1).getRow(0).getLastCellNum());
-
- // Text should be sheet based
- assertEquals("Sheet1A1", wbH.getSheetAt(0).getRow(0).getCell(0).getRichStringCellValue().getString());
- assertEquals("Sheet2A1", wbH.getSheetAt(1).getRow(0).getCell(0).getRichStringCellValue().getString());
- assertEquals("Sheet1A1", wbU.getSheetAt(0).getRow(0).getCell(0).getRichStringCellValue().getString());
- assertEquals("Sheet2A1", wbU.getSheetAt(1).getRow(0).getCell(0).getRichStringCellValue().getString());
- }
-
- /**
- * Check that we can get and set the hidden flags
- * as expected
- */
- public void testHideUnHideFlags() throws Exception {
- assertTrue(wbH.isSheetHidden(0));
- assertFalse(wbH.isSheetHidden(1));
- assertFalse(wbU.isSheetHidden(0));
- assertFalse(wbU.isSheetHidden(1));
- }
-
- /**
- * Turn the sheet with none hidden into the one with
- * one hidden
- */
- public void testHide() throws Exception {
- wbU.setSheetHidden(0, true);
- assertTrue(wbU.isSheetHidden(0));
- assertFalse(wbU.isSheetHidden(1));
- XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wbU);
- assertTrue(wb2.isSheetHidden(0));
- assertFalse(wb2.isSheetHidden(1));
- }
-
- /**
- * Turn the sheet with one hidden into the one with
- * none hidden
- */
- public void testUnHide() throws Exception {
- wbH.setSheetHidden(0, false);
- assertFalse(wbH.isSheetHidden(0));
- assertFalse(wbH.isSheetHidden(1));
- XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wbH);
- assertFalse(wb2.isSheetHidden(0));
- assertFalse(wb2.isSheetHidden(1));
- }
-}
+/* ====================================================================
+ 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.xssf.usermodel;
+
+import junit.framework.TestCase;
+import org.apache.poi.xssf.XSSFTestDataSamples;
+
+/**
+ * @author Yegor Kozlov
+ */
+public final class TestSheetHiding extends TestCase {
+ private XSSFWorkbook wbH;
+ private XSSFWorkbook wbU;
+
+ protected void setUp() {
+ wbH = XSSFTestDataSamples.openSampleWorkbook("TwoSheetsOneHidden.xlsx");
+ wbU = XSSFTestDataSamples.openSampleWorkbook("TwoSheetsNoneHidden.xlsx");
+ }
+
+ /**
+ * Test that we get the right number of sheets,
+ * with the right text on them, no matter what
+ * the hidden flags are
+ */
+ public void testTextSheets() throws Exception {
+ // Both should have two sheets
+ assertEquals(2, wbH.getNumberOfSheets());
+ assertEquals(2, wbU.getNumberOfSheets());
+
+ // All sheets should have one row
+ assertEquals(0, wbH.getSheetAt(0).getLastRowNum());
+ assertEquals(0, wbH.getSheetAt(1).getLastRowNum());
+ assertEquals(0, wbU.getSheetAt(0).getLastRowNum());
+ assertEquals(0, wbU.getSheetAt(1).getLastRowNum());
+
+ // All rows should have one column
+ assertEquals(1, wbH.getSheetAt(0).getRow(0).getLastCellNum());
+ assertEquals(1, wbH.getSheetAt(1).getRow(0).getLastCellNum());
+ assertEquals(1, wbU.getSheetAt(0).getRow(0).getLastCellNum());
+ assertEquals(1, wbU.getSheetAt(1).getRow(0).getLastCellNum());
+
+ // Text should be sheet based
+ assertEquals("Sheet1A1", wbH.getSheetAt(0).getRow(0).getCell(0).getRichStringCellValue().getString());
+ assertEquals("Sheet2A1", wbH.getSheetAt(1).getRow(0).getCell(0).getRichStringCellValue().getString());
+ assertEquals("Sheet1A1", wbU.getSheetAt(0).getRow(0).getCell(0).getRichStringCellValue().getString());
+ assertEquals("Sheet2A1", wbU.getSheetAt(1).getRow(0).getCell(0).getRichStringCellValue().getString());
+ }
+
+ /**
+ * Check that we can get and set the hidden flags
+ * as expected
+ */
+ public void testHideUnHideFlags() throws Exception {
+ assertTrue(wbH.isSheetHidden(0));
+ assertFalse(wbH.isSheetHidden(1));
+ assertFalse(wbU.isSheetHidden(0));
+ assertFalse(wbU.isSheetHidden(1));
+ }
+
+ /**
+ * Turn the sheet with none hidden into the one with
+ * one hidden
+ */
+ public void testHide() throws Exception {
+ wbU.setSheetHidden(0, true);
+ assertTrue(wbU.isSheetHidden(0));
+ assertFalse(wbU.isSheetHidden(1));
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wbU);
+ assertTrue(wb2.isSheetHidden(0));
+ assertFalse(wb2.isSheetHidden(1));
+ }
+
+ /**
+ * Turn the sheet with one hidden into the one with
+ * none hidden
+ */
+ public void testUnHide() throws Exception {
+ wbH.setSheetHidden(0, false);
+ assertFalse(wbH.isSheetHidden(0));
+ assertFalse(wbH.isSheetHidden(1));
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wbH);
+ assertFalse(wb2.isSheetHidden(0));
+ assertFalse(wb2.isSheetHidden(1));
+ }
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetShiftRows.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetShiftRows.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetShiftRows.java Thu May 21 00:55:56 2009
@@ -1,62 +1,63 @@
-/* ====================================================================
- 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.xssf.usermodel;
-
-import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
-import org.apache.poi.ss.ITestDataProvider;
-import org.apache.poi.xssf.XSSFITestDataProvider;
-
-/**
- * @author Yegor Kozlov
- */
-public class TestSheetShiftRows extends BaseTestSheetShiftRows {
-
- @Override
- protected ITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
- }
-
- public void testShiftRows() {
- baseTestShiftRows("SimpleMultiCell.xlsx");
- }
-
- public void testShiftRow() {
- baseTestShiftRow();
- }
-
- public void testShiftNames() {
- baseTestShiftWithNames();
- }
-
- //TODO support shifting of page breaks
- public void $testShiftRowBreaks() {
- baseTestShiftRowBreaks();
- }
-
- //TODO support shifting of comments.
- public void $testShiftWithComments() {
- baseTestShiftWithComments("comments.xlsx");
- }
-
- public void testShiftWithFormulas() {
- baseTestShiftWithFormulas("ForShifting.xlsx");
- }
-
- public void testShiftWithMergedRegions() {
- baseTestShiftWithMergedRegions();
- }
-}
+/* ====================================================================
+ 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.xssf.usermodel;
+
+import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
+import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+
+/**
+ * @author Yegor Kozlov
+ */
+public final class TestSheetShiftRows extends BaseTestSheetShiftRows {
+
+ @Override
+ protected ITestDataProvider getTestDataProvider(){
+ return XSSFITestDataProvider.getInstance();
+ }
+
+ public void testShiftRows() {
+ baseTestShiftRows("SimpleMultiCell.xlsx");
+ }
+
+ public void testShiftRow() {
+ baseTestShiftRow();
+ }
+
+ public void testShiftNames() {
+ baseTestShiftWithNames();
+ }
+
+ //TODO support shifting of page breaks
+ public void $testShiftRowBreaks() {
+ baseTestShiftRowBreaks();
+ }
+
+ //TODO support shifting of comments.
+ public void $testShiftWithComments() {
+ baseTestShiftWithComments("comments.xlsx");
+ }
+
+ public void testShiftWithFormulas() {
+ baseTestShiftWithFormulas("ForShifting.xlsx");
+ }
+
+ public void testShiftWithMergedRegions() {
+ baseTestShiftWithMergedRegions();
+ }
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java Thu May 21 00:55:56 2009
@@ -1,76 +1,77 @@
-/* ====================================================================
- 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.xssf.usermodel;
-
-import junit.framework.TestCase;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.apache.poi.ss.usermodel.BaseTestNamedRange;
-
-/**
- * @author Yegor Kozlov
- */
-public class TestXSSFName extends BaseTestNamedRange {
-
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
- }
-
- //TODO combine testRepeatingRowsAndColums() for HSSF and XSSF
- public void testRepeatingRowsAndColums() {
- // First test that setting RR&C for same sheet more than once only creates a
- // single Print_Titles built-in record
- XSSFWorkbook wb = getTestDataProvider().createWorkbook();
- XSSFSheet sheet = wb.createSheet("FirstSheet");
-
- // set repeating rows and columns twice for the first sheet
- for (int i = 0; i < 2; i++) {
- wb.setRepeatingRowsAndColumns(0, 0, 0, 0, 3);
- //sheet.createFreezePane(0, 3);
- }
- assertEquals(1, wb.getNumberOfNames());
- XSSFName nr1 = wb.getNameAt(0);
-
- assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr1.getNameName());
- assertEquals("'FirstSheet'!$A:$A,'FirstSheet'!$1:$4", nr1.getRefersToFormula());
-
- // Save and re-open
- XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(wb);
-
- assertEquals(1, nwb.getNumberOfNames());
- nr1 = nwb.getNameAt(0);
-
- assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr1.getNameName());
- assertEquals("'FirstSheet'!$A:$A,'FirstSheet'!$1:$4", nr1.getRefersToFormula());
-
- // check that setting RR&C on a second sheet causes a new Print_Titles built-in
- // name to be created
- sheet = nwb.createSheet("SecondSheet");
- nwb.setRepeatingRowsAndColumns(1, 1, 2, 0, 0);
-
- assertEquals(2, nwb.getNumberOfNames());
- XSSFName nr2 = nwb.getNameAt(1);
-
- assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr2.getNameName());
- assertEquals("'SecondSheet'!$B:$C,'SecondSheet'!$1:$1", nr2.getRefersToFormula());
-
- nwb.setRepeatingRowsAndColumns(1, -1, -1, -1, -1);
- }
-
-
-}
+/* ====================================================================
+ 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.xssf.usermodel;
+
+import junit.framework.TestCase;
+import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.ss.usermodel.BaseTestNamedRange;
+
+/**
+ * @author Yegor Kozlov
+ */
+public final class TestXSSFName extends BaseTestNamedRange {
+
+ @Override
+ protected XSSFITestDataProvider getTestDataProvider(){
+ return XSSFITestDataProvider.getInstance();
+ }
+
+ //TODO combine testRepeatingRowsAndColums() for HSSF and XSSF
+ public void testRepeatingRowsAndColums() {
+ // First test that setting RR&C for same sheet more than once only creates a
+ // single Print_Titles built-in record
+ XSSFWorkbook wb = getTestDataProvider().createWorkbook();
+ XSSFSheet sheet = wb.createSheet("FirstSheet");
+
+ // set repeating rows and columns twice for the first sheet
+ for (int i = 0; i < 2; i++) {
+ wb.setRepeatingRowsAndColumns(0, 0, 0, 0, 3);
+ //sheet.createFreezePane(0, 3);
+ }
+ assertEquals(1, wb.getNumberOfNames());
+ XSSFName nr1 = wb.getNameAt(0);
+
+ assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr1.getNameName());
+ assertEquals("'FirstSheet'!$A:$A,'FirstSheet'!$1:$4", nr1.getRefersToFormula());
+
+ // Save and re-open
+ XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+
+ assertEquals(1, nwb.getNumberOfNames());
+ nr1 = nwb.getNameAt(0);
+
+ assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr1.getNameName());
+ assertEquals("'FirstSheet'!$A:$A,'FirstSheet'!$1:$4", nr1.getRefersToFormula());
+
+ // check that setting RR&C on a second sheet causes a new Print_Titles built-in
+ // name to be created
+ sheet = nwb.createSheet("SecondSheet");
+ nwb.setRepeatingRowsAndColumns(1, 1, 2, 0, 0);
+
+ assertEquals(2, nwb.getNumberOfNames());
+ XSSFName nr2 = nwb.getNameAt(1);
+
+ assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr2.getNameName());
+ assertEquals("'SecondSheet'!$B:$C,'SecondSheet'!$1:$1", nr2.getRefersToFormula());
+
+ nwb.setRepeatingRowsAndColumns(1, -1, -1, -1, -1);
+ }
+
+
+}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java?rev=776905&r1=776904&r2=776905&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java Thu May 21 00:55:56 2009
@@ -1,73 +1,74 @@
-/* ====================================================================
- 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.xssf.usermodel;
-
-import junit.framework.TestCase;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.BaseTestPicture;
-import org.apache.poi.xssf.XSSFITestDataProvider;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.STEditAs;
-
-import java.util.List;
-import java.util.Arrays;
-
-/**
- * @author Yegor Kozlov
- */
-public class TestXSSFPicture extends BaseTestPicture {
-
- @Override
- protected XSSFITestDataProvider getTestDataProvider(){
- return XSSFITestDataProvider.getInstance();
- }
-
- public void testResize() {
- baseTestResize(new XSSFClientAnchor(0, 0, 504825, 85725, (short)0, 0, (short)1, 8));
- }
-
-
- public void testCreate(){
- XSSFWorkbook wb = new XSSFWorkbook();
- XSSFSheet sheet = wb.createSheet();
- XSSFDrawing drawing = sheet.createDrawingPatriarch();
-
- byte[] jpegData = "test jpeg data".getBytes();
-
- List<XSSFPictureData> pictures = wb.getAllPictures();
- assertEquals(0, pictures.size());
-
- int jpegIdx = wb.addPicture(jpegData, XSSFWorkbook.PICTURE_TYPE_JPEG);
- assertEquals(1, pictures.size());
- assertEquals("jpeg", pictures.get(jpegIdx).suggestFileExtension());
- assertTrue(Arrays.equals(jpegData, pictures.get(jpegIdx).getData()));
-
- XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 10, 30);
- assertEquals(ClientAnchor.MOVE_AND_RESIZE, anchor.getAnchorType());
- anchor.setAnchorType(ClientAnchor.DONT_MOVE_AND_RESIZE);
- assertEquals(ClientAnchor.DONT_MOVE_AND_RESIZE, anchor.getAnchorType());
-
- XSSFPicture shape = drawing.createPicture(anchor, jpegIdx);
- assertTrue(anchor.equals(shape.getAnchor()));
- assertNotNull(shape.getPictureData());
- assertTrue(Arrays.equals(jpegData, shape.getPictureData().getData()));
-
- CTTwoCellAnchor ctShapeHolder = drawing.getCTDrawing().getTwoCellAnchorArray(0);
- // STEditAs.ABSOLUTE corresponds to ClientAnchor.DONT_MOVE_AND_RESIZE
- assertEquals(STEditAs.ABSOLUTE, ctShapeHolder.getEditAs());
- }
-}
+/* ====================================================================
+ 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.xssf.usermodel;
+
+import junit.framework.TestCase;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.BaseTestPicture;
+import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.STEditAs;
+
+import java.util.List;
+import java.util.Arrays;
+
+/**
+ * @author Yegor Kozlov
+ */
+public final class TestXSSFPicture extends BaseTestPicture {
+
+ @Override
+ protected XSSFITestDataProvider getTestDataProvider(){
+ return XSSFITestDataProvider.getInstance();
+ }
+
+ public void testResize() {
+ baseTestResize(new XSSFClientAnchor(0, 0, 504825, 85725, (short)0, 0, (short)1, 8));
+ }
+
+
+ public void testCreate(){
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = wb.createSheet();
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+
+ byte[] jpegData = "test jpeg data".getBytes();
+
+ List<XSSFPictureData> pictures = wb.getAllPictures();
+ assertEquals(0, pictures.size());
+
+ int jpegIdx = wb.addPicture(jpegData, XSSFWorkbook.PICTURE_TYPE_JPEG);
+ assertEquals(1, pictures.size());
+ assertEquals("jpeg", pictures.get(jpegIdx).suggestFileExtension());
+ assertTrue(Arrays.equals(jpegData, pictures.get(jpegIdx).getData()));
+
+ XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+ assertEquals(ClientAnchor.MOVE_AND_RESIZE, anchor.getAnchorType());
+ anchor.setAnchorType(ClientAnchor.DONT_MOVE_AND_RESIZE);
+ assertEquals(ClientAnchor.DONT_MOVE_AND_RESIZE, anchor.getAnchorType());
+
+ XSSFPicture shape = drawing.createPicture(anchor, jpegIdx);
+ assertTrue(anchor.equals(shape.getAnchor()));
+ assertNotNull(shape.getPictureData());
+ assertTrue(Arrays.equals(jpegData, shape.getPictureData().getData()));
+
+ CTTwoCellAnchor ctShapeHolder = drawing.getCTDrawing().getTwoCellAnchorArray(0);
+ // STEditAs.ABSOLUTE corresponds to ClientAnchor.DONT_MOVE_AND_RESIZE
+ assertEquals(STEditAs.ABSOLUTE, ctShapeHolder.getEditAs());
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org