mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-07 17:48:35 +00:00
ATS-702 Add AIO tests from Pdf Renderer (#233)
* ATS-702 implement AIOControllerTikaTest * ATS-702 Implement PDFIT in AIO
This commit is contained in:
@@ -80,16 +80,23 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<PDF_RENDERER_EXE>/usr/bin/alfresco-pdf-renderer</PDF_RENDERER_EXE>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Transform Core
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
@@ -67,9 +67,9 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -96,15 +96,15 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
||||
private ExecutionResult mockExecutionResult;
|
||||
|
||||
@Mock
|
||||
private RuntimeExec mockTransformCommand;
|
||||
protected RuntimeExec mockTransformCommand;
|
||||
|
||||
@Mock
|
||||
private RuntimeExec mockCheckCommand;
|
||||
protected RuntimeExec mockCheckCommand;
|
||||
|
||||
@Value("${transform.core.pdfrenderer.exe}")
|
||||
private String execPath;
|
||||
protected String execPath;
|
||||
|
||||
PdfRendererCommandExecutor commandExecutor;
|
||||
protected PdfRendererCommandExecutor commandExecutor;
|
||||
|
||||
@PostConstruct
|
||||
private void init()
|
||||
@@ -112,17 +112,22 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
||||
commandExecutor = new PdfRendererCommandExecutor(execPath);
|
||||
}
|
||||
|
||||
@SpyBean
|
||||
private AlfrescoPdfRendererController controller;
|
||||
@Autowired
|
||||
protected AbstractTransformerController controller;
|
||||
|
||||
@Before
|
||||
public void before() throws IOException
|
||||
{
|
||||
setFields();
|
||||
|
||||
mockTransformCommand("pdf", "png", APPLICATION_PDF_VALUE, true);
|
||||
}
|
||||
|
||||
protected void setFields()
|
||||
{
|
||||
ReflectionTestUtils.setField(commandExecutor, "transformCommand", mockTransformCommand);
|
||||
ReflectionTestUtils.setField(commandExecutor, "checkCommand", mockCheckCommand);
|
||||
ReflectionTestUtils.setField(controller, "commandExecutor", commandExecutor);
|
||||
|
||||
mockTransformCommand("pdf", "png", "application/pdf", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,6 +144,7 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
||||
this.sourceExtension = sourceExtension;
|
||||
this.targetExtension = targetExtension;
|
||||
this.sourceMimetype = sourceMimetype;
|
||||
this.targetMimetype = IMAGE_PNG_VALUE;
|
||||
|
||||
expectedOptions = null;
|
||||
expectedSourceSuffix = null;
|
||||
@@ -220,6 +226,8 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
||||
.multipart("/transform")
|
||||
.file(sourceFile)
|
||||
.param("targetExtension", targetExtension)
|
||||
.param("targetMimetype", targetMimetype)
|
||||
.param("sourceMimetype", sourceMimetype)
|
||||
|
||||
.param("page", "2")
|
||||
|
||||
@@ -242,6 +250,8 @@ public class AlfrescoPdfRendererControllerTest extends AbstractTransformerContro
|
||||
.multipart("/transform")
|
||||
.file(sourceFile)
|
||||
.param("targetExtension", targetExtension)
|
||||
.param("targetMimetype", targetMimetype)
|
||||
.param("sourceMimetype", sourceMimetype)
|
||||
|
||||
.param("page", "2")
|
||||
|
||||
|
@@ -27,12 +27,17 @@
|
||||
package org.alfresco.transformer;
|
||||
|
||||
import static java.text.MessageFormat.format;
|
||||
import static java.util.function.Function.identity;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
import static org.alfresco.transformer.EngineClient.sendTRequest;
|
||||
import static org.alfresco.transformer.TestFileInfo.testFile;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -54,11 +59,19 @@ public class AlfrescoPdfRendererTransformationIT
|
||||
AlfrescoPdfRendererTransformationIT.class);
|
||||
private static final String ENGINE_URL = "http://localhost:8090";
|
||||
|
||||
private static final Map<String, TestFileInfo> TEST_FILES = Stream.of(
|
||||
testFile("application/pdf","pdf","quick.pdf"),
|
||||
testFile("application/illustrator","ai","quickCS3.ai") ,
|
||||
testFile("application/illustrator","ai","quickCS5.ai")
|
||||
).collect(toMap(TestFileInfo::getPath, identity()));
|
||||
|
||||
private final String sourceFile;
|
||||
private final String sourceMimetype;
|
||||
|
||||
public AlfrescoPdfRendererTransformationIT(String sourceFile)
|
||||
{
|
||||
this.sourceFile = sourceFile;
|
||||
this.sourceMimetype = TEST_FILES.get(sourceFile).getMimeType();
|
||||
}
|
||||
|
||||
@Parameterized.Parameters
|
||||
@@ -74,12 +87,13 @@ public class AlfrescoPdfRendererTransformationIT
|
||||
@Test
|
||||
public void testTransformation()
|
||||
{
|
||||
final String descriptor = format("Transform ({0} -> png)", sourceFile);
|
||||
final String descriptor = format("Transform ({0}, {1} -> {2}, {3})",
|
||||
sourceFile, sourceMimetype, "image/png", "png");
|
||||
|
||||
try
|
||||
{
|
||||
final ResponseEntity<Resource> response = sendTRequest(ENGINE_URL, sourceFile, null,
|
||||
null, "png");
|
||||
final ResponseEntity<Resource> response = sendTRequest(ENGINE_URL, sourceFile, sourceMimetype,
|
||||
"image/png", "png");
|
||||
assertEquals(descriptor, OK, response.getStatusCode());
|
||||
}
|
||||
catch (Exception e)
|
||||
|
Reference in New Issue
Block a user