|
37 | 37 |
|
38 | 38 | /** |
39 | 39 | * Basic test harness. |
40 | | - * |
41 | | - * Requires test file to be downloaded separately. |
42 | 40 | */ |
43 | 41 | @SuppressWarnings("boxing") |
44 | 42 | public class PerformanceTest { |
@@ -68,20 +66,21 @@ public class PerformanceTest { |
68 | 66 |
|
69 | 67 | private static final CSVFormat format = CSVFormat.EXCEL; |
70 | 68 |
|
71 | | - private static final File BIG_FILE = new File("src/test/resources/perf/worldcitiespop.txt"); |
| 69 | + private static final String TEST_RESRC = "org/apache/commons/csv/perf/worldcitiespop.txt.gz"; |
| 70 | + private static final File BIG_FILE = new File(System.getProperty("java.io.tmpdir"), "worldcitiespop.txt"); |
72 | 71 |
|
73 | 72 | public static void main(final String [] args) throws Exception { |
74 | 73 | if (BIG_FILE.exists()) { |
75 | 74 | System.out.printf("Found test fixture %s: %,d bytes.%n", BIG_FILE, BIG_FILE.length()); |
76 | 75 | } else { |
77 | | - final File compressedFile = new File(BIG_FILE.getParentFile(), BIG_FILE.getName() + ".gz"); |
78 | | - System.out.printf("Decompressing test fixture %s...%n", compressedFile); |
79 | | - long bytesOut = 0L; |
80 | | - try (final InputStream input = new GZIPInputStream(new FileInputStream(compressedFile)); |
81 | | - final OutputStream output = new FileOutputStream(BIG_FILE)) { |
82 | | - bytesOut = IOUtils.copy(input, output); |
83 | | - } |
84 | | - System.out.printf("Decompressed test fixture %s: %,d bytes to: %s: %,d bytes.%n", compressedFile, compressedFile.length(), BIG_FILE, bytesOut); |
| 76 | + System.out.println("Decompressing test fixture to: " + BIG_FILE + "..."); |
| 77 | + try ( |
| 78 | + final InputStream input = new GZIPInputStream( |
| 79 | + PerformanceTest.class.getClassLoader().getResourceAsStream(TEST_RESRC)); |
| 80 | + final OutputStream output = new FileOutputStream(BIG_FILE)) { |
| 81 | + IOUtils.copy(input, output); |
| 82 | + System.out.println(String.format("Decompressed test fixture %s: %,d bytes.", BIG_FILE, BIG_FILE.length())); |
| 83 | + } |
85 | 84 | } |
86 | 85 | final int argc = args.length; |
87 | 86 | if (argc > 0) { |
|
0 commit comments