@Test public void testFileUncompress() throws Throwable { String resources = getClass().getResource("/zip").toURI().getPath(); LOG.info("Resources folder: " + resources); String zipFile = resources + "/test_uncompress.zip"; ZipInputStream zipInputStream = FileRuntimeHelper.getZipInputStream(zipFile); int entryCount = 0; List<String> entries = Arrays.asList("folder_1/file_1_1.txt", "folder_1/file_1_2.csv", "folder_2/file_2_1.txt", "folder_2/file_2_2.csv", "test.txt"); while (true) { ZipEntry entry = FileRuntimeHelper.getCurrentZipEntry(zipInputStream); if (entry == null) { break; } entryCount++; LOG.debug("Entry name: " + entry.getName()); Assert.assertTrue(entries.contains(entry.getName())); } LOG.debug("Entries count: " + entryCount); Assert.assertEquals(5, entryCount); } }
public void init() throws IOException { fileNameOrStream = props.fileName.getValue(); sourceIsStream = fileNameOrStream instanceof InputStream; encoding = getEncoding(); schemaIsDynamic = AvroUtils.isIncludeAllFields(props.main.schema.getValue()); header = (props.header.getValue() == null) ? -1 : props.header.getValue(); if (schemaIsDynamic) { header = header - 1; } if (props instanceof TFileInputDelimitedProperties) { uncompress = ((TFileInputDelimitedProperties) props).uncompress.getValue(); splitRecord = ((TFileInputDelimitedProperties) props).splitRecord.getValue(); if (((TFileInputDelimitedProperties) props).random.getValue()) { nbRandom = (((TFileInputDelimitedProperties) props).nbRandom.getValue() == null || uncompress) ? -1 : ((TFileInputDelimitedProperties) props).nbRandom.getValue(); } } footer = (props.footer.getValue() == null || uncompress) ? -1 : props.footer.getValue(); limit = (props.limit.getValue() == null) ? -1 : props.limit.getValue(); if (sourceIsStream) { zipInputStream = FileRuntimeHelper.getZipInputStream((InputStream) fileNameOrStream); } else { zipInputStream = FileRuntimeHelper.getZipInputStream(String.valueOf(fileNameOrStream)); } fieldSeparator = getFieldSeparator(); rowSeparator = getRowSeparator(); setEscapeAndTextEnclosure(props.escapeChar.getValue(), props.textEnclosure.getValue()); }