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:
parent
d1765d7e76
commit
a59402a37f
@ -22,6 +22,7 @@ package org.apache.poi.dev;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
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.openxml4j.opc.PackageAccess;
|
||||||
import org.apache.poi.util.NullOutputStream;
|
import org.apache.poi.util.NullOutputStream;
|
||||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestOOXMLLister {
|
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
|
@Test
|
||||||
public void testMain() throws IOException, InvalidFormatException {
|
public void testMain() throws IOException, InvalidFormatException {
|
||||||
File file = XSSFTestDataSamples.getSampleFile("Formatting.xlsx");
|
File file = XSSFTestDataSamples.getSampleFile("Formatting.xlsx");
|
||||||
|
@ -22,14 +22,38 @@ package org.apache.poi.dev;
|
|||||||
|
|
||||||
import org.apache.poi.util.TempFile;
|
import org.apache.poi.util.TempFile;
|
||||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
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.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class TestOOXMLPrettyPrint {
|
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
|
@Test
|
||||||
public void testMain() throws Exception {
|
public void testMain() throws Exception {
|
||||||
File file = XSSFTestDataSamples.getSampleFile("Formatting.xlsx");
|
File file = XSSFTestDataSamples.getSampleFile("Formatting.xlsx");
|
||||||
|
@ -49,10 +49,13 @@ import org.apache.poi.openxml4j.opc.PackageAccess;
|
|||||||
import org.apache.poi.poifs.filesystem.OPOIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.OPOIFSFileSystem;
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
import org.apache.poi.util.IOUtils;
|
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.xdgf.extractor.XDGFVisioExtractor;
|
||||||
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
|
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
|
||||||
import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
|
import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
|
||||||
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
|
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
|
||||||
|
import org.apache.poi.xssf.usermodel.TestMatrixFormulasFromXMLSpreadsheet;
|
||||||
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -61,6 +64,9 @@ import org.junit.Test;
|
|||||||
* Test that the extractor factory plays nicely
|
* Test that the extractor factory plays nicely
|
||||||
*/
|
*/
|
||||||
public class TestExtractorFactory {
|
public class TestExtractorFactory {
|
||||||
|
|
||||||
|
private static final POILogger LOG = POILogFactory.getLogger(TestExtractorFactory.class);
|
||||||
|
|
||||||
private static File txt;
|
private static File txt;
|
||||||
|
|
||||||
private static File xls;
|
private static File xls;
|
||||||
@ -691,7 +697,7 @@ public class TestExtractorFactory {
|
|||||||
} catch(UnsupportedFileFormatException e) {
|
} catch(UnsupportedFileFormatException e) {
|
||||||
// Good
|
// Good
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("TestExtractorFactory.testPackage() failed on " + txt);
|
LOG.log(POILogger.WARN, "TestExtractorFactory.testPackage() failed on " + txt);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,8 +129,8 @@ public final class TestProper {
|
|||||||
final ValueEval ret = TextFunction.PROPER.evaluate(new ValueEval[]{strArg}, 0, 0);
|
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());
|
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
|
// Took approx. 600ms on a decent Laptop in July 2016
|
||||||
System.out.println("Took: " + (System.currentTimeMillis() - start) + "ms");
|
//System.out.println("Took: " + (System.currentTimeMillis() - start) + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkProper(String input, String expected) {
|
private void checkProper(String input, String expected) {
|
||||||
|
@ -283,7 +283,6 @@ public class TestCommentsTable {
|
|||||||
// Set the comment on a sheet
|
// Set the comment on a sheet
|
||||||
//
|
//
|
||||||
private static void setComment(Sheet sheet, Cell cell, Drawing<?> drawing, String commentText, CreationHelper helper, ClientAnchor anchor) {
|
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.setCol1(cell.getColumnIndex());
|
||||||
anchor.setCol2(cell.getColumnIndex());
|
anchor.setCol2(cell.getColumnIndex());
|
||||||
anchor.setRow1(cell.getRowIndex());
|
anchor.setRow1(cell.getRowIndex());
|
||||||
|
@ -211,8 +211,6 @@ public class TestAutoSizeColumnTracker {
|
|||||||
private static void assumeRequiredFontsAreInstalled(final Workbook workbook, final Cell cell) {
|
private static void assumeRequiredFontsAreInstalled(final Workbook workbook, final Cell cell) {
|
||||||
// autoSize will fail if required fonts are not installed, skip this test then
|
// autoSize will fail if required fonts are not installed, skip this test then
|
||||||
Font font = workbook.getFontAt(cell.getCellStyle().getFontIndex());
|
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,
|
Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font,
|
||||||
SheetUtil.canComputeColumnWidth(font));
|
SheetUtil.canComputeColumnWidth(font));
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,6 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
|
|||||||
File out = new File("Test.xlsx");
|
File out = new File("Test.xlsx");
|
||||||
out.delete();
|
out.delete();
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
System.out.println("Iteration " + i);
|
|
||||||
final SXSSFWorkbook wb;
|
final SXSSFWorkbook wb;
|
||||||
if (out.exists()) {
|
if (out.exists()) {
|
||||||
wb = new SXSSFWorkbook(
|
wb = new SXSSFWorkbook(
|
||||||
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
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.eval.ErrorEval;
|
||||||
import org.apache.poi.ss.formula.functions.TestMathX;
|
import org.apache.poi.ss.formula.functions.TestMathX;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
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.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.util.LocaleUtil;
|
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.apache.poi.xssf.XSSFTestDataSamples;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -49,6 +52,8 @@ import junit.framework.AssertionFailedError;
|
|||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public final class TestMatrixFormulasFromXMLSpreadsheet {
|
public final class TestMatrixFormulasFromXMLSpreadsheet {
|
||||||
|
|
||||||
|
private static final POILogger LOG = POILogFactory.getLogger(TestMatrixFormulasFromXMLSpreadsheet.class);
|
||||||
|
|
||||||
private static XSSFWorkbook workbook;
|
private static XSSFWorkbook workbook;
|
||||||
private static Sheet sheet;
|
private static Sheet sheet;
|
||||||
private static FormulaEvaluator evaluator;
|
private static FormulaEvaluator evaluator;
|
||||||
@ -213,13 +218,13 @@ public final class TestMatrixFormulasFromXMLSpreadsheet {
|
|||||||
*/
|
*/
|
||||||
private static String getTargetFunctionName(Row r) {
|
private static String getTargetFunctionName(Row r) {
|
||||||
if(r == null) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
Cell cell = r.getCell(Navigator.START_OPERATORS_COL_INDEX);
|
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) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
if(cell.getCellType() == CellType.BLANK) {
|
if(cell.getCellType() == CellType.BLANK) {
|
||||||
|
@ -103,7 +103,6 @@ public final class TestUnfixedBugs {
|
|||||||
Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("54071.xlsx");
|
Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("54071.xlsx");
|
||||||
Sheet sheet = workbook.getSheetAt(0);
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
int rows = sheet.getPhysicalNumberOfRows();
|
int rows = sheet.getPhysicalNumberOfRows();
|
||||||
System.out.println(">> file rows is:"+(rows-1)+" <<");
|
|
||||||
Row title = sheet.getRow(0);
|
Row title = sheet.getRow(0);
|
||||||
|
|
||||||
Date prev = null;
|
Date prev = null;
|
||||||
@ -115,7 +114,7 @@ public final class TestUnfixedBugs {
|
|||||||
if (titleName.startsWith("time")) {
|
if (titleName.startsWith("time")) {
|
||||||
// here the output will produce ...59 or ...58 for the rows, probably POI is
|
// here the output will produce ...59 or ...58 for the rows, probably POI is
|
||||||
// doing some different rounding or some other small difference...
|
// doing some different rounding or some other small difference...
|
||||||
System.out.println("==Time:"+cell.getDateCellValue());
|
//System.out.println("==Time:"+cell.getDateCellValue());
|
||||||
if(prev != null) {
|
if(prev != null) {
|
||||||
assertEquals(prev, cell.getDateCellValue());
|
assertEquals(prev, cell.getDateCellValue());
|
||||||
}
|
}
|
||||||
|
@ -2649,7 +2649,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
Cell cell = aRow.getCell(1);
|
Cell cell = aRow.getCell(1);
|
||||||
if (cell.getCellType() == CellType.FORMULA) {
|
if (cell.getCellType() == CellType.FORMULA) {
|
||||||
String formula = cell.getCellFormula();
|
String formula = cell.getCellFormula();
|
||||||
//System.out.println("formula: " + formula);
|
|
||||||
assertNotNull(formula);
|
assertNotNull(formula);
|
||||||
assertTrue(formula.contains("WORKDAY"));
|
assertTrue(formula.contains("WORKDAY"));
|
||||||
} else {
|
} else {
|
||||||
@ -2786,7 +2785,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
Sheet newSheet = wb.createSheet();
|
Sheet newSheet = wb.createSheet();
|
||||||
//Sheet newSheet = wb.createSheet(sheetName);
|
//Sheet newSheet = wb.createSheet(sheetName);
|
||||||
int newSheetIndex = wb.getSheetIndex(newSheet);
|
int newSheetIndex = wb.getSheetIndex(newSheet);
|
||||||
//System.out.println(newSheetIndex);
|
|
||||||
wb.setSheetName(newSheetIndex, sheetName);
|
wb.setSheetName(newSheetIndex, sheetName);
|
||||||
wb.setSheetOrder(sheetName, sheetIndex);
|
wb.setSheetOrder(sheetName, sheetIndex);
|
||||||
}
|
}
|
||||||
@ -2873,8 +2871,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
for (int cellNum = row.getFirstCellNum(); cellNum < row.getLastCellNum(); cellNum++) {
|
for (int cellNum = row.getFirstCellNum(); cellNum < row.getLastCellNum(); cellNum++) {
|
||||||
Cell cell = row.getCell(cellNum);
|
Cell cell = row.getCell(cellNum);
|
||||||
String fmtCellValue = formatter.formatCellValue(cell);
|
String fmtCellValue = formatter.formatCellValue(cell);
|
||||||
|
|
||||||
System.out.println("Cell: " + fmtCellValue);
|
|
||||||
assertNotNull(fmtCellValue);
|
assertNotNull(fmtCellValue);
|
||||||
assertFalse(fmtCellValue.equals("0"));
|
assertFalse(fmtCellValue.equals("0"));
|
||||||
}
|
}
|
||||||
@ -3178,7 +3174,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
Row r = s.getRow(3);
|
Row r = s.getRow(3);
|
||||||
Cell c = r.getCell(0);
|
Cell c = r.getCell(0);
|
||||||
assertEquals(CellType.FORMULA, c.getCellType());
|
assertEquals(CellType.FORMULA, c.getCellType());
|
||||||
System.out.println(c.getCellFormula());
|
|
||||||
eval.setDebugEvaluationOutputForNextEval(true);
|
eval.setDebugEvaluationOutputForNextEval(true);
|
||||||
CellValue cv = eval.evaluate(c);
|
CellValue cv = eval.evaluate(c);
|
||||||
assertNotNull(cv);
|
assertNotNull(cv);
|
||||||
|
@ -1509,7 +1509,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
assertEquals("J7", new CellReference(cell).formatAsString());
|
assertEquals("J7", new CellReference(cell).formatAsString());
|
||||||
assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellType());
|
assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("[Cell Formula] J7 cell formula", "5+2", cell.getCellFormula());
|
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
|
// Cell Formula with Reference
|
||||||
// Formula row references should be adjusted by destRowNum-srcRowNum
|
// Formula row references should be adjusted by destRowNum-srcRowNum
|
||||||
@ -1536,7 +1536,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
|||||||
|
|
||||||
// Array Formula
|
// Array Formula
|
||||||
cell = CellUtil.getCell(destRow, col++);
|
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()
|
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
|
||||||
/*
|
/*
|
||||||
assertEquals("[Array Formula] N7 cell type", CellType.FORMULA, cell.getCellType());
|
assertEquals("[Array Formula] N7 cell type", CellType.FORMULA, cell.getCellType());
|
||||||
|
@ -22,10 +22,15 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
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.apache.poi.xssf.XSSFTestDataSamples;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestXSSFSheetMergeRegions {
|
public class TestXSSFSheetMergeRegions {
|
||||||
|
|
||||||
|
private static final POILogger LOG = POILogFactory.getLogger(TestXSSFSheetMergeRegions.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeRegionsSpeed() throws IOException {
|
public void testMergeRegionsSpeed() throws IOException {
|
||||||
final XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57893-many-merges.xlsx");
|
final XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57893-many-merges.xlsx");
|
||||||
@ -39,7 +44,7 @@ public class TestXSSFSheetMergeRegions {
|
|||||||
if(millis < 2000) {
|
if(millis < 2000) {
|
||||||
break;
|
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;
|
boolean inGump = false;
|
||||||
|
@ -167,9 +167,10 @@ public class TestXWPFPictureData extends TestCase {
|
|||||||
for (XWPFRun run : paragraph.getRuns()) {
|
for (XWPFRun run : paragraph.getRuns()) {
|
||||||
for (XWPFPicture picture : run.getEmbeddedPictures()) {
|
for (XWPFPicture picture : run.getEmbeddedPictures()) {
|
||||||
if (paragraph.getDocument() != null) {
|
if (paragraph.getDocument() != null) {
|
||||||
//System.out.println(picture.getCTPicture());
|
|
||||||
XWPFPictureData data = picture.getPictureData();
|
XWPFPictureData data = picture.getPictureData();
|
||||||
if (data != null) System.out.println(data.getFileName());
|
if (data != null) {
|
||||||
|
fail("Should have returned null: "+ data.getFileName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import static org.apache.poi.POITestCase.assertContains;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ import org.apache.poi.hpsf.*;
|
|||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.hssf.extractor.ExcelExtractor;
|
import org.apache.poi.hssf.extractor.ExcelExtractor;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -194,8 +196,10 @@ public final class TestHPSFPropertiesExtractor {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test61300Extractor() throws NoPropertySetStreamException, MarkUnsupportedException, IOException {
|
public void test61300Extractor() throws NoPropertySetStreamException, MarkUnsupportedException, IOException {
|
||||||
HPSFPropertiesExtractor.main(new String[]{
|
try (NPOIFSFileSystem npoifs = new NPOIFSFileSystem(
|
||||||
POIDataSamples.getPOIFSInstance().getFile("61300.bin").getAbsolutePath()
|
POIDataSamples.getPOIFSInstance().getFile("61300.bin"))) {
|
||||||
});
|
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(npoifs);
|
||||||
|
assertContains(ext.getText(), "PID_CODEPAGE = 1252");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
|||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.util.LocaleUtil;
|
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.AfterClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -48,6 +50,9 @@ import junit.framework.AssertionFailedError;
|
|||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public final class TestMatrixFormulasFromBinarySpreadsheet {
|
public final class TestMatrixFormulasFromBinarySpreadsheet {
|
||||||
|
|
||||||
|
private static final POILogger LOG = POILogFactory.getLogger(TestMatrixFormulasFromBinarySpreadsheet.class);
|
||||||
|
|
||||||
|
|
||||||
private static HSSFWorkbook workbook;
|
private static HSSFWorkbook workbook;
|
||||||
private static Sheet sheet;
|
private static Sheet sheet;
|
||||||
private static FormulaEvaluator evaluator;
|
private static FormulaEvaluator evaluator;
|
||||||
@ -212,13 +217,15 @@ public final class TestMatrixFormulasFromBinarySpreadsheet {
|
|||||||
*/
|
*/
|
||||||
private static String getTargetFunctionName(Row r) {
|
private static String getTargetFunctionName(Row r) {
|
||||||
if(r == null) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
Cell cell = r.getCell(Navigator.START_OPERATORS_COL_INDEX);
|
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) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
if(cell.getCellType() == CellType.BLANK) {
|
if(cell.getCellType() == CellType.BLANK) {
|
||||||
|
@ -23,18 +23,41 @@ import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
|
|||||||
import org.apache.poi.poifs.property.NPropertyTable;
|
import org.apache.poi.poifs.property.NPropertyTable;
|
||||||
import org.apache.poi.util.TempFile;
|
import org.apache.poi.util.TempFile;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class TestPOIFSDump {
|
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 TEST_FILE = HSSFTestDataSamples.getSampleFile("46515.xls").getAbsolutePath();
|
||||||
private static final String INVALID_FILE = HSSFTestDataSamples.getSampleFile("48936-strings.txt").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();
|
private static final String INVALID_XLSX_FILE = HSSFTestDataSamples.getSampleFile("47668.xlsx").getAbsolutePath();
|
||||||
|
@ -28,6 +28,7 @@ import java.net.URL;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestPresetGeometries {
|
public class TestPresetGeometries {
|
||||||
@ -67,6 +68,7 @@ public class TestPresetGeometries {
|
|||||||
PresetGeometries._inst = null;
|
PresetGeometries._inst = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore("problem solved? Turn back on if this debugging is still in process.")
|
||||||
@Test
|
@Test
|
||||||
public void testCheckXMLParser() throws Exception{
|
public void testCheckXMLParser() throws Exception{
|
||||||
// Gump reports a strange error because of an unavailable XML Parser, let's try to find out where
|
// Gump reports a strange error because of an unavailable XML Parser, let's try to find out where
|
||||||
|
@ -1571,30 +1571,28 @@ public abstract class BaseTestBugzillaIssues {
|
|||||||
// First cell of array formula, OK
|
// First cell of array formula, OK
|
||||||
int rowId = 0;
|
int rowId = 0;
|
||||||
int cellId = 1;
|
int cellId = 1;
|
||||||
System.out.println("Reading row " + rowId + ", col " + cellId);
|
|
||||||
|
|
||||||
Row row = sheet.getRow(rowId);
|
Row row = sheet.getRow(rowId);
|
||||||
Cell cell = row.getCell(cellId);
|
Cell cell = row.getCell(cellId);
|
||||||
|
|
||||||
System.out.println("Formula:" + cell.getCellFormula());
|
assertEquals("A1", cell.getCellFormula());
|
||||||
if (CellType.FORMULA == cell.getCellType()) {
|
if (CellType.FORMULA == cell.getCellType()) {
|
||||||
CellType formulaResultType = cell.getCachedFormulaResultType();
|
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
|
// Second cell of array formula, NOT OK for xlsx files
|
||||||
rowId = 1;
|
rowId = 1;
|
||||||
cellId = 1;
|
cellId = 1;
|
||||||
System.out.println("Reading row " + rowId + ", col " + cellId);
|
|
||||||
|
|
||||||
row = sheet.getRow(rowId);
|
row = sheet.getRow(rowId);
|
||||||
cell = row.getCell(cellId);
|
cell = row.getCell(cellId);
|
||||||
System.out.println("Formula:" + cell.getCellFormula());
|
assertEquals("A1", cell.getCellFormula());
|
||||||
|
|
||||||
if (CellType.FORMULA == cell.getCellType()) {
|
if (CellType.FORMULA == cell.getCellType()) {
|
||||||
CellType formulaResultType = cell.getCachedFormulaResultType();
|
CellType formulaResultType = cell.getCachedFormulaResultType();
|
||||||
System.out.println("Formula Result Type:" + formulaResultType);
|
assertEquals(CellType.STRING, formulaResultType);
|
||||||
}
|
}
|
||||||
|
|
||||||
workbook.close();
|
workbook.close();
|
||||||
|
@ -107,7 +107,6 @@ public class BaseTestCellUtil {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setCellStyleProperties() throws IOException {
|
public void setCellStyleProperties() throws IOException {
|
||||||
System.out.println("setCellStyleProps start");
|
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
Sheet s = wb.createSheet();
|
Sheet s = wb.createSheet();
|
||||||
Row r = s.createRow(0);
|
Row r = s.createRow(0);
|
||||||
@ -130,7 +129,6 @@ public class BaseTestCellUtil {
|
|||||||
c = r.createCell(1);
|
c = r.createCell(1);
|
||||||
CellUtil.setCellStyleProperties(c, props);
|
CellUtil.setCellStyleProperties(c, props);
|
||||||
int styCnt3 = wb.getNumCellStyles();
|
int styCnt3 = wb.getNumCellStyles();
|
||||||
System.out.println("setCellStyleProps nearing end");
|
|
||||||
assertEquals("No additional styles should have been created", styCnt2, styCnt3);
|
assertEquals("No additional styles should have been created", styCnt2, styCnt3);
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
|
@ -110,7 +110,7 @@ public final class TestDateFormatConverter extends TestCase {
|
|||||||
workbook.write(outputStream);
|
workbook.write(outputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Open " + outputFile.getAbsolutePath() + " in Excel");
|
//System.out.println("Open " + outputFile.getAbsolutePath() + " in Excel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,11 +27,33 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestHexDump {
|
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
|
@Test
|
||||||
public void testDump() throws IOException {
|
public void testDump() throws IOException {
|
||||||
byte[] testArray = testArray();
|
byte[] testArray = testArray();
|
||||||
|
@ -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 {
|
private void assertCharEquals(char expected, byte[] data) throws IOException {
|
||||||
Reader reader = new LittleEndianCP950Reader(data);
|
Reader reader = new LittleEndianCP950Reader(data);
|
||||||
|
Loading…
Reference in New Issue
Block a user