use of org.alfresco.service.cmr.rendition.CompositeRenditionDefinition in project alfresco-repository by Alfresco.
the class RenditionServiceIntegrationTest method testCompositeReformatAndResizeRendition.
@Test
public void testCompositeReformatAndResizeRendition() throws Exception {
final QName renditionName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "composite");
final int newX = 20;
final int newY = 30;
renditionNode = transactionHelper.doInTransaction(new //
RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>() {
public NodeRef execute() throws Throwable {
CompositeRenditionDefinition compositeDefinition = makeCompositeReformatAndResizeDefinition(renditionName, newX, newY);
ChildAssociationRef renditionAssoc = renditionService.render(nodeWithDocContent, compositeDefinition);
validateRenditionAssociation(renditionAssoc, renditionName);
return renditionAssoc.getChildRef();
}
});
transactionHelper.doInTransaction(new //
RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
public Void execute() throws Throwable {
List<ChildAssociationRef> renditions = renditionService.getRenditions(nodeWithDocContent);
assertEquals("There should only be one rendition", 1, renditions.size());
ChildAssociationRef renditionAssoc = renditions.get(0);
assertEquals("The association name should match the composite rendition name", renditionName, renditionAssoc.getQName());
NodeRef rendition = renditionAssoc.getChildRef();
ContentReader reader = contentService.getReader(rendition, ContentModel.PROP_CONTENT);
assertEquals("The mimetype is wrong", MimetypeMap.MIMETYPE_IMAGE_JPEG, reader.getMimetype());
assertNotNull("Reader to rendered image was null", reader);
BufferedImage img = ImageIO.read(reader.getContentInputStream());
assertEquals("Rendered image had wrong height", newY, img.getHeight());
assertEquals("Rendered image had wrong width", newX, img.getWidth());
return null;
}
});
}
Aggregations