Search in sources :

Example 31 with TransformationOptionLimits

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

the class TransformerConfigLimitsTest method propertyOrderJava7Test.

// MNT-14295 With Java 7 the order in which properties were supplied changed from
// what happen with Java 6 and happens with 8. When combined with a bug to do with
// always clearing the max value when setting a limit or the limit when setting
// the max value, the initial map of TransformerConfigLimits would be different.
// Java 7 was used as the runtime for 4.2 and the 5.0 but Java 8 became the default
// from 5.0.1.
// None of the other unit tests in this class failed as a none of them provided
// both max and limit values.
@Test
public void propertyOrderJava7Test() {
    mockProperties(transformerProperties, "content.transformer.default.timeoutMs", "120000", "content.transformer.default.readLimitTimeMs", "-1");
    extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
    TransformationOptionLimits limits = extractor.getLimits(transformer1, "text/plain", "image/png", null);
    assertEquals(120000L, limits.getTimeoutMs());
    assertEquals(-1L, limits.getReadLimitTimeMs());
}
Also used : TransformationOptionLimits(org.alfresco.service.cmr.repository.TransformationOptionLimits) Test(org.junit.Test)

Example 32 with TransformationOptionLimits

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

the class TransformerConfigLimitsTest method defaultTest.

@Test
public // A value is specified as a transformer default without mimetypes
void defaultTest() {
    mockProperties(transformerProperties, "content.transformer.default.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)

Example 33 with TransformationOptionLimits

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

the class TransformerConfigLimitsTest method transformerWildcardTest.

@Test
public // Checks wildcard usage at the transformer level
void transformerWildcardTest() {
    mockProperties(transformerProperties, "content.transformer.transformer1.extensions.*.png.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)

Example 34 with TransformationOptionLimits

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

the class TransformerConfigLimitsTest method bothMaxAndLimitSetIgnoreLimitTest.

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

Example 35 with TransformationOptionLimits

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

the class TransformerConfigLimitsTest method transformerMimetypesUseTest.

// ---------------------------------------
@Test
public // A value is specified for a transformer, mimetypes and use
void transformerMimetypesUseTest() {
    mockProperties(transformerProperties, "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes", "10", "content.transformer.transformer1.extensions.pdf.png.maxSourceSizeKBytes.use.index", "20");
    extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
    TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null);
    assertEquals(10, limits.getMaxSourceSizeKBytes());
    limits = extractor.getLimits(transformer1, "application/pdf", "image/png", "index");
    assertEquals(20, 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