mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-07 17:48:35 +00:00
ATS-702 Add AIOControllerTest for Imagemagick transforms (#208)
Runs the tests inherited from the imagemagick-boot-test-jar through the All in One Transformer Co-authored-by: Erik Knizat <erik.knizat@alfresco.com> Co-authored-by: kristian <kristian.dimitrov@alfresco.com> Co-authored-by: eknizat <26163420+eknizat@users.noreply.github.com>
This commit is contained in:
@@ -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";
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user