Search in sources :

Example 11 with TransformationOptionLimits

use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.

the class TransformerConfigLimitsTest method systemWideDefaultsUsedInTransformersTest.

@Test
public // transformer specific values.
void systemWideDefaultsUsedInTransformersTest() {
    mockProperties(transformerProperties, "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes", "10", "content.transformer.transformer1.maxSourceSizeKBytes", "15", "content.transformer.default.timeoutMs", "120000", "content.transformer.default.extensions.txt.png.pageLimit", "1");
    extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
    TransformationOptionLimits pdfToPngLimits = extractor.getLimits(transformer1, "application/pdf", "image/png", null);
    assertEquals(10, pdfToPngLimits.getMaxSourceSizeKBytes());
    assertEquals(120000L, pdfToPngLimits.getTimeoutMs());
    assertEquals(-1, pdfToPngLimits.getPageLimit());
    TransformationOptionLimits txtToPngLimits = extractor.getLimits(transformer1, "text/plain", "image/png", null);
    assertEquals(15, txtToPngLimits.getMaxSourceSizeKBytes());
    assertEquals(120000L, txtToPngLimits.getTimeoutMs());
    assertEquals(1, txtToPngLimits.getPageLimit());
}
Also used : TransformationOptionLimits(org.alfresco.service.cmr.repository.TransformationOptionLimits) Test(org.junit.Test)

Example 12 with TransformationOptionLimits

use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.

the class TransformerConfigLimitsTest method dontCombineTest.

@Test
public // always specify them in the spring configuration, which was removed in 4.2.
void dontCombineTest() {
    mockProperties(transformerProperties, "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes", "-1", "content.transformer.transformer1.maxSourceSizeKBytes", "20");
    extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
    TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null);
    assertEquals(-1, limits.getMaxSourceSizeKBytes());
}
Also used : TransformationOptionLimits(org.alfresco.service.cmr.repository.TransformationOptionLimits) Test(org.junit.Test)

Example 13 with TransformationOptionLimits

use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.

the class TransformerConfigLimitsTest method bothMaxAndLimitSetIgnoreMaxTest.

@Test
public void bothMaxAndLimitSetIgnoreMaxTest() {
    mockProperties(transformerProperties, "content.transformer.default.readLimitTimeMs", "120000", "content.transformer.default.timeoutMs", "990000");
    extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
    TransformationOptionLimits limits = extractor.getLimits(transformer1, "text/plain", "image/png", null);
    assertEquals(-1L, limits.getTimeoutMs());
    assertEquals(120000L, limits.getReadLimitTimeMs());
}
Also used : TransformationOptionLimits(org.alfresco.service.cmr.repository.TransformationOptionLimits) Test(org.junit.Test)

Example 14 with TransformationOptionLimits

use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.

the class TransformerConfigLimitsTest method systemWideWildcardTest.

@Test
public // Checks wildcard usage at the system wide level
void systemWideWildcardTest() {
    mockProperties(transformerProperties, "content.transformer.transformer1.maxSourceSizeKBytes", "15", "content.transformer.default.timeoutMs", "120000", "content.transformer.default.extensions.txt.*.pageLimit", "1");
    extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
    TransformationOptionLimits txtToPngLimits = extractor.getLimits(transformer1, "text/plain", "image/png", null);
    assertEquals(15, txtToPngLimits.getMaxSourceSizeKBytes());
    assertEquals(120000L, txtToPngLimits.getTimeoutMs());
    assertEquals(1, txtToPngLimits.getPageLimit());
}
Also used : TransformationOptionLimits(org.alfresco.service.cmr.repository.TransformationOptionLimits) Test(org.junit.Test)

Example 15 with TransformationOptionLimits

use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.

the class TransformerConfigLimitsTest method transformerTest.

@Test
public // A value is specified for a transformer
void transformerTest() {
    mockProperties(transformerProperties, "content.transformer.transformer1.maxSourceSizeKBytes", "10");
    extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
    TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null);
    assertEquals(10, limits.getMaxSourceSizeKBytes());
}
Also used : TransformationOptionLimits(org.alfresco.service.cmr.repository.TransformationOptionLimits) Test(org.junit.Test)

Aggregations

TransformationOptionLimits (org.alfresco.service.cmr.repository.TransformationOptionLimits)39 Test (org.junit.Test)22 Map (java.util.Map)3 TransformationOptions (org.alfresco.service.cmr.repository.TransformationOptions)3 TimeoutException (java.util.concurrent.TimeoutException)2 AbstractContentReader (org.alfresco.repo.content.AbstractContentReader)2 ImageResizeOptions (org.alfresco.repo.content.transform.magick.ImageResizeOptions)2 ImageTransformationOptions (org.alfresco.repo.content.transform.magick.ImageTransformationOptions)2 SWFTransformationOptions (org.alfresco.repo.content.transform.swf.SWFTransformationOptions)2 ContentIOException (org.alfresco.service.cmr.repository.ContentIOException)2 TransformationOptionPair (org.alfresco.service.cmr.repository.TransformationOptionPair)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1