git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884379 13f79535-47bb-0310-9956-ffa450edef68tags/before_junit5_update
files.get(threadNum).add(file); | files.get(threadNum).add(file); | ||||
if (iter % 30 == 0) { | if (iter % 30 == 0) { | ||||
System.out.println("thread: " + threadNum + ", iter: " + iter + ": " + file); | |||||
// System.out.println("thread: " + threadNum + ", iter: " + iter + ": " + file); | |||||
} | } | ||||
} | } | ||||
} | } |
package org.apache.poi.xslf.usermodel; | package org.apache.poi.xslf.usermodel; | ||||
import static java.util.Arrays.asList; | import static java.util.Arrays.asList; | ||||
import static org.junit.Assert.assertTrue; | |||||
import static org.junit.Assume.assumeFalse; | import static org.junit.Assume.assumeFalse; | ||||
import java.io.File; | import java.io.File; | ||||
} | } | ||||
private String[] getArgs(String format) throws IOException { | private String[] getArgs(String format) throws IOException { | ||||
File tmpDir = new File("build/tmp/"); | |||||
// fix maven build errors | |||||
if (!tmpDir.exists()) { | |||||
assertTrue(tmpDir.mkdirs()); | |||||
} | |||||
final List<String> args = new ArrayList<>(asList( | final List<String> args = new ArrayList<>(asList( | ||||
"-format", format, // png,gif,jpg,svg,pdf or null for test | "-format", format, // png,gif,jpg,svg,pdf or null for test | ||||
"-slide", "-1", // -1 for all | "-slide", "-1", // -1 for all | ||||
"-outdir", new File("build/tmp/").getCanonicalPath(), | |||||
"-outdir", tmpDir.getCanonicalPath(), | |||||
"-outpat", "${basename}-${slideno}-${ext}.${format}", | "-outpat", "${basename}-${slideno}-${ext}.${format}", | ||||
// "-dump", new File("build/tmp/", pptFile+".json").getCanonicalPath(), | // "-dump", new File("build/tmp/", pptFile+".json").getCanonicalPath(), | ||||
"-dump", "null", | "-dump", "null", |
@Test | @Test | ||||
public void testArrayStoreException() throws Exception { | public void testArrayStoreException() throws Exception { | ||||
File tmpDir = new File("build/tmp/"); | |||||
// fix maven build errors | |||||
if (!tmpDir.exists()) { | |||||
assertTrue(tmpDir.mkdirs()); | |||||
} | |||||
File file = POIDataSamples.getSlideShowInstance().getFile("aascu.org_workarea_downloadasset.aspx_id=5864.pptx"); | File file = POIDataSamples.getSlideShowInstance().getFile("aascu.org_workarea_downloadasset.aspx_id=5864.pptx"); | ||||
String[] args = { | String[] args = { | ||||
"-format", "null", // png,gif,jpg,svg or null for test | "-format", "null", // png,gif,jpg,svg or null for test | ||||
"-slide", "-1", // -1 for all | "-slide", "-1", // -1 for all | ||||
"-outdir", new File("build/tmp/").getCanonicalPath(), | |||||
"-outdir", tmpDir.getCanonicalPath(), | |||||
"-quiet", | "-quiet", | ||||
"-fixside", "long", | "-fixside", "long", | ||||
"-scale", "800", | "-scale", "800", |
package org.apache.poi.xssf.usermodel; | package org.apache.poi.xssf.usermodel; | ||||
import org.apache.poi.ss.usermodel.CellType; | |||||
import org.apache.poi.ss.util.CellAddress; | |||||
import org.apache.poi.ss.util.CellRangeAddress; | |||||
import org.junit.After; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell; | |||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertTrue; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.util.Locale; | import java.util.Locale; | ||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertTrue; | |||||
import org.apache.poi.ss.usermodel.CellType; | |||||
import org.apache.poi.ss.util.CellAddress; | |||||
import org.apache.poi.ss.util.CellRangeAddress; | |||||
import org.junit.After; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell; | |||||
public class TestXSSFSheetShiftRowsAndColumns { | public class TestXSSFSheetShiftRowsAndColumns { | ||||
private static final File resultDir = new File("build/custom-reports-test"); | private static final File resultDir = new File("build/custom-reports-test"); | ||||
*/ | */ | ||||
final CellRangeAddress range = new CellRangeAddress(FIRST_MERGE_ROW,LAST_MERGE_ROW,FIRST_MERGE_COL,LAST_MERGE_COL); | final CellRangeAddress range = new CellRangeAddress(FIRST_MERGE_ROW,LAST_MERGE_ROW,FIRST_MERGE_COL,LAST_MERGE_COL); | ||||
sheet.addMergedRegion(range); | sheet.addMergedRegion(range); | ||||
System.out.println(String.format(Locale.US, "\n%s: mergeArea=%s", procName,range)); | |||||
writeFile(procName); | writeFile(procName); | ||||
} | } | ||||
public void cleanup() throws IOException { | public void cleanup() throws IOException { | ||||
final String procName = "TestXSSFSheetRemoveTable.cleanup"; | final String procName = "TestXSSFSheetRemoveTable.cleanup"; | ||||
if (workbook == null) { | if (workbook == null) { | ||||
System.out.println(String.format(Locale.ROOT,"%s: workbook==null",procName)); | |||||
return; | return; | ||||
} | } | ||||
if(fileName == null) { | if(fileName == null) { | ||||
System.out.println(String.format(Locale.ROOT, "%s: fileName==null",procName)); | |||||
return; | return; | ||||
} | } | ||||
final File file = new File(resultDir,fileName); | final File file = new File(resultDir,fileName); | ||||
try (OutputStream fileOut = new FileOutputStream(file)) { | try (OutputStream fileOut = new FileOutputStream(file)) { | ||||
workbook.write(fileOut); | workbook.write(fileOut); | ||||
System.out.println(String.format(Locale.ROOT, "%s: test file written to %s",procName,file.getAbsolutePath())); | |||||
} | } | ||||
} | } | ||||
testCellAddresses(procName,0,0); | testCellAddresses(procName,0,0); | ||||
testMergeRegion(procName,0,0); | testMergeRegion(procName,0,0); | ||||
System.out.println(String.format(Locale.US, "%s: finished without error", procName)); | |||||
} | } | ||||
@Test | @Test | ||||
sheet.shiftRows(INSERT_ROW, numRows-1, nRowsToShift); | sheet.shiftRows(INSERT_ROW, numRows-1, nRowsToShift); | ||||
testCellAddresses(procName,nRowsToShift,0); | testCellAddresses(procName,nRowsToShift,0); | ||||
System.out.println(String.format(Locale.US, "%s: finished without error", procName)); | |||||
} | } | ||||
@Test | @Test | ||||
sheet.shiftRows(INSERT_ROW, numRows-1, nRowsToShift); | sheet.shiftRows(INSERT_ROW, numRows-1, nRowsToShift); | ||||
testMergeRegion(procName,nRowsToShift,0); | testMergeRegion(procName,nRowsToShift,0); | ||||
System.out.println(String.format(Locale.US, "%s: finished without error", procName)); | |||||
} | } | ||||
@Test | @Test | ||||
sheet.shiftColumns(INSERT_COLUMN, numCols-1, nShift); | sheet.shiftColumns(INSERT_COLUMN, numCols-1, nShift); | ||||
testCellAddresses(procName,0,nShift); | testCellAddresses(procName,0,nShift); | ||||
System.out.println(String.format(Locale.US, "%s: finished without error", procName)); | |||||
} | } | ||||
@Test | @Test | ||||
sheet.shiftColumns(INSERT_COLUMN, numCols-1, nShift); | sheet.shiftColumns(INSERT_COLUMN, numCols-1, nShift); | ||||
testMergeRegion(procName,0, nShift); | testMergeRegion(procName,0, nShift); | ||||
System.out.println(String.format(Locale.US, "%s: finished without error", procName)); | |||||
} | } | ||||
/** | /** | ||||
for(int nRow = 0;nRow<nNumRows;++nRow) { | for(int nRow = 0;nRow<nNumRows;++nRow) { | ||||
final XSSFRow row = sheet.getRow(nRow); | final XSSFRow row = sheet.getRow(nRow); | ||||
if(row == null) { | if(row == null) { | ||||
System.out.println(String.format(Locale.US, "%s: Row %d is empty", procName,nRow)); | |||||
continue; | continue; | ||||
} | } | ||||
for(int nCol = 0;nCol<nNumCols;++nCol) { | for(int nCol = 0;nCol<nNumCols;++nCol) { | ||||
final String address = new CellAddress(nRow,nCol).formatAsString(); | final String address = new CellAddress(nRow,nCol).formatAsString(); | ||||
final XSSFCell cell = row.getCell(nCol); | final XSSFCell cell = row.getCell(nCol); | ||||
if(cell == null) { | if(cell == null) { | ||||
System.out.println(String.format(Locale.US, "%s: Cell %s is empty", procName,address)); | |||||
continue; | continue; | ||||
} | } | ||||
final CTCell ctCell = cell.getCTCell(); | final CTCell ctCell = cell.getCTCell(); | ||||
final Object cellAddress = cell.getAddress().formatAsString(); | final Object cellAddress = cell.getAddress().formatAsString(); | ||||
final Object r = ctCell.getR(); | final Object r = ctCell.getR(); | ||||
if(nCol == 0 || nRow == 0) { | |||||
System.out.println(String.format(Locale.US, "%s: Row %d col %d address=%s cell.address=%s cell.getR=%s", procName, nRow, | |||||
nCol, address, cellAddress, ctCell.getR())); | |||||
} | |||||
assertEquals(String.format(Locale.US, "%s: Testing cell.getAddress",procName),address,cellAddress); | assertEquals(String.format(Locale.US, "%s: Testing cell.getAddress",procName),address,cellAddress); | ||||
assertEquals(String.format(Locale.US, "%s: Testing ctCell.getR",procName),address,r); | assertEquals(String.format(Locale.US, "%s: Testing ctCell.getR",procName),address,r); | ||||
} | } |
==================================================================== */ | ==================================================================== */ | ||||
package org.apache.poi.hdgf.dev; | package org.apache.poi.hdgf.dev; | ||||
import java.io.File; | |||||
import java.io.PrintStream; | |||||
import org.apache.poi.POIDataSamples; | import org.apache.poi.POIDataSamples; | ||||
import org.apache.poi.util.NullPrintStream; | |||||
import org.junit.AfterClass; | |||||
import org.junit.BeforeClass; | |||||
import org.junit.Test; | import org.junit.Test; | ||||
import java.io.File; | |||||
public class TestVSDDumper { | public class TestVSDDumper { | ||||
private static PrintStream oldStdOut; | |||||
@BeforeClass | |||||
public static void muteStdout() { | |||||
oldStdOut = System.out; | |||||
System.setOut(new NullPrintStream()); | |||||
} | |||||
@AfterClass | |||||
public static void restoreStdout() { | |||||
System.setOut(oldStdOut); | |||||
} | |||||
@Test | @Test | ||||
public void main() throws Exception { | public void main() throws Exception { | ||||
File file = POIDataSamples.getDiagramInstance().getFile("Test_Visio-Some_Random_Text.vsd"); | File file = POIDataSamples.getDiagramInstance().getFile("Test_Visio-Some_Random_Text.vsd"); |
==================================================================== */ | ==================================================================== */ | ||||
package org.apache.poi.hslf.dev; | package org.apache.poi.hslf.dev; | ||||
import org.apache.poi.EmptyFileException; | |||||
import org.junit.Test; | |||||
import static org.junit.Assert.fail; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.PrintStream; | |||||
import static org.junit.Assert.fail; | |||||
import org.apache.poi.EmptyFileException; | |||||
import org.apache.poi.util.NullPrintStream; | |||||
import org.junit.AfterClass; | |||||
import org.junit.BeforeClass; | |||||
import org.junit.Test; | |||||
public class TestSLWTListing extends BasePPTIteratingTest { | public class TestSLWTListing extends BasePPTIteratingTest { | ||||
private static PrintStream oldStdErr; | |||||
@BeforeClass | |||||
public static void muteStdErr() { | |||||
oldStdErr = System.err; | |||||
System.setErr(new NullPrintStream()); | |||||
} | |||||
@AfterClass | |||||
public static void restoreStdErr() { | |||||
System.setErr(oldStdErr); | |||||
} | |||||
@Test | @Test | ||||
public void testMain() throws IOException { | public void testMain() throws IOException { | ||||
// calls System.exit(): SLWTListing.main(new String[0]); | // calls System.exit(): SLWTListing.main(new String[0]); |
==================================================================== */ | ==================================================================== */ | ||||
package org.apache.poi.hwpf.dev; | package org.apache.poi.hwpf.dev; | ||||
import java.io.File; | |||||
import java.io.PrintStream; | |||||
import org.apache.poi.POIDataSamples; | import org.apache.poi.POIDataSamples; | ||||
import org.apache.poi.util.NullPrintStream; | |||||
import org.junit.After; | import org.junit.After; | ||||
import org.junit.AfterClass; | |||||
import org.junit.BeforeClass; | |||||
import org.junit.Test; | import org.junit.Test; | ||||
import java.io.File; | |||||
public class TestHWPFLister { | public class TestHWPFLister { | ||||
private static PrintStream oldStdOut; | |||||
@BeforeClass | |||||
public static void muteStdout() { | |||||
oldStdOut = System.out; | |||||
System.setOut(new NullPrintStream()); | |||||
} | |||||
@AfterClass | |||||
public static void restoreStdout() { | |||||
System.setOut(oldStdOut); | |||||
} | |||||
@After | @After | ||||
public void tearDown() { | public void tearDown() { | ||||
// the main-method sets these properties, we need to revert them here to not affect other tests | // the main-method sets these properties, we need to revert them here to not affect other tests |
==================================================================== */ | ==================================================================== */ | ||||
package org.apache.poi.hwpf.usermodel; | package org.apache.poi.hwpf.usermodel; | ||||
import org.apache.poi.hwpf.HWPFDocument; | |||||
import org.apache.poi.hwpf.HWPFTestDataSamples; | |||||
import org.apache.poi.util.HexDump; | |||||
import org.junit.Test; | |||||
import org.junit.runner.RunWith; | |||||
import org.junit.runners.Parameterized; | |||||
import static org.junit.Assert.assertTrue; | |||||
import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.List; | import java.util.List; | ||||
import static org.junit.Assert.assertTrue; | |||||
import org.apache.poi.hwpf.HWPFDocument; | |||||
import org.apache.poi.hwpf.HWPFTestDataSamples; | |||||
import org.apache.poi.util.HexDump; | |||||
import org.junit.Test; | |||||
import org.junit.runner.RunWith; | |||||
import org.junit.runners.Parameterized; | |||||
/** | /** | ||||
* Bug 47563 - Exception when working with table | * Bug 47563 - Exception when working with table | ||||
@Test | @Test | ||||
public void test() throws Exception { | public void test() throws Exception { | ||||
System.out.println(); | |||||
System.out.println("Testing with rows: " + rows + ", columns: " + columns); | |||||
// POI apparently can't create a document from scratch, | // POI apparently can't create a document from scratch, | ||||
// so we need an existing empty dummy document | // so we need an existing empty dummy document | ||||
try (HWPFDocument doc = HWPFTestDataSamples.openSampleFile("empty.doc")) { | try (HWPFDocument doc = HWPFTestDataSamples.openSampleFile("empty.doc")) { | ||||
TableRow row = table.getRow(rowIdx); | TableRow row = table.getRow(rowIdx); | ||||
row.sanityCheck(); | row.sanityCheck(); | ||||
System.out.println("row " + rowIdx); | |||||
for (int colIdx = 0; colIdx < row.numCells(); colIdx++) { | for (int colIdx = 0; colIdx < row.numCells(); colIdx++) { | ||||
TableCell cell = row.getCell(colIdx); | TableCell cell = row.getCell(colIdx); | ||||
cell.sanityCheck(); | cell.sanityCheck(); | ||||
System.out.println("column " + colIdx + ", num paragraphs " | |||||
+ cell.numParagraphs()); | |||||
Paragraph par = cell.getParagraph(0); | Paragraph par = cell.getParagraph(0); | ||||
par.sanityCheck(); | par.sanityCheck(); | ||||