Apply some IDE suggestions, add tests, set unit-test to isolated

Without Isolation, one test did change static settings 
and thus could cause flaky tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911891 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-08-24 08:53:01 +00:00
parent cdb2ba1398
commit 2999073715
4 changed files with 13 additions and 3 deletions

View File

@ -217,6 +217,8 @@ public class XSSFFileHandler extends SpreadsheetHandler {
}
handleExtracting(file);
handleAdditional(file);
}
@Test

View File

@ -22,6 +22,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Isolated;
import java.io.File;
import java.io.IOException;
@ -30,6 +31,7 @@ import java.io.InputStream;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@Isolated // changes static values, so other tests should not run at the same time
class TestOPCPackageFileLimit {
@Test
void testWithReducedFileLimit() throws InvalidFormatException {

View File

@ -67,6 +67,12 @@ public final class TestReadOnlySharedStringsTable {
assertEquals(i1.getString(), rtbl.getItemAt(i).getString());
assertEquals(i1.getString(), rtbl2.getItemAt(i).getString());
}
// verify invalid indices
assertThrows(IllegalStateException.class,
() -> rtbl.getItemAt(stbl.getUniqueCount()));
assertThrows(IndexOutOfBoundsException.class,
() -> rtbl.getItemAt(-1));
}
}
}

View File

@ -1085,17 +1085,17 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
int count;
@Override
public void write(int b) throws IOException {
public void write(int b) {
count++;
}
@Override
public void write(byte[] b) throws IOException {
public void write(byte[] b) {
count += b.length;
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
public void write(byte[] b, int off, int len) {
count += len;
}