60805 (partial) -- remove/suppress println in tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808903 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tim Allison 2017-09-19 15:52:21 +00:00
parent d1765d7e76
commit a59402a37f
22 changed files with 145 additions and 47 deletions

View File

@ -22,6 +22,7 @@ package org.apache.poi.dev;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@ -29,9 +30,29 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.util.NullOutputStream;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class TestOOXMLLister {
private static PrintStream SYSTEM_OUT;
@BeforeClass
public static void setUp() {
SYSTEM_OUT = System.out;
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(int b) throws IOException {
}
}));
}
@AfterClass
public static void tearDown() {
System.setOut(SYSTEM_OUT);
}
@Test
public void testMain() throws IOException, InvalidFormatException {
File file = XSSFTestDataSamples.getSampleFile("Formatting.xlsx");

View File

@ -22,14 +22,38 @@ package org.apache.poi.dev;
import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class TestOOXMLPrettyPrint {
private static PrintStream SYSTEM_OUT;
@BeforeClass
public static void setUp() {
SYSTEM_OUT = System.out;
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(int b) throws IOException {
}
}));
}
@AfterClass
public static void tearDown() {
System.setOut(SYSTEM_OUT);
}
@Test
public void testMain() throws Exception {
File file = XSSFTestDataSamples.getSampleFile("Formatting.xlsx");

View File

@ -49,10 +49,13 @@ import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.poifs.filesystem.OPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.xdgf.extractor.XDGFVisioExtractor;
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
import org.apache.poi.xssf.usermodel.TestMatrixFormulasFromXMLSpreadsheet;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.junit.BeforeClass;
import org.junit.Test;
@ -61,6 +64,9 @@ import org.junit.Test;
* Test that the extractor factory plays nicely
*/
public class TestExtractorFactory {
private static final POILogger LOG = POILogFactory.getLogger(TestExtractorFactory.class);
private static File txt;
private static File xls;
@ -691,7 +697,7 @@ public class TestExtractorFactory {
} catch(UnsupportedFileFormatException e) {
// Good
} catch (Exception e) {
System.out.println("TestExtractorFactory.testPackage() failed on " + txt);
LOG.log(POILogger.WARN, "TestExtractorFactory.testPackage() failed on " + txt);
throw e;
}
}

View File

@ -129,8 +129,8 @@ public final class TestProper {
final ValueEval ret = TextFunction.PROPER.evaluate(new ValueEval[]{strArg}, 0, 0);
assertEquals("Some Longer Text That Needs A Number Of Replacements To Check For Runtime Of Different Implementations", ((StringEval)ret).getStringValue());
}
// Took aprox. 600ms on a decent Laptop in July 2016
System.out.println("Took: " + (System.currentTimeMillis() - start) + "ms");
// Took approx. 600ms on a decent Laptop in July 2016
//System.out.println("Took: " + (System.currentTimeMillis() - start) + "ms");
}
private void checkProper(String input, String expected) {

View File

@ -283,7 +283,6 @@ public class TestCommentsTable {
// Set the comment on a sheet
//
private static void setComment(Sheet sheet, Cell cell, Drawing<?> drawing, String commentText, CreationHelper helper, ClientAnchor anchor) {
System.out.println("Setting col: " + cell.getColumnIndex() + " and row " + cell.getRowIndex());
anchor.setCol1(cell.getColumnIndex());
anchor.setCol2(cell.getColumnIndex());
anchor.setRow1(cell.getRowIndex());

View File

@ -211,8 +211,6 @@ public class TestAutoSizeColumnTracker {
private static void assumeRequiredFontsAreInstalled(final Workbook workbook, final Cell cell) {
// autoSize will fail if required fonts are not installed, skip this test then
Font font = workbook.getFontAt(cell.getCellStyle().getFontIndex());
System.out.println(font.getFontHeightInPoints());
System.out.println(font.getFontName());
Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font,
SheetUtil.canComputeColumnWidth(font));
}

View File

@ -385,7 +385,6 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
File out = new File("Test.xlsx");
out.delete();
for (int i = 0; i < 2; i++) {
System.out.println("Iteration " + i);
final SXSSFWorkbook wb;
if (out.exists()) {
wb = new SXSSFWorkbook(

View File

@ -27,6 +27,7 @@ import java.util.List;
import java.util.Locale;
import org.apache.poi.poifs.crypt.TestSignatureInfo;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.functions.TestMathX;
import org.apache.poi.ss.usermodel.Cell;
@ -36,6 +37,8 @@ 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.AfterClass;
import org.junit.Test;
@ -48,7 +51,9 @@ import junit.framework.AssertionFailedError;
@RunWith(Parameterized.class)
public final class TestMatrixFormulasFromXMLSpreadsheet {
private static final POILogger LOG = POILogFactory.getLogger(TestMatrixFormulasFromXMLSpreadsheet.class);
private static XSSFWorkbook workbook;
private static Sheet sheet;
private static FormulaEvaluator evaluator;
@ -213,13 +218,13 @@ public final class TestMatrixFormulasFromXMLSpreadsheet {
*/
private static String getTargetFunctionName(Row r) {
if(r == null) {
System.err.println("Warning - given null row, can't figure out function name");
LOG.log(POILogger.WARN, "Warning - given null row, can't figure out function name");
return null;
}
Cell cell = r.getCell(Navigator.START_OPERATORS_COL_INDEX);
System.err.println(String.valueOf(Navigator.START_OPERATORS_COL_INDEX));
LOG.log(POILogger.DEBUG, String.valueOf(Navigator.START_OPERATORS_COL_INDEX));
if(cell == null) {
System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", can't figure out function name");
LOG.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", can't figure out function name");
return null;
}
if(cell.getCellType() == CellType.BLANK) {

View File

@ -103,7 +103,6 @@ public final class TestUnfixedBugs {
Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("54071.xlsx");
Sheet sheet = workbook.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
System.out.println(">> file rows is:"+(rows-1)+" <<");
Row title = sheet.getRow(0);
Date prev = null;
@ -115,7 +114,7 @@ public final class TestUnfixedBugs {
if (titleName.startsWith("time")) {
// here the output will produce ...59 or ...58 for the rows, probably POI is
// doing some different rounding or some other small difference...
System.out.println("==Time:"+cell.getDateCellValue());
//System.out.println("==Time:"+cell.getDateCellValue());
if(prev != null) {
assertEquals(prev, cell.getDateCellValue());
}

View File

@ -2649,7 +2649,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
Cell cell = aRow.getCell(1);
if (cell.getCellType() == CellType.FORMULA) {
String formula = cell.getCellFormula();
//System.out.println("formula: " + formula);
assertNotNull(formula);
assertTrue(formula.contains("WORKDAY"));
} else {
@ -2786,7 +2785,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
Sheet newSheet = wb.createSheet();
//Sheet newSheet = wb.createSheet(sheetName);
int newSheetIndex = wb.getSheetIndex(newSheet);
//System.out.println(newSheetIndex);
wb.setSheetName(newSheetIndex, sheetName);
wb.setSheetOrder(sheetName, sheetIndex);
}
@ -2873,8 +2871,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
for (int cellNum = row.getFirstCellNum(); cellNum < row.getLastCellNum(); cellNum++) {
Cell cell = row.getCell(cellNum);
String fmtCellValue = formatter.formatCellValue(cell);
System.out.println("Cell: " + fmtCellValue);
assertNotNull(fmtCellValue);
assertFalse(fmtCellValue.equals("0"));
}
@ -3178,7 +3174,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
Row r = s.getRow(3);
Cell c = r.getCell(0);
assertEquals(CellType.FORMULA, c.getCellType());
System.out.println(c.getCellFormula());
eval.setDebugEvaluationOutputForNextEval(true);
CellValue cv = eval.evaluate(c);
assertNotNull(cv);

View File

@ -1509,7 +1509,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
assertEquals("J7", new CellReference(cell).formatAsString());
assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula] J7 cell formula", "5+2", cell.getCellFormula());
System.out.println("Cell formula evaluation currently unsupported");
//System.out.println("Cell formula evaluation currently unsupported");
// Cell Formula with Reference
// Formula row references should be adjusted by destRowNum-srcRowNum
@ -1536,7 +1536,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// Array Formula
cell = CellUtil.getCell(destRow, col++);
System.out.println("Array formulas currently unsupported");
//System.out.println("Array formulas currently unsupported");
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
/*
assertEquals("[Array Formula] N7 cell type", CellType.FORMULA, cell.getCellType());

View File

@ -22,10 +22,15 @@ import java.io.IOException;
import java.util.List;
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.Test;
public class TestXSSFSheetMergeRegions {
private static final POILogger LOG = POILogFactory.getLogger(TestXSSFSheetMergeRegions.class);
@Test
public void testMergeRegionsSpeed() throws IOException {
final XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57893-many-merges.xlsx");
@ -39,7 +44,7 @@ public class TestXSSFSheetMergeRegions {
if(millis < 2000) {
break;
}
System.out.println("Retry " + i + " because run-time is too high: " + millis);
LOG.log(POILogger.INFO,"Retry " + i + " because run-time is too high: " + millis);
}
boolean inGump = false;

View File

@ -167,9 +167,10 @@ public class TestXWPFPictureData extends TestCase {
for (XWPFRun run : paragraph.getRuns()) {
for (XWPFPicture picture : run.getEmbeddedPictures()) {
if (paragraph.getDocument() != null) {
//System.out.println(picture.getCTPicture());
XWPFPictureData data = picture.getPictureData();
if (data != null) System.out.println(data.getFileName());
if (data != null) {
fail("Should have returned null: "+ data.getFileName());
}
}
}
}

View File

@ -21,6 +21,7 @@ import static org.apache.poi.POITestCase.assertContains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@ -29,6 +30,7 @@ import org.apache.poi.hpsf.*;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.extractor.ExcelExtractor;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.junit.Test;
@ -194,8 +196,10 @@ public final class TestHPSFPropertiesExtractor {
@Test
public void test61300Extractor() throws NoPropertySetStreamException, MarkUnsupportedException, IOException {
HPSFPropertiesExtractor.main(new String[]{
POIDataSamples.getPOIFSInstance().getFile("61300.bin").getAbsolutePath()
});
try (NPOIFSFileSystem npoifs = new NPOIFSFileSystem(
POIDataSamples.getPOIFSInstance().getFile("61300.bin"))) {
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(npoifs);
assertContains(ext.getText(), "PID_CODEPAGE = 1252");
}
}
}

View File

@ -36,6 +36,8 @@ 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.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -47,7 +49,10 @@ import junit.framework.AssertionFailedError;
@RunWith(Parameterized.class)
public final class TestMatrixFormulasFromBinarySpreadsheet {
private static final POILogger LOG = POILogFactory.getLogger(TestMatrixFormulasFromBinarySpreadsheet.class);
private static HSSFWorkbook workbook;
private static Sheet sheet;
private static FormulaEvaluator evaluator;
@ -212,13 +217,15 @@ public final class TestMatrixFormulasFromBinarySpreadsheet {
*/
private static String getTargetFunctionName(Row r) {
if(r == null) {
System.err.println("Warning - given null row, can't figure out function name");
LOG.log(POILogger.WARN,"Warning - given null row, can't figure out function name");
return null;
}
Cell cell = r.getCell(Navigator.START_OPERATORS_COL_INDEX);
System.err.println(String.valueOf(Navigator.START_OPERATORS_COL_INDEX));
LOG.log(POILogger.INFO, String.valueOf(Navigator.START_OPERATORS_COL_INDEX));
if(cell == null) {
System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", can't figure out function name");
LOG.log(POILogger.WARN,
"Warning - Row " + r.getRowNum() + " has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", can't figure out function name");
return null;
}
if(cell.getCellType() == CellType.BLANK) {

View File

@ -23,18 +23,41 @@ import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
import org.apache.poi.poifs.property.NPropertyTable;
import org.apache.poi.util.TempFile;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import static org.junit.Assert.*;
public class TestPOIFSDump {
private static PrintStream SYSTEM;
@BeforeClass
public static void setUp() {
SYSTEM = System.out;
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(int b) throws IOException {
}
}
));
}
@AfterClass
public static void resetSystemOut() {
System.setOut(SYSTEM);
}
private static final String TEST_FILE = HSSFTestDataSamples.getSampleFile("46515.xls").getAbsolutePath();
private static final String INVALID_FILE = HSSFTestDataSamples.getSampleFile("48936-strings.txt").getAbsolutePath();
private static final String INVALID_XLSX_FILE = HSSFTestDataSamples.getSampleFile("47668.xlsx").getAbsolutePath();

View File

@ -28,6 +28,7 @@ import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
public class TestPresetGeometries {
@ -67,6 +68,7 @@ public class TestPresetGeometries {
PresetGeometries._inst = null;
}
@Ignore("problem solved? Turn back on if this debugging is still in process.")
@Test
public void testCheckXMLParser() throws Exception{
// Gump reports a strange error because of an unavailable XML Parser, let's try to find out where

View File

@ -1571,30 +1571,28 @@ public abstract class BaseTestBugzillaIssues {
// First cell of array formula, OK
int rowId = 0;
int cellId = 1;
System.out.println("Reading row " + rowId + ", col " + cellId);
Row row = sheet.getRow(rowId);
Cell cell = row.getCell(cellId);
System.out.println("Formula:" + cell.getCellFormula());
assertEquals("A1", cell.getCellFormula());
if (CellType.FORMULA == cell.getCellType()) {
CellType formulaResultType = cell.getCachedFormulaResultType();
System.out.println("Formula Result Type:" + formulaResultType);
assertEquals(CellType.STRING, formulaResultType);
}
// *******************************
// Second cell of array formula, NOT OK for xlsx files
rowId = 1;
cellId = 1;
System.out.println("Reading row " + rowId + ", col " + cellId);
row = sheet.getRow(rowId);
cell = row.getCell(cellId);
System.out.println("Formula:" + cell.getCellFormula());
assertEquals("A1", cell.getCellFormula());
if (CellType.FORMULA == cell.getCellType()) {
CellType formulaResultType = cell.getCachedFormulaResultType();
System.out.println("Formula Result Type:" + formulaResultType);
assertEquals(CellType.STRING, formulaResultType);
}
workbook.close();

View File

@ -107,7 +107,6 @@ public class BaseTestCellUtil {
@Test
public void setCellStyleProperties() throws IOException {
System.out.println("setCellStyleProps start");
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r = s.createRow(0);
@ -130,7 +129,6 @@ public class BaseTestCellUtil {
c = r.createCell(1);
CellUtil.setCellStyleProperties(c, props);
int styCnt3 = wb.getNumCellStyles();
System.out.println("setCellStyleProps nearing end");
assertEquals("No additional styles should have been created", styCnt2, styCnt3);
wb.close();

View File

@ -110,7 +110,7 @@ public final class TestDateFormatConverter extends TestCase {
workbook.write(outputStream);
}
System.out.println("Open " + outputFile.getAbsolutePath() + " in Excel");
//System.out.println("Open " + outputFile.getAbsolutePath() + " in Excel");
}
}

View File

@ -27,11 +27,33 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class TestHexDump {
private static PrintStream SYSTEM_OUT;
@BeforeClass
public static void setUp() {
SYSTEM_OUT = System.out;
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(int b) throws IOException {
}
}));
}
@AfterClass
public static void tearDown() {
System.setOut(SYSTEM_OUT);
}
@Test
public void testDump() throws IOException {
byte[] testArray = testArray();

View File

@ -58,14 +58,6 @@ public class TestLittleEndianCP950Reader {
}
@Test
public void one() {
byte b = (byte) 0xfe;
byte c = (byte) 0xd3;
int i = ((b & 0xff) << 8) + (c & 0xff);
System.out.println(i);
}
private void assertCharEquals(char expected, byte[] data) throws IOException {
Reader reader = new LittleEndianCP950Reader(data);