mirror of https://github.com/apache/poi.git
Add some more testing for bug 63151: NullPointerException in HSSFOptimiser.optimiseFonts(), also execute it as part of large regression tests in the future
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1854190 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
34d6410bc1
commit
8c6e95f597
|
@ -64,6 +64,8 @@ public class HSSFFileHandler extends SpreadsheetHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
HSSFOptimiser.optimiseFonts(wb);
|
||||
}
|
||||
|
||||
private static final Set<String> EXPECTED_ADDITIONAL_FAILURES = new HashSet<>();
|
||||
|
@ -85,6 +87,7 @@ public class HSSFFileHandler extends SpreadsheetHandler {
|
|||
public void handleAdditional(File file) throws Exception {
|
||||
// redirect stdout as the examples often write lots of text
|
||||
PrintStream oldOut = System.out;
|
||||
String fileWithParent = file.getParentFile().getName() + "/" + file.getName();
|
||||
try {
|
||||
System.setOut(new PrintStream(new OutputStream() {
|
||||
@Override
|
||||
|
@ -95,11 +98,11 @@ public class HSSFFileHandler extends SpreadsheetHandler {
|
|||
BiffViewer.main(new String[]{file.getAbsolutePath()});
|
||||
|
||||
assertFalse("Expected Extraction to fail for file " + file + " and handler " + this + ", but did not fail!",
|
||||
EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName()));
|
||||
EXPECTED_ADDITIONAL_FAILURES.contains(fileWithParent));
|
||||
} catch (OldExcelFormatException e) {
|
||||
// old excel formats are not supported here
|
||||
} catch (RuntimeException e) {
|
||||
if(!EXPECTED_ADDITIONAL_FAILURES.contains(file.getParentFile().getName() + "/" + file.getName())) {
|
||||
if(!EXPECTED_ADDITIONAL_FAILURES.contains(fileWithParent)) {
|
||||
throw e;
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -712,7 +712,7 @@ public class UnicodeString implements Comparable<UnicodeString> {
|
|||
if (field_4_format_runs != null) {
|
||||
for (int i = 0; i < field_4_format_runs.size();i++) {
|
||||
FormatRun r = field_4_format_runs.get(i);
|
||||
buffer.append(" .format_run"+i+" = ").append(r).append("\n");
|
||||
buffer.append(" .format_run").append(i).append(" = ").append(r).append("\n");
|
||||
}
|
||||
}
|
||||
if (field_5_ext_rst != null) {
|
||||
|
|
|
@ -59,9 +59,10 @@ public final class TestUnicodeString {
|
|||
private static void confirmSize(int expectedSize, UnicodeString s) {
|
||||
confirmSize(expectedSize, s, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note - a value of zero for <tt>amountUsedInCurrentRecord</tt> would only ever occur just
|
||||
* after a {@link ContinueRecord} had been started. In the initial {@link SSTRecord} this
|
||||
* after a {@link ContinueRecord} had been started. In the initial {@link SSTRecord} this
|
||||
* value starts at 8 (for the first {@link UnicodeString} written). In general, it can be
|
||||
* any value between 0 and {@link #MAX_DATA_SIZE}
|
||||
*/
|
||||
|
@ -181,7 +182,7 @@ public final class TestUnicodeString {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void formatRun() throws Exception {
|
||||
public void formatRun() {
|
||||
FormatRun fr = new FormatRun((short)4, (short)0x15c);
|
||||
assertEquals(4, fr.getCharacterPos());
|
||||
assertEquals(0x15c, fr.getFontIndex());
|
||||
|
@ -207,7 +208,7 @@ public final class TestUnicodeString {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void extRstFromEmpty() throws Exception {
|
||||
public void extRstFromEmpty() {
|
||||
ExtRst ext = new ExtRst();
|
||||
|
||||
assertEquals(0, ext.getNumberOfRuns());
|
||||
|
@ -231,14 +232,14 @@ public final class TestUnicodeString {
|
|||
assertEquals(-1, b[0]);
|
||||
assertEquals(-1, b[1]);
|
||||
assertEquals(14, b[2]);
|
||||
assertEquals(00, b[3]);
|
||||
assertEquals(0, b[3]);
|
||||
|
||||
// Reserved
|
||||
assertEquals(1, b[4]);
|
||||
assertEquals(0, b[5]);
|
||||
// Data size
|
||||
assertEquals(10, b[6]);
|
||||
assertEquals(00, b[7]);
|
||||
assertEquals(0, b[7]);
|
||||
// Font*2
|
||||
assertEquals(0, b[8]);
|
||||
assertEquals(0, b[9]);
|
||||
|
@ -274,13 +275,13 @@ public final class TestUnicodeString {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void extRstFromData() throws Exception {
|
||||
public void extRstFromData() {
|
||||
byte[] data = new byte[] {
|
||||
01, 00, 0x0C, 00,
|
||||
00, 00, 0x37, 00,
|
||||
00, 00,
|
||||
00, 00, 00, 00,
|
||||
00, 00 // Cruft at the end, as found from real files
|
||||
1, 0, 0x0C, 0,
|
||||
0, 0, 0x37, 0,
|
||||
0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0 // Cruft at the end, as found from real files
|
||||
};
|
||||
assertEquals(16, data.length);
|
||||
|
||||
|
@ -298,7 +299,7 @@ public final class TestUnicodeString {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void corruptExtRstDetection() throws Exception {
|
||||
public void corruptExtRstDetection() {
|
||||
byte[] data = new byte[] {
|
||||
0x79, 0x79, 0x11, 0x11,
|
||||
0x22, 0x22, 0x33, 0x33,
|
||||
|
@ -385,7 +386,7 @@ public final class TestUnicodeString {
|
|||
* @return a string of the specified number of characters
|
||||
*/
|
||||
private static UnicodeString makeUnicodeString(int numChars, boolean is16Bit) {
|
||||
StringBuilder b = new StringBuilder(numChars);
|
||||
StringBuilder b = new StringBuilder(numChars);
|
||||
int charBase = is16Bit ? 0x8A00 : 'A';
|
||||
for (int i = 0; i < numChars; i++) {
|
||||
char ch = (char) ((i % 16) + charBase);
|
||||
|
|
Loading…
Reference in New Issue