Skip to content

Commit c69f9ed

Browse files
committed
Add test for batch mode of commandline app
1 parent 1812520 commit c69f9ed

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/test/java/technology/tabula/TestCommandLineApp.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import static org.junit.Assert.*;
44

55
import java.io.IOException;
6+
import java.nio.file.Files;
7+
import java.nio.file.Path;
8+
import java.nio.file.FileSystem;
9+
import java.nio.file.FileSystems;
610

711
import org.apache.commons.cli.CommandLine;
812
import org.apache.commons.cli.CommandLineParser;
@@ -35,6 +39,30 @@ public void testExtractSpreadsheetWithArea() throws ParseException, IOException
3539
}));
3640
}
3741

42+
@Test
43+
public void testExtractBatchSpreadsheetWithArea() throws ParseException, IOException {
44+
FileSystem fs = FileSystems.getDefault();
45+
String expectedCsv = UtilsForTesting.loadCsv("src/test/resources/technology/tabula/csv/spreadsheet_no_bounding_frame.csv");
46+
Path tmpFolder = Files.createTempDirectory("tabula-java-batch-test");
47+
tmpFolder.toFile().deleteOnExit();
48+
49+
Path copiedPDF = tmpFolder.resolve(fs.getPath("spreadsheet.pdf"));
50+
Path sourcePDF = fs.getPath("src/test/resources/technology/tabula/spreadsheet_no_bounding_frame.pdf");
51+
Files.copy(sourcePDF, copiedPDF);
52+
copiedPDF.toFile().deleteOnExit();
53+
54+
this.csvFromCommandLineArgs(new String[] {
55+
"-b", tmpFolder.toString(),
56+
"-p", "1", "-a",
57+
"150.56,58.9,654.7,536.12", "-f",
58+
"CSV"
59+
});
60+
61+
Path csvPath = tmpFolder.resolve(fs.getPath("spreadsheet.csv"));
62+
assertTrue(csvPath.toFile().exists());
63+
assertArrayEquals(expectedCsv.getBytes(), Files.readAllBytes(csvPath));
64+
}
65+
3866
@Test
3967
public void testExtractSpreadsheetWithAreaAndNewFile() throws ParseException, IOException {
4068

0 commit comments

Comments
 (0)