aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2020-01-03 23:30:36 +0000
committerAndreas Beeker <kiwiwings@apache.org>2020-01-03 23:30:36 +0000
commitd66af200eb869618718d8078d98ec5c6a74920aa (patch)
tree7a6df29f71a3110ecdefe9ae7afbd6a1ab74b9c6 /src
parent4aa8334e3b695cc34a2bfb035b9cc35dc9271e73 (diff)
downloadpoi-d66af200eb869618718d8078d98ec5c6a74920aa.tar.gz
poi-d66af200eb869618718d8078d98ec5c6a74920aa.zip
Sonar fixes - Tests should include assertions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1872302 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hssf/record/OldSheetRecord.java14
-rw-r--r--src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java366
-rw-r--r--src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java594
-rw-r--r--src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java206
-rw-r--r--src/testcases/org/apache/poi/hssf/model/TestSheet.java18
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java16
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java4
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java7
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java9
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestFontRecord.java6
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java10
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java5
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestNameCommentRecord.java3
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestNameRecord.java3
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java5
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestObjRecord.java10
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestRecalcIdRecord.java4
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java3
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestSubRecord.java3
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java9
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestTableRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java5
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestAxisLineFormatRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestAxisParentRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestAxisRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestAxisUsedRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestChartRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestDefaultDataLabelTextPropertiesRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestFontBasisRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestFontIndexRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java7
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestNumberFormatIndexRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestObjectLinkRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestPlotGrowthRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestSeriesChartGroupIndexRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestSeriesIndexRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestSeriesListRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestSeriesRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestSeriesTextRecord.java6
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestSeriesToChartGroupRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestUnitsRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java1
-rw-r--r--src/testcases/org/apache/poi/hssf/record/pivot/TestExtendedPivotTableViewFieldsRecord.java1
61 files changed, 713 insertions, 648 deletions
diff --git a/src/java/org/apache/poi/hssf/record/OldSheetRecord.java b/src/java/org/apache/poi/hssf/record/OldSheetRecord.java
index 0672faa054..6c0e81c6fb 100644
--- a/src/java/org/apache/poi/hssf/record/OldSheetRecord.java
+++ b/src/java/org/apache/poi/hssf/record/OldSheetRecord.java
@@ -17,8 +17,11 @@
package org.apache.poi.hssf.record;
+import java.io.IOException;
+
import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.RecordFormatException;
/**
* Title: Bound Sheet Record (aka BundleSheet) (0x0085) for BIFF 5<P>
@@ -44,6 +47,17 @@ public final class OldSheetRecord {
field_2_visibility = in.readUByte();
field_3_type = in.readUByte();
int field_4_sheetname_length = in.readUByte();
+ in.mark(1);
+ byte b = in.readByte();
+ // if the sheet name starts with a 0, we need to skip one byte, otherwise the following records will
+ // fail with a LeftOverDataException
+ if (b != 0) {
+ try {
+ in.reset();
+ } catch (IOException e) {
+ throw new RecordFormatException(e);
+ }
+ }
field_5_sheetname = IOUtils.safelyAllocate(field_4_sheetname_length, MAX_RECORD_LENGTH);
in.read(field_5_sheetname, 0, field_4_sheetname_length);
}
diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
index acfc68cfc8..1ce8a92c22 100644
--- a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
+++ b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
@@ -30,19 +30,19 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.security.Permission;
import org.apache.poi.EmptyFileException;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.RecordFormatException;
-import org.junit.Ignore;
import org.junit.Test;
/**
- * Unit tests for the Excel 5/95 and Excel 4 (and older) text
+ * Unit tests for the Excel 5/95 and Excel 4 (and older) text
* extractor
*/
public final class TestOldExcelExtractor {
@@ -53,168 +53,163 @@ public final class TestOldExcelExtractor {
@Test
public void testSimpleExcel3() throws IOException {
- OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls");
-
- // Check we can call getText without error
- String text = extractor.getText();
-
- // Check we find a few words we expect in there
- assertContains(text, "Season beginning August");
- assertContains(text, "USDA");
-
- // Check we find a few numbers we expect in there
- assertContains(text, "347");
- assertContains(text, "228");
-
- // Check we find a few string-literal dates in there
- assertContains(text, "1981/82");
-
- // Check the type
- assertEquals(3, extractor.getBiffVersion());
- assertEquals(0x10, extractor.getFileType());
-
- extractor.close();
+ try (OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls")) {
+
+ // Check we can call getText without error
+ String text = extractor.getText();
+
+ // Check we find a few words we expect in there
+ assertContains(text, "Season beginning August");
+ assertContains(text, "USDA");
+
+ // Check we find a few numbers we expect in there
+ assertContains(text, "347");
+ assertContains(text, "228");
+
+ // Check we find a few string-literal dates in there
+ assertContains(text, "1981/82");
+
+ // Check the type
+ assertEquals(3, extractor.getBiffVersion());
+ assertEquals(0x10, extractor.getFileType());
+
+ }
}
-
+
@Test
public void testSimpleExcel3NoReading() throws IOException {
- OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls");
- assertNotNull(extractor);
-
- extractor.close();
+ try (OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls")) {
+ assertNotNull(extractor);
+ }
}
@Test
public void testSimpleExcel4() throws IOException {
- OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls");
-
- // Check we can call getText without error
- String text = extractor.getText();
-
- // Check we find a few words we expect in there
- assertContains(text, "Size");
- assertContains(text, "Returns");
-
- // Check we find a few numbers we expect in there
- assertContains(text, "11");
- assertContains(text, "784");
-
- // Check the type
- assertEquals(4, extractor.getBiffVersion());
- assertEquals(0x10, extractor.getFileType());
-
- extractor.close();
- }
-
- @Test
- public void testSimpleExcel5() throws IOException {
- for (String ver : new String[] {"5", "95"}) {
- OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls");
-
+ try (OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls")) {
+
// Check we can call getText without error
String text = extractor.getText();
-
+
// Check we find a few words we expect in there
- assertContains(text, "Sample Excel");
- assertContains(text, "Written and saved");
-
+ assertContains(text, "Size");
+ assertContains(text, "Returns");
+
// Check we find a few numbers we expect in there
- assertContains(text, "15");
- assertContains(text, "169");
-
- // Check we got the sheet names (new formats only)
- assertContains(text, "Sheet: Feuil3");
-
+ assertContains(text, "11");
+ assertContains(text, "784");
+
// Check the type
- assertEquals(5, extractor.getBiffVersion());
- assertEquals(0x05, extractor.getFileType());
+ assertEquals(4, extractor.getBiffVersion());
+ assertEquals(0x10, extractor.getFileType());
- extractor.close();
}
}
@Test
- public void testStrings() throws IOException {
- OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls");
- String text = extractor.getText();
-
- // Simple strings
- assertContains(text, "Table 10 -- Examination Coverage:");
- assertContains(text, "Recommended and Average Recommended Additional Tax After");
- assertContains(text, "Individual income tax returns, total");
-
- // More complicated strings
- assertContains(text, "$100,000 or more");
- assertContains(text, "S corporation returns, Form 1120S [10,15]");
- assertContains(text, "individual income tax return \u201Cshort forms.\u201D");
-
- // Formula based strings
- // TODO Find some then test
-
- extractor.close();
+ public void testSimpleExcel5() throws IOException {
+ for (String ver : new String[] {"5", "95"}) {
+ try (OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls")) {
+
+ // Check we can call getText without error
+ String text = extractor.getText();
+
+ // Check we find a few words we expect in there
+ assertContains(text, "Sample Excel");
+ assertContains(text, "Written and saved");
+
+ // Check we find a few numbers we expect in there
+ assertContains(text, "15");
+ assertContains(text, "169");
+
+ // Check we got the sheet names (new formats only)
+ assertContains(text, "Sheet: Feuil3");
+
+ // Check the type
+ assertEquals(5, extractor.getBiffVersion());
+ assertEquals(0x05, extractor.getFileType());
+
+ }
+ }
}
@Test
- public void testFormattedNumbersExcel4() throws IOException {
- OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls");
- String text = extractor.getText();
-
- // Simple numbers
- assertContains(text, "151");
- assertContains(text, "784");
-
- // Numbers which come from formulas
- assertContains(text, "0.398"); // TODO Rounding
- assertContains(text, "624");
-
- // Formatted numbers
- // TODO
-// assertContains(text, "55,624");
-// assertContains(text, "11,743,477");
-
- extractor.close();
+ public void testStrings() throws IOException {
+ try (OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls")) {
+ String text = extractor.getText();
+
+ // Simple strings
+ assertContains(text, "Table 10 -- Examination Coverage:");
+ assertContains(text, "Recommended and Average Recommended Additional Tax After");
+ assertContains(text, "Individual income tax returns, total");
+
+ // More complicated strings
+ assertContains(text, "$100,000 or more");
+ assertContains(text, "S corporation returns, Form 1120S [10,15]");
+ assertContains(text, "individual income tax return \u201Cshort forms.\u201D");
+
+ // Formula based strings
+ // TODO Find some then test
+ }
}
-
+
@Test
- public void testFormattedNumbersExcel5() throws IOException {
- for (String ver : new String[] {"5", "95"}) {
- OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls");
+ public void testFormattedNumbersExcel4() throws IOException {
+ try (OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls")) {
String text = extractor.getText();
-
+
// Simple numbers
- assertContains(text, "1");
-
+ assertContains(text, "151");
+ assertContains(text, "784");
+
// Numbers which come from formulas
- assertContains(text, "13");
- assertContains(text, "169");
-
+ assertContains(text, "0.398"); // TODO Rounding
+ assertContains(text, "624");
+
// Formatted numbers
// TODO
-// assertContains(text, "100.00%");
-// assertContains(text, "155.00%");
-// assertContains(text, "1,125");
-// assertContains(text, "189,945");
-// assertContains(text, "1,234,500");
-// assertContains(text, "$169.00");
-// assertContains(text, "$1,253.82");
-
- extractor.close();
+ // assertContains(text, "55,624");
+ // assertContains(text, "11,743,477");
}
}
-
+
+ @Test
+ public void testFormattedNumbersExcel5() throws IOException {
+ for (String ver : new String[] {"5", "95"}) {
+ try (OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls")) {
+ String text = extractor.getText();
+
+ // Simple numbers
+ assertContains(text, "1");
+
+ // Numbers which come from formulas
+ assertContains(text, "13");
+ assertContains(text, "169");
+
+ // Formatted numbers
+ // TODO
+ // assertContains(text, "100.00%");
+ // assertContains(text, "155.00%");
+ // assertContains(text, "1,125");
+ // assertContains(text, "189,945");
+ // assertContains(text, "1,234,500");
+ // assertContains(text, "$169.00");
+ // assertContains(text, "$1,253.82");
+ }
+ }
+ }
+
@Test
public void testFromFile() throws IOException {
for (String ver : new String[] {"4", "5", "95"}) {
String filename = "testEXCEL_"+ver+".xls";
File f = HSSFTestDataSamples.getSampleFile(filename);
-
- OldExcelExtractor extractor = new OldExcelExtractor(f);
- String text = extractor.getText();
- assertNotNull(text);
- assertTrue(text.length() > 100);
- extractor.close();
+ try (OldExcelExtractor extractor = new OldExcelExtractor(f)) {
+ String text = extractor.getText();
+ assertNotNull(text);
+ assertTrue(text.length() > 100);
+ }
}
}
@@ -224,12 +219,11 @@ public final class TestOldExcelExtractor {
String filename = "testEXCEL_"+ver+".xls";
File f = HSSFTestDataSamples.getSampleFile(filename);
- try (InputStream stream = new FileInputStream(f)) {
- OldExcelExtractor extractor = new OldExcelExtractor(stream);
+ try (InputStream stream = new FileInputStream(f);
+ OldExcelExtractor extractor = new OldExcelExtractor(stream)) {
String text = extractor.getText();
assertNotNull(text);
assertTrue(text.length() > 100);
- extractor.close();
}
}
}
@@ -237,14 +231,14 @@ public final class TestOldExcelExtractor {
@Test(expected=OfficeXmlFileException.class)
public void testOpenInvalidFile1() throws IOException {
// a file that exists, but is a different format
- createExtractor("WithVariousData.xlsx");
+ createExtractor("WithVariousData.xlsx").close();
}
-
-
+
+
@Test(expected=RecordFormatException.class)
public void testOpenInvalidFile2() throws IOException {
// a completely different type of file
- createExtractor("48936-strings.txt");
+ createExtractor("48936-strings.txt").close();
}
@Test(expected=FileNotFoundException.class)
@@ -258,71 +252,72 @@ public final class TestOldExcelExtractor {
@Test(expected=EmptyFileException.class)
public void testOpenNonExistingFile() throws IOException {
// a file that exists, but is a different format
- OldExcelExtractor extractor = new OldExcelExtractor(new File("notexistingfile.xls"));
- extractor.close();
+ new OldExcelExtractor(new File("notexistingfile.xls")).close();
}
-
+
@Test
public void testInputStream() throws IOException {
File file = HSSFTestDataSamples.getSampleFile("testEXCEL_3.xls");
- try (InputStream stream = new FileInputStream(file)) {
- OldExcelExtractor extractor = new OldExcelExtractor(stream);
+ try (InputStream stream = new FileInputStream(file);
+ OldExcelExtractor extractor = new OldExcelExtractor(stream);) {
String text = extractor.getText();
assertNotNull(text);
- extractor.close();
}
}
@Test
public void testInputStreamNPOIHeader() throws IOException {
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
- try (InputStream stream = new FileInputStream(file)) {
- OldExcelExtractor extractor = new OldExcelExtractor(stream);
- extractor.close();
+ try (InputStream stream = new FileInputStream(file);
+ OldExcelExtractor extractor = new OldExcelExtractor(stream)) {
+ String text = extractor.getText();
+ assertNotNull(text);
}
}
@Test
public void testPOIFSFileSystem() throws IOException {
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
- try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
- OldExcelExtractor extractor = new OldExcelExtractor(fs);
- extractor.close();
+ try (POIFSFileSystem fs = new POIFSFileSystem(file);
+ OldExcelExtractor extractor = new OldExcelExtractor(fs)){
+ String text = extractor.getText();
+ assertNotNull(text);
}
}
@Test
public void testDirectoryNode() throws IOException {
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
- try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
- OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot());
- extractor.close();
+ try (POIFSFileSystem fs = new POIFSFileSystem(file);
+ OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot())) {
+ String text = extractor.getText();
+ assertNotNull(text);
}
}
- @Test
+ @Test(expected = FileNotFoundException.class)
public void testDirectoryNodeInvalidFile() throws IOException {
File file = POIDataSamples.getDocumentInstance().getFile("test.doc");
- try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
- OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot());
- extractor.close();
- fail("Should catch exception here");
- } catch (FileNotFoundException e) {
- // expected here
+ try (POIFSFileSystem fs = new POIFSFileSystem(file);
+ OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot())) {
+ fail("Should throw exception here");
}
}
- @Ignore("Calls System.exit()")
- @Test
+ @Test(expected = ExitException.class)
public void testMainUsage() throws IOException {
PrintStream save = System.err;
+ SecurityManager sm = System.getSecurityManager();
+ System.setSecurityManager(new NoExitSecurityManager());
try {
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
PrintStream str = new PrintStream(out, false, "UTF-8");
System.setErr(str);
+ // calls System.exit()
OldExcelExtractor.main(new String[]{});
}
} finally {
+ System.setSecurityManager(sm);
System.setErr(save);
}
}
@@ -333,34 +328,49 @@ public final class TestOldExcelExtractor {
PrintStream save = System.out;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- try {
- PrintStream str = new PrintStream(out, false, "UTF-8");
- System.setOut(str);
- OldExcelExtractor.main(new String[] {file.getAbsolutePath()});
- } finally {
- out.close();
- }
+ PrintStream str = new PrintStream(out, false, "UTF-8");
+ System.setOut(str);
+ OldExcelExtractor.main(new String[] {file.getAbsolutePath()});
String string = out.toString("UTF-8");
- assertTrue("Had: " + string,
- string.contains("Table C-13--Lemons"));
+ assertTrue("Had: " + string, string.contains("Table C-13--Lemons"));
} finally {
System.setOut(save);
}
}
- @Test
+ @Test(expected = EncryptedDocumentException.class)
public void testEncryptionException() throws IOException {
//test file derives from Common Crawl
File file = HSSFTestDataSamples.getSampleFile("60284.xls");
- OldExcelExtractor ex = new OldExcelExtractor(file);
- assertEquals(5, ex.getBiffVersion());
- assertEquals(5, ex.getFileType());
- try {
+
+ try (OldExcelExtractor ex = new OldExcelExtractor(file)) {
+ assertEquals(5, ex.getBiffVersion());
+ assertEquals(5, ex.getFileType());
ex.getText();
- fail();
- } catch (EncryptedDocumentException e) {
- assertTrue("correct exception thrown", true);
}
- ex.close();
+ }
+
+ private static class NoExitSecurityManager extends SecurityManager {
+ @Override
+ public void checkPermission(Permission perm) {
+ // allow anything.
+ }
+ @Override
+ public void checkPermission(Permission perm, Object context) {
+ // allow anything.
+ }
+ @Override
+ public void checkExit(int status) {
+ super.checkExit(status);
+ throw new ExitException(status);
+ }
+ }
+
+ private static class ExitException extends SecurityException {
+ public final int status;
+ public ExitException(int status) {
+ super("There is no escape!");
+ this.status = status;
+ }
}
}
diff --git a/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java b/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
index 82b1409dbd..abc58d3f7d 100644
--- a/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
+++ b/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
@@ -27,10 +27,8 @@ import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -178,15 +176,10 @@ public class TestDrawingAggregate {
@Test
public void testAllTestSamples() throws IOException {
File[] xls = new File(System.getProperty("POI.testdata.path"), "spreadsheet").listFiles(
- new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".xls");
- }
- }
+ (dir, name) -> name.endsWith(".xls")
);
assertNotNull(
- "Need to find files in test-data path, had path: " + new File(System.getProperty("POI.testdata.path"), "spreadsheet"),
+ "Need to find files in test-data path, had path: " + new File(System.getProperty("POI.testdata.path"), "spreadsheet"),
xls);
for(File file : xls) {
HSSFWorkbook wb;
@@ -203,7 +196,7 @@ public class TestDrawingAggregate {
String filename = file.getName();
System.out.println("Drawing Aggregate re-write test failed for " + filename);
e.printStackTrace(System.out);
-
+
fail("Error when writing and re-reading workbook " + filename + "\n" + e);
}
wb.close();
@@ -246,12 +239,17 @@ public class TestDrawingAggregate {
*/
@Test
public void testFailing() throws IOException {
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("15573.xls");
- HSSFSheet sh = wb.getSheetAt(0);
- sh.getDrawingPatriarch();
-
- HSSFTestDataSamples.writeOutAndReadBack(wb).close();
- wb.close();
+ try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("15573.xls")) {
+ HSSFSheet sh = wb.getSheetAt(0);
+ HSSFPatriarch dp = sh.getDrawingPatriarch();
+ assertNotNull(dp);
+
+ try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb)) {
+ HSSFSheet sh2 = wb2.getSheetAt(0);
+ HSSFPatriarch dp2 = sh2.getDrawingPatriarch();
+ assertNotNull(dp2);
+ }
+ }
}
private static byte[] toByteArray(List<RecordBase> records) {
@@ -269,76 +267,81 @@ public class TestDrawingAggregate {
@Test
public void testSolverContainerMustBeSavedDuringSerialization() throws IOException{
- HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("SolverContainerAfterSPGR.xls");
- HSSFSheet sh = wb1.getSheetAt(0);
- InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
- List<RecordBase> records = ish.getRecords();
- // records to be aggregated
- List<RecordBase> dgRecords = records.subList(19, 22);
- byte[] dgBytes = toByteArray(dgRecords);
- sh.getDrawingPatriarch();
- EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
- assertEquals(agg.getEscherRecords().get(0).getChildRecords().size(), 3);
- assertEquals(agg.getEscherRecords().get(0).getChild(2).getRecordId(), EscherContainerRecord.SOLVER_CONTAINER);
- HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
- wb1.close();
- sh = wb2.getSheetAt(0);
- sh.getDrawingPatriarch();
- ish = HSSFTestHelper.getSheetForTest(sh);
- agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
- assertEquals(agg.getEscherRecords().get(0).getChildRecords().size(), 3);
- assertEquals(agg.getEscherRecords().get(0).getChild(2).getRecordId(), EscherContainerRecord.SOLVER_CONTAINER);
-
-
- // collect drawing records into a byte buffer.
- agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
- byte[] dgBytesAfterSave = agg.serialize();
- assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
- assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
- wb2.close();
+ try (HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("SolverContainerAfterSPGR.xls")) {
+ HSSFSheet sh = wb1.getSheetAt(0);
+ InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
+ List<RecordBase> records = ish.getRecords();
+ // records to be aggregated
+ List<RecordBase> dgRecords = records.subList(19, 22);
+ byte[] dgBytes = toByteArray(dgRecords);
+ sh.getDrawingPatriarch();
+ EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
+ assertNotNull(agg);
+ assertEquals(agg.getEscherRecords().get(0).getChildRecords().size(), 3);
+ assertEquals(agg.getEscherRecords().get(0).getChild(2).getRecordId(), EscherContainerRecord.SOLVER_CONTAINER);
+ try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
+ sh = wb2.getSheetAt(0);
+ sh.getDrawingPatriarch();
+ ish = HSSFTestHelper.getSheetForTest(sh);
+ agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
+ assertNotNull(agg);
+ assertEquals(agg.getEscherRecords().get(0).getChildRecords().size(), 3);
+ assertEquals(agg.getEscherRecords().get(0).getChild(2).getRecordId(), EscherContainerRecord.SOLVER_CONTAINER);
+
+
+ // collect drawing records into a byte buffer.
+ agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
+ assertNotNull(agg);
+ byte[] dgBytesAfterSave = agg.serialize();
+ assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
+ assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
+ }
+ }
}
@Test
public void testFileWithTextbox() throws IOException{
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("text.xls");
- HSSFSheet sh = wb.getSheetAt(0);
- InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
- List<RecordBase> records = ish.getRecords();
- // records to be aggregated
- List<RecordBase> dgRecords = records.subList(19, 23);
- byte[] dgBytes = toByteArray(dgRecords);
- sh.getDrawingPatriarch();
-
- // collect drawing records into a byte buffer.
- EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
- byte[] dgBytesAfterSave = agg.serialize();
- assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
- assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
- wb.close();
+ try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("text.xls")) {
+ HSSFSheet sh = wb.getSheetAt(0);
+ InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
+ List<RecordBase> records = ish.getRecords();
+ // records to be aggregated
+ List<RecordBase> dgRecords = records.subList(19, 23);
+ byte[] dgBytes = toByteArray(dgRecords);
+ sh.getDrawingPatriarch();
+
+ // collect drawing records into a byte buffer.
+ EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
+ assertNotNull(agg);
+ byte[] dgBytesAfterSave = agg.serialize();
+ assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
+ assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
+ }
}
@Test
public void testFileWithCharts() throws IOException {
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49581.xls");
- HSSFSheet sh = wb.getSheetAt(0);
- InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
- List<RecordBase> records = ish.getRecords();
- // records to be aggregated
- List<RecordBase> dgRecords = records.subList(19, 21);
- byte[] dgBytes = toByteArray(dgRecords);
- sh.getDrawingPatriarch();
-
- // collect drawing records into a byte buffer.
- EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
- byte[] dgBytesAfterSave = agg.serialize();
- assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
- for (int i=0; i< dgBytes.length; i++){
- if (dgBytes[i] != dgBytesAfterSave[i]){
- System.out.println("pos = " + i);
+ try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49581.xls")) {
+ HSSFSheet sh = wb.getSheetAt(0);
+ InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
+ List<RecordBase> records = ish.getRecords();
+ // records to be aggregated
+ List<RecordBase> dgRecords = records.subList(19, 21);
+ byte[] dgBytes = toByteArray(dgRecords);
+ sh.getDrawingPatriarch();
+
+ // collect drawing records into a byte buffer.
+ EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
+ assertNotNull(agg);
+ byte[] dgBytesAfterSave = agg.serialize();
+ assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
+ for (int i = 0; i < dgBytes.length; i++) {
+ if (dgBytes[i] != dgBytesAfterSave[i]) {
+ System.out.println("pos = " + i);
+ }
}
+ assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
}
- assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
- wb.close();
}
/**
@@ -346,62 +349,62 @@ public class TestDrawingAggregate {
*/
@Test
public void test45129() throws IOException {
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("45129.xls");
- HSSFSheet sh = wb.getSheetAt(0);
+ try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("45129.xls")) {
+ HSSFSheet sh = wb.getSheetAt(0);
- InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
- InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
+ InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
+ InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
- List<RecordBase> records = isheet.getRecords();
+ List<RecordBase> records = isheet.getRecords();
- // the sheet's drawing is not aggregated
- assertEquals("wrong size of sheet records stream", 394, records.size());
- // the last record before the drawing block
- assertTrue(
- "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
- records.get(18) instanceof RowRecordsAggregate);
+ // the sheet's drawing is not aggregated
+ assertEquals("wrong size of sheet records stream", 394, records.size());
+ // the last record before the drawing block
+ assertTrue(
+ "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
+ records.get(18) instanceof RowRecordsAggregate);
- // records to be aggregated
- List<RecordBase> dgRecords = records.subList(19, 389);
- // collect drawing records into a byte buffer.
- byte[] dgBytes = toByteArray(dgRecords);
+ // records to be aggregated
+ List<RecordBase> dgRecords = records.subList(19, 389);
+ // collect drawing records into a byte buffer.
+ byte[] dgBytes = toByteArray(dgRecords);
- for (RecordBase rb : dgRecords) {
- Record r = (Record) rb;
- short sid = r.getSid();
- // we expect that drawing block consists of either
- // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
+ for (RecordBase rb : dgRecords) {
+ Record r = (Record) rb;
+ short sid = r.getSid();
+ // we expect that drawing block consists of either
+ // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
+ assertTrue(
+ sid == DrawingRecord.sid ||
+ sid == ContinueRecord.sid ||
+ sid == ObjRecord.sid ||
+ sid == TextObjectRecord.sid);
+ }
+
+ // the first record after the drawing block
assertTrue(
- sid == DrawingRecord.sid ||
- sid == ContinueRecord.sid ||
- sid == ObjRecord.sid ||
- sid == TextObjectRecord.sid);
- }
+ "records.get(389) is expected to be Window2",
+ records.get(389) instanceof WindowTwoRecord);
- // the first record after the drawing block
- assertTrue(
- "records.get(389) is expected to be Window2",
- records.get(389) instanceof WindowTwoRecord);
-
- // aggregate drawing records.
- // The subrange [19, 388] is expected to be replaced with a EscherAggregate object
- DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
- int loc = isheet.aggregateDrawingRecords(drawingManager, false);
- EscherAggregate agg = (EscherAggregate) records.get(loc);
-
- assertEquals("wrong size of the aggregated sheet records stream", 25, records.size());
- assertTrue(
- "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
- records.get(18) instanceof RowRecordsAggregate);
- assertTrue("records.get(19) is expected to be EscherAggregate but was " + records.get(19).getClass().getSimpleName(),
- records.get(19) instanceof EscherAggregate);
- assertTrue("records.get(20) is expected to be Window2 but was " + records.get(20).getClass().getSimpleName(),
- records.get(20) instanceof WindowTwoRecord);
+ // aggregate drawing records.
+ // The subrange [19, 388] is expected to be replaced with a EscherAggregate object
+ DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
+ int loc = isheet.aggregateDrawingRecords(drawingManager, false);
+ EscherAggregate agg = (EscherAggregate) records.get(loc);
- byte[] dgBytesAfterSave = agg.serialize();
- assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
- assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
- wb.close();
+ assertEquals("wrong size of the aggregated sheet records stream", 25, records.size());
+ assertTrue(
+ "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
+ records.get(18) instanceof RowRecordsAggregate);
+ assertTrue("records.get(19) is expected to be EscherAggregate but was " + records.get(19).getClass().getSimpleName(),
+ records.get(19) instanceof EscherAggregate);
+ assertTrue("records.get(20) is expected to be Window2 but was " + records.get(20).getClass().getSimpleName(),
+ records.get(20) instanceof WindowTwoRecord);
+
+ byte[] dgBytesAfterSave = agg.serialize();
+ assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
+ assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
+ }
}
/**
@@ -414,208 +417,207 @@ public class TestDrawingAggregate {
*/
@Test
public void testSerializeDrawingBigger8k() throws IOException {
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls");
- InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
- HSSFSheet sh = wb.getSheetAt(0);
- InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
+ try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls")) {
+ InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
+ HSSFSheet sh = wb.getSheetAt(0);
+ InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
- List<RecordBase> records = isheet.getRecords();
+ List<RecordBase> records = isheet.getRecords();
- // the sheet's drawing is not aggregated
- assertEquals("wrong size of sheet records stream", 32, records.size());
- // the last record before the drawing block
- assertTrue(
- "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
- records.get(18) instanceof RowRecordsAggregate);
+ // the sheet's drawing is not aggregated
+ assertEquals("wrong size of sheet records stream", 32, records.size());
+ // the last record before the drawing block
+ assertTrue(
+ "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
+ records.get(18) instanceof RowRecordsAggregate);
- // records to be aggregated
- List<RecordBase> dgRecords = records.subList(19, 26);
- for (RecordBase rb : dgRecords) {
- Record r = (Record) rb;
- short sid = r.getSid();
- // we expect that drawing block consists of either
- // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
+ // records to be aggregated
+ List<RecordBase> dgRecords = records.subList(19, 26);
+ for (RecordBase rb : dgRecords) {
+ Record r = (Record) rb;
+ short sid = r.getSid();
+ // we expect that drawing block consists of either
+ // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
+ assertTrue(
+ sid == DrawingRecord.sid ||
+ sid == ContinueRecord.sid ||
+ sid == ObjRecord.sid ||
+ sid == NoteRecord.sid ||
+ sid == TextObjectRecord.sid);
+ }
+ // collect drawing records into a byte buffer.
+ byte[] dgBytes = toByteArray(dgRecords);
+
+ // the first record after the drawing block
assertTrue(
- sid == DrawingRecord.sid ||
- sid == ContinueRecord.sid ||
- sid == ObjRecord.sid ||
- sid == NoteRecord.sid ||
- sid == TextObjectRecord.sid);
- }
- // collect drawing records into a byte buffer.
- byte[] dgBytes = toByteArray(dgRecords);
-
- // the first record after the drawing block
- assertTrue(
- "records.get(26) is expected to be Window2",
- records.get(26) instanceof WindowTwoRecord);
-
- // aggregate drawing records.
- // The subrange [19, 38] is expected to be replaced with a EscherAggregate object
- DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
- int loc = isheet.aggregateDrawingRecords(drawingManager, false);
- EscherAggregate agg = (EscherAggregate) records.get(loc);
-
- assertEquals("wrong size of the aggregated sheet records stream", 26, records.size());
- assertTrue(
- "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
- records.get(18) instanceof RowRecordsAggregate);
- assertTrue("records.get(19) is expected to be EscherAggregate but was " + records.get(19).getClass().getSimpleName(),
- records.get(19) instanceof EscherAggregate);
- assertTrue("records.get(20) is expected to be Window2 but was " + records.get(20).getClass().getSimpleName(),
- records.get(20) instanceof WindowTwoRecord);
+ "records.get(26) is expected to be Window2",
+ records.get(26) instanceof WindowTwoRecord);
- byte[] dgBytesAfterSave = agg.serialize();
- assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
- assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
- wb.close();
+ // aggregate drawing records.
+ // The subrange [19, 38] is expected to be replaced with a EscherAggregate object
+ DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
+ int loc = isheet.aggregateDrawingRecords(drawingManager, false);
+ EscherAggregate agg = (EscherAggregate) records.get(loc);
+
+ assertEquals("wrong size of the aggregated sheet records stream", 26, records.size());
+ assertTrue(
+ "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
+ records.get(18) instanceof RowRecordsAggregate);
+ assertTrue("records.get(19) is expected to be EscherAggregate but was " + records.get(19).getClass().getSimpleName(),
+ records.get(19) instanceof EscherAggregate);
+ assertTrue("records.get(20) is expected to be Window2 but was " + records.get(20).getClass().getSimpleName(),
+ records.get(20) instanceof WindowTwoRecord);
+
+ byte[] dgBytesAfterSave = agg.serialize();
+ assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
+ assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
+ }
}
@Test
public void testSerializeDrawingBigger8k_noAggregation() throws IOException {
- HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls");
-
- InternalSheet isheet = HSSFTestHelper.getSheetForTest(wb1.getSheetAt(0));
- List<RecordBase> records = isheet.getRecords();
-
- HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
- wb1.close();
- InternalSheet isheet2 = HSSFTestHelper.getSheetForTest(wb2.getSheetAt(0));
- List<RecordBase> records2 = isheet2.getRecords();
-
- assertEquals(records.size(), records2.size());
- for (int i = 0; i < records.size(); i++) {
- RecordBase r1 = records.get(i);
- RecordBase r2 = records2.get(i);
- assertSame(r1.getClass(), r2.getClass());
- assertEquals(r1.getRecordSize(), r2.getRecordSize());
- if (r1 instanceof Record) {
- assertEquals(((Record) r1).getSid(), ((Record) r2).getSid());
- assertArrayEquals(((Record) r1).serialize(), ((Record) r2).serialize());
+ try (HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls")) {
+ InternalSheet isheet = HSSFTestHelper.getSheetForTest(wb1.getSheetAt(0));
+ List<RecordBase> records = isheet.getRecords();
+
+ try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
+ InternalSheet isheet2 = HSSFTestHelper.getSheetForTest(wb2.getSheetAt(0));
+ List<RecordBase> records2 = isheet2.getRecords();
+
+ assertEquals(records.size(), records2.size());
+ for (int i = 0; i < records.size(); i++) {
+ RecordBase r1 = records.get(i);
+ RecordBase r2 = records2.get(i);
+ assertSame(r1.getClass(), r2.getClass());
+ assertEquals(r1.getRecordSize(), r2.getRecordSize());
+ if (r1 instanceof Record) {
+ assertEquals(((Record) r1).getSid(), ((Record) r2).getSid());
+ assertArrayEquals(((Record) r1).serialize(), ((Record) r2).serialize());
+ }
+ }
}
}
- wb2.close();
}
@Test
public void testSerializeDrawingWithComments() throws IOException {
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingAndComments.xls");
- HSSFSheet sh = wb.getSheetAt(0);
- InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
- InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
-
- List<RecordBase> records = isheet.getRecords();
-
- // the sheet's drawing is not aggregated
- assertEquals("wrong size of sheet records stream", 46, records.size());
- // the last record before the drawing block
- assertTrue(
- "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
- records.get(18) instanceof RowRecordsAggregate);
-
- // records to be aggregated
- List<RecordBase> dgRecords = records.subList(19, 39);
- for (RecordBase rb : dgRecords) {
- Record r = (Record) rb;
- short sid = r.getSid();
- // we expect that drawing block consists of either
- // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
+ try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingAndComments.xls")) {
+ HSSFSheet sh = wb.getSheetAt(0);
+ InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
+ InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
+
+ List<RecordBase> records = isheet.getRecords();
+
+ // the sheet's drawing is not aggregated
+ assertEquals("wrong size of sheet records stream", 46, records.size());
+ // the last record before the drawing block
assertTrue(
- sid == DrawingRecord.sid ||
- sid == ContinueRecord.sid ||
- sid == ObjRecord.sid ||
- sid == NoteRecord.sid ||
- sid == TextObjectRecord.sid);
- }
- // collect drawing records into a byte buffer.
- byte[] dgBytes = toByteArray(dgRecords);
-
- // the first record after the drawing block
- assertTrue(
- "records.get(39) is expected to be Window2",
- records.get(39) instanceof WindowTwoRecord);
-
- // aggregate drawing records.
- // The subrange [19, 38] is expected to be replaced with a EscherAggregate object
- DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
- int loc = isheet.aggregateDrawingRecords(drawingManager, false);
- EscherAggregate agg = (EscherAggregate) records.get(loc);
-
- assertEquals("wrong size of the aggregated sheet records stream", 27, records.size());
- assertTrue(
- "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
- records.get(18) instanceof RowRecordsAggregate);
- assertTrue("records.get(19) is expected to be EscherAggregate but was " + records.get(19).getClass().getSimpleName(),
- records.get(19) instanceof EscherAggregate);
- assertTrue("records.get(20) is expected to be Window2 but was " + records.get(20).getClass().getSimpleName(),
- records.get(20) instanceof WindowTwoRecord);
+ "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
+ records.get(18) instanceof RowRecordsAggregate);
- byte[] dgBytesAfterSave = agg.serialize();
- assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
- assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
- wb.close();
+ // records to be aggregated
+ List<RecordBase> dgRecords = records.subList(19, 39);
+ for (RecordBase rb : dgRecords) {
+ Record r = (Record) rb;
+ short sid = r.getSid();
+ // we expect that drawing block consists of either
+ // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
+ assertTrue(
+ sid == DrawingRecord.sid ||
+ sid == ContinueRecord.sid ||
+ sid == ObjRecord.sid ||
+ sid == NoteRecord.sid ||
+ sid == TextObjectRecord.sid);
+ }
+ // collect drawing records into a byte buffer.
+ byte[] dgBytes = toByteArray(dgRecords);
+
+ // the first record after the drawing block
+ assertTrue(
+ "records.get(39) is expected to be Window2",
+ records.get(39) instanceof WindowTwoRecord);
+
+ // aggregate drawing records.
+ // The subrange [19, 38] is expected to be replaced with a EscherAggregate object
+ DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
+ int loc = isheet.aggregateDrawingRecords(drawingManager, false);
+ EscherAggregate agg = (EscherAggregate) records.get(loc);
+
+ assertEquals("wrong size of the aggregated sheet records stream", 27, records.size());
+ assertTrue(
+ "records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(),
+ records.get(18) instanceof RowRecordsAggregate);
+ assertTrue("records.get(19) is expected to be EscherAggregate but was " + records.get(19).getClass().getSimpleName(),
+ records.get(19) instanceof EscherAggregate);
+ assertTrue("records.get(20) is expected to be Window2 but was " + records.get(20).getClass().getSimpleName(),
+ records.get(20) instanceof WindowTwoRecord);
+
+ byte[] dgBytesAfterSave = agg.serialize();
+ assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
+ assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
+ }
}
@Test
public void testFileWithPictures() throws IOException {
- HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ContinueRecordProblem.xls");
- HSSFSheet sh = wb.getSheetAt(0);
+ try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ContinueRecordProblem.xls")) {
+ HSSFSheet sh = wb.getSheetAt(0);
- InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
- InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
+ InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
+ InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
- List<RecordBase> records = isheet.getRecords();
+ List<RecordBase> records = isheet.getRecords();
- // the sheet's drawing is not aggregated
- assertEquals("wrong size of sheet records stream", 315, records.size());
- // the last record before the drawing block
- assertTrue(
- "records.get(21) is expected to be RowRecordsAggregate but was " + records.get(21).getClass().getSimpleName(),
- records.get(21) instanceof RowRecordsAggregate);
+ // the sheet's drawing is not aggregated
+ assertEquals("wrong size of sheet records stream", 315, records.size());
+ // the last record before the drawing block
+ assertTrue(
+ "records.get(21) is expected to be RowRecordsAggregate but was " + records.get(21).getClass().getSimpleName(),
+ records.get(21) instanceof RowRecordsAggregate);
- // records to be aggregated
- List<RecordBase> dgRecords = records.subList(22, 300);
- for (RecordBase rb : dgRecords) {
- Record r = (Record) rb;
- short sid = r.getSid();
- // we expect that drawing block consists of either
- // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
+ // records to be aggregated
+ List<RecordBase> dgRecords = records.subList(22, 300);
+ for (RecordBase rb : dgRecords) {
+ Record r = (Record) rb;
+ short sid = r.getSid();
+ // we expect that drawing block consists of either
+ // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
+ assertTrue(
+ sid == DrawingRecord.sid ||
+ sid == ContinueRecord.sid ||
+ sid == ObjRecord.sid ||
+ sid == TextObjectRecord.sid);
+ }
+ // collect drawing records into a byte buffer.
+ byte[] dgBytes = toByteArray(dgRecords);
+
+ // the first record after the drawing block
assertTrue(
- sid == DrawingRecord.sid ||
- sid == ContinueRecord.sid ||
- sid == ObjRecord.sid ||
- sid == TextObjectRecord.sid);
- }
- // collect drawing records into a byte buffer.
- byte[] dgBytes = toByteArray(dgRecords);
-
- // the first record after the drawing block
- assertTrue(
- "records.get(300) is expected to be Window2",
- records.get(300) instanceof WindowTwoRecord);
-
- // aggregate drawing records.
- // The subrange [19, 299] is expected to be replaced with a EscherAggregate object
- DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
- int loc = isheet.aggregateDrawingRecords(drawingManager, false);
- EscherAggregate agg = (EscherAggregate) records.get(loc);
-
- assertEquals("wrong size of the aggregated sheet records stream", 38, records.size());
- assertTrue(
- "records.get(21) is expected to be RowRecordsAggregate but was " + records.get(21).getClass().getSimpleName(),
- records.get(21) instanceof RowRecordsAggregate);
- assertTrue("records.get(22) is expected to be EscherAggregate but was " + records.get(22).getClass().getSimpleName(),
- records.get(22) instanceof EscherAggregate);
- assertTrue("records.get(23) is expected to be Window2 but was " + records.get(23).getClass().getSimpleName(),
- records.get(23) instanceof WindowTwoRecord);
+ "records.get(300) is expected to be Window2",
+ records.get(300) instanceof WindowTwoRecord);
- byte[] dgBytesAfterSave = agg.serialize();
- assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
- assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
- wb.close();
+ // aggregate drawing records.
+ // The subrange [19, 299] is expected to be replaced with a EscherAggregate object
+ DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
+ int loc = isheet.aggregateDrawingRecords(drawingManager, false);
+ EscherAggregate agg = (EscherAggregate) records.get(loc);
+
+ assertEquals("wrong size of the aggregated sheet records stream", 38, records.size());
+ assertTrue(
+ "records.get(21) is expected to be RowRecordsAggregate but was " + records.get(21).getClass().getSimpleName(),
+ records.get(21) instanceof RowRecordsAggregate);
+ assertTrue("records.get(22) is expected to be EscherAggregate but was " + records.get(22).getClass().getSimpleName(),
+ records.get(22) instanceof EscherAggregate);
+ assertTrue("records.get(23) is expected to be Window2 but was " + records.get(23).getClass().getSimpleName(),
+ records.get(23) instanceof WindowTwoRecord);
+
+ byte[] dgBytesAfterSave = agg.serialize();
+ assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
+ assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
+ }
}
@Test
diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
index b95b700bfb..8c0cf9b82f 100644
--- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
+++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
@@ -17,7 +17,11 @@
package org.apache.poi.hssf.model;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.Locale;
@@ -37,45 +41,10 @@ import org.apache.poi.ss.formula.FormulaParseException;
import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.constant.ErrorConstant;
-import org.apache.poi.ss.formula.ptg.AbstractFunctionPtg;
-import org.apache.poi.ss.formula.ptg.AddPtg;
-import org.apache.poi.ss.formula.ptg.Area3DPtg;
-import org.apache.poi.ss.formula.ptg.AreaI;
-import org.apache.poi.ss.formula.ptg.AreaPtg;
-import org.apache.poi.ss.formula.ptg.AreaPtgBase;
-import org.apache.poi.ss.formula.ptg.ArrayPtg;
-import org.apache.poi.ss.formula.ptg.AttrPtg;
-import org.apache.poi.ss.formula.ptg.BoolPtg;
-import org.apache.poi.ss.formula.ptg.ConcatPtg;
-import org.apache.poi.ss.formula.ptg.DividePtg;
-import org.apache.poi.ss.formula.ptg.EqualPtg;
-import org.apache.poi.ss.formula.ptg.ErrPtg;
-import org.apache.poi.ss.formula.ptg.FuncPtg;
-import org.apache.poi.ss.formula.ptg.FuncVarPtg;
-import org.apache.poi.ss.formula.ptg.GreaterThanPtg;
-import org.apache.poi.ss.formula.ptg.IntPtg;
-import org.apache.poi.ss.formula.ptg.IntersectionPtg;
-import org.apache.poi.ss.formula.ptg.MemAreaPtg;
-import org.apache.poi.ss.formula.ptg.MemFuncPtg;
-import org.apache.poi.ss.formula.ptg.MissingArgPtg;
-import org.apache.poi.ss.formula.ptg.MultiplyPtg;
-import org.apache.poi.ss.formula.ptg.NamePtg;
-import org.apache.poi.ss.formula.ptg.NameXPtg;
-import org.apache.poi.ss.formula.ptg.NumberPtg;
-import org.apache.poi.ss.formula.ptg.ParenthesisPtg;
-import org.apache.poi.ss.formula.ptg.PercentPtg;
-import org.apache.poi.ss.formula.ptg.PowerPtg;
-import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.ss.formula.ptg.RangePtg;
-import org.apache.poi.ss.formula.ptg.Ref3DPtg;
-import org.apache.poi.ss.formula.ptg.RefPtg;
-import org.apache.poi.ss.formula.ptg.StringPtg;
-import org.apache.poi.ss.formula.ptg.SubtractPtg;
-import org.apache.poi.ss.formula.ptg.UnaryMinusPtg;
-import org.apache.poi.ss.formula.ptg.UnaryPlusPtg;
-import org.apache.poi.ss.formula.ptg.UnionPtg;
+import org.apache.poi.ss.formula.ptg.*;
import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
import org.apache.poi.ss.usermodel.FormulaError;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.util.HexRead;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@@ -211,7 +180,7 @@ public final class TestFormulaParser {
}
}
}
-
+
private static void assertEqualsIgnoreCase(String expected, String actual) {
assertEquals(expected.toLowerCase(Locale.ROOT), actual.toLowerCase(Locale.ROOT));
}
@@ -230,22 +199,30 @@ public final class TestFormulaParser {
@Test
public void testWorksheetReferences() throws IOException {
- HSSFWorkbook wb = new HSSFWorkbook();
+ try (HSSFWorkbook wb = new HSSFWorkbook()) {
- wb.createSheet("NoQuotesNeeded");
- wb.createSheet("Quotes Needed Here &#$@");
+ HSSFSheet sheet1 = wb.createSheet("NoQuotesNeeded");
+ sheet1.createRow(0).createCell(0).setCellValue("NoQuotesNeeded");
+ HSSFSheet sheet2 = wb.createSheet("Quotes Needed Here &#$@");
+ sheet2.createRow(0).createCell(0).setCellValue("Quotes Needed Here &#$@");
- HSSFSheet sheet = wb.createSheet("Test");
- HSSFRow row = sheet.createRow(0);
- HSSFCell cell;
+ HSSFSheet sheet = wb.createSheet("Test");
+ HSSFRow row = sheet.createRow(0);
- cell = row.createCell(0);
- cell.setCellFormula("NoQuotesNeeded!A1");
+ FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
+ HSSFCell cell;
+ String act;
- cell = row.createCell(1);
- cell.setCellFormula("'Quotes Needed Here &#$@'!A1");
-
- wb.close();
+ cell = row.createCell(0);
+ cell.setCellFormula("NoQuotesNeeded!A1");
+ act = evaluator.evaluate(cell).getStringValue();
+ assertEquals("NoQuotesNeeded", act);
+
+ cell = row.createCell(1);
+ cell.setCellFormula("'Quotes Needed Here &#$@'!A1");
+ act = evaluator.evaluate(cell).getStringValue();
+ assertEquals("Quotes Needed Here &#$@", act);
+ }
}
@Test
@@ -330,18 +307,21 @@ public final class TestFormulaParser {
/** bug 35027, underscore in sheet name */
@Test
public void testUnderscore() throws IOException {
- HSSFWorkbook wb = new HSSFWorkbook();
+ try (HSSFWorkbook wb = new HSSFWorkbook()) {
+ HSSFSheet sheet1 = wb.createSheet("Cash_Flow");
+ sheet1.createRow(0).createCell(0).setCellValue("Cash_Flow");
- wb.createSheet("Cash_Flow");
+ HSSFSheet sheet = wb.createSheet("Test");
+ HSSFRow row = sheet.createRow(0);
+ HSSFCell cell;
- HSSFSheet sheet = wb.createSheet("Test");
- HSSFRow row = sheet.createRow(0);
- HSSFCell cell;
+ cell = row.createCell(0);
+ cell.setCellFormula("Cash_Flow!A1");
- cell = row.createCell(0);
- cell.setCellFormula("Cash_Flow!A1");
-
- wb.close();
+ FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
+ String act = evaluator.evaluate(cell).getStringValue();
+ assertEquals("Cash_Flow", act);
+ }
}
/** bug 49725, defined names with underscore */
@@ -387,7 +367,7 @@ public final class TestFormulaParser {
cell.setCellFormula("INDEX(DA6_LEO_WBS_Name,MATCH($A3,DA6_LEO_WBS_Number,0))");
assertEquals("INDEX(DA6_LEO_WBS_Name,MATCH($A3,DA6_LEO_WBS_Number,0))", cell.getCellFormula());
-
+
wb.close();
}
@@ -469,7 +449,7 @@ public final class TestFormulaParser {
cell.setCellFormula("-10E-1/3.1E2*4E3/3E4");
formula = cell.getCellFormula();
assertEquals("Exponential formula string", "-1/310*4000/30000", formula);
-
+
wb.close();
}
@@ -511,7 +491,7 @@ public final class TestFormulaParser {
cell.setCellFormula("10E-1");
formula = cell.getCellFormula();
assertEquals("1", formula);
-
+
wb.close();
}
@@ -537,7 +517,7 @@ public final class TestFormulaParser {
cell.setCellFormula("A1...A2");
formula = cell.getCellFormula();
assertEquals("A1:A2", formula);
-
+
wb.close();
}
@@ -547,51 +527,51 @@ public final class TestFormulaParser {
wb.createSheet("Cash_Flow");
wb.createSheet("Test Sheet");
-
+
HSSFSheet sheet = wb.createSheet("Test");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell(0);
String formula;
-
+
// References to a single cell:
-
+
// One sheet
cell.setCellFormula("Cash_Flow!A1");
formula = cell.getCellFormula();
assertEquals("Cash_Flow!A1", formula);
-
+
// Then the other
cell.setCellFormula("\'Test Sheet\'!A1");
formula = cell.getCellFormula();
assertEquals("\'Test Sheet\'!A1", formula);
-
+
// Now both
cell.setCellFormula("Cash_Flow:\'Test Sheet\'!A1");
formula = cell.getCellFormula();
assertEquals("Cash_Flow:\'Test Sheet\'!A1", formula);
-
+
// References to a range (area) of cells:
-
+
// One sheet
cell.setCellFormula("Cash_Flow!A1:B2");
formula = cell.getCellFormula();
assertEquals("Cash_Flow!A1:B2", formula);
-
+
// Then the other
cell.setCellFormula("\'Test Sheet\'!A1:B2");
formula = cell.getCellFormula();
assertEquals("\'Test Sheet\'!A1:B2", formula);
-
+
// Now both
cell.setCellFormula("Cash_Flow:\'Test Sheet\'!A1:B2");
formula = cell.getCellFormula();
assertEquals("Cash_Flow:\'Test Sheet\'!A1:B2", formula);
-
+
wb.close();
}
-
+
/**
* Test for bug observable at svn revision 618865 (5-Feb-2008)<br>
* a formula consisting of a single no-arg function got rendered without the function braces
@@ -604,7 +584,7 @@ public final class TestFormulaParser {
FuncPtg.create(10),
};
assertEquals("NA()", HSSFFormulaParser.toFormulaString(book, ptgs));
-
+
book.close();
}
@@ -758,7 +738,7 @@ public final class TestFormulaParser {
StringPtg sp = (StringPtg) parseSingleToken(formula, StringPtg.class);
assertEquals(expectedValue, sp.getValue());
}
-
+
@Test
public void testParseStringLiterals_bug28754() throws IOException {
@@ -813,7 +793,7 @@ public final class TestFormulaParser {
formulaString = toFormulaString(ptgs);
assertEquals("IF(1<2,SUM(5,2,IF(3>2,SUM(A1:A2),6)),4)", formulaString);
}
-
+
@Test
public void testParserErrors() {
parseExpectedException(" 12 . 345 ");
@@ -827,12 +807,12 @@ public final class TestFormulaParser {
parseExpectedException("IF(TRUE)");
parseExpectedException("countif(A1:B5, C1, D1)");
-
+
parseExpectedException("(");
parseExpectedException(")");
parseExpectedException("+");
parseExpectedException("42+");
-
+
parseExpectedException("IF(");
}
@@ -860,7 +840,7 @@ public final class TestFormulaParser {
fail("Identified bug 44539");
}
assertEquals("SUM(A32769:A32770)", cell.getCellFormula());
-
+
wb.close();
}
@@ -1048,7 +1028,7 @@ public final class TestFormulaParser {
book.close();
}
-
+
@Test
public void testParseArray() {
Ptg[] ptgs;
@@ -1135,7 +1115,7 @@ public final class TestFormulaParser {
wb.setSheetName(0, "A1...A2");
cell.setCellFormula("A1...A2!B1");
assertEquals("A1...A2!B1", cell.getCellFormula());
-
+
wb.close();
}
@@ -1147,7 +1127,7 @@ public final class TestFormulaParser {
cell.setCellFormula("'true'!B2");
assertEquals("'true'!B2", cell.getCellFormula());
-
+
wb.close();
}
@@ -1172,10 +1152,10 @@ public final class TestFormulaParser {
// try setting the same formula in a cell
cell.setCellFormula("[multibookFormulaB.xls]AnotherSheet!B1");
assertEquals("[multibookFormulaB.xls]AnotherSheet!B1", cell.getCellFormula());
-
+
wbA.close();
}
-
+
private static void confirmSingle3DRef(Ptg[] ptgs, int expectedExternSheetIndex) {
assertEquals(1, ptgs.length);
Ptg ptg0 = ptgs[0];
@@ -1207,7 +1187,7 @@ public final class TestFormulaParser {
// We don't check the type of the operands.
confirmTokenClasses("1,2", MemAreaPtg.class, IntPtg.class, IntPtg.class, UnionPtg.class);
-
+
wb.close();
}
@@ -1235,38 +1215,38 @@ public final class TestFormulaParser {
// This used to be an error but now parses. Union has the same behaviour.
confirmTokenClasses("1 2", MemAreaPtg.class, IntPtg.class, IntPtg.class, IntersectionPtg.class);
-
+
wb.close();
}
-
+
@Test
public void testComparisonInParen() {
- confirmTokenClasses("(A1 > B2)",
- RefPtg.class,
- RefPtg.class,
- GreaterThanPtg.class,
+ confirmTokenClasses("(A1 > B2)",
+ RefPtg.class,
+ RefPtg.class,
+ GreaterThanPtg.class,
ParenthesisPtg.class
);
}
-
+
@Test
public void testUnionInParen() {
- confirmTokenClasses("(A1:B2,B2:C3)",
- MemAreaPtg.class,
- AreaPtg.class,
- AreaPtg.class,
- UnionPtg.class,
+ confirmTokenClasses("(A1:B2,B2:C3)",
+ MemAreaPtg.class,
+ AreaPtg.class,
+ AreaPtg.class,
+ UnionPtg.class,
ParenthesisPtg.class
);
}
@Test
public void testIntersectionInParen() {
- confirmTokenClasses("(A1:B2 B2:C3)",
- MemAreaPtg.class,
- AreaPtg.class,
- AreaPtg.class,
- IntersectionPtg.class,
+ confirmTokenClasses("(A1:B2 B2:C3)",
+ MemAreaPtg.class,
+ AreaPtg.class,
+ AreaPtg.class,
+ IntersectionPtg.class,
ParenthesisPtg.class
);
}
@@ -1348,7 +1328,7 @@ public final class TestFormulaParser {
HSSFCell cell_D1 = row.createCell(2);
cell_D1.setCellFormula("NOT(POI\\2009=\"3.5-final\")");
assertEquals("NOT(POI\\2009=\"3.5-final\")", cell_D1.getCellFormula());
-
+
wb.close();
}
@@ -1366,7 +1346,7 @@ public final class TestFormulaParser {
}
// the exact example from the bugzilla description:
HSSFFormulaParser.parse("SUMPRODUCT(A!C7:A!C67, B8:B68) / B69", wb);
-
+
wb.close();
}
@@ -1429,7 +1409,7 @@ public final class TestFormulaParser {
Area3DPtg.class,
UnionPtg.class
);
-
+
wb.close();
}
@@ -1563,7 +1543,7 @@ public final class TestFormulaParser {
throw e;
}
confirmTokenClasses(result, IntPtg.class, NamePtg.class, AddPtg.class);
-
+
wb.close();
}
@@ -1607,7 +1587,7 @@ public final class TestFormulaParser {
n.setRefersToFormula("1+1");
ptgs = HSSFFormulaParser.parse("B0", wb);
confirmTokenClasses(ptgs, NamePtg.class);
-
+
wb.close();
}
@@ -1618,9 +1598,9 @@ public final class TestFormulaParser {
@Test
public void test57196_Formula() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
- Ptg[] ptgs = HSSFFormulaParser.parse("DEC2HEX(HEX2DEC(O8)-O2+D2)", wb, FormulaType.CELL, -1);
+ Ptg[] ptgs = HSSFFormulaParser.parse("DEC2HEX(HEX2DEC(O8)-O2+D2)", wb, FormulaType.CELL, -1);
assertNotNull("Ptg array should not be null", ptgs);
-
+
confirmTokenClasses(ptgs,
NameXPtg.class, // ??
NameXPtg.class, // ??
@@ -1645,7 +1625,7 @@ public final class TestFormulaParser {
assertEquals("O2", o2.toFormulaString());
assertEquals("D2", d2.toFormulaString());
assertEquals(255, dec2Hex.getFunctionIndex());
-
+
wb.close();
- }
+ }
}
diff --git a/src/testcases/org/apache/poi/hssf/model/TestSheet.java b/src/testcases/org/apache/poi/hssf/model/TestSheet.java
index 105cf9cb54..9bd9f1eb4c 100644
--- a/src/testcases/org/apache/poi/hssf/model/TestSheet.java
+++ b/src/testcases/org/apache/poi/hssf/model/TestSheet.java
@@ -202,15 +202,15 @@ public final class TestSheet {
assertEquals("Should be no more merged regions", 0, sheet.getNumMergedRegions());
}
- @Test
- public void testGetMergedRegionAt() {
- //TODO
- }
-
- @Test
- public void testGetNumMergedRegions() {
- //TODO
- }
+ // @Test
+ // public void testGetMergedRegionAt() {
+ // TODO
+ // }
+
+ // @Test
+ // public void testGetNumMergedRegions() {
+ // TODO
+ // }
/**
* Makes sure all rows registered for this sheet are aggregated, they were being skipped
diff --git a/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java b/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java
index 612fbcb651..f63993e424 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java
@@ -17,17 +17,25 @@
package org.apache.poi.hssf.record;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Sheet;
import org.junit.Test;
-/**
- *
- */
+
public final class TestBOFRecord {
@Test
public void testBOFRecord() throws IOException {
// This used to throw an error before - #42794
- HSSFTestDataSamples.openSampleWorkbook("bug_42794.xls").close();
+ try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("bug_42794.xls")) {
+ Sheet sh = wb.getSheetAt(0);
+ for (int i=1; i<=10; i++) {
+ double act = sh.getRow(i).getCell(0).getNumericCellValue();
+ assertEquals(i, act, 0);
+ }
+ }
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java b/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
index 6dab9734d7..13336d525d 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
@@ -73,6 +73,7 @@ public final class TestCFRuleRecord {
}
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testCreateCFRuleRecord() throws IOException {
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
@@ -96,6 +97,7 @@ public final class TestCFRuleRecord {
}
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testCreateCFRule12Record() throws IOException {
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
@@ -422,7 +424,7 @@ public final class TestCFRuleRecord {
assertTrue(refNPtg.isRowRelative());
byte[] data = rr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
+ confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
}
@Test
diff --git a/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java
index 7c0c4293f1..d46cda971c 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java
@@ -56,6 +56,7 @@ public final class TestCommonObjectDataSubRecord {
assertEquals(18, record.getDataSize());
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
CommonObjectDataSubRecord record = new CommonObjectDataSubRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java
index baa3a91db9..b8b1e20bd8 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java
@@ -72,6 +72,7 @@ public final class TestEmbeddedObjectRefSubRecord {
assertArrayEquals(ser, ser2);
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testCameraTool_bug45912() {
/*
@@ -95,6 +96,7 @@ public final class TestEmbeddedObjectRefSubRecord {
/**
* tests various examples of OLE controls
*/
+ @SuppressWarnings("squid:S2699")
@Test
public void testVarious() {
String[] rawData = {
@@ -125,9 +127,10 @@ public final class TestEmbeddedObjectRefSubRecord {
EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in, data.length);
byte[] ser2 = rec.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding("Test record " + i, EORSR_SID, data, ser2);
+ confirmRecordEncoding("Test record " + i, EORSR_SID, data, ser2);
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testVisioDrawing_bug46199() {
/*
@@ -146,6 +149,6 @@ public final class TestEmbeddedObjectRefSubRecord {
// bug 22860 - Not enough data (3) to read requested (4) bytes
EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in, data46199.length);
byte[] ser2 = rec.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(EORSR_SID, data46199, ser2);
+ confirmRecordEncoding(EORSR_SID, data46199, ser2);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java
index d894ceb401..71de921dcc 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java
@@ -57,6 +57,7 @@ public final class TestExtendedFormatRecord {
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
// .fontindex = 0
@@ -122,6 +123,7 @@ public final class TestExtendedFormatRecord {
+ @SuppressWarnings("squid:S2699")
@Test
public void testCloneOnto() {
ExtendedFormatRecord base = createEFR();
diff --git a/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java b/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java
index e3bbb09fa3..3bb3c8394a 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -57,7 +58,7 @@ public final class TestExternalNameRecord {
assertEquals("FDS", enr.getText());
// bug 44695
- TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataFDS, enr.serialize());
+ confirmRecordEncoding(0x0023, dataFDS, enr.serialize());
}
@Test
@@ -81,7 +82,7 @@ public final class TestExternalNameRecord {
assertFalse(enr.isPicureLink());
assertTrue(enr.isStdDocumentNameIdentifier());
- TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataAutoDocName, enr.serialize());
+ confirmRecordEncoding(0x0023, dataAutoDocName, enr.serialize());
}
@Test
@@ -96,7 +97,7 @@ public final class TestExternalNameRecord {
assertFalse(enr.isPicureLink());
assertFalse(enr.isStdDocumentNameIdentifier());
- TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataPlainName, enr.serialize());
+ confirmRecordEncoding(0x0023, dataPlainName, enr.serialize());
}
@Test
@@ -121,7 +122,7 @@ public final class TestExternalNameRecord {
ExternalNameRecord enr = createSimpleENR(dataDDE);
assertEquals("010672AT0 MUNI,[RTG_MOODY_UNDERLYING,RTG_SP_UNDERLYING]", enr.getText());
- TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataDDE, enr.serialize());
+ confirmRecordEncoding(0x0023, dataDDE, enr.serialize());
}
@Test
diff --git a/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java b/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java
index 1e3a19bfb4..69f6254f96 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java
@@ -18,6 +18,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -67,6 +68,7 @@ public final class TestFontRecord {
assertEquals(21 + 4, record.getRecordSize());
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
// .fontheight = c8
@@ -96,7 +98,7 @@ public final class TestFontRecord {
record.setFontName("Arial");
byte [] recordBytes = record.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(0x31, data, recordBytes);
+ confirmRecordEncoding(0x31, data, recordBytes);
}
@Test
@@ -150,6 +152,6 @@ public final class TestFontRecord {
assertEquals(0, fr.getFontName().length());
byte[] recordBytes = fr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(SID, emptyNameData, recordBytes);
+ confirmRecordEncoding(SID, emptyNameData, recordBytes);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java b/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
index 80b62f8d8a..0d5bcfbae6 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
@@ -16,6 +16,7 @@
==================================================================== */
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -453,12 +454,13 @@ public final class TestHyperlinkRecord {
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testReserializeTargetFrame() {
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataTargetFrame);
HyperlinkRecord hr = new HyperlinkRecord(in);
byte[] ser = hr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(HyperlinkRecord.sid, dataTargetFrame, ser);
+ confirmRecordEncoding(HyperlinkRecord.sid, dataTargetFrame, ser);
}
@Test
@@ -467,7 +469,7 @@ public final class TestHyperlinkRecord {
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataLinkToWorkbook);
HyperlinkRecord hr = new HyperlinkRecord(in);
byte[] ser = hr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(HyperlinkRecord.sid, dataLinkToWorkbook, ser);
+ confirmRecordEncoding(HyperlinkRecord.sid, dataLinkToWorkbook, ser);
assertNotEquals("Identified bug in reading workbook link", "YEARFR~1.XLS", hr.getAddress());
assertEquals("yearfracExamples.xls", hr.getAddress());
}
@@ -478,7 +480,7 @@ public final class TestHyperlinkRecord {
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataUNC);
HyperlinkRecord hr = new HyperlinkRecord(in);
byte[] ser = hr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(HyperlinkRecord.sid, dataUNC, ser);
+ confirmRecordEncoding(HyperlinkRecord.sid, dataUNC, ser);
assertNotNull(hr.toString());
}
@@ -541,6 +543,6 @@ public final class TestHyperlinkRecord {
assertEquals("testfolder/test.PDF", link.getAddress());
byte[] ser = link.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(HyperlinkRecord.sid, data_47498, ser);
+ confirmRecordEncoding(HyperlinkRecord.sid, data_47498, ser);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java
index a7afa8feb1..ab54970fb1 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestLbsDataSubRecord.java
@@ -18,6 +18,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -71,7 +72,7 @@ public final class TestLbsDataSubRecord {
// check that it re-serializes to the same data
byte[] ser = record.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(ObjRecord.sid, data, ser);
+ confirmRecordEncoding(ObjRecord.sid, data, ser);
}
/**
@@ -109,7 +110,7 @@ public final class TestLbsDataSubRecord {
// check that it re-serializes to the same data
byte[] ser = record.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(ObjRecord.sid, data, ser);
+ confirmRecordEncoding(ObjRecord.sid, data, ser);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestNameCommentRecord.java b/src/testcases/org/apache/poi/hssf/record/TestNameCommentRecord.java
index b21fe7daf8..062784675f 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestNameCommentRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestNameCommentRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertEquals;
import org.apache.poi.util.HexRead;
@@ -37,6 +38,6 @@ public final class TestNameCommentRecord {
assertEquals("name", ncr.getNameText());
assertEquals("comment", ncr.getCommentText());
final byte[] data2 = ncr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(NameCommentRecord.sid, data, data2);
+ confirmRecordEncoding(NameCommentRecord.sid, data, data2);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java b/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java
index bdb6ce3253..6ddc194a11 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -68,7 +69,7 @@ public final class TestNameRecord {
NameRecord nr = new NameRecord(in);
assertEquals(0x0020, nr.getOptionFlag());
byte[] data2 = nr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(NameRecord.sid, data, data2);
+ confirmRecordEncoding(NameRecord.sid, data, data2);
}
@Test
diff --git a/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java b/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java
index ecdce5de84..c2ccad9a4a 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -64,7 +65,7 @@ public final class TestNoteRecord {
record.setAuthor("Apache Software Foundation");
byte[] ser = record.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(NoteRecord.sid, testData, ser);
+ confirmRecordEncoding(NoteRecord.sid, testData, ser);
}
@Test
@@ -107,7 +108,7 @@ public final class TestNoteRecord {
assertTrue(nr.authorIsMultibyte());
byte[] ser = nr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(NoteRecord.sid, data, ser);
+ confirmRecordEncoding(NoteRecord.sid, data, ser);
// Re-check
in = TestcaseRecordInputStream.create(ser);
diff --git a/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java b/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java
index b20dc35bfd..0cda75422c 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -107,11 +108,11 @@ public final class TestObjRecord {
assertTrue( subrecords.get(0) instanceof CommonObjectDataSubRecord);
assertTrue( subrecords.get(1) instanceof EndSubRecord );
}
-
+
@Test
public void testReadWriteWithPadding_bug45133() {
ObjRecord record = new ObjRecord(TestcaseRecordInputStream.create(recdataNeedingPadding));
-
+
if (record.getRecordSize() == 34) {
fail("Identified bug 45133");
}
@@ -124,11 +125,12 @@ public final class TestObjRecord {
assertEquals(GroupMarkerSubRecord.class, subrecords.get(1).getClass());
assertEquals(EndSubRecord.class, subrecords.get(2).getClass());
}
-
+
/**
* Check that ObjRecord tolerates and preserves padding to a 4-byte boundary
* (normally padding is to a 2-byte boundary).
*/
+ @SuppressWarnings("squid:S2699")
@Test
public void test4BytePadding() {
// actual data from file saved by Excel 2007
@@ -142,6 +144,6 @@ public final class TestObjRecord {
ObjRecord record = new ObjRecord(in);
// check that it re-serializes to the same data
byte[] ser = record.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(ObjRecord.sid, data, ser);
+ confirmRecordEncoding(ObjRecord.sid, data, ser);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java b/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java
index 6a7cf43e5b..f787ef25e5 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java
@@ -50,6 +50,7 @@ public final class TestPaneRecord {
assertEquals( 14, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
PaneRecord record = new PaneRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/TestRecalcIdRecord.java b/src/testcases/org/apache/poi/hssf/record/TestRecalcIdRecord.java
index 0a53b899e7..bbaeae4a23 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestRecalcIdRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestRecalcIdRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -32,6 +33,7 @@ public final class TestRecalcIdRecord {
return result;
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testBasicDeserializeReserialize() {
@@ -41,7 +43,7 @@ public final class TestRecalcIdRecord {
"1D EB 01 00"); // engine id
RecalcIdRecord r = create(data);
- TestcaseRecordInputStream.confirmRecordEncoding(RecalcIdRecord.sid, data, r.serialize());
+ confirmRecordEncoding(RecalcIdRecord.sid, data, r.serialize());
}
@Test
diff --git a/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java
index 24a8b65bdc..561a966861 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java
@@ -42,6 +42,7 @@ public final class TestSCLRecord {
assertEquals( 8, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SCLRecord record = new SCLRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java b/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java
index 0860d248b3..a2236addc9 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertEquals;
import org.apache.poi.util.HexRead;
@@ -35,6 +36,6 @@ public final class TestStyleRecord {
assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
// bug 46385 - Incorrect number of bytes written - expected 27 but got 18
byte[] ser = sr.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(StyleRecord.sid, data, ser);
+ confirmRecordEncoding(StyleRecord.sid, data, ser);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSubRecord.java
index 468a50c3e2..bbeea09ce0 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestSubRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestSubRecord.java
@@ -19,6 +19,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -141,6 +142,6 @@ public final class TestSubRecord {
ObjRecord or = new ObjRecord(in);
// make sure POI properly truncates the ObjRecord data
byte[] data2 = or.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(ObjRecord.sid, data, data2);
+ confirmRecordEncoding(ObjRecord.sid, data, data2);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java
index ebe818d231..da8f6a1576 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java
@@ -26,6 +26,7 @@ import static org.apache.poi.hssf.record.SupBookRecord.CH_STARTUP_DIR;
import static org.apache.poi.hssf.record.SupBookRecord.CH_UP_DIR;
import static org.apache.poi.hssf.record.SupBookRecord.CH_VOLUME;
import static org.apache.poi.hssf.record.SupBookRecord.PATH_SEPERATOR;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -99,20 +100,22 @@ public final class TestSupBookRecord {
/**
* Tests that we can store the record
*/
+ @SuppressWarnings("squid:S2699")
@Test
public void testStoreIR() {
SupBookRecord record = SupBookRecord.createInternalReferences((short)4);
- TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataIR, record.serialize());
+ confirmRecordEncoding(0x01AE, dataIR, record.serialize());
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStoreER() {
String url = "testURL";
String[] sheetNames = { "Sheet1", "Sheet2", };
SupBookRecord record = SupBookRecord.createExternalReferences(url, sheetNames);
- TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataER, record.serialize());
+ confirmRecordEncoding(0x01AE, dataER, record.serialize());
}
@Test
@@ -120,7 +123,7 @@ public final class TestSupBookRecord {
SupBookRecord record = SupBookRecord.createAddInFunctions();
assertEquals(1, record.getNumberOfSheets());
assertTrue(record.isAddInFunctions());
- TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataAIF, record.serialize());
+ confirmRecordEncoding(0x01AE, dataAIF, record.serialize());
}
@Test
diff --git a/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java b/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java
index 3c7e7469b9..7f052df943 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java
@@ -63,6 +63,7 @@ public final class TestTableRecord {
assertEquals( 16 + 4, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore()
{
diff --git a/src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java b/src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java
index 9672cce6c3..38806d9020 100644
--- a/src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/TestWriteAccessRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertEquals;
import org.apache.poi.util.HexRead;
@@ -61,7 +62,7 @@ public final class TestWriteAccessRecord {
+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
+ HEX_SIXTYFOUR_SPACES);
- TestcaseRecordInputStream.confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
+ confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
}
@Test
@@ -90,6 +91,6 @@ public final class TestWriteAccessRecord {
+ "20 20 20 20 20 20 20 20 20 20 20 "
+ HEX_SIXTYFOUR_SPACES);
- TestcaseRecordInputStream.confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
+ confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java
index ad88292845..9df58a8427 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java
@@ -58,6 +58,7 @@ public final class TestAreaFormatRecord {
assertEquals( 20, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
AreaFormatRecord record = new AreaFormatRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java
index f434376902..1bf68f0558 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java
@@ -48,6 +48,7 @@ public final class TestAreaRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
AreaRecord record = new AreaRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisLineFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisLineFormatRecord.java
index 67d1a76ebf..ac12f27119 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisLineFormatRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisLineFormatRecord.java
@@ -42,6 +42,7 @@ public final class TestAxisLineFormatRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
AxisLineFormatRecord record = new AxisLineFormatRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java
index d83e2eac55..d17dcfa765 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java
@@ -63,6 +63,7 @@ public final class TestAxisOptionsRecord {
assertEquals( 22, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
AxisOptionsRecord record = new AxisOptionsRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisParentRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisParentRecord.java
index 25fcc7695d..7f12260a89 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisParentRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisParentRecord.java
@@ -50,6 +50,7 @@ public final class TestAxisParentRecord {
assertEquals( 22, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
AxisParentRecord record = new AxisParentRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisRecord.java
index f862dcc595..56ba5d58a3 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisRecord.java
@@ -50,6 +50,7 @@ public final class TestAxisRecord {
assertEquals( 4 + 18, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
AxisRecord record = new AxisRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisUsedRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisUsedRecord.java
index 0b3525b541..b2907aa5ea 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisUsedRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisUsedRecord.java
@@ -42,6 +42,7 @@ public final class TestAxisUsedRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
AxisUsedRecord record = new AxisUsedRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java
index 16b919ee92..ca4f581612 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java
@@ -51,6 +51,7 @@ public final class TestBarRecord {
assertEquals( 10, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
BarRecord record = new BarRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java
index b5bcdf9e38..d23783b755 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java
@@ -53,6 +53,7 @@ public final class TestCategorySeriesAxisRecord {
assertEquals( 4 + 8, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
CategorySeriesAxisRecord record = new CategorySeriesAxisRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestChartRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestChartRecord.java
index 24fbc51966..545e236623 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestChartRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestChartRecord.java
@@ -48,6 +48,7 @@ public final class TestChartRecord {
assertEquals( 20, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
ChartRecord record = new ChartRecord();
@@ -56,7 +57,6 @@ public final class TestChartRecord {
record.setWidth( 30474216 );
record.setHeight( 15060168 );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(ChartRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java
index 970a6ba977..adce7880dc 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java
@@ -48,6 +48,7 @@ public final class TestDatRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
DatRecord record = new DatRecord();
@@ -56,7 +57,6 @@ public final class TestDatRecord {
record.setBorder( true );
record.setShowSeriesKey( true );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(DatRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java
index 0ae90d7bcb..47b22d6a5d 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java
@@ -50,6 +50,7 @@ public final class TestDataFormatRecord {
assertEquals( 12, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
DataFormatRecord record = new DataFormatRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestDefaultDataLabelTextPropertiesRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestDefaultDataLabelTextPropertiesRecord.java
index f72055c44c..1dd31d92d6 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestDefaultDataLabelTextPropertiesRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestDefaultDataLabelTextPropertiesRecord.java
@@ -43,6 +43,7 @@ public final class TestDefaultDataLabelTextPropertiesRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
DefaultDataLabelTextPropertiesRecord record = new DefaultDataLabelTextPropertiesRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestFontBasisRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestFontBasisRecord.java
index e9054e5f1a..d478945fbd 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestFontBasisRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestFontBasisRecord.java
@@ -50,6 +50,7 @@ public final class TestFontBasisRecord {
assertEquals( 14, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
FontBasisRecord record = new FontBasisRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestFontIndexRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestFontIndexRecord.java
index 3a2bb44417..1f055491af 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestFontIndexRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestFontIndexRecord.java
@@ -43,6 +43,7 @@ public final class TestFontIndexRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
FontIndexRecord record = new FontIndexRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java
index 6e42e8e1ff..86e2729d4c 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java
@@ -48,6 +48,7 @@ public final class TestFrameRecord {
assertEquals( 8, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
FrameRecord record = new FrameRecord();
@@ -56,7 +57,6 @@ public final class TestFrameRecord {
record.setAutoSize( false );
record.setAutoPosition( true );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(FrameRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java
index 1adf85a12f..16eaf33b72 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java
@@ -62,22 +62,17 @@ public final class TestLegendRecord {
assertEquals(24, record.getRecordSize());
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
LegendRecord record = new LegendRecord();
record.setXAxisUpperLeft(0xe76);
-
record.setYAxisUpperLeft(0x786);
-
record.setXSize(0x119);
-
record.setYSize(0x8b);
-
record.setType((byte) 0x3);
-
record.setSpacing((byte) 0x1);
-
record.setOptions((short) 0x1f);
record.setAutoPosition(true);
record.setAutoSeries(true);
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java
index 2945a81c0c..7305134f35 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java
@@ -54,6 +54,7 @@ public final class TestLineFormatRecord {
assertEquals( 16, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
LineFormatRecord record = new LineFormatRecord();
@@ -64,7 +65,6 @@ public final class TestLineFormatRecord {
record.setDrawTicks( false );
record.setColourPaletteIndex( (short)0x4d );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(LineFormatRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java
index ce9476906c..ae5b652b9a 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java
@@ -175,6 +175,7 @@ recordid = 0x1051, size =8
assertEquals( data.length + 4, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
LinkedDataRecord record = new LinkedDataRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestNumberFormatIndexRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestNumberFormatIndexRecord.java
index 052c861bc6..c5efa00df4 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestNumberFormatIndexRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestNumberFormatIndexRecord.java
@@ -42,6 +42,7 @@ public final class TestNumberFormatIndexRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
NumberFormatIndexRecord record = new NumberFormatIndexRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestObjectLinkRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestObjectLinkRecord.java
index f1ab4a1461..8913ca60d6 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestObjectLinkRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestObjectLinkRecord.java
@@ -45,6 +45,7 @@ public final class TestObjectLinkRecord {
assertEquals( 10, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
ObjectLinkRecord record = new ObjectLinkRecord();
@@ -53,7 +54,6 @@ public final class TestObjectLinkRecord {
record.setLink1( (short)0x00 );
record.setLink2( (short)0x00 );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(ObjectLinkRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestPlotGrowthRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestPlotGrowthRecord.java
index 65b007d792..f12474fa54 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestPlotGrowthRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestPlotGrowthRecord.java
@@ -45,13 +45,13 @@ public final class TestPlotGrowthRecord {
assertEquals( 12, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
PlotGrowthRecord record = new PlotGrowthRecord();
record.setHorizontalScale( 65536 );
record.setVerticalScale( 65536 );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(PlotGrowthRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesChartGroupIndexRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesChartGroupIndexRecord.java
index a8c6cdb716..ea674198c9 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesChartGroupIndexRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesChartGroupIndexRecord.java
@@ -42,12 +42,12 @@ public final class TestSeriesChartGroupIndexRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SeriesChartGroupIndexRecord record = new SeriesChartGroupIndexRecord();
record.setChartGroupIndex( (short)0 );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(SeriesChartGroupIndexRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesIndexRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesIndexRecord.java
index af82aff3cb..1607f88cbd 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesIndexRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesIndexRecord.java
@@ -42,12 +42,12 @@ public final class TestSeriesIndexRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SeriesIndexRecord record = new SeriesIndexRecord();
record.setIndex( (short)3 );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(SeriesIndexRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java
index 91c809d1f4..232a1f7b70 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java
@@ -50,6 +50,7 @@ public final class TestSeriesLabelsRecord {
assertEquals( 2+4, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SeriesLabelsRecord record = new SeriesLabelsRecord();
@@ -60,7 +61,6 @@ public final class TestSeriesLabelsRecord {
record.setShowLabel( false );
record.setShowBubbleSizes( false );
-
byte [] recordBytes = record.serialize();
confirmRecordEncoding(SeriesLabelsRecord.sid, data, recordBytes);
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesListRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesListRecord.java
index c35178a7c5..fe310f233b 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesListRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesListRecord.java
@@ -45,6 +45,7 @@ public final class TestSeriesListRecord {
assertEquals( 4 + 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SeriesListRecord record = new SeriesListRecord(new short[] { (short)0x2001, (short)0xf0ff } );
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesRecord.java
index cff843b8a5..dd6c944881 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesRecord.java
@@ -53,6 +53,7 @@ public final class TestSeriesRecord {
assertEquals( 16, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SeriesRecord record = new SeriesRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesTextRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesTextRecord.java
index c705e3b798..138415f49f 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesTextRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesTextRecord.java
@@ -17,6 +17,7 @@
package org.apache.poi.hssf.record.chart;
+import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -43,6 +44,7 @@ public final class TestSeriesTextRecord {
assertEquals(SIMPLE_DATA.length + 4, record.getRecordSize());
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SeriesTextRecord record = new SeriesTextRecord();
@@ -51,7 +53,7 @@ public final class TestSeriesTextRecord {
record.setText("Value Number");
byte[] recordBytes = record.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(SeriesTextRecord.sid, SIMPLE_DATA, recordBytes);
+ confirmRecordEncoding(SeriesTextRecord.sid, SIMPLE_DATA, recordBytes);
}
@Test
@@ -88,6 +90,6 @@ public final class TestSeriesTextRecord {
assertTrue("Identified bug 45784b", str.getRecordSize() >= 0);
byte[] ser = str.serialize();
- TestcaseRecordInputStream.confirmRecordEncoding(SeriesTextRecord.sid, data, ser);
+ confirmRecordEncoding(SeriesTextRecord.sid, data, ser);
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesToChartGroupRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesToChartGroupRecord.java
index fcec0025dc..9f24bb5637 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesToChartGroupRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesToChartGroupRecord.java
@@ -42,6 +42,7 @@ public final class TestSeriesToChartGroupRecord {
assertEquals( 0x6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SeriesToChartGroupRecord record = new SeriesToChartGroupRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java
index b8faa10d40..fb9273fb30 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java
@@ -56,6 +56,7 @@ public final class TestSheetPropertiesRecord {
assertEquals( 8, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
SheetPropertiesRecord record = new SheetPropertiesRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java
index a46fddc112..5e0b854743 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java
@@ -81,6 +81,7 @@ public final class TestTextRecord {
assertEquals( 36, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
TextRecord record = new TextRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java
index efd8a0383e..7b64608cda 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java
@@ -63,6 +63,7 @@ public final class TestTickRecord {
assertEquals( 34, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
TickRecord record = new TickRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestUnitsRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestUnitsRecord.java
index 450cc93316..f99c6a4e87 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestUnitsRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestUnitsRecord.java
@@ -43,6 +43,7 @@ public final class TestUnitsRecord {
assertEquals( 6, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
UnitsRecord record = new UnitsRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java
index bd4d16af71..5c5fe7bf69 100644
--- a/src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java
@@ -64,6 +64,7 @@ public final class TestValueRangeRecord {
assertEquals( 42+4, record.getRecordSize() );
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testStore() {
ValueRangeRecord record = new ValueRangeRecord();
diff --git a/src/testcases/org/apache/poi/hssf/record/pivot/TestExtendedPivotTableViewFieldsRecord.java b/src/testcases/org/apache/poi/hssf/record/pivot/TestExtendedPivotTableViewFieldsRecord.java
index 8418388c54..113951d32c 100644
--- a/src/testcases/org/apache/poi/hssf/record/pivot/TestExtendedPivotTableViewFieldsRecord.java
+++ b/src/testcases/org/apache/poi/hssf/record/pivot/TestExtendedPivotTableViewFieldsRecord.java
@@ -44,6 +44,7 @@ public final class TestExtendedPivotTableViewFieldsRecord {
assertEquals(data.length, rec.getRecordSize());
}
+ @SuppressWarnings("squid:S2699")
@Test
public void testOlderFormat_bug46918() {
// There are 10 SXVDEX records in the file (not uploaded) that originated bugzilla 46918