List of usage examples for org.apache.poi.openxml4j.util ZipSecureFile getMinInflateRatio
public static double getMinInflateRatio()
From source file:org.pentaho.di.trans.steps.excelinput.ExcelInputContentParsingTest.java
License:Apache License
@Test public void testZipBombConfiguration_Default() throws Exception { // First set some random values Long bogusMaxEntrySize = 1000L; ZipSecureFile.setMaxEntrySize(bogusMaxEntrySize); Long bogusMaxTextSize = 1000L; ZipSecureFile.setMaxTextSize(bogusMaxTextSize); Double bogusMinInflateRatio = 0.5d; ZipSecureFile.setMinInflateRatio(bogusMinInflateRatio); // Verify that the bogus values were set assertEquals(bogusMaxEntrySize, (Long) ZipSecureFile.getMaxEntrySize()); assertEquals(bogusMaxTextSize, (Long) ZipSecureFile.getMaxTextSize()); assertEquals(bogusMinInflateRatio, (Double) ZipSecureFile.getMinInflateRatio()); // Initializing the ExcelInput step should make the new values to be set meta.setSpreadSheetType(SpreadSheetType.SAX_POI); init("Balance_Type_Codes.xlsx"); // Verify that the default values were used assertEquals(Const.KETTLE_ZIP_MAX_ENTRY_SIZE_DEFAULT, (Long) ZipSecureFile.getMaxEntrySize()); assertEquals(Const.KETTLE_ZIP_MAX_TEXT_SIZE_DEFAULT, (Long) ZipSecureFile.getMaxTextSize()); assertEquals(Const.KETTLE_ZIP_MIN_INFLATE_RATIO_DEFAULT, (Double) ZipSecureFile.getMinInflateRatio()); }
From source file:org.pentaho.di.trans.steps.excelinput.ExcelInputContentParsingTest.java
License:Apache License
@Test public void testZipBombConfiguration() throws Exception { Long maxEntrySizeVal = 3L * 1024 * 1024 * 1024; Long maxTextSizeVal = 2L * 1024 * 1024 * 1024; Double minInflateRatioVal = 0.123d; // First set the property values System.setProperty(Const.KETTLE_ZIP_MAX_ENTRY_SIZE, maxEntrySizeVal.toString()); System.setProperty(Const.KETTLE_ZIP_MAX_TEXT_SIZE, maxTextSizeVal.toString()); System.setProperty(Const.KETTLE_ZIP_MIN_INFLATE_RATIO, minInflateRatioVal.toString()); //ExcelInput excelInput = new ExcelInput( null, null, 0, null, null ); // Initializing the ExcelInput step should make the new values to be set meta.setSpreadSheetType(SpreadSheetType.SAX_POI); init("Balance_Type_Codes.xlsx"); // Verify that the setted values were used assertEquals(maxEntrySizeVal, (Long) ZipSecureFile.getMaxEntrySize()); assertEquals(maxTextSizeVal, (Long) ZipSecureFile.getMaxTextSize()); assertEquals(minInflateRatioVal, (Double) ZipSecureFile.getMinInflateRatio()); }
From source file:org.pentaho.di.trans.steps.excelinput.ExcelInputContentParsingTest.java
License:Apache License
@Test public void testXLSXCompressionRatioIsBig() throws Exception { // For this zip to be correctly handed, we need to allow a lower inflate ratio Double minInflateRatio = 0.007d; System.setProperty(Const.KETTLE_ZIP_MIN_INFLATE_RATIO, minInflateRatio.toString()); meta.setSpreadSheetType(SpreadSheetType.SAX_POI); init("Balance_Type_Codes.xlsx"); // Verify that the minimum allowed inflate ratio is the expected assertEquals(minInflateRatio, (Double) ZipSecureFile.getMinInflateRatio()); setFields(new ExcelInputField("FIST ID", -1, -1), new ExcelInputField("SOURCE SYSTEM", -1, -1)); process();/*from w w w . j a va2 s . co m*/ checkErrors(); checkContent(new Object[][] { { "FIST0200", "ACM" } }); }