use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class BinaryPassThroughContentTransformerTest method testIsTransformable.
public void testIsTransformable() throws Exception {
TransformationOptions options = new TransformationOptions();
boolean reliability = false;
reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_TEXT_PLAIN, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, options);
assertFalse("Mimetype should not be supported", reliability);
reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_XML, -1, MimetypeMap.MIMETYPE_XML, options);
assertFalse("Mimetype should not be supported", reliability);
reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_WORD, -1, MimetypeMap.MIMETYPE_WORD, options);
assertTrue("Mimetype should be supported", reliability);
reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_EXCEL, -1, MimetypeMap.MIMETYPE_EXCEL, options);
assertTrue("Mimetype should be supported", reliability);
}
use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class ContentTransformerRegistryTest method testGetActiveTransformersEnabledDisabled.
public void testGetActiveTransformersEnabledDisabled() throws Exception {
TransformationOptions options = new TransformationOptions();
Assert.assertFalse(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty());
try {
registry.setEnabled(false);
Assert.assertTrue(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty());
} finally {
registry.setEnabled(true);
}
Assert.assertFalse(registry.getActiveTransformers(MIMETYPE_TEXT_PLAIN, -1, MIMETYPE_TEXT_PLAIN, options).isEmpty());
}
use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class TransformerConfigDynamicTransformersTest method pipelineTest.
@Test
public // Simple pipeline
void pipelineTest() {
mockProperties(transformerProperties, "content.transformer.transformerA.pipeline", "transformer1|pdf|transformer2|png|transformer3");
assertEquals(0, new TransformerConfigDynamicTransformers(transformerConfig, transformerProperties, mimetypeService, legacySynchronousTransformClient, transformerRegistry, transformerDebug, null, null, null).getErrorCount());
assertEquals(4, transformerRegistry.getAllTransformers().size());
assertEquals(1, transformerRegistry.getTransformers().size());
// Throws an exception if it does not exist
ContentTransformer trans = transformerRegistry.getTransformer("transformer.transformerA");
// Check the pipeline
ComplexContentTransformer transformer = (ComplexContentTransformer) trans;
assertEquals(2, transformer.getIntermediateMimetypes().size());
assertEquals("application/pdf", transformer.getIntermediateMimetypes().get(0));
assertEquals("image/png", transformer.getIntermediateMimetypes().get(1));
assertEquals(3, transformer.getIntermediateTransformers().size());
assertEquals("transformer.transformer1", transformer.getIntermediateTransformers().get(0).getName());
assertEquals("transformer.transformer2", transformer.getIntermediateTransformers().get(1).getName());
assertEquals("transformer.transformer3", transformer.getIntermediateTransformers().get(2).getName());
//
transformer.isTransformable("application/pdf", -1, "text/txt", new TransformationOptions());
}
use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class StringExtractingContentTransformerTest method testInterTextTransform.
public void testInterTextTransform() throws Exception {
ContentReader reader = writeContent("text/xml", "MacDingbat");
// check transformability
assertTrue(transformer.isTransformable(reader.getMimetype(), -1, targetWriter.getMimetype(), new TransformationOptions()));
// transform
transformer.transform(reader, targetWriter);
// get a reader onto the transformed content and check
ContentReader checkReader = targetWriter.getReader();
String checkContent = checkReader.getContentString();
assertEquals("Content check failed", SOME_CONTENT, checkContent);
}
Aggregations