REPO-4617 Add missing source types for T-engines (#95)

Update missing sourceMediaType -> targetMediaType for alfresco-pdf-renderer
   Update missing sourceMediaType -> targetMediaType for imagemagick
   Update missing sourceMediaType -> targetMediaType for tika libreoffice
   Update missing sourceMediaType -> targetMediaType for tika
   Update missing sourceMediaType -> targetMediaType for misc transformer
   Add T-engine Integration Tests
   Fix JavaDoc warnings
   Add sample files for tested mimetypes
This commit is contained in:
Alexandru-Eusebiu Epure
2019-09-03 13:34:07 +03:00
committed by GitHub
parent cec236355f
commit bcd6fefe4d
83 changed files with 13928 additions and 204 deletions

View File

@@ -12,7 +12,8 @@
{
"transformerName": "pdfrenderer",
"supportedSourceAndTargetList": [
{"sourceMediaType": "application/pdf", "targetMediaType": "image/png" }
{"sourceMediaType": "application/pdf", "targetMediaType": "image/png" },
{"sourceMediaType": "application/illustrator", "targetMediaType": "image/png" }
],
"transformOptions": [
"pdfRendererOptions"

View File

@@ -26,51 +26,65 @@
*/
package org.alfresco.transformer;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
import static java.text.MessageFormat.format;
import static org.alfresco.transformer.EngineClient.sendTRequest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.springframework.http.HttpStatus.OK;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import com.google.common.collect.ImmutableSet;
/**
* @author Cezar Leahu
*/
public class TransformationIT
@RunWith(Parameterized.class)
public class AlfrescoPdfRendererTransformationIT
{
private static final Logger logger = LoggerFactory.getLogger(TransformationIT.class);
private static final Logger logger = LoggerFactory.getLogger(
AlfrescoPdfRendererTransformationIT.class);
private static final String ENGINE_URL = "http://localhost:8090";
@Test
public void testPdfToPng() throws Exception
private final String sourceFile;
public AlfrescoPdfRendererTransformationIT(String sourceFile)
{
sendTRequest("quick.pdf", "png");
this.sourceFile = sourceFile;
}
private static void sendTRequest(final String sourceFile, final String targetExtension)
@Parameterized.Parameters
public static Set<String> engineTransformations()
{
final RestTemplate restTemplate = new RestTemplate();
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MULTIPART_FORM_DATA);
//headers.setAccept(MULTIPART_FORM_DATA_VALUE);
return ImmutableSet.of(
"quick.pdf",
"quickCS3.ai",
"quickCS5.ai"
);
}
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
body.add("file", new ClassPathResource(sourceFile));
body.add("targetExtension", targetExtension);
@Test
public void testTransformation()
{
final String descriptor = format("Transform ({0} -> png)", sourceFile);
final HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<>(body, headers);
final ResponseEntity<Resource> response = restTemplate.postForEntity(
ENGINE_URL + "/transform",
entity, Resource.class);
logger.info("Response: {}", response);
try
{
final ResponseEntity<Resource> response = sendTRequest(ENGINE_URL, sourceFile, null,
null, "png");
assertEquals(descriptor, OK, response.getStatusCode());
}
catch (Exception e)
{
fail(descriptor + " exception: " + e.getMessage());
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long