]> source.dussan.org Git - poi.git/commitdiff
add tests
authorPJ Fanning <fanningpj@apache.org>
Wed, 22 Dec 2021 19:40:44 +0000 (19:40 +0000)
committerPJ Fanning <fanningpj@apache.org>
Wed, 22 Dec 2021 19:40:44 +0000 (19:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896288 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java
poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFFont.java

index fa834e1c760e03554add25fb24dc2e49f38f3b8f..9a058eb8a5bdfd1775884ace2a67a04105d0a74b 100644 (file)
@@ -131,7 +131,7 @@ public class XSSFReader {
      * or {@link ReadOnlySharedStringsTable}.
      * @since POI 5.2.0
      */
-    public boolean useReadOnlySharedStringsTable(boolean useReadOnlySharedStringsTable) {
+    public boolean useReadOnlySharedStringsTable() {
         return useReadOnlySharedStringsTable;
     }
 
index 1b02f66108ebd70a4a81e3ecf559e816293efdd0..5506a364bd3a796357a6fe4fac70fa017fb2bd87 100644 (file)
@@ -44,9 +44,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.XMLHelper;
 import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.model.Comments;
-import org.apache.poi.xssf.model.CommentsTable;
-import org.apache.poi.xssf.model.StylesTable;
+import org.apache.poi.xssf.model.*;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFComment;
 import org.apache.poi.xssf.usermodel.XSSFShape;
@@ -72,9 +70,18 @@ public final class TestXSSFReader {
             assertNotNull(r.getWorkbookData());
             assertNotNull(r.getSharedStringsData());
             assertNotNull(r.getStylesData());
-
-            assertNotNull(r.getSharedStringsTable());
             assertNotNull(r.getStylesTable());
+
+            SharedStrings sst1 = r.getSharedStringsTable();
+            assertNotNull(sst1);
+            assertTrue(sst1 instanceof SharedStringsTable, "instanceof SharedStringsTable");
+
+            assertFalse(r.useReadOnlySharedStringsTable(), "useReadOnlySharedStringsTable defaults to false");
+            r.setUseReadOnlySharedStringsTable(true);
+            assertTrue(r.useReadOnlySharedStringsTable(), "useReadOnlySharedStringsTable changed to true");
+            SharedStrings sst2 = r.getSharedStringsTable();
+            assertNotNull(sst2);
+            assertTrue(sst2 instanceof ReadOnlySharedStringsTable, "instanceof ReadOnlySharedStringsTable");
         }
     }
 
index de6ec4324a40d92ecdfe001be786e6ac93c5b70e..251cf3257b06245271db950ddf3e40bf0f5b7f36 100644 (file)
@@ -299,7 +299,7 @@ public final class TestXSSFFont extends BaseTestFont{
 
         byte[] bytes = Integer.toHexString(0xF1F1F1).getBytes(LocaleUtil.CHARSET_1252);
         color.setRgb(bytes);
-        XSSFColor newColor=XSSFColor.from(color, null);
+        XSSFColor newColor = XSSFColor.from(color);
         xssfFont.setColor(newColor);
         assertEquals(ctFont.getColorArray(0).getRgb()[2],newColor.getRGB()[2]);