mirror of https://github.com/apache/poi.git
Sonar fixes - Tests should include assertions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1872302 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4aa8334e3b
commit
d66af200eb
|
@ -17,8 +17,11 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.poi.util.HexDump;
|
import org.apache.poi.util.HexDump;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
|
import org.apache.poi.util.RecordFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title: Bound Sheet Record (aka BundleSheet) (0x0085) for BIFF 5<P>
|
* 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_2_visibility = in.readUByte();
|
||||||
field_3_type = in.readUByte();
|
field_3_type = in.readUByte();
|
||||||
int field_4_sheetname_length = 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);
|
field_5_sheetname = IOUtils.safelyAllocate(field_4_sheetname_length, MAX_RECORD_LENGTH);
|
||||||
in.read(field_5_sheetname, 0, field_4_sheetname_length);
|
in.read(field_5_sheetname, 0, field_4_sheetname_length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,15 +30,15 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.security.Permission;
|
||||||
|
|
||||||
import org.apache.poi.EmptyFileException;
|
import org.apache.poi.EmptyFileException;
|
||||||
import org.apache.poi.EncryptedDocumentException;
|
import org.apache.poi.EncryptedDocumentException;
|
||||||
import org.apache.poi.POIDataSamples;
|
import org.apache.poi.POIDataSamples;
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
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.OfficeXmlFileException;
|
||||||
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
import org.apache.poi.util.RecordFormatException;
|
import org.apache.poi.util.RecordFormatException;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ public final class TestOldExcelExtractor {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleExcel3() throws IOException {
|
public void testSimpleExcel3() throws IOException {
|
||||||
OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls");
|
try (OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls")) {
|
||||||
|
|
||||||
// Check we can call getText without error
|
// Check we can call getText without error
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
|
@ -73,21 +73,20 @@ public final class TestOldExcelExtractor {
|
||||||
assertEquals(3, extractor.getBiffVersion());
|
assertEquals(3, extractor.getBiffVersion());
|
||||||
assertEquals(0x10, extractor.getFileType());
|
assertEquals(0x10, extractor.getFileType());
|
||||||
|
|
||||||
extractor.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleExcel3NoReading() throws IOException {
|
public void testSimpleExcel3NoReading() throws IOException {
|
||||||
OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls");
|
try (OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls")) {
|
||||||
assertNotNull(extractor);
|
assertNotNull(extractor);
|
||||||
|
}
|
||||||
extractor.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleExcel4() throws IOException {
|
public void testSimpleExcel4() throws IOException {
|
||||||
OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls");
|
try (OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls")) {
|
||||||
|
|
||||||
// Check we can call getText without error
|
// Check we can call getText without error
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
|
@ -104,13 +103,13 @@ public final class TestOldExcelExtractor {
|
||||||
assertEquals(4, extractor.getBiffVersion());
|
assertEquals(4, extractor.getBiffVersion());
|
||||||
assertEquals(0x10, extractor.getFileType());
|
assertEquals(0x10, extractor.getFileType());
|
||||||
|
|
||||||
extractor.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleExcel5() throws IOException {
|
public void testSimpleExcel5() throws IOException {
|
||||||
for (String ver : new String[] {"5", "95"}) {
|
for (String ver : new String[] {"5", "95"}) {
|
||||||
OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls");
|
try (OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls")) {
|
||||||
|
|
||||||
// Check we can call getText without error
|
// Check we can call getText without error
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
|
@ -130,13 +129,13 @@ public final class TestOldExcelExtractor {
|
||||||
assertEquals(5, extractor.getBiffVersion());
|
assertEquals(5, extractor.getBiffVersion());
|
||||||
assertEquals(0x05, extractor.getFileType());
|
assertEquals(0x05, extractor.getFileType());
|
||||||
|
|
||||||
extractor.close();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStrings() throws IOException {
|
public void testStrings() throws IOException {
|
||||||
OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls");
|
try (OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls")) {
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
|
|
||||||
// Simple strings
|
// Simple strings
|
||||||
|
@ -151,13 +150,12 @@ public final class TestOldExcelExtractor {
|
||||||
|
|
||||||
// Formula based strings
|
// Formula based strings
|
||||||
// TODO Find some then test
|
// TODO Find some then test
|
||||||
|
}
|
||||||
extractor.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormattedNumbersExcel4() throws IOException {
|
public void testFormattedNumbersExcel4() throws IOException {
|
||||||
OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls");
|
try (OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls")) {
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
|
|
||||||
// Simple numbers
|
// Simple numbers
|
||||||
|
@ -170,16 +168,15 @@ public final class TestOldExcelExtractor {
|
||||||
|
|
||||||
// Formatted numbers
|
// Formatted numbers
|
||||||
// TODO
|
// TODO
|
||||||
// assertContains(text, "55,624");
|
// assertContains(text, "55,624");
|
||||||
// assertContains(text, "11,743,477");
|
// assertContains(text, "11,743,477");
|
||||||
|
}
|
||||||
extractor.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormattedNumbersExcel5() throws IOException {
|
public void testFormattedNumbersExcel5() throws IOException {
|
||||||
for (String ver : new String[] {"5", "95"}) {
|
for (String ver : new String[] {"5", "95"}) {
|
||||||
OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls");
|
try (OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls")) {
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
|
|
||||||
// Simple numbers
|
// Simple numbers
|
||||||
|
@ -191,15 +188,14 @@ public final class TestOldExcelExtractor {
|
||||||
|
|
||||||
// Formatted numbers
|
// Formatted numbers
|
||||||
// TODO
|
// TODO
|
||||||
// assertContains(text, "100.00%");
|
// assertContains(text, "100.00%");
|
||||||
// assertContains(text, "155.00%");
|
// assertContains(text, "155.00%");
|
||||||
// assertContains(text, "1,125");
|
// assertContains(text, "1,125");
|
||||||
// assertContains(text, "189,945");
|
// assertContains(text, "189,945");
|
||||||
// assertContains(text, "1,234,500");
|
// assertContains(text, "1,234,500");
|
||||||
// assertContains(text, "$169.00");
|
// assertContains(text, "$169.00");
|
||||||
// assertContains(text, "$1,253.82");
|
// assertContains(text, "$1,253.82");
|
||||||
|
}
|
||||||
extractor.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,12 +205,11 @@ public final class TestOldExcelExtractor {
|
||||||
String filename = "testEXCEL_"+ver+".xls";
|
String filename = "testEXCEL_"+ver+".xls";
|
||||||
File f = HSSFTestDataSamples.getSampleFile(filename);
|
File f = HSSFTestDataSamples.getSampleFile(filename);
|
||||||
|
|
||||||
OldExcelExtractor extractor = new OldExcelExtractor(f);
|
try (OldExcelExtractor extractor = new OldExcelExtractor(f)) {
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
assertNotNull(text);
|
assertNotNull(text);
|
||||||
assertTrue(text.length() > 100);
|
assertTrue(text.length() > 100);
|
||||||
|
}
|
||||||
extractor.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,12 +219,11 @@ public final class TestOldExcelExtractor {
|
||||||
String filename = "testEXCEL_"+ver+".xls";
|
String filename = "testEXCEL_"+ver+".xls";
|
||||||
File f = HSSFTestDataSamples.getSampleFile(filename);
|
File f = HSSFTestDataSamples.getSampleFile(filename);
|
||||||
|
|
||||||
try (InputStream stream = new FileInputStream(f)) {
|
try (InputStream stream = new FileInputStream(f);
|
||||||
OldExcelExtractor extractor = new OldExcelExtractor(stream);
|
OldExcelExtractor extractor = new OldExcelExtractor(stream)) {
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
assertNotNull(text);
|
assertNotNull(text);
|
||||||
assertTrue(text.length() > 100);
|
assertTrue(text.length() > 100);
|
||||||
extractor.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,14 +231,14 @@ public final class TestOldExcelExtractor {
|
||||||
@Test(expected=OfficeXmlFileException.class)
|
@Test(expected=OfficeXmlFileException.class)
|
||||||
public void testOpenInvalidFile1() throws IOException {
|
public void testOpenInvalidFile1() throws IOException {
|
||||||
// a file that exists, but is a different format
|
// a file that exists, but is a different format
|
||||||
createExtractor("WithVariousData.xlsx");
|
createExtractor("WithVariousData.xlsx").close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(expected=RecordFormatException.class)
|
@Test(expected=RecordFormatException.class)
|
||||||
public void testOpenInvalidFile2() throws IOException {
|
public void testOpenInvalidFile2() throws IOException {
|
||||||
// a completely different type of file
|
// a completely different type of file
|
||||||
createExtractor("48936-strings.txt");
|
createExtractor("48936-strings.txt").close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=FileNotFoundException.class)
|
@Test(expected=FileNotFoundException.class)
|
||||||
|
@ -258,71 +252,72 @@ public final class TestOldExcelExtractor {
|
||||||
@Test(expected=EmptyFileException.class)
|
@Test(expected=EmptyFileException.class)
|
||||||
public void testOpenNonExistingFile() throws IOException {
|
public void testOpenNonExistingFile() throws IOException {
|
||||||
// a file that exists, but is a different format
|
// a file that exists, but is a different format
|
||||||
OldExcelExtractor extractor = new OldExcelExtractor(new File("notexistingfile.xls"));
|
new OldExcelExtractor(new File("notexistingfile.xls")).close();
|
||||||
extractor.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInputStream() throws IOException {
|
public void testInputStream() throws IOException {
|
||||||
File file = HSSFTestDataSamples.getSampleFile("testEXCEL_3.xls");
|
File file = HSSFTestDataSamples.getSampleFile("testEXCEL_3.xls");
|
||||||
try (InputStream stream = new FileInputStream(file)) {
|
try (InputStream stream = new FileInputStream(file);
|
||||||
OldExcelExtractor extractor = new OldExcelExtractor(stream);
|
OldExcelExtractor extractor = new OldExcelExtractor(stream);) {
|
||||||
String text = extractor.getText();
|
String text = extractor.getText();
|
||||||
assertNotNull(text);
|
assertNotNull(text);
|
||||||
extractor.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInputStreamNPOIHeader() throws IOException {
|
public void testInputStreamNPOIHeader() throws IOException {
|
||||||
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
|
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
|
||||||
try (InputStream stream = new FileInputStream(file)) {
|
try (InputStream stream = new FileInputStream(file);
|
||||||
OldExcelExtractor extractor = new OldExcelExtractor(stream);
|
OldExcelExtractor extractor = new OldExcelExtractor(stream)) {
|
||||||
extractor.close();
|
String text = extractor.getText();
|
||||||
|
assertNotNull(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPOIFSFileSystem() throws IOException {
|
public void testPOIFSFileSystem() throws IOException {
|
||||||
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
|
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
|
||||||
try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
|
try (POIFSFileSystem fs = new POIFSFileSystem(file);
|
||||||
OldExcelExtractor extractor = new OldExcelExtractor(fs);
|
OldExcelExtractor extractor = new OldExcelExtractor(fs)){
|
||||||
extractor.close();
|
String text = extractor.getText();
|
||||||
|
assertNotNull(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDirectoryNode() throws IOException {
|
public void testDirectoryNode() throws IOException {
|
||||||
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
|
File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
|
||||||
try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
|
try (POIFSFileSystem fs = new POIFSFileSystem(file);
|
||||||
OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot());
|
OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot())) {
|
||||||
extractor.close();
|
String text = extractor.getText();
|
||||||
|
assertNotNull(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = FileNotFoundException.class)
|
||||||
public void testDirectoryNodeInvalidFile() throws IOException {
|
public void testDirectoryNodeInvalidFile() throws IOException {
|
||||||
File file = POIDataSamples.getDocumentInstance().getFile("test.doc");
|
File file = POIDataSamples.getDocumentInstance().getFile("test.doc");
|
||||||
try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
|
try (POIFSFileSystem fs = new POIFSFileSystem(file);
|
||||||
OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot());
|
OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot())) {
|
||||||
extractor.close();
|
fail("Should throw exception here");
|
||||||
fail("Should catch exception here");
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
// expected here
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("Calls System.exit()")
|
@Test(expected = ExitException.class)
|
||||||
@Test
|
|
||||||
public void testMainUsage() throws IOException {
|
public void testMainUsage() throws IOException {
|
||||||
PrintStream save = System.err;
|
PrintStream save = System.err;
|
||||||
|
SecurityManager sm = System.getSecurityManager();
|
||||||
|
System.setSecurityManager(new NoExitSecurityManager());
|
||||||
try {
|
try {
|
||||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||||
PrintStream str = new PrintStream(out, false, "UTF-8");
|
PrintStream str = new PrintStream(out, false, "UTF-8");
|
||||||
System.setErr(str);
|
System.setErr(str);
|
||||||
|
// calls System.exit()
|
||||||
OldExcelExtractor.main(new String[]{});
|
OldExcelExtractor.main(new String[]{});
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
System.setSecurityManager(sm);
|
||||||
System.setErr(save);
|
System.setErr(save);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,34 +328,49 @@ public final class TestOldExcelExtractor {
|
||||||
PrintStream save = System.out;
|
PrintStream save = System.out;
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
try {
|
|
||||||
PrintStream str = new PrintStream(out, false, "UTF-8");
|
PrintStream str = new PrintStream(out, false, "UTF-8");
|
||||||
System.setOut(str);
|
System.setOut(str);
|
||||||
OldExcelExtractor.main(new String[] {file.getAbsolutePath()});
|
OldExcelExtractor.main(new String[] {file.getAbsolutePath()});
|
||||||
} finally {
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
String string = out.toString("UTF-8");
|
String string = out.toString("UTF-8");
|
||||||
assertTrue("Had: " + string,
|
assertTrue("Had: " + string, string.contains("Table C-13--Lemons"));
|
||||||
string.contains("Table C-13--Lemons"));
|
|
||||||
} finally {
|
} finally {
|
||||||
System.setOut(save);
|
System.setOut(save);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = EncryptedDocumentException.class)
|
||||||
public void testEncryptionException() throws IOException {
|
public void testEncryptionException() throws IOException {
|
||||||
//test file derives from Common Crawl
|
//test file derives from Common Crawl
|
||||||
File file = HSSFTestDataSamples.getSampleFile("60284.xls");
|
File file = HSSFTestDataSamples.getSampleFile("60284.xls");
|
||||||
OldExcelExtractor ex = new OldExcelExtractor(file);
|
|
||||||
|
try (OldExcelExtractor ex = new OldExcelExtractor(file)) {
|
||||||
assertEquals(5, ex.getBiffVersion());
|
assertEquals(5, ex.getBiffVersion());
|
||||||
assertEquals(5, ex.getFileType());
|
assertEquals(5, ex.getFileType());
|
||||||
try {
|
|
||||||
ex.getText();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,8 @@ import static org.junit.Assert.fail;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -178,12 +176,7 @@ public class TestDrawingAggregate {
|
||||||
@Test
|
@Test
|
||||||
public void testAllTestSamples() throws IOException {
|
public void testAllTestSamples() throws IOException {
|
||||||
File[] xls = new File(System.getProperty("POI.testdata.path"), "spreadsheet").listFiles(
|
File[] xls = new File(System.getProperty("POI.testdata.path"), "spreadsheet").listFiles(
|
||||||
new FilenameFilter() {
|
(dir, name) -> name.endsWith(".xls")
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.endsWith(".xls");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
assertNotNull(
|
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"),
|
||||||
|
@ -246,12 +239,17 @@ public class TestDrawingAggregate {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFailing() throws IOException {
|
public void testFailing() throws IOException {
|
||||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("15573.xls");
|
try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("15573.xls")) {
|
||||||
HSSFSheet sh = wb.getSheetAt(0);
|
HSSFSheet sh = wb.getSheetAt(0);
|
||||||
sh.getDrawingPatriarch();
|
HSSFPatriarch dp = sh.getDrawingPatriarch();
|
||||||
|
assertNotNull(dp);
|
||||||
|
|
||||||
HSSFTestDataSamples.writeOutAndReadBack(wb).close();
|
try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb)) {
|
||||||
wb.close();
|
HSSFSheet sh2 = wb2.getSheetAt(0);
|
||||||
|
HSSFPatriarch dp2 = sh2.getDrawingPatriarch();
|
||||||
|
assertNotNull(dp2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] toByteArray(List<RecordBase> records) {
|
private static byte[] toByteArray(List<RecordBase> records) {
|
||||||
|
@ -269,7 +267,7 @@ public class TestDrawingAggregate {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSolverContainerMustBeSavedDuringSerialization() throws IOException{
|
public void testSolverContainerMustBeSavedDuringSerialization() throws IOException{
|
||||||
HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("SolverContainerAfterSPGR.xls");
|
try (HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("SolverContainerAfterSPGR.xls")) {
|
||||||
HSSFSheet sh = wb1.getSheetAt(0);
|
HSSFSheet sh = wb1.getSheetAt(0);
|
||||||
InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
|
InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
|
||||||
List<RecordBase> records = ish.getRecords();
|
List<RecordBase> records = ish.getRecords();
|
||||||
|
@ -278,29 +276,32 @@ public class TestDrawingAggregate {
|
||||||
byte[] dgBytes = toByteArray(dgRecords);
|
byte[] dgBytes = toByteArray(dgRecords);
|
||||||
sh.getDrawingPatriarch();
|
sh.getDrawingPatriarch();
|
||||||
EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
||||||
|
assertNotNull(agg);
|
||||||
assertEquals(agg.getEscherRecords().get(0).getChildRecords().size(), 3);
|
assertEquals(agg.getEscherRecords().get(0).getChildRecords().size(), 3);
|
||||||
assertEquals(agg.getEscherRecords().get(0).getChild(2).getRecordId(), EscherContainerRecord.SOLVER_CONTAINER);
|
assertEquals(agg.getEscherRecords().get(0).getChild(2).getRecordId(), EscherContainerRecord.SOLVER_CONTAINER);
|
||||||
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
|
||||||
wb1.close();
|
|
||||||
sh = wb2.getSheetAt(0);
|
sh = wb2.getSheetAt(0);
|
||||||
sh.getDrawingPatriarch();
|
sh.getDrawingPatriarch();
|
||||||
ish = HSSFTestHelper.getSheetForTest(sh);
|
ish = HSSFTestHelper.getSheetForTest(sh);
|
||||||
agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
||||||
|
assertNotNull(agg);
|
||||||
assertEquals(agg.getEscherRecords().get(0).getChildRecords().size(), 3);
|
assertEquals(agg.getEscherRecords().get(0).getChildRecords().size(), 3);
|
||||||
assertEquals(agg.getEscherRecords().get(0).getChild(2).getRecordId(), EscherContainerRecord.SOLVER_CONTAINER);
|
assertEquals(agg.getEscherRecords().get(0).getChild(2).getRecordId(), EscherContainerRecord.SOLVER_CONTAINER);
|
||||||
|
|
||||||
|
|
||||||
// collect drawing records into a byte buffer.
|
// collect drawing records into a byte buffer.
|
||||||
agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
||||||
|
assertNotNull(agg);
|
||||||
byte[] dgBytesAfterSave = agg.serialize();
|
byte[] dgBytesAfterSave = agg.serialize();
|
||||||
assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
|
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);
|
assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
|
||||||
wb2.close();
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFileWithTextbox() throws IOException{
|
public void testFileWithTextbox() throws IOException{
|
||||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("text.xls");
|
try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("text.xls")) {
|
||||||
HSSFSheet sh = wb.getSheetAt(0);
|
HSSFSheet sh = wb.getSheetAt(0);
|
||||||
InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
|
InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
|
||||||
List<RecordBase> records = ish.getRecords();
|
List<RecordBase> records = ish.getRecords();
|
||||||
|
@ -311,15 +312,16 @@ public class TestDrawingAggregate {
|
||||||
|
|
||||||
// collect drawing records into a byte buffer.
|
// collect drawing records into a byte buffer.
|
||||||
EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
||||||
|
assertNotNull(agg);
|
||||||
byte[] dgBytesAfterSave = agg.serialize();
|
byte[] dgBytesAfterSave = agg.serialize();
|
||||||
assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
|
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);
|
assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
|
||||||
wb.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFileWithCharts() throws IOException {
|
public void testFileWithCharts() throws IOException {
|
||||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49581.xls");
|
try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49581.xls")) {
|
||||||
HSSFSheet sh = wb.getSheetAt(0);
|
HSSFSheet sh = wb.getSheetAt(0);
|
||||||
InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
|
InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
|
||||||
List<RecordBase> records = ish.getRecords();
|
List<RecordBase> records = ish.getRecords();
|
||||||
|
@ -330,15 +332,16 @@ public class TestDrawingAggregate {
|
||||||
|
|
||||||
// collect drawing records into a byte buffer.
|
// collect drawing records into a byte buffer.
|
||||||
EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid);
|
||||||
|
assertNotNull(agg);
|
||||||
byte[] dgBytesAfterSave = agg.serialize();
|
byte[] dgBytesAfterSave = agg.serialize();
|
||||||
assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
|
assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
|
||||||
for (int i=0; i< dgBytes.length; i++){
|
for (int i = 0; i < dgBytes.length; i++) {
|
||||||
if (dgBytes[i] != dgBytesAfterSave[i]){
|
if (dgBytes[i] != dgBytesAfterSave[i]) {
|
||||||
System.out.println("pos = " + 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,7 +349,7 @@ public class TestDrawingAggregate {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void test45129() throws IOException {
|
public void test45129() throws IOException {
|
||||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("45129.xls");
|
try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("45129.xls")) {
|
||||||
HSSFSheet sh = wb.getSheetAt(0);
|
HSSFSheet sh = wb.getSheetAt(0);
|
||||||
|
|
||||||
InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
|
InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
|
||||||
|
@ -401,7 +404,7 @@ public class TestDrawingAggregate {
|
||||||
byte[] dgBytesAfterSave = agg.serialize();
|
byte[] dgBytesAfterSave = agg.serialize();
|
||||||
assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
|
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);
|
assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
|
||||||
wb.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -414,7 +417,7 @@ public class TestDrawingAggregate {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSerializeDrawingBigger8k() throws IOException {
|
public void testSerializeDrawingBigger8k() throws IOException {
|
||||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls");
|
try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls")) {
|
||||||
InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
|
InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
|
||||||
HSSFSheet sh = wb.getSheetAt(0);
|
HSSFSheet sh = wb.getSheetAt(0);
|
||||||
InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
|
InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
|
||||||
|
@ -469,19 +472,17 @@ public class TestDrawingAggregate {
|
||||||
byte[] dgBytesAfterSave = agg.serialize();
|
byte[] dgBytesAfterSave = agg.serialize();
|
||||||
assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
|
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);
|
assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
|
||||||
wb.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerializeDrawingBigger8k_noAggregation() throws IOException {
|
public void testSerializeDrawingBigger8k_noAggregation() throws IOException {
|
||||||
HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls");
|
try (HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls")) {
|
||||||
|
|
||||||
InternalSheet isheet = HSSFTestHelper.getSheetForTest(wb1.getSheetAt(0));
|
InternalSheet isheet = HSSFTestHelper.getSheetForTest(wb1.getSheetAt(0));
|
||||||
List<RecordBase> records = isheet.getRecords();
|
List<RecordBase> records = isheet.getRecords();
|
||||||
|
|
||||||
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
|
||||||
wb1.close();
|
|
||||||
InternalSheet isheet2 = HSSFTestHelper.getSheetForTest(wb2.getSheetAt(0));
|
InternalSheet isheet2 = HSSFTestHelper.getSheetForTest(wb2.getSheetAt(0));
|
||||||
List<RecordBase> records2 = isheet2.getRecords();
|
List<RecordBase> records2 = isheet2.getRecords();
|
||||||
|
|
||||||
|
@ -496,12 +497,13 @@ public class TestDrawingAggregate {
|
||||||
assertArrayEquals(((Record) r1).serialize(), ((Record) r2).serialize());
|
assertArrayEquals(((Record) r1).serialize(), ((Record) r2).serialize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wb2.close();
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerializeDrawingWithComments() throws IOException {
|
public void testSerializeDrawingWithComments() throws IOException {
|
||||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingAndComments.xls");
|
try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingAndComments.xls")) {
|
||||||
HSSFSheet sh = wb.getSheetAt(0);
|
HSSFSheet sh = wb.getSheetAt(0);
|
||||||
InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
|
InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
|
||||||
InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
|
InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
|
||||||
|
@ -555,13 +557,13 @@ public class TestDrawingAggregate {
|
||||||
byte[] dgBytesAfterSave = agg.serialize();
|
byte[] dgBytesAfterSave = agg.serialize();
|
||||||
assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
|
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);
|
assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
|
||||||
wb.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFileWithPictures() throws IOException {
|
public void testFileWithPictures() throws IOException {
|
||||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ContinueRecordProblem.xls");
|
try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ContinueRecordProblem.xls")) {
|
||||||
HSSFSheet sh = wb.getSheetAt(0);
|
HSSFSheet sh = wb.getSheetAt(0);
|
||||||
|
|
||||||
InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
|
InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
|
||||||
|
@ -615,7 +617,7 @@ public class TestDrawingAggregate {
|
||||||
byte[] dgBytesAfterSave = agg.serialize();
|
byte[] dgBytesAfterSave = agg.serialize();
|
||||||
assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
|
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);
|
assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave);
|
||||||
wb.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -17,7 +17,11 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.model;
|
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.io.IOException;
|
||||||
import java.util.Locale;
|
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.FormulaParser;
|
||||||
import org.apache.poi.ss.formula.FormulaType;
|
import org.apache.poi.ss.formula.FormulaType;
|
||||||
import org.apache.poi.ss.formula.constant.ErrorConstant;
|
import org.apache.poi.ss.formula.constant.ErrorConstant;
|
||||||
import org.apache.poi.ss.formula.ptg.AbstractFunctionPtg;
|
import org.apache.poi.ss.formula.ptg.*;
|
||||||
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.usermodel.BaseTestBugzillaIssues;
|
import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
|
||||||
import org.apache.poi.ss.usermodel.FormulaError;
|
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.ss.usermodel.Name;
|
||||||
import org.apache.poi.util.HexRead;
|
import org.apache.poi.util.HexRead;
|
||||||
import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
||||||
|
@ -230,22 +199,30 @@ public final class TestFormulaParser {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWorksheetReferences() throws IOException {
|
public void testWorksheetReferences() throws IOException {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||||
|
|
||||||
wb.createSheet("NoQuotesNeeded");
|
HSSFSheet sheet1 = wb.createSheet("NoQuotesNeeded");
|
||||||
wb.createSheet("Quotes Needed Here &#$@");
|
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");
|
HSSFSheet sheet = wb.createSheet("Test");
|
||||||
HSSFRow row = sheet.createRow(0);
|
HSSFRow row = sheet.createRow(0);
|
||||||
|
|
||||||
|
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
HSSFCell cell;
|
HSSFCell cell;
|
||||||
|
String act;
|
||||||
|
|
||||||
cell = row.createCell(0);
|
cell = row.createCell(0);
|
||||||
cell.setCellFormula("NoQuotesNeeded!A1");
|
cell.setCellFormula("NoQuotesNeeded!A1");
|
||||||
|
act = evaluator.evaluate(cell).getStringValue();
|
||||||
|
assertEquals("NoQuotesNeeded", act);
|
||||||
|
|
||||||
cell = row.createCell(1);
|
cell = row.createCell(1);
|
||||||
cell.setCellFormula("'Quotes Needed Here &#$@'!A1");
|
cell.setCellFormula("'Quotes Needed Here &#$@'!A1");
|
||||||
|
act = evaluator.evaluate(cell).getStringValue();
|
||||||
wb.close();
|
assertEquals("Quotes Needed Here &#$@", act);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -330,9 +307,9 @@ public final class TestFormulaParser {
|
||||||
/** bug 35027, underscore in sheet name */
|
/** bug 35027, underscore in sheet name */
|
||||||
@Test
|
@Test
|
||||||
public void testUnderscore() throws IOException {
|
public void testUnderscore() throws IOException {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||||
|
HSSFSheet sheet1 = wb.createSheet("Cash_Flow");
|
||||||
wb.createSheet("Cash_Flow");
|
sheet1.createRow(0).createCell(0).setCellValue("Cash_Flow");
|
||||||
|
|
||||||
HSSFSheet sheet = wb.createSheet("Test");
|
HSSFSheet sheet = wb.createSheet("Test");
|
||||||
HSSFRow row = sheet.createRow(0);
|
HSSFRow row = sheet.createRow(0);
|
||||||
|
@ -341,7 +318,10 @@ public final class TestFormulaParser {
|
||||||
cell = row.createCell(0);
|
cell = row.createCell(0);
|
||||||
cell.setCellFormula("Cash_Flow!A1");
|
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 */
|
/** bug 49725, defined names with underscore */
|
||||||
|
|
|
@ -202,15 +202,15 @@ public final class TestSheet {
|
||||||
assertEquals("Should be no more merged regions", 0, sheet.getNumMergedRegions());
|
assertEquals("Should be no more merged regions", 0, sheet.getNumMergedRegions());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void testGetMergedRegionAt() {
|
// public void testGetMergedRegionAt() {
|
||||||
//TODO
|
// TODO
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void testGetNumMergedRegions() {
|
// public void testGetNumMergedRegions() {
|
||||||
//TODO
|
// TODO
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes sure all rows registered for this sheet are aggregated, they were being skipped
|
* Makes sure all rows registered for this sheet are aggregated, they were being skipped
|
||||||
|
|
|
@ -17,17 +17,25 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final class TestBOFRecord {
|
public final class TestBOFRecord {
|
||||||
@Test
|
@Test
|
||||||
public void testBOFRecord() throws IOException {
|
public void testBOFRecord() throws IOException {
|
||||||
// This used to throw an error before - #42794
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ public final class TestCFRuleRecord {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testCreateCFRuleRecord() throws IOException {
|
public void testCreateCFRuleRecord() throws IOException {
|
||||||
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
||||||
|
@ -96,6 +97,7 @@ public final class TestCFRuleRecord {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testCreateCFRule12Record() throws IOException {
|
public void testCreateCFRule12Record() throws IOException {
|
||||||
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
||||||
|
@ -422,7 +424,7 @@ public final class TestCFRuleRecord {
|
||||||
assertTrue(refNPtg.isRowRelative());
|
assertTrue(refNPtg.isRowRelative());
|
||||||
|
|
||||||
byte[] data = rr.serialize();
|
byte[] data = rr.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
|
confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -56,6 +56,7 @@ public final class TestCommonObjectDataSubRecord {
|
||||||
assertEquals(18, record.getDataSize());
|
assertEquals(18, record.getDataSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
CommonObjectDataSubRecord record = new CommonObjectDataSubRecord();
|
CommonObjectDataSubRecord record = new CommonObjectDataSubRecord();
|
||||||
|
|
|
@ -72,6 +72,7 @@ public final class TestEmbeddedObjectRefSubRecord {
|
||||||
assertArrayEquals(ser, ser2);
|
assertArrayEquals(ser, ser2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testCameraTool_bug45912() {
|
public void testCameraTool_bug45912() {
|
||||||
/*
|
/*
|
||||||
|
@ -95,6 +96,7 @@ public final class TestEmbeddedObjectRefSubRecord {
|
||||||
/**
|
/**
|
||||||
* tests various examples of OLE controls
|
* tests various examples of OLE controls
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testVarious() {
|
public void testVarious() {
|
||||||
String[] rawData = {
|
String[] rawData = {
|
||||||
|
@ -125,9 +127,10 @@ public final class TestEmbeddedObjectRefSubRecord {
|
||||||
|
|
||||||
EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in, data.length);
|
EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in, data.length);
|
||||||
byte[] ser2 = rec.serialize();
|
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
|
@Test
|
||||||
public void testVisioDrawing_bug46199() {
|
public void testVisioDrawing_bug46199() {
|
||||||
/*
|
/*
|
||||||
|
@ -146,6 +149,6 @@ public final class TestEmbeddedObjectRefSubRecord {
|
||||||
// bug 22860 - Not enough data (3) to read requested (4) bytes
|
// bug 22860 - Not enough data (3) to read requested (4) bytes
|
||||||
EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in, data46199.length);
|
EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in, data46199.length);
|
||||||
byte[] ser2 = rec.serialize();
|
byte[] ser2 = rec.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(EORSR_SID, data46199, ser2);
|
confirmRecordEncoding(EORSR_SID, data46199, ser2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public final class TestExtendedFormatRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
// .fontindex = 0
|
// .fontindex = 0
|
||||||
|
@ -122,6 +123,7 @@ public final class TestExtendedFormatRecord {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testCloneOnto() {
|
public void testCloneOnto() {
|
||||||
ExtendedFormatRecord base = createEFR();
|
ExtendedFormatRecord base = createEFR();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
@ -57,7 +58,7 @@ public final class TestExternalNameRecord {
|
||||||
assertEquals("FDS", enr.getText());
|
assertEquals("FDS", enr.getText());
|
||||||
|
|
||||||
// bug 44695
|
// bug 44695
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataFDS, enr.serialize());
|
confirmRecordEncoding(0x0023, dataFDS, enr.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -81,7 +82,7 @@ public final class TestExternalNameRecord {
|
||||||
assertFalse(enr.isPicureLink());
|
assertFalse(enr.isPicureLink());
|
||||||
assertTrue(enr.isStdDocumentNameIdentifier());
|
assertTrue(enr.isStdDocumentNameIdentifier());
|
||||||
|
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataAutoDocName, enr.serialize());
|
confirmRecordEncoding(0x0023, dataAutoDocName, enr.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -96,7 +97,7 @@ public final class TestExternalNameRecord {
|
||||||
assertFalse(enr.isPicureLink());
|
assertFalse(enr.isPicureLink());
|
||||||
assertFalse(enr.isStdDocumentNameIdentifier());
|
assertFalse(enr.isStdDocumentNameIdentifier());
|
||||||
|
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataPlainName, enr.serialize());
|
confirmRecordEncoding(0x0023, dataPlainName, enr.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -121,7 +122,7 @@ public final class TestExternalNameRecord {
|
||||||
ExternalNameRecord enr = createSimpleENR(dataDDE);
|
ExternalNameRecord enr = createSimpleENR(dataDDE);
|
||||||
assertEquals("010672AT0 MUNI,[RTG_MOODY_UNDERLYING,RTG_SP_UNDERLYING]", enr.getText());
|
assertEquals("010672AT0 MUNI,[RTG_MOODY_UNDERLYING,RTG_SP_UNDERLYING]", enr.getText());
|
||||||
|
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(0x0023, dataDDE, enr.serialize());
|
confirmRecordEncoding(0x0023, dataDDE, enr.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.poi.hssf.record;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
@ -67,6 +68,7 @@ public final class TestFontRecord {
|
||||||
assertEquals(21 + 4, record.getRecordSize());
|
assertEquals(21 + 4, record.getRecordSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
// .fontheight = c8
|
// .fontheight = c8
|
||||||
|
@ -96,7 +98,7 @@ public final class TestFontRecord {
|
||||||
record.setFontName("Arial");
|
record.setFontName("Arial");
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(0x31, data, recordBytes);
|
confirmRecordEncoding(0x31, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -150,6 +152,6 @@ public final class TestFontRecord {
|
||||||
|
|
||||||
assertEquals(0, fr.getFontName().length());
|
assertEquals(0, fr.getFontName().length());
|
||||||
byte[] recordBytes = fr.serialize();
|
byte[] recordBytes = fr.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(SID, emptyNameData, recordBytes);
|
confirmRecordEncoding(SID, emptyNameData, recordBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.hssf.record;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
@ -453,12 +454,13 @@ public final class TestHyperlinkRecord {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testReserializeTargetFrame() {
|
public void testReserializeTargetFrame() {
|
||||||
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataTargetFrame);
|
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataTargetFrame);
|
||||||
HyperlinkRecord hr = new HyperlinkRecord(in);
|
HyperlinkRecord hr = new HyperlinkRecord(in);
|
||||||
byte[] ser = hr.serialize();
|
byte[] ser = hr.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(HyperlinkRecord.sid, dataTargetFrame, ser);
|
confirmRecordEncoding(HyperlinkRecord.sid, dataTargetFrame, ser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -467,7 +469,7 @@ public final class TestHyperlinkRecord {
|
||||||
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataLinkToWorkbook);
|
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataLinkToWorkbook);
|
||||||
HyperlinkRecord hr = new HyperlinkRecord(in);
|
HyperlinkRecord hr = new HyperlinkRecord(in);
|
||||||
byte[] ser = hr.serialize();
|
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());
|
assertNotEquals("Identified bug in reading workbook link", "YEARFR~1.XLS", hr.getAddress());
|
||||||
assertEquals("yearfracExamples.xls", hr.getAddress());
|
assertEquals("yearfracExamples.xls", hr.getAddress());
|
||||||
}
|
}
|
||||||
|
@ -478,7 +480,7 @@ public final class TestHyperlinkRecord {
|
||||||
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataUNC);
|
RecordInputStream in = TestcaseRecordInputStream.create(HyperlinkRecord.sid, dataUNC);
|
||||||
HyperlinkRecord hr = new HyperlinkRecord(in);
|
HyperlinkRecord hr = new HyperlinkRecord(in);
|
||||||
byte[] ser = hr.serialize();
|
byte[] ser = hr.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(HyperlinkRecord.sid, dataUNC, ser);
|
confirmRecordEncoding(HyperlinkRecord.sid, dataUNC, ser);
|
||||||
assertNotNull(hr.toString());
|
assertNotNull(hr.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,6 +543,6 @@ public final class TestHyperlinkRecord {
|
||||||
assertEquals("testfolder/test.PDF", link.getAddress());
|
assertEquals("testfolder/test.PDF", link.getAddress());
|
||||||
|
|
||||||
byte[] ser = link.serialize();
|
byte[] ser = link.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(HyperlinkRecord.sid, data_47498, ser);
|
confirmRecordEncoding(HyperlinkRecord.sid, data_47498, ser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.poi.hssf.record;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -71,7 +72,7 @@ public final class TestLbsDataSubRecord {
|
||||||
|
|
||||||
// check that it re-serializes to the same data
|
// check that it re-serializes to the same data
|
||||||
byte[] ser = record.serialize();
|
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
|
// check that it re-serializes to the same data
|
||||||
byte[] ser = record.serialize();
|
byte[] ser = record.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(ObjRecord.sid, data, ser);
|
confirmRecordEncoding(ObjRecord.sid, data, ser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.assertEquals;
|
||||||
|
|
||||||
import org.apache.poi.util.HexRead;
|
import org.apache.poi.util.HexRead;
|
||||||
|
@ -37,6 +38,6 @@ public final class TestNameCommentRecord {
|
||||||
assertEquals("name", ncr.getNameText());
|
assertEquals("name", ncr.getNameText());
|
||||||
assertEquals("comment", ncr.getCommentText());
|
assertEquals("comment", ncr.getCommentText());
|
||||||
final byte[] data2 = ncr.serialize();
|
final byte[] data2 = ncr.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(NameCommentRecord.sid, data, data2);
|
confirmRecordEncoding(NameCommentRecord.sid, data, data2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
@ -68,7 +69,7 @@ public final class TestNameRecord {
|
||||||
NameRecord nr = new NameRecord(in);
|
NameRecord nr = new NameRecord(in);
|
||||||
assertEquals(0x0020, nr.getOptionFlag());
|
assertEquals(0x0020, nr.getOptionFlag());
|
||||||
byte[] data2 = nr.serialize();
|
byte[] data2 = nr.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(NameRecord.sid, data, data2);
|
confirmRecordEncoding(NameRecord.sid, data, data2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -64,7 +65,7 @@ public final class TestNoteRecord {
|
||||||
record.setAuthor("Apache Software Foundation");
|
record.setAuthor("Apache Software Foundation");
|
||||||
|
|
||||||
byte[] ser = record.serialize();
|
byte[] ser = record.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(NoteRecord.sid, testData, ser);
|
confirmRecordEncoding(NoteRecord.sid, testData, ser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -107,7 +108,7 @@ public final class TestNoteRecord {
|
||||||
assertTrue(nr.authorIsMultibyte());
|
assertTrue(nr.authorIsMultibyte());
|
||||||
|
|
||||||
byte[] ser = nr.serialize();
|
byte[] ser = nr.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(NoteRecord.sid, data, ser);
|
confirmRecordEncoding(NoteRecord.sid, data, ser);
|
||||||
|
|
||||||
// Re-check
|
// Re-check
|
||||||
in = TestcaseRecordInputStream.create(ser);
|
in = TestcaseRecordInputStream.create(ser);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -129,6 +130,7 @@ public final class TestObjRecord {
|
||||||
* Check that ObjRecord tolerates and preserves padding to a 4-byte boundary
|
* Check that ObjRecord tolerates and preserves padding to a 4-byte boundary
|
||||||
* (normally padding is to a 2-byte boundary).
|
* (normally padding is to a 2-byte boundary).
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void test4BytePadding() {
|
public void test4BytePadding() {
|
||||||
// actual data from file saved by Excel 2007
|
// actual data from file saved by Excel 2007
|
||||||
|
@ -142,6 +144,6 @@ public final class TestObjRecord {
|
||||||
ObjRecord record = new ObjRecord(in);
|
ObjRecord record = new ObjRecord(in);
|
||||||
// check that it re-serializes to the same data
|
// check that it re-serializes to the same data
|
||||||
byte[] ser = record.serialize();
|
byte[] ser = record.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(ObjRecord.sid, data, ser);
|
confirmRecordEncoding(ObjRecord.sid, data, ser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public final class TestPaneRecord {
|
||||||
assertEquals( 14, record.getRecordSize() );
|
assertEquals( 14, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
PaneRecord record = new PaneRecord();
|
PaneRecord record = new PaneRecord();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ public final class TestRecalcIdRecord {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testBasicDeserializeReserialize() {
|
public void testBasicDeserializeReserialize() {
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@ public final class TestRecalcIdRecord {
|
||||||
"1D EB 01 00"); // engine id
|
"1D EB 01 00"); // engine id
|
||||||
|
|
||||||
RecalcIdRecord r = create(data);
|
RecalcIdRecord r = create(data);
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(RecalcIdRecord.sid, data, r.serialize());
|
confirmRecordEncoding(RecalcIdRecord.sid, data, r.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -42,6 +42,7 @@ public final class TestSCLRecord {
|
||||||
assertEquals( 8, record.getRecordSize() );
|
assertEquals( 8, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SCLRecord record = new SCLRecord();
|
SCLRecord record = new SCLRecord();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.assertEquals;
|
||||||
|
|
||||||
import org.apache.poi.util.HexRead;
|
import org.apache.poi.util.HexRead;
|
||||||
|
@ -35,6 +36,6 @@ public final class TestStyleRecord {
|
||||||
assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
|
assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
|
||||||
// bug 46385 - Incorrect number of bytes written - expected 27 but got 18
|
// bug 46385 - Incorrect number of bytes written - expected 27 but got 18
|
||||||
byte[] ser = sr.serialize();
|
byte[] ser = sr.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(StyleRecord.sid, data, ser);
|
confirmRecordEncoding(StyleRecord.sid, data, ser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.apache.poi.hssf.record;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
@ -141,6 +142,6 @@ public final class TestSubRecord {
|
||||||
ObjRecord or = new ObjRecord(in);
|
ObjRecord or = new ObjRecord(in);
|
||||||
// make sure POI properly truncates the ObjRecord data
|
// make sure POI properly truncates the ObjRecord data
|
||||||
byte[] data2 = or.serialize();
|
byte[] data2 = or.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(ObjRecord.sid, data, data2);
|
confirmRecordEncoding(ObjRecord.sid, data, data2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_UP_DIR;
|
||||||
import static org.apache.poi.hssf.record.SupBookRecord.CH_VOLUME;
|
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.SupBookRecord.PATH_SEPERATOR;
|
||||||
|
import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
@ -99,20 +100,22 @@ public final class TestSupBookRecord {
|
||||||
/**
|
/**
|
||||||
* Tests that we can store the record
|
* Tests that we can store the record
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStoreIR() {
|
public void testStoreIR() {
|
||||||
SupBookRecord record = SupBookRecord.createInternalReferences((short)4);
|
SupBookRecord record = SupBookRecord.createInternalReferences((short)4);
|
||||||
|
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataIR, record.serialize());
|
confirmRecordEncoding(0x01AE, dataIR, record.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStoreER() {
|
public void testStoreER() {
|
||||||
String url = "testURL";
|
String url = "testURL";
|
||||||
String[] sheetNames = { "Sheet1", "Sheet2", };
|
String[] sheetNames = { "Sheet1", "Sheet2", };
|
||||||
SupBookRecord record = SupBookRecord.createExternalReferences(url, sheetNames);
|
SupBookRecord record = SupBookRecord.createExternalReferences(url, sheetNames);
|
||||||
|
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataER, record.serialize());
|
confirmRecordEncoding(0x01AE, dataER, record.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -120,7 +123,7 @@ public final class TestSupBookRecord {
|
||||||
SupBookRecord record = SupBookRecord.createAddInFunctions();
|
SupBookRecord record = SupBookRecord.createAddInFunctions();
|
||||||
assertEquals(1, record.getNumberOfSheets());
|
assertEquals(1, record.getNumberOfSheets());
|
||||||
assertTrue(record.isAddInFunctions());
|
assertTrue(record.isAddInFunctions());
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataAIF, record.serialize());
|
confirmRecordEncoding(0x01AE, dataAIF, record.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -63,6 +63,7 @@ public final class TestTableRecord {
|
||||||
assertEquals( 16 + 4, record.getRecordSize() );
|
assertEquals( 16 + 4, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore()
|
public void testStore()
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.assertEquals;
|
||||||
|
|
||||||
import org.apache.poi.util.HexRead;
|
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 "
|
+ "20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "
|
||||||
+ HEX_SIXTYFOUR_SPACES);
|
+ HEX_SIXTYFOUR_SPACES);
|
||||||
|
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
|
confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -90,6 +91,6 @@ public final class TestWriteAccessRecord {
|
||||||
+ "20 20 20 20 20 20 20 20 20 20 20 "
|
+ "20 20 20 20 20 20 20 20 20 20 20 "
|
||||||
+ HEX_SIXTYFOUR_SPACES);
|
+ HEX_SIXTYFOUR_SPACES);
|
||||||
|
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
|
confirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.serialize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public final class TestAreaFormatRecord {
|
||||||
assertEquals( 20, record.getRecordSize() );
|
assertEquals( 20, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
AreaFormatRecord record = new AreaFormatRecord();
|
AreaFormatRecord record = new AreaFormatRecord();
|
||||||
|
|
|
@ -48,6 +48,7 @@ public final class TestAreaRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
AreaRecord record = new AreaRecord();
|
AreaRecord record = new AreaRecord();
|
||||||
|
|
|
@ -42,6 +42,7 @@ public final class TestAxisLineFormatRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
AxisLineFormatRecord record = new AxisLineFormatRecord();
|
AxisLineFormatRecord record = new AxisLineFormatRecord();
|
||||||
|
|
|
@ -63,6 +63,7 @@ public final class TestAxisOptionsRecord {
|
||||||
assertEquals( 22, record.getRecordSize() );
|
assertEquals( 22, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
AxisOptionsRecord record = new AxisOptionsRecord();
|
AxisOptionsRecord record = new AxisOptionsRecord();
|
||||||
|
|
|
@ -50,6 +50,7 @@ public final class TestAxisParentRecord {
|
||||||
assertEquals( 22, record.getRecordSize() );
|
assertEquals( 22, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
AxisParentRecord record = new AxisParentRecord();
|
AxisParentRecord record = new AxisParentRecord();
|
||||||
|
|
|
@ -50,6 +50,7 @@ public final class TestAxisRecord {
|
||||||
assertEquals( 4 + 18, record.getRecordSize() );
|
assertEquals( 4 + 18, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
AxisRecord record = new AxisRecord();
|
AxisRecord record = new AxisRecord();
|
||||||
|
|
|
@ -42,6 +42,7 @@ public final class TestAxisUsedRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
AxisUsedRecord record = new AxisUsedRecord();
|
AxisUsedRecord record = new AxisUsedRecord();
|
||||||
|
|
|
@ -51,6 +51,7 @@ public final class TestBarRecord {
|
||||||
assertEquals( 10, record.getRecordSize() );
|
assertEquals( 10, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
BarRecord record = new BarRecord();
|
BarRecord record = new BarRecord();
|
||||||
|
|
|
@ -53,6 +53,7 @@ public final class TestCategorySeriesAxisRecord {
|
||||||
assertEquals( 4 + 8, record.getRecordSize() );
|
assertEquals( 4 + 8, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
CategorySeriesAxisRecord record = new CategorySeriesAxisRecord();
|
CategorySeriesAxisRecord record = new CategorySeriesAxisRecord();
|
||||||
|
|
|
@ -48,6 +48,7 @@ public final class TestChartRecord {
|
||||||
assertEquals( 20, record.getRecordSize() );
|
assertEquals( 20, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
ChartRecord record = new ChartRecord();
|
ChartRecord record = new ChartRecord();
|
||||||
|
@ -56,7 +57,6 @@ public final class TestChartRecord {
|
||||||
record.setWidth( 30474216 );
|
record.setWidth( 30474216 );
|
||||||
record.setHeight( 15060168 );
|
record.setHeight( 15060168 );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(ChartRecord.sid, data, recordBytes);
|
confirmRecordEncoding(ChartRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public final class TestDatRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
DatRecord record = new DatRecord();
|
DatRecord record = new DatRecord();
|
||||||
|
@ -56,7 +57,6 @@ public final class TestDatRecord {
|
||||||
record.setBorder( true );
|
record.setBorder( true );
|
||||||
record.setShowSeriesKey( true );
|
record.setShowSeriesKey( true );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(DatRecord.sid, data, recordBytes);
|
confirmRecordEncoding(DatRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public final class TestDataFormatRecord {
|
||||||
assertEquals( 12, record.getRecordSize() );
|
assertEquals( 12, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
DataFormatRecord record = new DataFormatRecord();
|
DataFormatRecord record = new DataFormatRecord();
|
||||||
|
|
|
@ -43,6 +43,7 @@ public final class TestDefaultDataLabelTextPropertiesRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
DefaultDataLabelTextPropertiesRecord record = new DefaultDataLabelTextPropertiesRecord();
|
DefaultDataLabelTextPropertiesRecord record = new DefaultDataLabelTextPropertiesRecord();
|
||||||
|
|
|
@ -50,6 +50,7 @@ public final class TestFontBasisRecord {
|
||||||
assertEquals( 14, record.getRecordSize() );
|
assertEquals( 14, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
FontBasisRecord record = new FontBasisRecord();
|
FontBasisRecord record = new FontBasisRecord();
|
||||||
|
|
|
@ -43,6 +43,7 @@ public final class TestFontIndexRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
FontIndexRecord record = new FontIndexRecord();
|
FontIndexRecord record = new FontIndexRecord();
|
||||||
|
|
|
@ -48,6 +48,7 @@ public final class TestFrameRecord {
|
||||||
assertEquals( 8, record.getRecordSize() );
|
assertEquals( 8, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
FrameRecord record = new FrameRecord();
|
FrameRecord record = new FrameRecord();
|
||||||
|
@ -56,7 +57,6 @@ public final class TestFrameRecord {
|
||||||
record.setAutoSize( false );
|
record.setAutoSize( false );
|
||||||
record.setAutoPosition( true );
|
record.setAutoPosition( true );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(FrameRecord.sid, data, recordBytes);
|
confirmRecordEncoding(FrameRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,22 +62,17 @@ public final class TestLegendRecord {
|
||||||
assertEquals(24, record.getRecordSize());
|
assertEquals(24, record.getRecordSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
LegendRecord record = new LegendRecord();
|
LegendRecord record = new LegendRecord();
|
||||||
|
|
||||||
record.setXAxisUpperLeft(0xe76);
|
record.setXAxisUpperLeft(0xe76);
|
||||||
|
|
||||||
record.setYAxisUpperLeft(0x786);
|
record.setYAxisUpperLeft(0x786);
|
||||||
|
|
||||||
record.setXSize(0x119);
|
record.setXSize(0x119);
|
||||||
|
|
||||||
record.setYSize(0x8b);
|
record.setYSize(0x8b);
|
||||||
|
|
||||||
record.setType((byte) 0x3);
|
record.setType((byte) 0x3);
|
||||||
|
|
||||||
record.setSpacing((byte) 0x1);
|
record.setSpacing((byte) 0x1);
|
||||||
|
|
||||||
record.setOptions((short) 0x1f);
|
record.setOptions((short) 0x1f);
|
||||||
record.setAutoPosition(true);
|
record.setAutoPosition(true);
|
||||||
record.setAutoSeries(true);
|
record.setAutoSeries(true);
|
||||||
|
|
|
@ -54,6 +54,7 @@ public final class TestLineFormatRecord {
|
||||||
assertEquals( 16, record.getRecordSize() );
|
assertEquals( 16, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
LineFormatRecord record = new LineFormatRecord();
|
LineFormatRecord record = new LineFormatRecord();
|
||||||
|
@ -64,7 +65,6 @@ public final class TestLineFormatRecord {
|
||||||
record.setDrawTicks( false );
|
record.setDrawTicks( false );
|
||||||
record.setColourPaletteIndex( (short)0x4d );
|
record.setColourPaletteIndex( (short)0x4d );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(LineFormatRecord.sid, data, recordBytes);
|
confirmRecordEncoding(LineFormatRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,7 @@ recordid = 0x1051, size =8
|
||||||
assertEquals( data.length + 4, record.getRecordSize() );
|
assertEquals( data.length + 4, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
LinkedDataRecord record = new LinkedDataRecord();
|
LinkedDataRecord record = new LinkedDataRecord();
|
||||||
|
|
|
@ -42,6 +42,7 @@ public final class TestNumberFormatIndexRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
NumberFormatIndexRecord record = new NumberFormatIndexRecord();
|
NumberFormatIndexRecord record = new NumberFormatIndexRecord();
|
||||||
|
|
|
@ -45,6 +45,7 @@ public final class TestObjectLinkRecord {
|
||||||
assertEquals( 10, record.getRecordSize() );
|
assertEquals( 10, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
ObjectLinkRecord record = new ObjectLinkRecord();
|
ObjectLinkRecord record = new ObjectLinkRecord();
|
||||||
|
@ -53,7 +54,6 @@ public final class TestObjectLinkRecord {
|
||||||
record.setLink1( (short)0x00 );
|
record.setLink1( (short)0x00 );
|
||||||
record.setLink2( (short)0x00 );
|
record.setLink2( (short)0x00 );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(ObjectLinkRecord.sid, data, recordBytes);
|
confirmRecordEncoding(ObjectLinkRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,13 +45,13 @@ public final class TestPlotGrowthRecord {
|
||||||
assertEquals( 12, record.getRecordSize() );
|
assertEquals( 12, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
PlotGrowthRecord record = new PlotGrowthRecord();
|
PlotGrowthRecord record = new PlotGrowthRecord();
|
||||||
record.setHorizontalScale( 65536 );
|
record.setHorizontalScale( 65536 );
|
||||||
record.setVerticalScale( 65536 );
|
record.setVerticalScale( 65536 );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(PlotGrowthRecord.sid, data, recordBytes);
|
confirmRecordEncoding(PlotGrowthRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,12 +42,12 @@ public final class TestSeriesChartGroupIndexRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SeriesChartGroupIndexRecord record = new SeriesChartGroupIndexRecord();
|
SeriesChartGroupIndexRecord record = new SeriesChartGroupIndexRecord();
|
||||||
record.setChartGroupIndex( (short)0 );
|
record.setChartGroupIndex( (short)0 );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(SeriesChartGroupIndexRecord.sid, data, recordBytes);
|
confirmRecordEncoding(SeriesChartGroupIndexRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,12 +42,12 @@ public final class TestSeriesIndexRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SeriesIndexRecord record = new SeriesIndexRecord();
|
SeriesIndexRecord record = new SeriesIndexRecord();
|
||||||
record.setIndex( (short)3 );
|
record.setIndex( (short)3 );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(SeriesIndexRecord.sid, data, recordBytes);
|
confirmRecordEncoding(SeriesIndexRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public final class TestSeriesLabelsRecord {
|
||||||
assertEquals( 2+4, record.getRecordSize() );
|
assertEquals( 2+4, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SeriesLabelsRecord record = new SeriesLabelsRecord();
|
SeriesLabelsRecord record = new SeriesLabelsRecord();
|
||||||
|
@ -60,7 +61,6 @@ public final class TestSeriesLabelsRecord {
|
||||||
record.setShowLabel( false );
|
record.setShowLabel( false );
|
||||||
record.setShowBubbleSizes( false );
|
record.setShowBubbleSizes( false );
|
||||||
|
|
||||||
|
|
||||||
byte [] recordBytes = record.serialize();
|
byte [] recordBytes = record.serialize();
|
||||||
confirmRecordEncoding(SeriesLabelsRecord.sid, data, recordBytes);
|
confirmRecordEncoding(SeriesLabelsRecord.sid, data, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ public final class TestSeriesListRecord {
|
||||||
assertEquals( 4 + 6, record.getRecordSize() );
|
assertEquals( 4 + 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SeriesListRecord record = new SeriesListRecord(new short[] { (short)0x2001, (short)0xf0ff } );
|
SeriesListRecord record = new SeriesListRecord(new short[] { (short)0x2001, (short)0xf0ff } );
|
||||||
|
|
|
@ -53,6 +53,7 @@ public final class TestSeriesRecord {
|
||||||
assertEquals( 16, record.getRecordSize() );
|
assertEquals( 16, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SeriesRecord record = new SeriesRecord();
|
SeriesRecord record = new SeriesRecord();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.record.chart;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ public final class TestSeriesTextRecord {
|
||||||
assertEquals(SIMPLE_DATA.length + 4, record.getRecordSize());
|
assertEquals(SIMPLE_DATA.length + 4, record.getRecordSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SeriesTextRecord record = new SeriesTextRecord();
|
SeriesTextRecord record = new SeriesTextRecord();
|
||||||
|
@ -51,7 +53,7 @@ public final class TestSeriesTextRecord {
|
||||||
record.setText("Value Number");
|
record.setText("Value Number");
|
||||||
|
|
||||||
byte[] recordBytes = record.serialize();
|
byte[] recordBytes = record.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(SeriesTextRecord.sid, SIMPLE_DATA, recordBytes);
|
confirmRecordEncoding(SeriesTextRecord.sid, SIMPLE_DATA, recordBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -88,6 +90,6 @@ public final class TestSeriesTextRecord {
|
||||||
|
|
||||||
assertTrue("Identified bug 45784b", str.getRecordSize() >= 0);
|
assertTrue("Identified bug 45784b", str.getRecordSize() >= 0);
|
||||||
byte[] ser = str.serialize();
|
byte[] ser = str.serialize();
|
||||||
TestcaseRecordInputStream.confirmRecordEncoding(SeriesTextRecord.sid, data, ser);
|
confirmRecordEncoding(SeriesTextRecord.sid, data, ser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public final class TestSeriesToChartGroupRecord {
|
||||||
assertEquals( 0x6, record.getRecordSize() );
|
assertEquals( 0x6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SeriesToChartGroupRecord record = new SeriesToChartGroupRecord();
|
SeriesToChartGroupRecord record = new SeriesToChartGroupRecord();
|
||||||
|
|
|
@ -56,6 +56,7 @@ public final class TestSheetPropertiesRecord {
|
||||||
assertEquals( 8, record.getRecordSize() );
|
assertEquals( 8, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
SheetPropertiesRecord record = new SheetPropertiesRecord();
|
SheetPropertiesRecord record = new SheetPropertiesRecord();
|
||||||
|
|
|
@ -81,6 +81,7 @@ public final class TestTextRecord {
|
||||||
assertEquals( 36, record.getRecordSize() );
|
assertEquals( 36, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
TextRecord record = new TextRecord();
|
TextRecord record = new TextRecord();
|
||||||
|
|
|
@ -63,6 +63,7 @@ public final class TestTickRecord {
|
||||||
assertEquals( 34, record.getRecordSize() );
|
assertEquals( 34, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
TickRecord record = new TickRecord();
|
TickRecord record = new TickRecord();
|
||||||
|
|
|
@ -43,6 +43,7 @@ public final class TestUnitsRecord {
|
||||||
assertEquals( 6, record.getRecordSize() );
|
assertEquals( 6, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
UnitsRecord record = new UnitsRecord();
|
UnitsRecord record = new UnitsRecord();
|
||||||
|
|
|
@ -64,6 +64,7 @@ public final class TestValueRangeRecord {
|
||||||
assertEquals( 42+4, record.getRecordSize() );
|
assertEquals( 42+4, record.getRecordSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testStore() {
|
public void testStore() {
|
||||||
ValueRangeRecord record = new ValueRangeRecord();
|
ValueRangeRecord record = new ValueRangeRecord();
|
||||||
|
|
|
@ -44,6 +44,7 @@ public final class TestExtendedPivotTableViewFieldsRecord {
|
||||||
assertEquals(data.length, rec.getRecordSize());
|
assertEquals(data.length, rec.getRecordSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("squid:S2699")
|
||||||
@Test
|
@Test
|
||||||
public void testOlderFormat_bug46918() {
|
public void testOlderFormat_bug46918() {
|
||||||
// There are 10 SXVDEX records in the file (not uploaded) that originated bugzilla 46918
|
// There are 10 SXVDEX records in the file (not uploaded) that originated bugzilla 46918
|
||||||
|
|
Loading…
Reference in New Issue