Example usage for org.apache.poi.openxml4j.util ZipSecureFile getMaxTextSize

List of usage examples for org.apache.poi.openxml4j.util ZipSecureFile getMaxTextSize

Introduction

In this page you can find the example usage for org.apache.poi.openxml4j.util ZipSecureFile getMaxTextSize.

Prototype

public static long getMaxTextSize() 

Source Link

Document

Returns the current maximum allowed text size.

Usage

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());
}