mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-05-26 17:24:47 +00:00
ATS-702: Add AIO tests from LibreOffice (#231)
Created test-jar for libreoffice-boot Updated LibreOfficeControllerTest.java so it can provide inheritance Updated LibreOfficeControllerTest#testPojoTransform to uses a viable targetMimetype Fixed inconsitent naming for @Value annotation Moved surefire config to super pom Implement LibreOfficeIT on AIO Controller
This commit is contained in:
parent
6320e04b64
commit
410997689f
@ -62,6 +62,14 @@
|
||||
<scope>test</scope>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-transform-libreoffice-boot</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>tests</classifier>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -73,12 +73,8 @@ public class AIOControllerImageMagickTest extends ImageMagickControllerTest
|
||||
ReflectionTestUtils.setField(commandExecutor, "checkCommand", mockCheckCommand);
|
||||
ReflectionTestUtils.setField(adapter, "commandExecutor", commandExecutor);
|
||||
//Need to wire in the mocked adapter into the controller...
|
||||
if (ReflectionTestUtils.getField(transformRegistry,"transformerTransformMapping") instanceof Map)
|
||||
{
|
||||
Map<String,Transformer> transformers = transformRegistry.getTransformerTransformMapping();
|
||||
transformers.replace("imagemagick", adapter);
|
||||
ReflectionTestUtils.setField(transformRegistry, "transformerTransformMapping", transformers);
|
||||
}
|
||||
Map<String,Transformer> transformers = transformRegistry.getTransformerTransformMapping();
|
||||
transformers.replace("imagemagick", adapter);
|
||||
|
||||
mockTransformCommand("jpg", "png", "image/jpeg", true);
|
||||
}
|
||||
|
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Transform Core
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.transformer;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.alfresco.transformer.executors.LibreOfficeJavaExecutor;
|
||||
import org.alfresco.transformer.transformers.LibreOfficeAdapter;
|
||||
import org.alfresco.transformer.transformers.Transformer;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebMvcTest(AIOController.class)
|
||||
@Import(AIOCustomConfig.class)
|
||||
/**
|
||||
* Test the AIOController without a server.
|
||||
* Super class includes tests for the LibreOfficeController and AbstractTransformerController.
|
||||
*/
|
||||
public class AIOControllerLibreOfficeTest extends LibreOfficeControllerTest
|
||||
{
|
||||
|
||||
//Tests contained in LibreOfficeControllerTest
|
||||
|
||||
@Test
|
||||
public void testTestValidity()
|
||||
{
|
||||
// just test that we are actually testing against the AIOController (instead of MiscController)
|
||||
assertTrue("Wrong controller wired for test", controller instanceof AIOController);
|
||||
}
|
||||
|
||||
LibreOfficeAdapter adapter;
|
||||
|
||||
@Autowired
|
||||
AIOTransformRegistry transformRegistry;
|
||||
|
||||
@PostConstruct
|
||||
private void init() throws Exception
|
||||
{
|
||||
adapter = new LibreOfficeAdapter(execPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
// Used by the super class to mock the javaExecutor, a different implementation is required here
|
||||
protected void setJavaExecutor(AbstractTransformerController controller, LibreOfficeJavaExecutor javaExecutor)
|
||||
{
|
||||
ReflectionTestUtils.setField(adapter, "javaExecutor", javaExecutor);
|
||||
//Need to wire in the mocked adapter into the controller...
|
||||
Map<String,Transformer> transformers = transformRegistry.getTransformerTransformMapping();
|
||||
transformers.replace("libreoffice", adapter);
|
||||
// No need to set the transform registry to the controller as it is @Autowired in
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
|
||||
String... params)
|
||||
{
|
||||
final MockHttpServletRequestBuilder builder = super.mockMvcRequest(url, sourceFile, params)
|
||||
.param("targetMimetype", targetMimetype)
|
||||
.param("sourceMimetype", sourceMimetype);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testGetTransformConfigInfo()
|
||||
{
|
||||
// Ignore the test in super class as the way the AIO transformer provides config is fundementally different.
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testGetInfoFromConfigWithDuplicates()
|
||||
{
|
||||
// Ignore the test in super class as the way the AIO transformer provides config is fundementally different.
|
||||
|
||||
}
|
||||
@Test
|
||||
@Override
|
||||
public void testGetInfoFromConfigWithEmptyTransformOptions()
|
||||
{
|
||||
// Ignore the test in super class as the way the AIO transformer provides config is fundementally different.
|
||||
|
||||
}
|
||||
@Test
|
||||
@Override
|
||||
public void testGetInfoFromConfigWithNoTransformOptions()
|
||||
{
|
||||
// Ignore the test in super class as the way the AIO transformer provides config is fundementally different.
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Transform Core
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.transformer;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class AIOLibreOfficeTransformationIT extends LibreOfficeTransformationIT
|
||||
{
|
||||
|
||||
public AIOLibreOfficeTransformationIT(final Pair<TestFileInfo, TestFileInfo> entry)
|
||||
{
|
||||
super(entry);
|
||||
}
|
||||
}
|
@ -142,7 +142,7 @@ public class ImageMagickTransformationIT
|
||||
testFile(MIMETYPE_IMAGE_XBM,"xbm","quick.xbm"),
|
||||
testFile(MIMETYPE_IMAGE_XPM,"xpm","quick.xpm"),
|
||||
testFile(MIMETYPE_IMAGE_XWD,"xwd","quick.xwd")
|
||||
).collect(toMap(TestFileInfo::getPath, identity()));;
|
||||
).collect(toMap(TestFileInfo::getPath, identity()));
|
||||
|
||||
private final String sourceFile;
|
||||
private final String targetExtension;
|
||||
|
@ -91,16 +91,23 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<LIBREOFFICE_HOME>/opt/libreoffice6.3</LIBREOFFICE_HOME>
|
||||
</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>
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class LibreOfficeController extends AbstractTransformerController
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(LibreOfficeController.class);
|
||||
|
||||
@Value("${transform.core.libreoffice.home}")
|
||||
@Value("${transform.core.libreoffice.path}")
|
||||
private String execPath;
|
||||
|
||||
LibreOfficeJavaExecutor javaExecutor;
|
||||
|
@ -5,4 +5,4 @@ transform:
|
||||
config:
|
||||
location: classpath:libreoffice_engine_config.json
|
||||
libreoffice:
|
||||
home: ${LIBREOFFICE_HOME:/opt/libreoffice6.3}
|
||||
path: ${LIBREOFFICE_HOME:/opt/libreoffice6.3}
|
@ -26,6 +26,10 @@
|
||||
*/
|
||||
package org.alfresco.transformer;
|
||||
|
||||
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_MIMETYPE;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.TARGET_EXTENSION;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.TARGET_MIMETYPE;
|
||||
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_PDF;
|
||||
import static org.alfresco.transformer.executors.RuntimeExec.ExecutionResult;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -63,9 +67,9 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
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;
|
||||
@ -82,19 +86,20 @@ import javax.annotation.PostConstruct;
|
||||
* Super class includes tests for the AbstractTransformerController.
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebMvcTest(LibreOfficeControllerTest.class)
|
||||
@WebMvcTest(LibreOfficeController.class)
|
||||
public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
||||
{
|
||||
|
||||
private static final String ENGINE_CONFIG_NAME = "libreoffice_engine_config.json";
|
||||
protected static final String ENGINE_CONFIG_NAME = "libreoffice_engine_config.json";
|
||||
protected String targetMimetype = MIMETYPE_PDF;
|
||||
|
||||
@Mock
|
||||
private ExecutionResult mockExecutionResult;
|
||||
protected ExecutionResult mockExecutionResult;
|
||||
|
||||
@Value("${transform.core.libreoffice.home}")
|
||||
private String execPath;
|
||||
@Value("${transform.core.libreoffice.path}")
|
||||
protected String execPath;
|
||||
|
||||
LibreOfficeJavaExecutor javaExecutor;
|
||||
protected LibreOfficeJavaExecutor javaExecutor;
|
||||
|
||||
@PostConstruct
|
||||
private void init()
|
||||
@ -102,8 +107,8 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
||||
javaExecutor = Mockito.spy(new LibreOfficeJavaExecutor(execPath));
|
||||
}
|
||||
|
||||
@SpyBean
|
||||
private LibreOfficeController controller;
|
||||
@Autowired
|
||||
protected AbstractTransformerController controller;
|
||||
|
||||
@Before
|
||||
public void before() throws IOException
|
||||
@ -112,7 +117,7 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
||||
targetExtension = "pdf";
|
||||
sourceMimetype = "application/msword";
|
||||
|
||||
ReflectionTestUtils.setField(controller, "javaExecutor", javaExecutor);
|
||||
setJavaExecutor(controller,javaExecutor);
|
||||
|
||||
// The following is based on super.mockTransformCommand(...)
|
||||
// This is because LibreOffice used JodConverter rather than a RuntimeExec
|
||||
@ -152,6 +157,12 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
||||
}).when(javaExecutor).convert(any(), any());
|
||||
}
|
||||
|
||||
|
||||
protected void setJavaExecutor(AbstractTransformerController controller, LibreOfficeJavaExecutor javaExecutor)
|
||||
{
|
||||
ReflectionTestUtils.setField(controller, "javaExecutor", javaExecutor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEngineConfigName()
|
||||
{
|
||||
@ -180,10 +191,12 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
||||
.perform(MockMvcRequestBuilders
|
||||
.multipart("/transform")
|
||||
.file(sourceFile)
|
||||
.param("targetExtension", "xxx"))
|
||||
.param(TARGET_EXTENSION, "xxx")
|
||||
.param(SOURCE_MIMETYPE,sourceMimetype)
|
||||
.param(TARGET_MIMETYPE,targetMimetype))
|
||||
.andExpect(status().is(400))
|
||||
.andExpect(status().reason(
|
||||
containsString("LibreOffice - LibreOffice server conversion failed:")));
|
||||
containsString("LibreOffice server conversion failed:")));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -192,7 +205,7 @@ public class LibreOfficeControllerTest extends AbstractTransformerControllerTest
|
||||
transformRequest.setSourceExtension("doc");
|
||||
transformRequest.setTargetExtension("pdf");
|
||||
transformRequest.setSourceMediaType("application/msword");
|
||||
transformRequest.setTargetMediaType(IMAGE_PNG_VALUE);
|
||||
transformRequest.setTargetMediaType(targetMimetype);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -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.
|
||||
* -
|
||||
@ -28,15 +28,39 @@ 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 java.util.stream.Collectors.toSet;
|
||||
import static org.alfresco.transformer.EngineClient.sendTRequest;
|
||||
import static org.alfresco.transformer.TestFileInfo.testFile;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_EXCEL;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_HTML;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_SVG;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_OPENDOCUMENT_GRAPHICS;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_OPENDOCUMENT_PRESENTATION;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_OPENDOCUMENT_SPREADSHEET;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_OPENDOCUMENT_TEXT;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_OPENXML_PRESENTATION;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_PDF;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_PPT;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_RTF;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_TEXT_CSV;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_TSV;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_VISIO;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_VISIO_2013;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_WORD;
|
||||
import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_WORDPERFECT;
|
||||
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 com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -46,8 +70,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Cezar Leahu
|
||||
*/
|
||||
@ -56,47 +78,93 @@ public class LibreOfficeTransformationIT
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(LibreOfficeTransformationIT.class);
|
||||
private static final String ENGINE_URL = "http://localhost:8090";
|
||||
private static final Set<String> spreadsheetTargetMimetypes = ImmutableSet.of(
|
||||
"csv", "html", "ods", "pdf", "tsv", "xls");
|
||||
private static final Set<String> documentsTargetMimetypes = ImmutableSet.of(
|
||||
"doc", "html", "odt", "pdf", "rtf");
|
||||
private static final Set<String> graphicTargetMimetypes = ImmutableSet.of(
|
||||
"pdf", "svg");
|
||||
private static final Set<String> presentationTargetMimetypes = ImmutableSet.of(
|
||||
"html", "odp", "ppt", "pdf");
|
||||
private static final Set<TestFileInfo> spreadsheetTargets = ImmutableSet.of(
|
||||
testFile(MIMETYPE_TEXT_CSV, "csv",null),
|
||||
testFile(MIMETYPE_HTML,"html",null),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_SPREADSHEET,"ods",null),
|
||||
testFile(MIMETYPE_PDF,"pdf",null),
|
||||
testFile(MIMETYPE_TSV,"tsv",null),
|
||||
testFile(MIMETYPE_EXCEL,"xls",null)
|
||||
);
|
||||
|
||||
private static final Set<TestFileInfo> documentsTargets = ImmutableSet.of(
|
||||
testFile(MIMETYPE_WORD,"doc",null),
|
||||
testFile(MIMETYPE_HTML,"html",null),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_TEXT,"odt",null),
|
||||
testFile(MIMETYPE_PDF,"pdf",null),
|
||||
testFile(MIMETYPE_RTF,"rtf",null)
|
||||
);
|
||||
|
||||
private static final Set<TestFileInfo> graphicTargets = ImmutableSet.of(
|
||||
testFile(MIMETYPE_PDF,"pdf",null),
|
||||
testFile(MIMETYPE_IMAGE_SVG,"svg",null)
|
||||
);
|
||||
|
||||
private static final Set<TestFileInfo> presentationTargets = ImmutableSet.of(
|
||||
testFile(MIMETYPE_HTML,"html",null),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_PRESENTATION,"odp",null),
|
||||
testFile(MIMETYPE_PPT,"ppt",null),
|
||||
testFile(MIMETYPE_PDF,"pdf",null)
|
||||
);
|
||||
|
||||
private final String sourceFile;
|
||||
private final String targetExtension;
|
||||
private final String sourceMimetype;
|
||||
private final String targetMimetype;
|
||||
|
||||
public LibreOfficeTransformationIT(final Pair<String, String> entry)
|
||||
private static final Map<String,TestFileInfo> TEST_FILES = Stream.of(
|
||||
testFile(MIMETYPE_WORD ,"doc" ,"quick.doc"),
|
||||
testFile(MIMETYPE_OPENXML_WORDPROCESSING ,"docx" ,"quick.docx"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS ,"odg" ,"quick.odg"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_PRESENTATION ,"odp" ,"quick.odp"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_SPREADSHEET ,"ods" ,"quick.ods"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_TEXT ,"odt" ,"quick.odt"),
|
||||
testFile(MIMETYPE_PPT ,"ppt" ,"quick.ppt"),
|
||||
testFile(MIMETYPE_OPENXML_PRESENTATION ,"pptx" ,"quick.pptx"),
|
||||
testFile(MIMETYPE_VISIO ,"vdx" ,"quick.vdx"),
|
||||
testFile(MIMETYPE_VISIO_2013 ,"vsd" ,"quick.vsd"),
|
||||
testFile(MIMETYPE_WORDPERFECT ,"wpd" ,"quick.wpd"),
|
||||
testFile(MIMETYPE_EXCEL ,"xls" ,"quick.xls" ),
|
||||
testFile(MIMETYPE_OPENXML_SPREADSHEET ,"xlsx" ,"quick.xlsx"),
|
||||
testFile(MIMETYPE_TEXT_CSV ,"csv" ,"people.csv"),
|
||||
testFile(MIMETYPE_RTF ,"rtf" ,"sample.rtf"),
|
||||
testFile(MIMETYPE_HTML ,"html" ,"quick.html"),
|
||||
testFile(MIMETYPE_TSV ,"tsv" ,"sample.tsv")
|
||||
).collect(toMap(TestFileInfo::getPath, identity()));
|
||||
|
||||
public LibreOfficeTransformationIT(final Pair<TestFileInfo, TestFileInfo> entry)
|
||||
{
|
||||
sourceFile = entry.getKey();
|
||||
targetExtension = entry.getRight();
|
||||
sourceFile = entry.getLeft().getPath();
|
||||
targetExtension = entry.getRight().getExtension();
|
||||
sourceMimetype = entry.getLeft().getMimeType();
|
||||
targetMimetype = entry.getRight().getMimeType();
|
||||
}
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Set<Pair<String, String>> engineTransformations()
|
||||
public static Set<Pair<TestFileInfo, TestFileInfo>> engineTransformations()
|
||||
{
|
||||
return Stream
|
||||
.of(
|
||||
allTargets("quick.doc", documentsTargetMimetypes),
|
||||
allTargets("quick.docx", documentsTargetMimetypes),
|
||||
allTargets("quick.odg", graphicTargetMimetypes),
|
||||
allTargets("quick.odp", presentationTargetMimetypes),
|
||||
allTargets("quick.ods", spreadsheetTargetMimetypes),
|
||||
allTargets("quick.odt", documentsTargetMimetypes),
|
||||
allTargets("quick.ppt", presentationTargetMimetypes),
|
||||
allTargets("quick.pptx", presentationTargetMimetypes),
|
||||
allTargets("quick.vdx", graphicTargetMimetypes),
|
||||
allTargets("quick.vsd", graphicTargetMimetypes),
|
||||
allTargets("quick.wpd", documentsTargetMimetypes),
|
||||
allTargets("quick.xls", spreadsheetTargetMimetypes),
|
||||
allTargets("quick.xlsx", spreadsheetTargetMimetypes),
|
||||
allTargets("quick.doc", documentsTargets),
|
||||
allTargets("quick.docx", documentsTargets),
|
||||
allTargets("quick.html", documentsTargets),
|
||||
allTargets("quick.odt", documentsTargets),
|
||||
allTargets("quick.wpd", documentsTargets),
|
||||
allTargets("sample.rtf", documentsTargets),
|
||||
|
||||
allTargets("people.csv", spreadsheetTargetMimetypes),
|
||||
allTargets("sample.rtf", documentsTargetMimetypes),
|
||||
allTargets("quick.html", documentsTargetMimetypes),
|
||||
allTargets("sample.tsv", spreadsheetTargetMimetypes)
|
||||
allTargets("quick.odp", presentationTargets),
|
||||
allTargets("quick.ppt", presentationTargets),
|
||||
allTargets("quick.pptx", presentationTargets),
|
||||
|
||||
allTargets("quick.odg", graphicTargets),
|
||||
allTargets("quick.vdx", graphicTargets),
|
||||
allTargets("quick.vsd", graphicTargets),
|
||||
|
||||
allTargets("quick.ods", spreadsheetTargets),
|
||||
allTargets("quick.xls", spreadsheetTargets),
|
||||
allTargets("quick.xlsx", spreadsheetTargets),
|
||||
allTargets("people.csv", spreadsheetTargets),
|
||||
allTargets("sample.tsv", spreadsheetTargets)
|
||||
)
|
||||
.flatMap(identity())
|
||||
.collect(toSet());
|
||||
@ -105,12 +173,12 @@ public class LibreOfficeTransformationIT
|
||||
@Test
|
||||
public void testTransformation()
|
||||
{
|
||||
final String descriptor = format("Transform ({0} -> {1})", sourceFile, targetExtension);
|
||||
|
||||
final String descriptor = format("Transform ({0}, {1} -> {2}, {3})",
|
||||
sourceFile, sourceMimetype, targetMimetype, targetExtension);
|
||||
try
|
||||
{
|
||||
final ResponseEntity<Resource> response = sendTRequest(ENGINE_URL, sourceFile, null,
|
||||
null, targetExtension);
|
||||
final ResponseEntity<Resource> response = sendTRequest(ENGINE_URL, sourceFile, sourceMimetype,
|
||||
targetMimetype, targetExtension);
|
||||
assertEquals(descriptor, OK, response.getStatusCode());
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -119,11 +187,15 @@ public class LibreOfficeTransformationIT
|
||||
}
|
||||
}
|
||||
|
||||
private static Stream<Pair<String, String>> allTargets(final String sourceFile,
|
||||
final Set<String> mimetypes)
|
||||
private static Stream<Pair<TestFileInfo, TestFileInfo>> allTargets(final String sourceFile,
|
||||
final Set<TestFileInfo> mimetypes)
|
||||
{
|
||||
return mimetypes
|
||||
.stream()
|
||||
.map(k -> Pair.of(sourceFile, k));
|
||||
//Filter out duplicate mimetypes. eg. We do not want "Transform (quick.doc, application/msword -> application/msword, doc)" as these are not contained in the engine_config
|
||||
.filter(type -> !type.getMimeType().equals(TEST_FILES.get(sourceFile).getMimeType()))
|
||||
// Edge case: Transform (quick.ods, application/vnd.oasis.opendocument.spreadsheet -> text/csv, csv) not in engine_config
|
||||
.filter(type -> !(TEST_FILES.get(sourceFile).getMimeType().equals(MIMETYPE_OPENDOCUMENT_SPREADSHEET) && type.getMimeType().equals(MIMETYPE_TEXT_CSV)))
|
||||
.map(k -> Pair.of(TEST_FILES.get(sourceFile), k));
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ public interface MimetypeMap
|
||||
String MIMETYPE_EXCEL = "application/vnd.ms-excel";
|
||||
String MIMETYPE_BINARY = "application/octet-stream";
|
||||
String MIMETYPE_PPT = "application/vnd.ms-powerpoint";
|
||||
String MIMETYPE_RTF = "application/rtf";
|
||||
String MIMETYPE_TSV = "text/tab-separated-values";
|
||||
String MIMETYPE_APP_DWG = "application/dwg";
|
||||
String MIMETYPE_IMG_DWG = "image/vnd.dwg";
|
||||
String MIMETYPE_VIDEO_AVI = "video/x-msvideo";
|
||||
|
5
pom.xml
5
pom.xml
@ -73,8 +73,8 @@
|
||||
<id>libreoffice</id>
|
||||
<modules>
|
||||
<module>alfresco-transformer-base</module>
|
||||
<module>alfresco-transform-imagemagick/alfresco-transform-imagemagick</module>
|
||||
<module>alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot</module>
|
||||
<module>alfresco-transform-libreoffice/alfresco-transform-libreoffice</module>
|
||||
<module>alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
@ -346,6 +346,7 @@
|
||||
<IMAGEMAGICK_EXE>/usr/bin/convert</IMAGEMAGICK_EXE>
|
||||
<IMAGEMAGICK_DYN>/usr/lib64/ImageMagick-7.0.7/lib</IMAGEMAGICK_DYN>
|
||||
<IMAGEMAGICK_ROOT>/usr/lib64/ImageMagick-7.0.7</IMAGEMAGICK_ROOT>
|
||||
<LIBREOFFICE_HOME>/opt/libreoffice6.3</LIBREOFFICE_HOME>
|
||||
<PDF_RENDERER_EXE>/usr/bin/alfresco-pdf-renderer</PDF_RENDERER_EXE>
|
||||
<buildDirectory>${project.build.directory}</buildDirectory>
|
||||
</systemPropertyVariables>
|
||||
|
Loading…
x
Reference in New Issue
Block a user