Skip to content

Commit

Permalink
Apply some IDE suggestions, add tests, set unit-test to isolated
Browse files Browse the repository at this point in the history
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
  • Loading branch information
centic9 committed Aug 24, 2023
1 parent cdb2ba1 commit 2999073
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ void test() throws Exception {
}

handleExtracting(file);

handleAdditional(file);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
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;
Expand All @@ -30,6 +31,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ void testParse() throws Exception {
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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1085,17 +1085,17 @@ private static class CountingOS extends OutputStream {
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;
}

Expand Down

0 comments on commit 2999073

Please sign in to comment.