aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/ooxml/testcases/org')
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java10
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java16
-rw-r--r--src/ooxml/testcases/org/apache/poi/ss/tests/TestWorkbookFactory.java10
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java13
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java13
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java23
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java31
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java18
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetMergeRegions.java9
11 files changed, 78 insertions, 81 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java
index 8e97627336..481ce98620 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestListParts.java
@@ -24,15 +24,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.TreeMap;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public final class TestListParts {
- private static final POILogger LOG = POILogFactory.getLogger(TestListParts.class);
+ private static final Logger LOG = LogManager.getLogger(TestListParts.class);
private TreeMap<PackagePartName, String> expectedValues;
@@ -91,7 +91,7 @@ public final class TestListParts {
for (PackagePart part : p.getParts()) {
values.put(part.getPartName(), part.getContentType());
- LOG.log(POILogger.DEBUG, part.getPartName());
+ LOG.atDebug().log(part.getPartName());
}
// Compare expected values with values return by the package
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
index 0d8b8360c8..9f297f66c6 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
@@ -58,6 +58,8 @@ import com.google.common.io.Files;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.POIDataSamples;
import org.apache.poi.POITestCase;
@@ -78,8 +80,6 @@ import org.apache.poi.sl.usermodel.SlideShowFactory;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
@@ -98,7 +98,7 @@ import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public final class TestPackage {
- private static final POILogger LOG = POILogFactory.getLogger(TestPackage.class);
+ private static final Logger LOG = LogManager.getLogger(TestPackage.class);
private static final String NS_OOXML_WP_MAIN = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
private static final String CONTENT_EXT_PROPS = "application/vnd.openxmlformats-officedocument.extended-properties+xml";
private static final POIDataSamples xlsSamples = POIDataSamples.getSpreadSheetInstance();
@@ -458,7 +458,7 @@ public final class TestPackage {
for (PackagePart part : p.getParts()) {
values.put(part.getPartName(), part.getContentType());
- LOG.log(POILogger.DEBUG, part.getPartName());
+ LOG.atDebug().log(part.getPartName());
}
// Compare expected values with values return by the package
@@ -492,7 +492,7 @@ public final class TestPackage {
for (PackagePart part : p.getParts()) {
values.put(part.getPartName(), part.getContentType());
- LOG.log(POILogger.DEBUG, part.getPartName());
+ LOG.atDebug().log(part.getPartName());
}
// Compare expected values with values return by the package
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java
index 38c13780b2..d80c88ae12 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java
@@ -30,9 +30,9 @@ import java.io.InputStream;
import java.net.URI;
import java.util.regex.Pattern;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.junit.jupiter.api.Test;
@@ -44,7 +44,7 @@ class TestRelationships {
private static final String SHEET_WITH_COMMENTS =
"/xl/worksheets/sheet1.xml";
- private static final POILogger LOG = POILogFactory.getLogger(TestPackageCoreProperties.class);
+ private static final Logger LOG = LogManager.getLogger(TestPackageCoreProperties.class);
/**
* Test relationships are correctly loaded. This at the moment fails (as of r499)
@@ -56,7 +56,7 @@ class TestRelationships {
void testLoadRelationships() throws Exception {
InputStream is = openSampleStream("sample.xlsx");
try (OPCPackage pkg = OPCPackage.open(is)) {
- LOG.log(POILogger.DEBUG, "1: " + pkg);
+ LOG.atDebug().log("1: {}", pkg);
PackageRelationshipCollection rels = pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
PackageRelationship coreDocRelationship = rels.getRelationship(0);
PackagePart corePart = pkg.getPart(coreDocRelationship);
diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
index f8b7de4453..798b559047 100644
--- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
+++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
@@ -78,6 +78,8 @@ import javax.xml.crypto.dsig.XMLSignatureException;
import javax.xml.crypto.dsig.dom.DOMSignContext;
import org.apache.jcp.xml.dsig.internal.dom.DOMSignedInfo;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.POIDataSamples;
import org.apache.poi.ooxml.POIXMLDocument;
@@ -101,8 +103,6 @@ import org.apache.poi.poifs.storage.RawDataUtil;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
@@ -162,7 +162,7 @@ import org.w3.x2000.x09.xmldsig.SignatureDocument;
import org.w3c.dom.Document;
class TestSignatureInfo {
- private static final POILogger LOG = POILogFactory.getLogger(TestSignatureInfo.class);
+ private static final Logger LOG = LogManager.getLogger(TestSignatureInfo.class);
private static final POIDataSamples testdata = POIDataSamples.getXmlDSignInstance();
private static Calendar cal;
@@ -357,7 +357,7 @@ class TestSignatureInfo {
assertNotNull(result);
assertEquals(1, result.size(), "test-file: " + testFile);
X509Certificate signer = result.get(0);
- LOG.log(POILogger.DEBUG, "signer: ", signer.getSubjectX500Principal());
+ LOG.atDebug().log("signer: {}", signer.getSubjectX500Principal());
boolean b = si.verifySignature();
assertTrue(b, "test-file: " + testFile);
@@ -385,8 +385,8 @@ class TestSignatureInfo {
assertEquals(2, result.size(), "test-file: " + testFile);
X509Certificate signer1 = result.get(0);
X509Certificate signer2 = result.get(1);
- LOG.log(POILogger.DEBUG, "signer 1: ", signer1.getSubjectX500Principal());
- LOG.log(POILogger.DEBUG, "signer 2: ", signer2.getSubjectX500Principal());
+ LOG.atDebug().log("signer 1: {}", signer1.getSubjectX500Principal());
+ LOG.atDebug().log("signer 2: {}", signer2.getSubjectX500Principal());
boolean b = si.verifySignature();
assertTrue(b, "test-file: " + testFile);
@@ -527,8 +527,8 @@ class TestSignatureInfo {
} else {
TimeStampServiceValidator tspValidator = (validateChain, revocationData) -> {
for (X509Certificate certificate : validateChain) {
- LOG.log(POILogger.DEBUG, "certificate: ", certificate.getSubjectX500Principal());
- LOG.log(POILogger.DEBUG, "validity: ", certificate.getNotBefore(), " - ", certificate.getNotAfter());
+ LOG.atDebug().log("certificate: {}", certificate.getSubjectX500Principal());
+ LOG.atDebug().log("validity: {} - {}", certificate.getNotBefore(), certificate.getNotAfter());
}
};
signatureConfig.setTspValidator(tspValidator);
diff --git a/src/ooxml/testcases/org/apache/poi/ss/tests/TestWorkbookFactory.java b/src/ooxml/testcases/org/apache/poi/ss/tests/TestWorkbookFactory.java
index 2232d9a37b..200407e3ef 100644
--- a/src/ooxml/testcases/org/apache/poi/ss/tests/TestWorkbookFactory.java
+++ b/src/ooxml/testcases/org/apache/poi/ss/tests/TestWorkbookFactory.java
@@ -34,6 +34,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Stream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.EmptyFileException;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.POIDataSamples;
@@ -44,9 +46,6 @@ import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
-import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.SuppressForbidden;
import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -63,7 +62,7 @@ public final class TestWorkbookFactory {
private static final String[] xlsx_protected = new String[]{"protected_passtika.xlsx", "tika"};
private static final String txt = "SampleSS.txt";
- private static final POILogger LOGGER = POILogFactory.getLogger(TestWorkbookFactory.class);
+ private static final Logger LOGGER = LogManager.getLogger(TestWorkbookFactory.class);
/**
* Closes the sample workbook read in from filename.
@@ -95,8 +94,7 @@ public final class TestWorkbookFactory {
xwb.close();
} else {
// TODO: close() re-writes the sample-file?! Resort to revert() for now to close file handle...
- LOGGER.log(POILogger.WARN,
- "reverting XSSFWorkbook rather than closing it to avoid close() modifying the file on disk. Refer to bug 58779.");
+ LOGGER.atWarn().log("reverting XSSFWorkbook rather than closing it to avoid close() modifying the file on disk. Refer to bug 58779.");
xwb.getPackage().revert();
}
} else {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java
index 3d820ccb52..600ce5c31d 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java
@@ -17,6 +17,7 @@
package org.apache.poi.xssf.usermodel;
+import static org.apache.logging.log4j.util.Unbox.box;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
@@ -28,6 +29,8 @@ import java.util.List;
import java.util.Locale;
import java.util.stream.Stream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
@@ -40,8 +43,6 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -58,9 +59,9 @@ import org.junit.jupiter.params.provider.MethodSource;
*
*/
public final class TestFormulaEvaluatorOnXSSF {
- private static final POILogger LOG = POILogFactory.getLogger(TestFormulaEvaluatorOnXSSF.class);
+ private static final Logger LOG = LogManager.getLogger(TestFormulaEvaluatorOnXSSF.class);
- private static XSSFWorkbook workbook;
+ private static XSSFWorkbook workbook;
private static Sheet sheet;
private static FormulaEvaluator evaluator;
private static Locale userLocale;
@@ -244,12 +245,12 @@ public final class TestFormulaEvaluatorOnXSSF {
*/
private static String getTargetFunctionName(Row r) {
if(r == null) {
- LOG.log(POILogger.WARN, "Warning - given null row, can't figure out function name");
+ LOG.atWarn().log("Given null row, can't figure out function name");
return null;
}
Cell cell = r.getCell(SS.COLUMN_INDEX_FUNCTION_NAME);
if(cell == null) {
- LOG.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
+ LOG.atWarn().log("Row {} has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name", box(r.getRowNum()));
return null;
}
if(cell.getCellType() == CellType.BLANK) {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java
index d29fc2744e..b7f32acd67 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java
@@ -17,6 +17,7 @@
package org.apache.poi.xssf.usermodel;
+import static org.apache.logging.log4j.util.Unbox.box;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -27,6 +28,8 @@ import java.util.List;
import java.util.Locale;
import java.util.stream.Stream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.functions.BaseTestNumeric;
import org.apache.poi.ss.usermodel.Cell;
@@ -36,8 +39,6 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.params.ParameterizedTest;
@@ -46,7 +47,7 @@ import org.junit.jupiter.params.provider.MethodSource;
public final class TestMatrixFormulasFromXMLSpreadsheet {
- private static final POILogger LOG = POILogFactory.getLogger(TestMatrixFormulasFromXMLSpreadsheet.class);
+ private static final Logger LOG = LogManager.getLogger(TestMatrixFormulasFromXMLSpreadsheet.class);
private static XSSFWorkbook workbook;
private static Sheet sheet;
@@ -208,13 +209,13 @@ public final class TestMatrixFormulasFromXMLSpreadsheet {
*/
private static String getTargetFunctionName(Row r) {
if(r == null) {
- LOG.log(POILogger.WARN, "Warning - given null row, can't figure out function name");
+ LOG.atWarn().log("Given null row, can't figure out function name");
return null;
}
Cell cell = r.getCell(Navigator.START_OPERATORS_COL_INDEX);
- LOG.log(POILogger.DEBUG, String.valueOf(Navigator.START_OPERATORS_COL_INDEX));
+ LOG.atDebug().log( box(Navigator.START_OPERATORS_COL_INDEX));
if(cell == null) {
- LOG.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", can't figure out function name");
+ LOG.atWarn().log("Row {} has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", can't figure out function name", box(r.getRowNum()));
return null;
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java
index 91045bfbb7..4c458ea42b 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java
@@ -17,6 +17,9 @@
package org.apache.poi.xssf.usermodel;
+import static org.apache.logging.log4j.util.Unbox.box;
+import static org.apache.poi.xssf.usermodel.TestMultiSheetFormulaEvaluatorOnXSSF.SS.COLUMN_INDEX_FUNCTION_NAME;
+import static org.apache.poi.xssf.usermodel.TestMultiSheetFormulaEvaluatorOnXSSF.SS.COLUMN_INDEX_TEST_NAME;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -28,6 +31,8 @@ import java.util.List;
import java.util.Locale;
import java.util.stream.Stream;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
@@ -38,8 +43,6 @@ import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -49,9 +52,9 @@ import org.junit.jupiter.params.provider.MethodSource;
* Tests formulas for multi sheet reference (i.e. SUM(Sheet1:Sheet5!A1))
*/
public final class TestMultiSheetFormulaEvaluatorOnXSSF {
- private static final POILogger LOG = POILogFactory.getLogger(TestMultiSheetFormulaEvaluatorOnXSSF.class);
+ private static final Logger LOG = LogManager.getLogger(TestMultiSheetFormulaEvaluatorOnXSSF.class);
- private static XSSFWorkbook workbook;
+ private static XSSFWorkbook workbook;
private static Sheet sheet;
private static FormulaEvaluator evaluator;
@@ -211,12 +214,12 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF {
*/
private static String getTargetFunctionName(Row r) {
if(r == null) {
- LOG.log(POILogger.WARN, "Warning - given null row, can't figure out function name");
+ LOG.atWarn().log("Given null row, can't figure out function name");
return null;
}
- Cell cell = r.getCell(SS.COLUMN_INDEX_FUNCTION_NAME);
+ Cell cell = r.getCell(COLUMN_INDEX_FUNCTION_NAME);
if(cell == null) {
- LOG.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
+ LOG.atWarn().log("Row {} has no cell " + COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name", box(r.getRowNum()));
return null;
}
@@ -232,12 +235,12 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF {
*/
private static String getTargetTestName(Row r) {
if(r == null) {
- LOG.log(POILogger.WARN, "Warning - given null row, can't figure out test name");
+ LOG.atWarn().log("Given null row, can't figure out test name");
return null;
}
- Cell cell = r.getCell(SS.COLUMN_INDEX_TEST_NAME);
+ Cell cell = r.getCell(COLUMN_INDEX_TEST_NAME);
if(cell == null) {
- LOG.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name");
+ LOG.atWarn().log("Row {} has no cell " + COLUMN_INDEX_TEST_NAME + ", can't figure out test name", box(r.getRowNum()));
return null;
}
CellType ct = cell.getCellType();
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
index 650754e4c8..562fa9f246 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
@@ -17,6 +17,9 @@
package org.apache.poi.xssf.usermodel;
+import static java.time.Duration.between;
+import static java.time.Instant.now;
+import static org.apache.logging.log4j.util.Unbox.box;
import static org.apache.poi.extractor.ExtractorFactory.OOXML_PACKAGE;
import static org.apache.poi.openxml4j.opc.TestContentType.isOldXercesActive;
import static org.junit.jupiter.api.Assertions.*;
@@ -31,7 +34,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
-import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.Calendar;
@@ -45,6 +47,8 @@ import java.util.TreeMap;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.POIDataSamples;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.hssf.HSSFITestDataProvider;
@@ -96,8 +100,6 @@ import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.CellUtil;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.NullOutputStream;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.TempFile;
import org.apache.poi.util.XMLHelper;
import org.apache.poi.xssf.SXSSFITestDataProvider;
@@ -117,7 +119,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedName;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedNames;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIgnoredErrors;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTMergeCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTMergeCells;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
@@ -127,7 +128,7 @@ import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
public final class TestXSSFBugs extends BaseTestBugzillaIssues {
- private static final POILogger LOG = POILogFactory.getLogger(TestXSSFBugs.class);
+ private static final Logger LOG = LogManager.getLogger(TestXSSFBugs.class);
public TestXSSFBugs() {
super(XSSFITestDataProvider.instance);
@@ -2033,7 +2034,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
"DEC2BIN(A1), org.apache.poi.ss.formula.eval.StringEval [0]"
})
void test57196_WorkbookEvaluator(String formula, String expValue) throws IOException {
- String previousLogger = System.getProperty("org.apache.poi.util.POILogger");
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet("Sheet1");
XSSFRow row = sheet.createRow(0);
@@ -2051,13 +2051,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
ValueEval ve = workbookEvaluator.evaluate(new XSSFEvaluationCell(cell));
assertEquals(expValue, ve.toString());
- } finally {
- if (previousLogger == null) {
- System.clearProperty("org.apache.poi.util.POILogger");
- } else {
- System.setProperty("org.apache.poi.util.POILogger", previousLogger);
- }
- System.clearProperty("poi.log.level");
}
}
@@ -3429,24 +3422,24 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
void test58896WithFile() throws IOException {
try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("58896.xlsx")) {
Sheet sheet = wb.getSheetAt(0);
- Instant start = Instant.now();
+ Instant start = now();
- LOG.log(POILogger.INFO, "Autosizing columns...");
+ LOG.atInfo().log("Autosizing columns...");
for (int i = 0; i < 3; ++i) {
- LOG.log(POILogger.INFO, "Autosize ", i, " - ", Duration.between(start, Instant.now()));
+ LOG.atInfo().log("Autosize {} - {}", box(i), between(start, now()));
sheet.autoSizeColumn(i);
}
for (int i = 0; i < 69 - 35 + 1; ++i)
for (int j = 0; j < 8; ++j) {
int col = 3 + 2 + i * (8 + 2) + j;
- LOG.log(POILogger.INFO, "Autosize ", col, " - ", Duration.between(start, Instant.now()));
+ LOG.atInfo().log("Autosize {} - {}", box(col), between(start, now()));
sheet.autoSizeColumn(col);
}
- LOG.log(POILogger.INFO, Duration.between(start, Instant.now()));
+ LOG.atInfo().log(between(start, now()));
- assertTrue(Duration.between(start, Instant.now()).getSeconds() < 25);
+ assertTrue(between(start, now()).getSeconds() < 25);
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java
index a86d72282b..227dc3627b 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java
@@ -23,8 +23,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.jupiter.api.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
@@ -43,7 +43,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
*/
class TestXSSFColGrouping {
- private static final POILogger LOG = POILogFactory.getLogger(TestXSSFColGrouping.class);
+ private static final Logger LOG = LogManager.getLogger(TestXSSFColGrouping.class);
/**
@@ -65,7 +65,7 @@ class TestXSSFColGrouping {
sheet = wb2.getSheet("test");
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
- LOG.log(POILogger.DEBUG, "test52186/cols:" + cols);
+ LOG.atDebug().log("test52186/cols:{}", cols);
for (CTCol col : cols.getColArray()) {
assertTrue(col.isSetWidth(), "Col width attribute is unset: " + col);
}
@@ -91,7 +91,7 @@ class TestXSSFColGrouping {
sheet.setColumnGroupCollapsed(4, true);
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
- LOG.log(POILogger.DEBUG, "test52186_2/cols:" + cols);
+ LOG.atDebug().log("test52186_2/cols:{}", cols);
try (XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1, "testNoColsWithoutWidthWhenGroupingAndCollapsing")) {
sheet = wb2.getSheet("test");
@@ -125,7 +125,7 @@ class TestXSSFColGrouping {
sheet.groupColumn((short) 2, (short) 3);
sheet.getCTWorksheet().getColsArray(0);
- LOG.log(POILogger.DEBUG, "testMergingOverlappingCols_OVERLAPS_2_WRAPS/cols:" + cols);
+ LOG.atDebug().log("testMergingOverlappingCols_OVERLAPS_2_WRAPS/cols:{}", cols);
assertEquals(0, cols.getColArray(0).getOutlineLevel());
assertEquals(2, cols.getColArray(0).getMin()); // 1 based
@@ -173,7 +173,7 @@ class TestXSSFColGrouping {
sheet.groupColumn((short) 1, (short) 5);
cols = sheet.getCTWorksheet().getColsArray(0);
- LOG.log(POILogger.DEBUG, "testMergingOverlappingCols_OVERLAPS_1_WRAPS/cols:" + cols);
+ LOG.atDebug().log("testMergingOverlappingCols_OVERLAPS_1_WRAPS/cols:{}", cols);
assertEquals(1, cols.getColArray(0).getOutlineLevel());
assertEquals(2, cols.getColArray(0).getMin()); // 1 based
@@ -221,7 +221,7 @@ class TestXSSFColGrouping {
sheet.groupColumn((short) 3, (short) 5);
cols = sheet.getCTWorksheet().getColsArray(0);
- LOG.log(POILogger.DEBUG, "testMergingOverlappingCols_OVERLAPS_1_MINOR/cols:" + cols);
+ LOG.atDebug().log("testMergingOverlappingCols_OVERLAPS_1_MINOR/cols:{}", cols);
assertEquals(0, cols.getColArray(0).getOutlineLevel());
assertEquals(3, cols.getColArray(0).getMin()); // 1 based
@@ -270,7 +270,7 @@ class TestXSSFColGrouping {
sheet.groupColumn((short) 1, (short) 3);
cols = sheet.getCTWorksheet().getColsArray(0);
- LOG.log(POILogger.DEBUG, "testMergingOverlappingCols_OVERLAPS_2_MINOR/cols:" + cols);
+ LOG.atDebug().log("testMergingOverlappingCols_OVERLAPS_2_MINOR/cols:{}", cols);
assertEquals(1, cols.getColArray(0).getOutlineLevel());
assertEquals(2, cols.getColArray(0).getMin()); // 1 based
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetMergeRegions.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetMergeRegions.java
index 983f36cd8c..1cce6eb861 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetMergeRegions.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetMergeRegions.java
@@ -16,20 +16,21 @@
==================================================================== */
package org.apache.poi.xssf.usermodel;
+import static org.apache.logging.log4j.util.Unbox.box;
import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.jupiter.api.Test;
class TestXSSFSheetMergeRegions {
- private static final POILogger LOG = POILogFactory.getLogger(TestXSSFSheetMergeRegions.class);
+ private static final Logger LOG = LogManager.getLogger(TestXSSFSheetMergeRegions.class);
@Test
void testMergeRegionsSpeed() throws IOException {
@@ -43,7 +44,7 @@ class TestXSSFSheetMergeRegions {
if (millis < 2000) {
break;
}
- LOG.log(POILogger.INFO, "Retry ", i, " because run-time is too high: ", millis);
+ LOG.atInfo().log("Retry {} because run-time is too high: {}", box(i),box(millis));
}
boolean inGump = false;