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 d4814cec..19b1e5c3 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
@@ -38,6 +38,14 @@
test-jar
test
+
+ org.alfresco
+ alfresco-transform-imagemagick-boot
+ ${project.version}
+ tests
+ test-jar
+ test
+
org.springframework.boot
diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/main/java/org/alfresco/transformer/AIOController.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/main/java/org/alfresco/transformer/AIOController.java
index 6e571462..3a7aef78 100644
--- a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/main/java/org/alfresco/transformer/AIOController.java
+++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/main/java/org/alfresco/transformer/AIOController.java
@@ -126,9 +126,9 @@ public class AIOController extends AbstractTransformerController
@PostMapping(value = "/transform", consumes = MULTIPART_FORM_DATA_VALUE)
public ResponseEntity transform(HttpServletRequest request,
@RequestParam("file") MultipartFile sourceMultipartFile,
+ @RequestParam(TARGET_EXTENSION) String targetExtension,
@RequestParam(SOURCE_MIMETYPE) String sourceMimetype,
@RequestParam(TARGET_MIMETYPE) String targetMimetype,
- @RequestParam(TARGET_EXTENSION) String targetExtension,
@RequestParam Map requestParameters,
@RequestParam (value = TEST_DELAY, required = false) Long testDelay,
diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerHttpRequestTest.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerHttpRequestTest.java
new file mode 100644
index 00000000..0618960b
--- /dev/null
+++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerHttpRequestTest.java
@@ -0,0 +1,52 @@
+/*
+ * #%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.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+public class AIOControllerHttpRequestTest extends AbstractHttpRequestTest
+{
+
+ @Override
+ protected String getTransformerName()
+ {
+ return "All in One Transformer";
+ }
+
+ @Override
+ protected String getSourceExtension()
+ {
+ // Currently using same extension as ImageMagick tests
+ return "jpg";
+ }
+
+}
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
new file mode 100644
index 00000000..cc57695a
--- /dev/null
+++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOControllerImageMagickTest.java
@@ -0,0 +1,143 @@
+/*
+ * #%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 java.io.IOException;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+
+import org.alfresco.transformer.transformers.ImageMagickAdapter;
+import org.alfresco.transformer.transformers.Transformer;
+import org.junit.Before;
+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 ImageMagick transforms without a server.
+ * Super class includes tests for the AbstractTransformerController.
+ */
+public class AIOControllerImageMagickTest extends ImageMagickControllerTest
+{
+ // All tests contained in ImageMagickControllerTest
+
+ ImageMagickAdapter adapter;
+
+ @Autowired
+ AIOTransformRegistry transformRegistry;
+
+ @PostConstruct
+ private void init() throws Exception
+ {
+ adapter = new ImageMagickAdapter(EXE, DYN, ROOT);
+ }
+
+ @Before @Override
+ public void before() throws IOException
+ {
+ ReflectionTestUtils.setField(commandExecutor, "transformCommand", mockTransformCommand);
+ 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);
+ }
+
+ mockTransformCommand("jpg", "png", "image/jpeg", true);
+ }
+
+ @Override
+ protected AbstractTransformerController getController()
+ {
+ return controller;
+ }
+
+ @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 noTargetFileTest()
+ {
+ // Ignore the test in super class as the AIO transforms will not be selected .
+ // It is the mock that returns a zero length file for other transformers, when we supply an invalid targetExtension.
+ }
+
+ @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.
+
+ }
+
+}
diff --git a/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOImageMagickIT.java b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOImageMagickIT.java
new file mode 100644
index 00000000..5e26c5c9
--- /dev/null
+++ b/alfresco-transform-core-aio/alfresco-transform-core-aio-boot/src/test/java/org/alfresco/transformer/AIOImageMagickIT.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 AIOImageMagickIT extends ImageMagickTransformationIT
+{
+ //Tests are in ImageMagickTransformationIT
+ public AIOImageMagickIT(final Pair> entry)
+ {
+ super(entry);
+ }
+}
diff --git a/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/pom.xml b/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/pom.xml
index 075c870f..5052df2c 100644
--- a/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/pom.xml
+++ b/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/pom.xml
@@ -81,19 +81,23 @@
org.apache.maven.plugins
maven-surefire-plugin
-
-
- /usr/bin/convert
- /usr/lib64/ImageMagick-7.0.7/lib
- /usr/lib64/ImageMagick-7.0.7
- ${project.build.directory}
-
-
org.apache.maven.plugins
maven-failsafe-plugin
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+
+ test-jar
+
+
+
+
diff --git a/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/src/test/java/org/alfresco/transformer/ImageMagickControllerTest.java b/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/src/test/java/org/alfresco/transformer/ImageMagickControllerTest.java
index 62c8c9a4..a5334ed1 100644
--- a/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/src/test/java/org/alfresco/transformer/ImageMagickControllerTest.java
+++ b/alfresco-transform-imagemagick/alfresco-transform-imagemagick-boot/src/test/java/org/alfresco/transformer/ImageMagickControllerTest.java
@@ -27,6 +27,7 @@
package org.alfresco.transformer;
import static org.alfresco.transformer.executors.RuntimeExec.ExecutionResult;
+import static org.alfresco.transformer.util.MimetypeMap.PREFIX_IMAGE;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -66,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;
@@ -91,22 +92,22 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
private static final String ENGINE_CONFIG_NAME = "imagemagick_engine_config.json";
@Mock
- private ExecutionResult mockExecutionResult;
+ protected ExecutionResult mockExecutionResult;
@Mock
- private RuntimeExec mockTransformCommand;
+ protected RuntimeExec mockTransformCommand;
@Mock
- private RuntimeExec mockCheckCommand;
+ protected RuntimeExec mockCheckCommand;
@Value("${transform.core.imagemagick.exe}")
- private String EXE;
+ protected String EXE;
@Value("${transform.core.imagemagick.dyn}")
- private String DYN;
+ protected String DYN;
@Value("${transform.core.imagemagick.root}")
- private String ROOT;
+ protected String ROOT;
ImageMagickCommandExecutor commandExecutor;
@@ -116,8 +117,8 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
commandExecutor = new ImageMagickCommandExecutor(EXE, DYN, ROOT);
}
- @SpyBean
- private ImageMagickController controller;
+ @Autowired
+ protected AbstractTransformerController controller;
@Before
public void before() throws IOException
@@ -143,6 +144,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
this.sourceExtension = sourceExtension;
this.targetExtension = targetExtension;
this.sourceMimetype = sourceMimetype;
+ this.targetMimetype = PREFIX_IMAGE + targetExtension;
expectedOptions = null;
expectedSourceSuffix = null;
@@ -226,6 +228,8 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
+ .param("targetMimetype", targetMimetype)
+ .param("sourceMimetype", sourceMimetype)
.param("cropGravity", value))
.andExpect(status().is(OK.value()))
.andExpect(content().bytes(expectedTargetFileBytes))
@@ -242,6 +246,8 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
+ .param("targetMimetype", targetMimetype)
+ .param("sourceMimetype", sourceMimetype)
.param("cropGravity", "badValue"))
.andExpect(status().is(BAD_REQUEST.value()));
}
@@ -256,6 +262,8 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
+ .param("targetMimetype", targetMimetype)
+ .param("sourceMimetype", sourceMimetype)
.param("startPage", "2")
.param("endPage", "3")
@@ -292,7 +300,9 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
-
+ .param("targetMimetype", targetMimetype)
+ .param("sourceMimetype", sourceMimetype)
+
.param("startPage", "2")
.param("endPage", "3")
@@ -328,6 +338,8 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
+ .param("targetMimetype", targetMimetype)
+ .param("sourceMimetype", sourceMimetype)
.param("thumbnail", "false")
.param("resizeWidth", "321")
.param("resizeHeight", "654")
@@ -374,8 +386,10 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
transformRequest.setTransformRequestOptions(new HashMap<>());
transformRequest.setSourceReference(sourceFileRef);
transformRequest.setSourceExtension(sourceExtension);
+ transformRequest.setSourceMediaType(sourceMimetype);
transformRequest.setSourceSize(sourceFile.length());
transformRequest.setTargetExtension(targetExtension);
+ transformRequest.setTargetMediaType(targetMimetype);
// HTTP Request
HttpHeaders headers = new HttpHeaders();
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 d419c5f7..126283e4 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
@@ -28,13 +28,49 @@ 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_IMAGE_RAW_3FR;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_ARW;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_BMP;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_CGM;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_CR2;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_DNG;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_APPLICATION_EPS;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_GIF;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_IEF;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_JP2;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_JPEG;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_K25;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_MRW;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_NEF;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_ORF;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_PBM;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_PEF;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_PGM;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_PNG;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_PNM;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_PPJ;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_PPM;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_PSD;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_R3D;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_RAF;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAS;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_RW2;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_RWL;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_TIFF;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_RAW_X3F;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_XBM;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_XPM;
+import static org.alfresco.transformer.util.MimetypeMap.MIMETYPE_IMAGE_XWD;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.springframework.http.HttpStatus.OK;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
@@ -57,23 +93,72 @@ public class ImageMagickTransformationIT
{
private static final Logger logger = LoggerFactory.getLogger(ImageMagickTransformationIT.class);
private static final String ENGINE_URL = "http://localhost:8090";
- private static final List targetMimetypes = ImmutableList.of(
- "3fr", "arw", "bmp", "cgm",
- "cr2", "dng", "eps", "gif", "ief", "jp2", "jpg",
- "k25", "mrw", "nef", "orf", "pbm", "pef", "pgm", "png", "pnm", "ppj", "ppm",
- "psd", "r3d", "raf", "ras", "rw2", "rwl", "tiff", "x3f", "xbm", "xpm", "xwd");
+ private static final List> targetExtensions = new ImmutableList.Builder>()
+ .add(Pair.of("3fr",MIMETYPE_IMAGE_RAW_3FR))
+ .add(Pair.of("arw",MIMETYPE_IMAGE_RAW_ARW))
+ .add(Pair.of("bmp",MIMETYPE_IMAGE_BMP))
+ .add(Pair.of("cgm",MIMETYPE_IMAGE_CGM))
+ .add(Pair.of("cr2",MIMETYPE_IMAGE_RAW_CR2))
+ .add(Pair.of("dng",MIMETYPE_IMAGE_RAW_DNG))
+ .add(Pair.of("eps",MIMETYPE_APPLICATION_EPS))
+ .add(Pair.of("gif",MIMETYPE_IMAGE_GIF))
+ .add(Pair.of("ief",MIMETYPE_IMAGE_IEF))
+ .add(Pair.of("jp2",MIMETYPE_IMAGE_JP2))
+ .add(Pair.of("jpg",MIMETYPE_IMAGE_JPEG))
+ .add(Pair.of("k25",MIMETYPE_IMAGE_RAW_K25))
+ .add(Pair.of("mrw",MIMETYPE_IMAGE_RAW_MRW))
+ .add(Pair.of("nef",MIMETYPE_IMAGE_RAW_NEF))
+ .add(Pair.of("orf",MIMETYPE_IMAGE_RAW_ORF))
+ .add(Pair.of("pbm",MIMETYPE_IMAGE_PBM))
+ .add(Pair.of("pef",MIMETYPE_IMAGE_RAW_PEF))
+ .add(Pair.of("pgm",MIMETYPE_IMAGE_PGM))
+ .add(Pair.of("png",MIMETYPE_IMAGE_PNG))
+ .add(Pair.of("pnm",MIMETYPE_IMAGE_PNM))
+ .add(Pair.of("ppj",MIMETYPE_IMAGE_PPJ))
+ .add(Pair.of("ppm",MIMETYPE_IMAGE_PPM))
+ .add(Pair.of("psd",MIMETYPE_IMAGE_PSD))
+ .add(Pair.of("r3d",MIMETYPE_IMAGE_RAW_R3D))
+ .add(Pair.of("raf",MIMETYPE_IMAGE_RAW_RAF))
+ .add(Pair.of("ras",MIMETYPE_IMAGE_RAS))
+ .add(Pair.of("rw2",MIMETYPE_IMAGE_RAW_RW2))
+ .add(Pair.of("rwl",MIMETYPE_IMAGE_RAW_RWL))
+ .add(Pair.of("tiff",MIMETYPE_IMAGE_TIFF))
+ .add(Pair.of("x3f",MIMETYPE_IMAGE_RAW_X3F))
+ .add(Pair.of("xbm",MIMETYPE_IMAGE_XBM))
+ .add(Pair.of("xpm",MIMETYPE_IMAGE_XPM))
+ .add(Pair.of("xwd",MIMETYPE_IMAGE_XWD))
+ .build();
+ private static final Map TEST_FILES = Stream.of(
+ testFile(MIMETYPE_IMAGE_BMP,"bmp","quick.bmp"),
+ testFile(MIMETYPE_APPLICATION_EPS,"eps","quick.eps"),
+ testFile(MIMETYPE_IMAGE_GIF,"gif","quick.gif"),
+ testFile(MIMETYPE_IMAGE_JPEG,"jpg","quick.jpg"),
+ testFile(MIMETYPE_IMAGE_PBM,"pbm","quick.pbm"),
+ testFile(MIMETYPE_IMAGE_PGM,"pgm","quick.pgm"),
+ testFile(MIMETYPE_IMAGE_PNG,"png","quick.png"),
+ testFile(MIMETYPE_IMAGE_PNM,"pnm","quick.pnm"),
+ testFile(MIMETYPE_IMAGE_PPM,"ppm","quick.ppm"),
+ 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()));;
+
private final String sourceFile;
private final String targetExtension;
+ private final String sourceMimetype;
+ private final String targetMimetype;
- public ImageMagickTransformationIT(final Pair entry)
+ public ImageMagickTransformationIT(final Pair> entry)
{
- sourceFile = entry.getLeft();
- targetExtension = entry.getLeft();
+ sourceFile = entry.getLeft().getPath();
+ targetExtension = entry.getRight().getLeft();
+ sourceMimetype = entry.getLeft().getMimeType();
+ targetMimetype = entry.getRight().getRight();
}
@Parameterized.Parameters
- public static Set> engineTransformations()
+ public static Set>> engineTransformations()
{
return Stream
.of(
@@ -99,12 +184,12 @@ public class ImageMagickTransformationIT
@Test
public void testTransformation()
{
- final String descriptor = format("Transform ({0} -> {1})", sourceFile, null,
- 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)
@@ -113,10 +198,10 @@ public class ImageMagickTransformationIT
}
}
- private static Stream> allTargets(final String sourceFile)
+ private static Stream>> allTargets(final String sourceFile)
{
- return targetMimetypes
+ return targetExtensions
.stream()
- .map(k -> Pair.of(sourceFile, k));
+ .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 6e414670..4975afcc 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
@@ -69,11 +69,22 @@ public interface MimetypeMap
String MIMETYPE_APPLICATION_FLA = "application/x-fla";
String MIMETYPE_VIDEO_MPG = "video/mpeg";
String MIMETYPE_VIDEO_MP4 = "video/mp4";
+ String MIMETYPE_IMAGE_BMP = "image/bmp";
+ String MIMETYPE_IMAGE_CGM = "image/cgm";
String MIMETYPE_IMAGE_GIF = "image/gif";
+ String MIMETYPE_IMAGE_IEF = "image/ief";
String MIMETYPE_IMAGE_JPEG = "image/jpeg";
+ String MIMETYPE_IMAGE_JP2 = "image/jp2";
String MIMETYPE_IMAGE_RGB = "image/x-rgb";
String MIMETYPE_IMAGE_SVG = "image/svg+xml";
+ String MIMETYPE_IMAGE_PBM = "image/x-portable-bitmap";
+ String MIMETYPE_IMAGE_PGM = "image/x-portable-graymap";
+ String MIMETYPE_IMAGE_PNM = "image/x-portable-anymap";
String MIMETYPE_IMAGE_PNG = "image/png";
+ String MIMETYPE_IMAGE_PPM = "image/x-portable-pixmap";
+ String MIMETYPE_IMAGE_PPJ = "image/vnd.adobe.premiere";
+ String MIMETYPE_IMAGE_PSD = "image/vnd.adobe.photoshop";
+ String MIMETYPE_IMAGE_RAS = "image/x-cmu-raster";
String MIMETYPE_IMAGE_TIFF = "image/tiff";
String MIMETYPE_IMAGE_RAW_DNG = "image/x-raw-adobe";
String MIMETYPE_IMAGE_RAW_3FR = "image/x-raw-hasselblad";
@@ -90,6 +101,9 @@ public interface MimetypeMap
String MIMETYPE_IMAGE_RAW_RWL = "image/x-raw-leica";
String MIMETYPE_IMAGE_RAW_R3D = "image/x-raw-red";
String MIMETYPE_IMAGE_DWT = "image/x-dwt";
+ String MIMETYPE_IMAGE_XBM = "image/x-xbitmap";
+ String MIMETYPE_IMAGE_XPM = "image/x-xpixmap";
+ String MIMETYPE_IMAGE_XWD = "image/x-xwindowdump";
String MIMETYPE_APPLICATION_EPS = "application/eps";
String MIMETYPE_APPLICATION_PS = "application/postscript";
String MIMETYPE_JAVASCRIPT = "application/x-javascript";
diff --git a/alfresco-transformer-base/src/test/java/org/alfresco/transformer/AbstractTransformerControllerTest.java b/alfresco-transformer-base/src/test/java/org/alfresco/transformer/AbstractTransformerControllerTest.java
index ca2eafa8..3e8a7a09 100644
--- a/alfresco-transformer-base/src/test/java/org/alfresco/transformer/AbstractTransformerControllerTest.java
+++ b/alfresco-transformer-base/src/test/java/org/alfresco/transformer/AbstractTransformerControllerTest.java
@@ -26,6 +26,7 @@
*/
package org.alfresco.transformer;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -63,7 +64,9 @@ import org.alfresco.transform.client.model.config.Transformer;
import org.alfresco.transform.client.registry.TransformServiceRegistry;
import org.alfresco.transformer.clients.AlfrescoSharedFileStoreClient;
import org.alfresco.transformer.probes.ProbeTestTransform;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
@@ -84,6 +87,9 @@ import com.google.common.collect.ImmutableSet;
*/
public abstract class AbstractTransformerControllerTest
{
+ @Rule // added as part of ATS-702 to allow test resources to be read from the imported jar files to prevent test resource duplication
+ public TemporaryFolder folder= new TemporaryFolder();
+
@Autowired
protected MockMvc mockMvc;
@@ -99,6 +105,7 @@ public abstract class AbstractTransformerControllerTest
protected String sourceExtension;
protected String targetExtension;
protected String sourceMimetype;
+ protected String targetMimetype;
protected MockMultipartFile sourceFile;
protected String expectedOptions;
@@ -162,6 +169,7 @@ public abstract class AbstractTransformerControllerTest
protected File getTestFile(String testFilename, boolean required) throws IOException
{
+ File testFile = null;
ClassLoader classLoader = getClass().getClassLoader();
URL testFileUrl = classLoader.getResource(testFilename);
if (required && testFileUrl == null)
@@ -169,7 +177,28 @@ public abstract class AbstractTransformerControllerTest
throw new IOException("The test file " + testFilename +
" does not exist in the resources directory");
}
- return testFileUrl == null ? null : new File(URLDecoder.decode(testFileUrl.getPath(), "UTF-8"));
+ // added as part of ATS-702 to allow test resources to be read from the imported jar files to prevent test resource duplication
+ if(testFileUrl!=null)
+ {
+ try
+ {
+ testFile = folder.newFile(testFilename);
+ Files.copy(classLoader.getResourceAsStream(testFilename), testFile.toPath(),REPLACE_EXISTING);
+ }
+ catch (IOException e)
+ {
+ if(e.getMessage().contains("a file with the name \'" + testFilename + "\' already exists in the test folder"))
+ {
+ testFile = new File(URLDecoder.decode(folder.getRoot().getPath()+ File.separator + testFilename, "UTF-8"));
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+ return testFileUrl == null ? null : testFile;
}
protected MockHttpServletRequestBuilder mockMvcRequest(String url, MockMultipartFile sourceFile,
diff --git a/pom.xml b/pom.xml
index d0306f8a..c951949a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -342,6 +342,12 @@
1
true
+
+ /usr/bin/convert
+ /usr/lib64/ImageMagick-7.0.7/lib
+ /usr/lib64/ImageMagick-7.0.7
+ ${project.build.directory}
+