diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/pom.xml b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/pom.xml
index f8f297fc..65a40435 100644
--- a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/pom.xml
+++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/pom.xml
@@ -62,6 +62,14 @@
test
${project.version}
+
+ org.alfresco
+ alfresco-transform-libreoffice-boot
+ ${project.version}
+ tests
+ test-jar
+ test
+
org.springframework.boot
diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java
index 4e5c75f2..a83347fb 100644
--- a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java
+++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java
@@ -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 transformers = transformRegistry.getTransformerTransformMapping();
- transformers.replace("imagemagick", adapter);
- ReflectionTestUtils.setField(transformRegistry, "transformerTransformMapping", transformers);
- }
+ Map transformers = transformRegistry.getTransformerTransformMapping();
+ transformers.replace("imagemagick", adapter);
mockTransformCommand("jpg", "png", "image/jpeg", true);
}
diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerLibreOfficeTest.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerLibreOfficeTest.java
new file mode 100644
index 00000000..26f9cc46
--- /dev/null
+++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerLibreOfficeTest.java
@@ -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 .
+ * #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 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.
+
+ }
+}
\ No newline at end of file
diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOLibreOfficeTransformationIT.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOLibreOfficeTransformationIT.java
new file mode 100644
index 00000000..589fe43e
--- /dev/null
+++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOLibreOfficeTransformationIT.java
@@ -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 .
+ * #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 entry)
+ {
+ super(entry);
+ }
+}
\ No newline at end of file
diff --git a/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/src/test/java/org/alfresco/transformer/ImageMagickTransformationIT.java b/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/src/test/java/org/alfresco/transformer/ImageMagickTransformationIT.java
index 126283e4..cadb038a 100644
--- a/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/src/test/java/org/alfresco/transformer/ImageMagickTransformationIT.java
+++ b/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/src/test/java/org/alfresco/transformer/ImageMagickTransformationIT.java
@@ -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;
diff --git a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/pom.xml b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/pom.xml
index c89c9be2..140374c5 100644
--- a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/pom.xml
+++ b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/pom.xml
@@ -91,16 +91,23 @@
org.apache.maven.plugins
maven-surefire-plugin
-
-
- /opt/libreoffice6.3
-
-
org.apache.maven.plugins
maven-failsafe-plugin
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+
+ test-jar
+
+
+
+
diff --git a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/main/java/org/alfresco/transformer/LibreOfficeController.java b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/main/java/org/alfresco/transformer/LibreOfficeController.java
index df773cf9..10c89256 100644
--- a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/main/java/org/alfresco/transformer/LibreOfficeController.java
+++ b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/main/java/org/alfresco/transformer/LibreOfficeController.java
@@ -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;
diff --git a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/main/resources/application-default.yaml b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/main/resources/application-default.yaml
index a48b88e0..3a50c25f 100644
--- a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/main/resources/application-default.yaml
+++ b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/main/resources/application-default.yaml
@@ -5,4 +5,4 @@ transform:
config:
location: classpath:libreoffice_engine_config.json
libreoffice:
- home: ${LIBREOFFICE_HOME:/opt/libreoffice6.3}
\ No newline at end of file
+ path: ${LIBREOFFICE_HOME:/opt/libreoffice6.3}
\ No newline at end of file
diff --git a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/test/java/org/alfresco/transformer/LibreOfficeControllerTest.java b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/test/java/org/alfresco/transformer/LibreOfficeControllerTest.java
index 2653ca6c..dc0fe751 100644
--- a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/test/java/org/alfresco/transformer/LibreOfficeControllerTest.java
+++ b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/test/java/org/alfresco/transformer/LibreOfficeControllerTest.java
@@ -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
diff --git a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/test/java/org/alfresco/transformer/LibreOfficeTransformationIT.java b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/test/java/org/alfresco/transformer/LibreOfficeTransformationIT.java
index 7d897135..b90e80ed 100644
--- a/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/test/java/org/alfresco/transformer/LibreOfficeTransformationIT.java
+++ b/alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot/src/test/java/org/alfresco/transformer/LibreOfficeTransformationIT.java
@@ -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 spreadsheetTargetMimetypes = ImmutableSet.of(
- "csv", "html", "ods", "pdf", "tsv", "xls");
- private static final Set documentsTargetMimetypes = ImmutableSet.of(
- "doc", "html", "odt", "pdf", "rtf");
- private static final Set graphicTargetMimetypes = ImmutableSet.of(
- "pdf", "svg");
- private static final Set presentationTargetMimetypes = ImmutableSet.of(
- "html", "odp", "ppt", "pdf");
+ private static final Set 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 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 graphicTargets = ImmutableSet.of(
+ testFile(MIMETYPE_PDF,"pdf",null),
+ testFile(MIMETYPE_IMAGE_SVG,"svg",null)
+ );
+
+ private static final Set 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 entry)
+ private static final Map 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 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> engineTransformations()
+ public static Set> 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 response = sendTRequest(ENGINE_URL, sourceFile, null,
- null, targetExtension);
+ final ResponseEntity 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> allTargets(final String sourceFile,
- final Set mimetypes)
+ private static Stream> allTargets(final String sourceFile,
+ final Set 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));
}
}
diff --git a/alfresco-transformer-base/src/main/java/org/alfresco/transformer/util/MimetypeMap.java b/alfresco-transformer-base/src/main/java/org/alfresco/transformer/util/MimetypeMap.java
index 4975afcc..21e99cfe 100644
--- a/alfresco-transformer-base/src/main/java/org/alfresco/transformer/util/MimetypeMap.java
+++ b/alfresco-transformer-base/src/main/java/org/alfresco/transformer/util/MimetypeMap.java
@@ -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";
diff --git a/pom.xml b/pom.xml
index f0b06eaa..05675c17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -73,8 +73,8 @@
libreoffice
alfresco-transformer-base
- alfresco-transform-imagemagick/alfresco-transform-imagemagick
- alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot
+ alfresco-transform-libreoffice/alfresco-transform-libreoffice
+ alfresco-transform-libreoffice/alfresco-transform-libreoffice-boot
@@ -346,6 +346,7 @@
/usr/bin/convert
/usr/lib64/ImageMagick-7.0.7/lib
/usr/lib64/ImageMagick-7.0.7
+ /opt/libreoffice6.3
/usr/bin/alfresco-pdf-renderer
${project.build.directory}