Extract ROOT_DIR into constant, ignore .csv files

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1649124 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2015-01-02 21:07:14 +00:00
parent 302db39cb7
commit e8c5bd48ad

View File

@ -65,7 +65,9 @@ import org.junit.runners.Parameterized.Parameters;
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class TestAllFiles { public class TestAllFiles {
// map file extensions to the actual mappers private static final File ROOT_DIR = new File("test-data");
// map file extensions to the actual mappers
private static final Map<String, FileHandler> HANDLERS = new HashMap<String, FileHandler>(); private static final Map<String, FileHandler> HANDLERS = new HashMap<String, FileHandler>();
static { static {
// Excel // Excel
@ -136,6 +138,7 @@ public class TestAllFiles {
HANDLERS.put(".wav", new NullFileHandler()); HANDLERS.put(".wav", new NullFileHandler());
HANDLERS.put(".pfx", new NullFileHandler()); HANDLERS.put(".pfx", new NullFileHandler());
HANDLERS.put(".xml", new NullFileHandler()); HANDLERS.put(".xml", new NullFileHandler());
HANDLERS.put(".csv", new NullFileHandler());
// map some files without extension // map some files without extension
HANDLERS.put("spreadsheet/BigSSTRecord", new NullFileHandler()); HANDLERS.put("spreadsheet/BigSSTRecord", new NullFileHandler());
@ -223,7 +226,7 @@ public class TestAllFiles {
@Parameters(name="{index}: {0} using {1}") @Parameters(name="{index}: {0} using {1}")
public static Iterable<Object[]> files() { public static Iterable<Object[]> files() {
DirectoryScanner scanner = new DirectoryScanner(); DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(new File("test-data")); scanner.setBasedir(ROOT_DIR);
scanner.setExcludes(new String[] { "**/.svn/**" }); scanner.setExcludes(new String[] { "**/.svn/**" });
scanner.scan(); scanner.scan();
@ -248,7 +251,7 @@ public class TestAllFiles {
@Test @Test
public void testAllFiles() throws Exception { public void testAllFiles() throws Exception {
assertNotNull("Unknown file extension for file: " + file + ": " + getExtension(file), handler); assertNotNull("Unknown file extension for file: " + file + ": " + getExtension(file), handler);
InputStream stream = new BufferedInputStream(new FileInputStream(new File("test-data", file)),100); InputStream stream = new BufferedInputStream(new FileInputStream(new File(ROOT_DIR, file)),100);
try { try {
handler.handleFile(stream); handler.handleFile(stream);