use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class PoiOOXMLContentTransformerTest method testMnt12043.
/**
* MNT-12043: CLONE - Upload of PPTX causes very high memory usage leading to system instability
*
* @throws Exception
*/
public void testMnt12043() throws Exception {
transformer.setMimetypeService(mimetypeService);
transformer.setAdditionalThreadTimout(0);
configureExtractorLimits(transformer, SMALL_TIMEOUT);
File sourceFile = AbstractContentTransformerTest.loadNamedQuickTestFile(TEST_PPTX_FILE_NAME);
ContentReader sourceReader = new FileContentReader(sourceFile) {
@Override
public void setLimits(TransformationOptionLimits limits) {
// Test without content reader input stream timeout limits
}
};
sourceReader.setMimetype(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION);
ContentWriter tempWriter = AuthenticationUtil.runAs(new RunAsWork<ContentWriter>() {
@Override
public ContentWriter doWork() throws Exception {
ContentWriter result = contentService.getTempWriter();
result.setEncoding(ENCODING_UTF_8);
result.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
return result;
}
}, AuthenticationUtil.getAdminUserName());
long startTime = System.currentTimeMillis();
try {
transformer.transform(sourceReader, tempWriter);
// should not get here unless transform is too fast
long transformationTime = System.currentTimeMillis() - startTime;
fail("Content transformation took " + transformationTime + " ms, but should have failed with a timeout at " + SMALL_TIMEOUT + " ms");
} catch (ContentIOException e) {
long transformationTime = System.currentTimeMillis() - startTime;
assertTrue((TimeoutException.class.getName() + " exception is expected as the cause of transformation failure"), e.getCause() instanceof TimeoutException);
// Not sure we can have the following assert as we may have introduced an intermittent test failure. Already seen a time of 1009ms
assertTrue(("Failed content transformation took " + transformationTime + " ms, but should have failed with a timeout at " + SMALL_TIMEOUT + " ms"), transformationTime <= (SMALL_TIMEOUT + ADDITIONAL_PROCESSING_TIME));
}
assertFalse("Readable channel was not closed after transformation attempt!", sourceReader.isChannelOpen());
assertFalse("Writable channel was not closed after transformation attempt!", tempWriter.isChannelOpen());
}
use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class TransformerConfigLimitsTest method defaultMimetypesUseTest.
@Test
public // A value is specified as a transformer default with mimetypes and use
void defaultMimetypesUseTest() {
mockProperties(transformerProperties, "content.transformer.default.extensions.pdf.png.maxSourceSizeKBytes", "10", "content.transformer.default.extensions.pdf.png.maxSourceSizeKBytes.use.index", "20", // The following is ignored when "index" is specified, as the 'use' property is system wide.
"content.transformer.transformer2.maxSourceSizeKBytes", "30");
extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null);
assertEquals(10, limits.getMaxSourceSizeKBytes());
limits = extractor.getLimits(transformer2, "application/pdf", "image/png", "doclib");
assertEquals(30, limits.getMaxSourceSizeKBytes());
limits = extractor.getLimits(transformer2, "application/pdf", "image/png", "index");
assertEquals(20, limits.getMaxSourceSizeKBytes());
}
use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class TransformerConfigLimitsTest method propertyOrderJava8or6Test.
@Test
public void propertyOrderJava8or6Test() {
mockProperties(transformerProperties, "content.transformer.default.timeoutMs", "-1", "content.transformer.default.readLimitTimeMs", "120000");
extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
TransformationOptionLimits limits = extractor.getLimits(transformer1, "text/plain", "image/png", null);
assertEquals(-1L, limits.getTimeoutMs());
assertEquals(120000L, limits.getReadLimitTimeMs());
}
use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class TransformerConfigLimitsTest method transformerUseTest.
@Test
public // A value is specified for a transformer and use
void transformerUseTest() {
mockProperties(transformerProperties, "content.transformer.transformer2.maxSourceSizeKBytes", "10", "content.transformer.transformer1.maxSourceSizeKBytes.use.index", "20", // The following is ignored when "index" is specified, as the 'use' property is transformer wide.
"content.transformer.transformer1.maxSourceSizeKBytes", "30");
extractor = new TransformerConfigLimits(transformerProperties, mimetypeService);
TransformationOptionLimits limits = extractor.getLimits(transformer1, "application/pdf", "image/png", null);
assertEquals(30, limits.getMaxSourceSizeKBytes());
limits = extractor.getLimits(transformer1, "application/pdf", "image/png", "index");
assertEquals(20, limits.getMaxSourceSizeKBytes());
limits = extractor.getLimits(transformer2, "application/pdf", "image/png", "index");
assertEquals(10, limits.getMaxSourceSizeKBytes());
}
use of org.alfresco.service.cmr.repository.TransformationOptionLimits in project alfresco-repository by Alfresco.
the class TransformerConfigLimitsTest method defaultUseTest.
@Test
public // A value is specified as a transformer default without mimetypes but with a use
void defaultUseTest() {
mockProperties(transformerProperties, "content.transformer.default.maxSourceSizeKBytes", "10", "content.transformer.default.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());
}
Aggregations