@VisibleForTesting public void getSegmentFiles(DataSegment segment, File dir) throws SegmentLoadingException { getSegmentFiles(getFile(segment), dir); }
@Override public LoadSpecResult loadSegment(final File outDir) throws SegmentLoadingException { return new LoadSpecResult(puller.getSegmentFiles(path.toFile(), outDir).size()); } }
@Test public void simpleDirectoryTest() throws IOException, SegmentLoadingException { File srcDir = temporaryFolder.newFolder(); File tmpFile = File.createTempFile("test", "file", srcDir); File expectedOutput = new File(tmpDir, Files.getNameWithoutExtension(tmpFile.getAbsolutePath())); Assert.assertFalse(expectedOutput.exists()); puller.getSegmentFiles(srcDir, tmpDir); Assert.assertTrue(expectedOutput.exists()); } }
@Test public void simpleGZTest() throws IOException, SegmentLoadingException { File zipFile = File.createTempFile("gztest", ".gz"); File unZipFile = new File( tmpDir, Files.getNameWithoutExtension( zipFile.getAbsolutePath() ) ); unZipFile.delete(); zipFile.delete(); try (OutputStream fOutStream = new FileOutputStream(zipFile)) { try (OutputStream outputStream = new GZIPOutputStream(fOutStream)) { outputStream.write(new byte[0]); outputStream.flush(); } } Assert.assertTrue(zipFile.exists()); Assert.assertFalse(unZipFile.exists()); puller.getSegmentFiles(zipFile, tmpDir); Assert.assertTrue(unZipFile.exists()); }
@Test public void simpleZipTest() throws IOException, SegmentLoadingException { File file = new File(tmpDir, "test1data"); File zipFile = temporaryFolder.newFile("ziptest.zip"); try (OutputStream outputStream = new FileOutputStream(file)) { outputStream.write(new byte[0]); outputStream.flush(); } CompressionUtils.zip(tmpDir, zipFile); file.delete(); Assert.assertFalse(file.exists()); Assert.assertTrue(zipFile.exists()); puller.getSegmentFiles(zipFile, tmpDir); Assert.assertTrue(file.exists()); }
@VisibleForTesting public void getSegmentFiles(DataSegment segment, File dir) throws SegmentLoadingException { getSegmentFiles(getFile(segment), dir); }
@Override public LoadSpecResult loadSegment(final File outDir) throws SegmentLoadingException { return new LoadSpecResult(puller.getSegmentFiles(path.toFile(), outDir).size()); } }